@@ -1823,20 +1823,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1823
1823
}
1824
1824
1825
1825
fn collect_predicates_for_types ( & mut self ,
1826
- obligation : & TraitObligation < ' tcx > ,
1826
+ cause : ObligationCause < ' tcx > ,
1827
+ recursion_depth : usize ,
1827
1828
trait_def_id : DefId ,
1828
1829
types : ty:: Binder < Vec < Ty < ' tcx > > > )
1829
1830
-> Vec < PredicateObligation < ' tcx > >
1830
1831
{
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
-
1840
1832
// Because the types were potentially derived from
1841
1833
// higher-ranked obligations they may reference late-bound
1842
1834
// regions. For example, `for<'a> Foo<&'a int> : Copy` would
@@ -1859,14 +1851,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1859
1851
self . infcx ( ) . skolemize_late_bound_regions ( & ty, snapshot) ;
1860
1852
let Normalized { value : normalized_ty, mut obligations } =
1861
1853
project:: normalize_with_depth ( self ,
1862
- derived_cause . clone ( ) ,
1863
- obligation . recursion_depth + 1 ,
1854
+ cause . clone ( ) ,
1855
+ recursion_depth,
1864
1856
& skol_ty) ;
1865
1857
let skol_obligation =
1866
1858
util:: predicate_for_trait_def ( self . tcx ( ) ,
1867
- derived_cause . clone ( ) ,
1859
+ cause . clone ( ) ,
1868
1860
trait_def_id,
1869
- obligation . recursion_depth + 1 ,
1861
+ recursion_depth,
1870
1862
normalized_ty,
1871
1863
vec ! [ ] ) ;
1872
1864
obligations. push ( skol_obligation) ;
@@ -2013,7 +2005,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2013
2005
obligation)
2014
2006
} ;
2015
2007
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)
2017
2013
} else {
2018
2014
vec ! [ ]
2019
2015
} ;
@@ -2087,17 +2083,21 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2087
2083
nested : ty:: Binder < Vec < Ty < ' tcx > > > )
2088
2084
-> VtableDefaultImplData < PredicateObligation < ' tcx > >
2089
2085
{
2090
- debug ! ( "vtable_default_impl_data : nested={:?}" , nested) ;
2086
+ debug ! ( "vtable_default_impl : nested={:?}" , nested) ;
2091
2087
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) ;
2095
2094
2096
2095
let trait_obligations = self . infcx . in_snapshot ( |snapshot| {
2097
2096
let poly_trait_ref = obligation. predicate . to_poly_trait_ref ( ) ;
2098
2097
let ( trait_ref, skol_map) =
2099
2098
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,
2101
2101
obligation. recursion_depth + 1 ,
2102
2102
trait_def_id,
2103
2103
& trait_ref. substs ,
@@ -2107,7 +2107,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2107
2107
2108
2108
obligations. extend ( trait_obligations) ;
2109
2109
2110
- debug ! ( "vtable_default_impl_data : obligations={:?}" , obligations) ;
2110
+ debug ! ( "vtable_default_impl : obligations={:?}" , obligations) ;
2111
2111
2112
2112
VtableDefaultImplData {
2113
2113
trait_def_id : trait_def_id,
@@ -2131,8 +2131,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2131
2131
self . rematch_impl ( impl_def_id, obligation,
2132
2132
snapshot) ;
2133
2133
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)
2136
2138
} )
2137
2139
}
2138
2140
0 commit comments