about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/traits/coherence.rs1
-rw-r--r--src/librustc/middle/traits/mod.rs5
-rw-r--r--src/librustc/middle/traits/project.rs6
-rw-r--r--src/librustc/middle/traits/specialize/mod.rs10
-rw-r--r--src/librustc/middle/traits/specialize/specialization_graph.rs4
-rw-r--r--src/librustc_driver/test.rs6
-rw-r--r--src/librustc_mir/transform/type_check.rs7
-rw-r--r--src/librustc_trans/trans/collector.rs8
-rw-r--r--src/librustc_trans/trans/meth.rs13
-rw-r--r--src/librustc_typeck/coherence/overlap.rs13
-rw-r--r--src/librustc_typeck/collect.rs3
11 files changed, 47 insertions, 29 deletions
diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs
index 33a1e3816e3..64d1c992cbf 100644
--- a/src/librustc/middle/traits/coherence.rs
+++ b/src/librustc/middle/traits/coherence.rs
@@ -11,7 +11,6 @@
 //! See `README.md` for high-level documentation
 
 use super::{SelectionContext, Obligation, ObligationCause};
-use super::util;
 
 use middle::cstore::LOCAL_CRATE;
 use middle::def_id::DefId;
diff --git a/src/librustc/middle/traits/mod.rs b/src/librustc/middle/traits/mod.rs
index 76dbd2793f9..5f66e9e6344 100644
--- a/src/librustc/middle/traits/mod.rs
+++ b/src/librustc/middle/traits/mod.rs
@@ -433,7 +433,10 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi
 
     let elaborated_env = unnormalized_env.with_caller_bounds(predicates);
 
-    let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(elaborated_env), ProjectionMode::AnyFinal);
+    let infcx = infer::new_infer_ctxt(tcx,
+                                      &tcx.tables,
+                                      Some(elaborated_env),
+                                      ProjectionMode::AnyFinal);
     let predicates = match fully_normalize(&infcx,
                                            cause,
                                            &infcx.parameter_environment.caller_bounds) {
diff --git a/src/librustc/middle/traits/project.rs b/src/librustc/middle/traits/project.rs
index 469ce0a4d27..e86f3ed01a4 100644
--- a/src/librustc/middle/traits/project.rs
+++ b/src/librustc/middle/traits/project.rs
@@ -1121,7 +1121,7 @@ fn confirm_impl_candidate<'cx,'tcx>(
                 tcx.types.err
             });
             let substs = translate_substs(selcx.infcx(), impl_def_id, substs, node_item.node);
-            (ty.subst(tcx, &substs), nested)
+            (ty.subst(tcx, substs), nested)
         }
         None => {
             tcx.sess.span_bug(obligation.cause.span,
@@ -1135,7 +1135,9 @@ fn confirm_impl_candidate<'cx,'tcx>(
 ///
 /// Based on the "projection mode", this lookup may in fact only examine the
 /// topmost impl. See the comments for `ProjectionMode` for more details.
-fn assoc_ty_def<'cx, 'tcx>(selcx: &SelectionContext<'cx, 'tcx>, impl_def_id: DefId, assoc_ty_name: ast::Name)
+fn assoc_ty_def<'cx, 'tcx>(selcx: &SelectionContext<'cx, 'tcx>,
+                           impl_def_id: DefId,
+                           assoc_ty_name: ast::Name)
                            -> Option<specialization_graph::NodeItem<Rc<ty::AssociatedType<'tcx>>>>
 {
     let trait_def_id = selcx.tcx().impl_trait_ref(impl_def_id).unwrap().def_id;
diff --git a/src/librustc/middle/traits/specialize/mod.rs b/src/librustc/middle/traits/specialize/mod.rs
index 624ebc545fe..a692fe55a77 100644
--- a/src/librustc/middle/traits/specialize/mod.rs
+++ b/src/librustc/middle/traits/specialize/mod.rs
@@ -75,9 +75,9 @@ pub struct Overlap<'a, 'tcx: 'a> {
 /// resolved.
 pub fn translate_substs<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
                                   source_impl: DefId,
-                                  source_substs: Substs<'tcx>,
+                                  source_substs: &'tcx Substs<'tcx>,
                                   target_node: specialization_graph::Node)
-                                  -> Substs<'tcx> {
+                                  -> &'tcx Substs<'tcx> {
     let source_trait_ref = infcx.tcx
                                 .impl_trait_ref(source_impl)
                                 .unwrap()
@@ -111,7 +111,7 @@ pub fn translate_substs<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
     };
 
     // directly inherent the method generics, since those do not vary across impls
-    target_substs.with_method_from_subst(&source_substs)
+    infcx.tcx.mk_substs(target_substs.with_method_from_subst(source_substs))
 }
 
 /// Is impl1 a specialization of impl2?
@@ -164,7 +164,7 @@ pub fn specializes(tcx: &TyCtxt, impl1_def_id: DefId, impl2_def_id: DefId) -> bo
     };
     penv.caller_bounds.extend(normalization_obligations.into_iter().map(|o| o.predicate));
 
-    // Install the parameter environment, which means we take the predicates of impl1 as assumptions:
+    // Install the parameter environment, taking the predicates of impl1 as assumptions:
     infcx.parameter_environment = penv;
 
     // Attempt to prove that impl2 applies, given all of the above.
@@ -217,7 +217,7 @@ fn fulfill_implication<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
                    infcx.parameter_environment.caller_bounds);
             Err(())
         } else {
-            debug!("fulfill_implication: an impl for {:?} specializes {:?} (`where` clauses elided)",
+            debug!("fulfill_implication: an impl for {:?} specializes {:?}",
                    source_trait_ref,
                    target_trait_ref);
 
diff --git a/src/librustc/middle/traits/specialize/specialization_graph.rs b/src/librustc/middle/traits/specialize/specialization_graph.rs
index 4af8e1fe0a8..f2170f75a11 100644
--- a/src/librustc/middle/traits/specialize/specialization_graph.rs
+++ b/src/librustc/middle/traits/specialize/specialization_graph.rs
@@ -97,7 +97,7 @@ impl Graph {
                 let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, ProjectionMode::Topmost);
                 let overlap = traits::overlapping_impls(&infcx, possible_sibling, impl_def_id);
 
-                if let Some(trait_ref) = overlap {
+                if let Some(impl_header) = overlap {
                     let le = specializes(tcx, impl_def_id, possible_sibling);
                     let ge = specializes(tcx, possible_sibling, impl_def_id);
 
@@ -124,7 +124,7 @@ impl Graph {
                         // overlap, but no specialization; error out
                         return Err(Overlap {
                             with_impl: possible_sibling,
-                            on_trait_ref: trait_ref,
+                            on_trait_ref: impl_header.trait_ref.unwrap(),
                             in_context: infcx,
                         });
                     }
diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs
index 3cab9cfb88c..437672c5514 100644
--- a/src/librustc_driver/test.rs
+++ b/src/librustc_driver/test.rs
@@ -22,6 +22,7 @@ use rustc_typeck::middle::resolve_lifetime;
 use rustc_typeck::middle::stability;
 use rustc_typeck::middle::subst;
 use rustc_typeck::middle::subst::Subst;
+use rustc_typeck::middle::traits::ProjectionMode;
 use rustc_typeck::middle::ty::{self, Ty, TyCtxt, TypeFoldable};
 use rustc_typeck::middle::ty::relate::TypeRelation;
 use rustc_typeck::middle::infer::{self, TypeOrigin};
@@ -143,7 +144,10 @@ fn test_env<F>(source_string: &str,
                                lang_items,
                                index,
                                |tcx| {
-                                   let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
+                                   let infcx = infer::new_infer_ctxt(tcx,
+                                                                     &tcx.tables,
+                                                                     None,
+                                                                     ProjectionMode::AnyFinal);
                                    body(Env { infcx: &infcx });
                                    let free_regions = FreeRegionMap::new();
                                    infcx.resolve_regions_and_report_errors(&free_regions,
diff --git a/src/librustc_mir/transform/type_check.rs b/src/librustc_mir/transform/type_check.rs
index 45393d57101..d99e6ff4bf5 100644
--- a/src/librustc_mir/transform/type_check.rs
+++ b/src/librustc_mir/transform/type_check.rs
@@ -13,7 +13,7 @@
 
 use rustc::dep_graph::DepNode;
 use rustc::middle::infer::{self, InferCtxt};
-use rustc::middle::traits;
+use rustc::middle::traits::{self, ProjectionMode};
 use rustc::middle::ty::fold::TypeFoldable;
 use rustc::middle::ty::{self, Ty, TyCtxt};
 use rustc::mir::repr::*;
@@ -582,7 +582,10 @@ impl<'tcx> MirPass<'tcx> for TypeckMir {
         }
         let _task = tcx.dep_graph.in_task(DepNode::MirTypeck(id));
         let param_env = ty::ParameterEnvironment::for_item(tcx, id);
-        let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(param_env));
+        let infcx = infer::new_infer_ctxt(tcx,
+                                          &tcx.tables,
+                                          Some(param_env),
+                                          ProjectionMode::AnyFinal);
         let mut checker = TypeChecker::new(&infcx);
         {
             let mut verifier = TypeVerifier::new(&mut checker, mir);
diff --git a/src/librustc_trans/trans/collector.rs b/src/librustc_trans/trans/collector.rs
index b7e107ae5e7..cea97c1a1e7 100644
--- a/src/librustc_trans/trans/collector.rs
+++ b/src/librustc_trans/trans/collector.rs
@@ -823,7 +823,7 @@ fn do_static_trait_method_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                                                     impl_did,
                                                     tcx.mk_substs(callee_substs),
                                                     trait_method.name);
-            Some((impl_method.method.def_id, impl_method.substs))
+            Some((impl_method.method.def_id, &impl_method.substs))
         }
         // If we have a closure or a function pointer, we will also encounter
         // the concrete closure/function somewhere else (during closure or fn
@@ -983,7 +983,7 @@ fn create_trans_items_for_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                             if can_have_local_instance(ccx, impl_method.method.def_id) {
                                 Some(create_fn_trans_item(ccx,
                                                           impl_method.method.def_id,
-                                                          impl_method.substs,
+                                                          &impl_method.substs,
                                                           &Substs::trans_empty()))
                             } else {
                                 None
@@ -1163,12 +1163,12 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                     // the method type from the impl to substitute into.
                     let mth = meth::get_impl_method(tcx,
                                                     impl_def_id,
-                                                    callee_substs.clone(),
+                                                    callee_substs,
                                                     default_impl.name);
 
                     assert!(mth.is_provided);
 
-                    let predicates = mth.method.predicates.predicates.subst(tcx, mth.substs);
+                    let predicates = mth.method.predicates.predicates.subst(tcx, &mth.substs);
                     if !normalize_and_test_predicates(ccx, predicates.into_vec()) {
                         continue;
                     }
diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/trans/meth.rs
index 2965e44bc17..7397ccc2505 100644
--- a/src/librustc_trans/trans/meth.rs
+++ b/src/librustc_trans/trans/meth.rs
@@ -34,7 +34,6 @@ use trans::machine;
 use trans::type_::Type;
 use trans::type_of::*;
 use middle::ty::{self, Ty, TyCtxt, TypeFoldable};
-use middle::ty::MethodCall;
 
 use syntax::ast::{self, Name};
 use syntax::attr;
@@ -110,7 +109,7 @@ pub fn callee_for_trait_impl<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
             // those from the impl and those from the method:
             let impl_substs = vtable_impl.substs.with_method_from(&substs);
             let substs = ccx.tcx().mk_substs(impl_substs);
-            let mth = get_impl_method(ccx.tcx(), impl_did, impl_substs, mname);
+            let mth = get_impl_method(ccx.tcx(), impl_did, substs, mname);
 
             // Translate the function, bypassing Callee::def.
             // That is because default methods have the same ID as the
@@ -318,7 +317,7 @@ pub fn get_vtable<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                                 trans_fn_ref_with_substs(ccx,
                                                          mth.method.def_id,
                                                          None,
-                                                         mth.substs).val
+                                                         &mth.substs).val
                             }
                             None => nullptr
                         }
@@ -431,7 +430,7 @@ pub fn get_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
 
             // The substitutions we have are on the impl, so we grab
             // the method type from the impl to substitute into.
-            let mth = get_impl_method(tcx, impl_id, substs.clone(), name);
+            let mth = get_impl_method(tcx, impl_id, substs, name);
 
             debug!("get_vtable_methods: mth={:?}", mth);
 
@@ -441,7 +440,7 @@ pub fn get_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
             // method could then never be called, so we do not want to
             // try and trans it, in that case. Issue #23435.
             if mth.is_provided {
-                let predicates = mth.method.predicates.predicates.subst(tcx, mth.substs);
+                let predicates = mth.method.predicates.predicates.subst(tcx, &mth.substs);
                 if !normalize_and_test_predicates(ccx, predicates.into_vec()) {
                     debug!("get_vtable_methods: predicates do not hold");
                     return None;
@@ -473,14 +472,14 @@ fn opaque_method_ty<'tcx>(tcx: &TyCtxt<'tcx>, method_ty: &ty::BareFnTy<'tcx>)
 #[derive(Debug)]
 pub struct ImplMethod<'tcx> {
     pub method: Rc<ty::Method<'tcx>>,
-    pub substs: Substs<'tcx>,
+    pub substs: &'tcx Substs<'tcx>,
     pub is_provided: bool
 }
 
 /// Locates the applicable definition of a method, given its name.
 pub fn get_impl_method<'tcx>(tcx: &TyCtxt<'tcx>,
                              impl_def_id: DefId,
-                             substs: Substs<'tcx>,
+                             substs: &'tcx Substs<'tcx>,
                              name: Name)
                              -> ImplMethod<'tcx>
 {
diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs
index e4994eaa255..99dd72538c9 100644
--- a/src/librustc_typeck/coherence/overlap.rs
+++ b/src/librustc_typeck/coherence/overlap.rs
@@ -13,9 +13,12 @@
 //! constructor provide a method with the same name.
 
 use middle::cstore::CrateStore;
-use middle::traits;
+use middle::def_id::DefId;
+use middle::traits::{self, ProjectionMode};
+use middle::infer;
 use middle::ty::{self, TyCtxt};
 use syntax::ast;
+use syntax::codemap::Span;
 use rustc::dep_graph::DepNode;
 use rustc_front::hir;
 use rustc_front::intravisit;
@@ -86,7 +89,10 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
 
         for (i, &impl1_def_id) in impls.iter().enumerate() {
             for &impl2_def_id in &impls[(i+1)..] {
-                let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None);
+                let infcx = infer::new_infer_ctxt(self.tcx,
+                                                  &self.tcx.tables,
+                                                  None,
+                                                  ProjectionMode::Topmost);
                 if traits::overlapping_impls(&infcx, impl1_def_id, impl2_def_id).is_some() {
                     self.check_for_common_items_in_impls(impl1_def_id, impl2_def_id)
                 }
@@ -117,7 +123,8 @@ impl<'cx, 'tcx,'v> intravisit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
                         self.tcx.span_of_impl(impl_def_id).unwrap(), E0519,
                         "redundant default implementations of trait `{}`:",
                         trait_ref);
-                    err.span_note(self.tcx.span_of_impl(self.tcx.map.local_def_id(prev_id)).unwrap(),
+                    err.span_note(self.tcx.span_of_impl(self.tcx.map.local_def_id(prev_id))
+                                      .unwrap(),
                                   "redundant implementation is here:");
                     err.emit();
                 }
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 831c9804d1b..0f88640b629 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -804,7 +804,8 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
 
                     convert_method(ccx, ImplContainer(def_id),
                                    impl_item.name, impl_item.id, method_vis,
-                                   sig, impl_item.defaultness, selfty, &ty_generics, &ty_predicates);
+                                   sig, impl_item.defaultness, selfty, &ty_generics,
+                                   &ty_predicates);
                 }
             }