@@ -4,6 +4,7 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
44use rustc:: ty:: subst:: { GenericArg , Subst , GenericArgKind } ;
55use rustc:: ty:: { self , Ty , TyCtxt } ;
66use rustc:: util:: nodemap:: FxHashMap ;
7+ use syntax_pos:: Span ;
78
89use super :: explicit:: ExplicitPredicatesMap ;
910use super :: utils:: * ;
@@ -79,9 +80,11 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
7980 // (struct/enum/union) there will be outlive
8081 // requirements for adt_def.
8182 let field_ty = self . tcx . type_of ( field_def. did ) ;
83+ let field_span = self . tcx . def_span ( field_def. did ) ;
8284 insert_required_predicates_to_be_wf (
8385 self . tcx ,
8486 field_ty,
87+ field_span,
8588 self . global_inferred_outlives ,
8689 & mut item_required_predicates,
8790 & mut self . explicit_map ,
@@ -118,6 +121,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
118121fn insert_required_predicates_to_be_wf < ' tcx > (
119122 tcx : TyCtxt < ' tcx > ,
120123 field_ty : Ty < ' tcx > ,
124+ field_span : Span ,
121125 global_inferred_outlives : & FxHashMap < DefId , RequiredPredicates < ' tcx > > ,
122126 required_predicates : & mut RequiredPredicates < ' tcx > ,
123127 explicit_map : & mut ExplicitPredicatesMap < ' tcx > ,
@@ -130,7 +134,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
130134 // We also want to calculate potential predicates for the T
131135 ty:: Ref ( region, rty, _) => {
132136 debug ! ( "Ref" ) ;
133- insert_outlives_predicate ( tcx, rty. into ( ) , region, required_predicates) ;
137+ insert_outlives_predicate ( tcx, rty. into ( ) , region, field_span , required_predicates) ;
134138 }
135139
136140 // For each Adt (struct/enum/union) type `Foo<'a, T>`, we
@@ -158,7 +162,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
158162 // 'a` holds for `Foo`.
159163 debug ! ( "Adt" ) ;
160164 if let Some ( unsubstituted_predicates) = global_inferred_outlives. get ( & def. did ) {
161- for unsubstituted_predicate in unsubstituted_predicates {
165+ for ( unsubstituted_predicate, & span ) in unsubstituted_predicates {
162166 // `unsubstituted_predicate` is `U: 'b` in the
163167 // example above. So apply the substitution to
164168 // get `T: 'a` (or `predicate`):
@@ -167,6 +171,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
167171 tcx,
168172 predicate. 0 ,
169173 predicate. 1 ,
174+ span,
170175 required_predicates,
171176 ) ;
172177 }
@@ -272,7 +277,7 @@ pub fn check_explicit_predicates<'tcx>(
272277 ) ;
273278 let explicit_predicates = explicit_map. explicit_predicates_of ( tcx, def_id) ;
274279
275- for outlives_predicate in explicit_predicates. iter ( ) {
280+ for ( outlives_predicate, & span ) in explicit_predicates {
276281 debug ! ( "outlives_predicate = {:?}" , & outlives_predicate) ;
277282
278283 // Careful: If we are inferring the effects of a `dyn Trait<..>`
@@ -320,6 +325,6 @@ pub fn check_explicit_predicates<'tcx>(
320325
321326 let predicate = outlives_predicate. subst ( tcx, substs) ;
322327 debug ! ( "predicate = {:?}" , & predicate) ;
323- insert_outlives_predicate ( tcx, predicate. 0 . into ( ) , predicate. 1 , required_predicates) ;
328+ insert_outlives_predicate ( tcx, predicate. 0 . into ( ) , predicate. 1 , span , required_predicates) ;
324329 }
325330}
0 commit comments