]> git.lizzy.rs Git - rust.git/commitdiff
stop dropping impls from cause backtraces
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>
Sun, 1 May 2016 14:46:56 +0000 (17:46 +0300)
committerAriel Ben-Yehuda <ariel.byd@gmail.com>
Tue, 3 May 2016 15:52:55 +0000 (18:52 +0300)
src/librustc/traits/select.rs

index 8a6582e8420c087d837fc0a91ce6ac1e47db61d5..138ca7a0f350a4a857f085a1f72c186229250846 100644 (file)
@@ -1823,20 +1823,12 @@ fn constituent_types_for_ty(&self, t: Ty<'tcx>) -> Vec<Ty<'tcx>> {
     }
 
     fn collect_predicates_for_types(&mut self,
-                                    obligation: &TraitObligation<'tcx>,
+                                    cause: ObligationCause<'tcx>,
+                                    recursion_depth: usize,
                                     trait_def_id: DefId,
                                     types: ty::Binder<Vec<Ty<'tcx>>>)
                                     -> Vec<PredicateObligation<'tcx>>
     {
-        let derived_cause = match self.tcx().lang_items.to_builtin_kind(trait_def_id) {
-            Some(_) => {
-                self.derived_cause(obligation, BuiltinDerivedObligation)
-            },
-            None => {
-                self.derived_cause(obligation, ImplDerivedObligation)
-            }
-        };
-
         // Because the types were potentially derived from
         // higher-ranked obligations they may reference late-bound
         // regions. For example, `for<'a> Foo<&'a int> : Copy` would
@@ -1859,14 +1851,14 @@ fn collect_predicates_for_types(&mut self,
                     self.infcx().skolemize_late_bound_regions(&ty, snapshot);
                 let Normalized { value: normalized_ty, mut obligations } =
                     project::normalize_with_depth(self,
-                                                  derived_cause.clone(),
-                                                  obligation.recursion_depth + 1,
+                                                  cause.clone(),
+                                                  recursion_depth,
                                                   &skol_ty);
                 let skol_obligation =
                     util::predicate_for_trait_def(self.tcx(),
-                                                  derived_cause.clone(),
+                                                  cause.clone(),
                                                   trait_def_id,
-                                                  obligation.recursion_depth + 1,
+                                                  recursion_depth,
                                                   normalized_ty,
                                                   vec![]);
                 obligations.push(skol_obligation);
@@ -2013,7 +2005,11 @@ fn confirm_builtin_candidate(&mut self,
                           obligation)
             };
 
-            self.collect_predicates_for_types(obligation, trait_def, nested)
+            let cause = self.derived_cause(obligation, BuiltinDerivedObligation);
+            self.collect_predicates_for_types(cause,
+                                              obligation.recursion_depth+1,
+                                              trait_def,
+                                              nested)
         } else {
             vec![]
         };
@@ -2087,17 +2083,21 @@ fn vtable_default_impl(&mut self,
                            nested: ty::Binder<Vec<Ty<'tcx>>>)
                            -> VtableDefaultImplData<PredicateObligation<'tcx>>
     {
-        debug!("vtable_default_impl_data: nested={:?}", nested);
+        debug!("vtable_default_impl: nested={:?}", nested);
 
-        let mut obligations = self.collect_predicates_for_types(obligation,
-                                                                trait_def_id,
-                                                                nested);
+        let cause = self.derived_cause(obligation, BuiltinDerivedObligation);
+        let mut obligations = self.collect_predicates_for_types(
+            cause,
+            obligation.recursion_depth+1,
+            trait_def_id,
+            nested);
 
         let trait_obligations = self.infcx.in_snapshot(|snapshot| {
             let poly_trait_ref = obligation.predicate.to_poly_trait_ref();
             let (trait_ref, skol_map) =
                 self.infcx().skolemize_late_bound_regions(&poly_trait_ref, snapshot);
-            self.impl_or_trait_obligations(obligation.cause.clone(),
+            let cause = self.derived_cause(obligation, ImplDerivedObligation);
+            self.impl_or_trait_obligations(cause,
                                            obligation.recursion_depth + 1,
                                            trait_def_id,
                                            &trait_ref.substs,
@@ -2107,7 +2107,7 @@ fn vtable_default_impl(&mut self,
 
         obligations.extend(trait_obligations);
 
-        debug!("vtable_default_impl_data: obligations={:?}", obligations);
+        debug!("vtable_default_impl: obligations={:?}", obligations);
 
         VtableDefaultImplData {
             trait_def_id: trait_def_id,
@@ -2131,8 +2131,10 @@ fn confirm_impl_candidate(&mut self,
                 self.rematch_impl(impl_def_id, obligation,
                                   snapshot);
             debug!("confirm_impl_candidate substs={:?}", substs);
-            self.vtable_impl(impl_def_id, substs, obligation.cause.clone(),
-                             obligation.recursion_depth + 1, skol_map, snapshot)
+            let cause = self.derived_cause(obligation, ImplDerivedObligation);
+            self.vtable_impl(impl_def_id, substs, cause,
+                             obligation.recursion_depth + 1,
+                             skol_map, snapshot)
         })
     }