Skip to content

Commit 6c88384

Browse files
Ariel Ben-Yehudaarielb1
Ariel Ben-Yehuda
authored andcommitted
stop dropping impls from cause backtraces
1 parent 62db786 commit 6c88384

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

src/librustc/traits/select.rs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,20 +1823,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
18231823
}
18241824

18251825
fn collect_predicates_for_types(&mut self,
1826-
obligation: &TraitObligation<'tcx>,
1826+
cause: ObligationCause<'tcx>,
1827+
recursion_depth: usize,
18271828
trait_def_id: DefId,
18281829
types: ty::Binder<Vec<Ty<'tcx>>>)
18291830
-> Vec<PredicateObligation<'tcx>>
18301831
{
1831-
let derived_cause = match self.tcx().lang_items.to_builtin_kind(trait_def_id) {
1832-
Some(_) => {
1833-
self.derived_cause(obligation, BuiltinDerivedObligation)
1834-
},
1835-
None => {
1836-
self.derived_cause(obligation, ImplDerivedObligation)
1837-
}
1838-
};
1839-
18401832
// Because the types were potentially derived from
18411833
// higher-ranked obligations they may reference late-bound
18421834
// regions. For example, `for<'a> Foo<&'a int> : Copy` would
@@ -1859,14 +1851,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
18591851
self.infcx().skolemize_late_bound_regions(&ty, snapshot);
18601852
let Normalized { value: normalized_ty, mut obligations } =
18611853
project::normalize_with_depth(self,
1862-
derived_cause.clone(),
1863-
obligation.recursion_depth + 1,
1854+
cause.clone(),
1855+
recursion_depth,
18641856
&skol_ty);
18651857
let skol_obligation =
18661858
util::predicate_for_trait_def(self.tcx(),
1867-
derived_cause.clone(),
1859+
cause.clone(),
18681860
trait_def_id,
1869-
obligation.recursion_depth + 1,
1861+
recursion_depth,
18701862
normalized_ty,
18711863
vec![]);
18721864
obligations.push(skol_obligation);
@@ -2013,7 +2005,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
20132005
obligation)
20142006
};
20152007

2016-
self.collect_predicates_for_types(obligation, trait_def, nested)
2008+
let cause = self.derived_cause(obligation, BuiltinDerivedObligation);
2009+
self.collect_predicates_for_types(cause,
2010+
obligation.recursion_depth+1,
2011+
trait_def,
2012+
nested)
20172013
} else {
20182014
vec![]
20192015
};
@@ -2087,17 +2083,21 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
20872083
nested: ty::Binder<Vec<Ty<'tcx>>>)
20882084
-> VtableDefaultImplData<PredicateObligation<'tcx>>
20892085
{
2090-
debug!("vtable_default_impl_data: nested={:?}", nested);
2086+
debug!("vtable_default_impl: nested={:?}", nested);
20912087

2092-
let mut obligations = self.collect_predicates_for_types(obligation,
2093-
trait_def_id,
2094-
nested);
2088+
let cause = self.derived_cause(obligation, BuiltinDerivedObligation);
2089+
let mut obligations = self.collect_predicates_for_types(
2090+
cause,
2091+
obligation.recursion_depth+1,
2092+
trait_def_id,
2093+
nested);
20952094

20962095
let trait_obligations = self.infcx.in_snapshot(|snapshot| {
20972096
let poly_trait_ref = obligation.predicate.to_poly_trait_ref();
20982097
let (trait_ref, skol_map) =
20992098
self.infcx().skolemize_late_bound_regions(&poly_trait_ref, snapshot);
2100-
self.impl_or_trait_obligations(obligation.cause.clone(),
2099+
let cause = self.derived_cause(obligation, ImplDerivedObligation);
2100+
self.impl_or_trait_obligations(cause,
21012101
obligation.recursion_depth + 1,
21022102
trait_def_id,
21032103
&trait_ref.substs,
@@ -2107,7 +2107,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
21072107

21082108
obligations.extend(trait_obligations);
21092109

2110-
debug!("vtable_default_impl_data: obligations={:?}", obligations);
2110+
debug!("vtable_default_impl: obligations={:?}", obligations);
21112111

21122112
VtableDefaultImplData {
21132113
trait_def_id: trait_def_id,
@@ -2131,8 +2131,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
21312131
self.rematch_impl(impl_def_id, obligation,
21322132
snapshot);
21332133
debug!("confirm_impl_candidate substs={:?}", substs);
2134-
self.vtable_impl(impl_def_id, substs, obligation.cause.clone(),
2135-
obligation.recursion_depth + 1, skol_map, snapshot)
2134+
let cause = self.derived_cause(obligation, ImplDerivedObligation);
2135+
self.vtable_impl(impl_def_id, substs, cause,
2136+
obligation.recursion_depth + 1,
2137+
skol_map, snapshot)
21362138
})
21372139
}
21382140

0 commit comments

Comments
 (0)