]> git.lizzy.rs Git - rust.git/commitdiff
Fix rebase conflicts
authorNiko Matsakis <niko@alum.mit.edu>
Tue, 30 Dec 2014 17:09:21 +0000 (12:09 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 30 Dec 2014 17:09:21 +0000 (12:09 -0500)
src/librustc_typeck/check/closure.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/collect.rs
src/librustdoc/clean/mod.rs
src/test/compile-fail/trait-static-method-generic-inference.rs [new file with mode: 0644]
src/test/run-pass/trait-static-method-generic-inference.rs [deleted file]

index 85ead053d1d29d690d8a2f4dfc95a40ebacd5d60..eba040e7ea8b6ad226ab6ad9515f80d4d816b689 100644 (file)
@@ -48,7 +48,7 @@ pub fn check_expr_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
             match expected_sig_and_kind {
                 None => { // doesn't look like an unboxed closure
                     let region = astconv::opt_ast_region_to_region(fcx,
-                                                                   fcx.infcx(),
+                                                                   fcx,
                                                                    expr.span,
                                                                    &None);
 
@@ -117,7 +117,7 @@ fn check_unboxed_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
         abi::RustCall,
         expected_sig);
 
-    let region = match fcx.infcx().anon_regions(expr.span, 1) {
+    let region = match fcx.anon_regions(expr.span, 1) {
         Err(_) => {
             fcx.ccx.tcx.sess.span_bug(expr.span,
                                       "can't make anon regions here?!")
index 12ecfe6c2981c0b6075ecaa0fe2cea0019c59151..8069d00dda826fc8f4aa002b305e890e29d92267 100644 (file)
@@ -1933,7 +1933,7 @@ pub fn register_predicate(&self,
     }
 
     pub fn to_ty(&self, ast_t: &ast::Ty) -> Ty<'tcx> {
-        let t = ast_ty_to_ty(self, self.infcx(), ast_t);
+        let t = ast_ty_to_ty(self, self, ast_t);
 
         let mut bounds_checker = wf::BoundsChecker::new(self,
                                                         ast_t.span,
@@ -2123,18 +2123,18 @@ pub fn add_obligations_for_parameters(&self,
     }
 }
 
-//impl<'a, 'tcx> RegionScope for infer::InferCtxt<'a, 'tcx> {
-//    fn default_region_bound(&self, span: Span) -> Option<ty::Region> {
-//        Some(self.next_region_var(infer::MiscVariable(span)))
-//    }
-//
-//    fn anon_regions(&self, span: Span, count: uint)
-//                    -> Result<Vec<ty::Region>, Option<Vec<(String, uint)>>> {
-//        Ok(Vec::from_fn(count, |_| {
-//            self.next_region_var(infer::MiscVariable(span))
-//        }))
-//    }
-//}
+impl<'a, 'tcx> RegionScope for FnCtxt<'a, 'tcx> {
+    fn default_region_bound(&self, span: Span) -> Option<ty::Region> {
+        Some(self.infcx().next_region_var(infer::MiscVariable(span)))
+    }
+
+    fn anon_regions(&self, span: Span, count: uint)
+                    -> Result<Vec<ty::Region>, Option<Vec<(String, uint)>>> {
+        Ok(Vec::from_fn(count, |_| {
+            self.infcx().next_region_var(infer::MiscVariable(span))
+        }))
+    }
+}
 
 #[deriving(Copy, Show, PartialEq, Eq)]
 pub enum LvaluePreference {
@@ -2347,58 +2347,6 @@ fn autoderef_for_index<'a, 'tcx, T, F>(fcx: &FnCtxt<'a, 'tcx>,
     }
 }
 
-/// Autoderefs `base_expr`, looking for a `Slice` impl. If it finds one, installs the relevant
-/// method info and returns the result type (else None).
-fn try_overloaded_slice<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
-                                  method_call: MethodCall,
-                                  expr: &ast::Expr,
-                                  base_expr: &ast::Expr,
-                                  base_ty: Ty<'tcx>,
-                                  start_expr: &Option<P<ast::Expr>>,
-                                  end_expr: &Option<P<ast::Expr>>,
-                                  mutbl: ast::Mutability)
-                                  -> Option<Ty<'tcx>> // return type is result of slice
-{
-    let lvalue_pref = match mutbl {
-        ast::MutMutable => PreferMutLvalue,
-        ast::MutImmutable => NoPreference
-    };
-
-    let opt_method_ty =
-        autoderef_for_index(fcx, base_expr, base_ty, lvalue_pref, |adjusted_ty, autoderefref| {
-            try_overloaded_slice_step(fcx, method_call, expr, base_expr,
-                                      adjusted_ty, autoderefref, mutbl,
-                                      start_expr, end_expr)
-        });
-
-    // Regardless of whether the lookup succeeds, check the method arguments
-    // so that we have *some* type for each argument.
-    let method_ty_or_err = opt_method_ty.unwrap_or(fcx.tcx().types.err);
-
-    let mut args = vec![];
-    start_expr.as_ref().map(|x| args.push(x));
-    end_expr.as_ref().map(|x| args.push(x));
-
-    check_method_argument_types(fcx,
-                                expr.span,
-                                method_ty_or_err,
-                                expr,
-                                args.as_slice(),
-                                AutorefArgs::Yes,
-                                DontTupleArguments);
-
-    opt_method_ty.map(|method_ty| {
-        let result_ty = ty::ty_fn_ret(method_ty);
-        match result_ty {
-            ty::FnConverging(result_ty) => result_ty,
-            ty::FnDiverging => {
-                fcx.tcx().sess.span_bug(expr.span,
-                                        "slice trait does not define a `!` return")
-            }
-        }
-    })
-}
-
 /// Checks for a `Slice` (or `SliceMut`) impl at the relevant level of autoderef. If it finds one,
 /// installs method info and returns type of method (else None).
 fn try_overloaded_slice_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
@@ -4327,7 +4275,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
         let actual_structure_type = fcx.expr_ty(&*expr);
         if !ty::type_is_error(actual_structure_type) {
             let type_and_substs = astconv::ast_path_to_ty_relaxed(fcx,
-                                                                  fcx.infcx(),
+                                                                  fcx,
                                                                   struct_id,
                                                                   path);
             match fcx.mk_subty(false,
@@ -4410,8 +4358,8 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
                              },
                              base_t,
                              None);
-                          fcx.write_ty(idx.id, ty::mk_err());
-                          fcx.write_ty(id, ty::mk_err())
+                          fcx.write_ty(idx.id, fcx.tcx().types.err);
+                          fcx.write_ty(id, fcx.tcx().types.err);
                       }
                   }
                 }
@@ -4440,7 +4388,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
                               fcx.write_ty(id, element_ty);
                           }
                           _ => {
-                              check_expr_has_type(fcx, &**idx, ty::mk_err());
+                              check_expr_has_type(fcx, &**idx, fcx.tcx().types.err);
                               fcx.type_error_message(
                                   expr.span,
                                   |actual| {
@@ -4449,7 +4397,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
                                   },
                                   base_t,
                                   None);
-                              fcx.write_ty(id, ty::mk_err())
+                              fcx.write_ty(id, fcx.tcx().types.err);
                           }
                       }
                   }
@@ -4468,19 +4416,21 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
           });
 
           let idx_type = match (t_start, t_end) {
-            (Some(ty), None) | (None, Some(ty)) => Some(ty),
-            (Some(t_start), Some(t_end))
-              if ty::type_is_error(t_start) || ty::type_is_error(t_end) => {
-                Some(ty::mk_err())
-            }
-            (Some(t_start), Some(t_end)) => {
-                Some(infer::common_supertype(fcx.infcx(),
-                                             infer::RangeExpression(expr.span),
-                                             true,
-                                             t_start,
-                                             t_end))
-            }
-            _ => None
+              (Some(ty), None) | (None, Some(ty)) => {
+                  Some(ty)
+              }
+              (Some(t_start), Some(t_end)) if (ty::type_is_error(t_start) ||
+                                               ty::type_is_error(t_end)) => {
+                  Some(fcx.tcx().types.err)
+              }
+              (Some(t_start), Some(t_end)) => {
+                  Some(infer::common_supertype(fcx.infcx(),
+                                               infer::RangeExpression(expr.span),
+                                               true,
+                                               t_start,
+                                               t_end))
+              }
+              _ => None
           };
 
           // Note that we don't check the type of start/end satisfy any
@@ -4489,7 +4439,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
 
           let range_type = match idx_type {
             Some(idx_type) if ty::type_is_error(idx_type) => {
-                ty::mk_err()
+                fcx.tcx().types.err
             }
             Some(idx_type) => {
                 // Find the did from the appropriate lang item.
@@ -4515,7 +4465,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
                     ty::mk_struct(tcx, did, tcx.mk_substs(substs))
                 } else {
                     tcx.sess.span_err(expr.span, "No lang item for range syntax");
-                    ty::mk_err()
+                    fcx.tcx().types.err
                 }
             }
             None => {
@@ -4525,7 +4475,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
                     ty::mk_struct(tcx, did, tcx.mk_substs(substs))
                 } else {
                     tcx.sess.span_err(expr.span, "No lang item for range syntax");
-                    ty::mk_err()
+                    fcx.tcx().types.err
                 }
             }
           };
index 47473564254e13af2f0717a2e302a159ad451a42..9e184db3b84fec1ea943f578c037ae3e24f0d5fc 100644 (file)
@@ -1098,7 +1098,6 @@ fn predicates_for_associated_types<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
                 let bounds = compute_bounds(ccx,
                                             assoc_ty,
                                             assoc_type_def.bounds.as_slice(),
-                                            &assoc_type_def.unbound,
                                             assoc_type_def.span);
 
                 ty::predicates(ccx.tcx, assoc_ty, &bounds).into_iter()
index 467f34261ba78b297c83594ed917b1a5c0f1ba3b..1fbfbe7eb1ab50f26123d1492feae6d6fac1f2c1 100644 (file)
@@ -1474,7 +1474,7 @@ fn clean(&self, cx: &DocContext) -> Type {
 
             ty::ty_projection(ref data) => {
                 let trait_ref = match data.trait_ref.clean(cx) {
-                    TyParamBound::TraitBound(t) => t.trait_,
+                    TyParamBound::TraitBound(t, _) => t.trait_,
                     TyParamBound::RegionBound(_) => panic!("cleaning a trait got a region??"),
                 };
                 Type::QPath {
diff --git a/src/test/compile-fail/trait-static-method-generic-inference.rs b/src/test/compile-fail/trait-static-method-generic-inference.rs
new file mode 100644 (file)
index 0000000..651f663
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Issue #3902. We are (at least currently) unable to infer `Self`
+// based on `T`, even though there is only a single impl, because of
+// the possibility of associated types and other things (basically: no
+// constraints on `Self` here at all).
+
+mod base {
+    pub trait HasNew<T> {
+        fn new() -> T;
+    }
+
+    pub struct Foo {
+        dummy: (),
+    }
+
+    impl HasNew<Foo> for Foo {
+        fn new() -> Foo {
+            Foo { dummy: () }
+        }
+    }
+}
+
+pub fn foo() {
+    let _f: base::Foo = base::HasNew::new();
+    //~^ ERROR type annotations required
+}
+
+fn main() { }
diff --git a/src/test/run-pass/trait-static-method-generic-inference.rs b/src/test/run-pass/trait-static-method-generic-inference.rs
deleted file mode 100644 (file)
index 4151ad6..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-mod base {
-    pub trait HasNew<T> {
-        fn new() -> T;
-    }
-
-    pub struct Foo {
-        dummy: (),
-    }
-
-    impl HasNew<Foo> for Foo {
-        fn new() -> Foo {
-            Foo { dummy: () }
-        }
-    }
-
-    pub struct Bar {
-        dummy: (),
-    }
-
-    impl HasNew<Bar> for Bar {
-        fn new() -> Bar {
-            Bar { dummy: () }
-        }
-    }
-}
-
-pub fn main() {
-    let _f: base::Foo = base::HasNew::new();
-    let _b: base::Bar = base::HasNew::new();
-}