@@ -4,6 +4,7 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
4
4
use rustc:: ty:: subst:: { GenericArg , Subst , GenericArgKind } ;
5
5
use rustc:: ty:: { self , Ty , TyCtxt } ;
6
6
use rustc:: util:: nodemap:: FxHashMap ;
7
+ use syntax_pos:: Span ;
7
8
8
9
use super :: explicit:: ExplicitPredicatesMap ;
9
10
use super :: utils:: * ;
@@ -79,9 +80,11 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
79
80
// (struct/enum/union) there will be outlive
80
81
// requirements for adt_def.
81
82
let field_ty = self . tcx . type_of ( field_def. did ) ;
83
+ let field_span = self . tcx . def_span ( field_def. did ) ;
82
84
insert_required_predicates_to_be_wf (
83
85
self . tcx ,
84
86
field_ty,
87
+ field_span,
85
88
self . global_inferred_outlives ,
86
89
& mut item_required_predicates,
87
90
& mut self . explicit_map ,
@@ -118,6 +121,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
118
121
fn insert_required_predicates_to_be_wf < ' tcx > (
119
122
tcx : TyCtxt < ' tcx > ,
120
123
field_ty : Ty < ' tcx > ,
124
+ field_span : Span ,
121
125
global_inferred_outlives : & FxHashMap < DefId , RequiredPredicates < ' tcx > > ,
122
126
required_predicates : & mut RequiredPredicates < ' tcx > ,
123
127
explicit_map : & mut ExplicitPredicatesMap < ' tcx > ,
@@ -130,7 +134,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
130
134
// We also want to calculate potential predicates for the T
131
135
ty:: Ref ( region, rty, _) => {
132
136
debug ! ( "Ref" ) ;
133
- insert_outlives_predicate ( tcx, rty. into ( ) , region, required_predicates) ;
137
+ insert_outlives_predicate ( tcx, rty. into ( ) , region, field_span , required_predicates) ;
134
138
}
135
139
136
140
// For each Adt (struct/enum/union) type `Foo<'a, T>`, we
@@ -158,7 +162,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
158
162
// 'a` holds for `Foo`.
159
163
debug ! ( "Adt" ) ;
160
164
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 {
162
166
// `unsubstituted_predicate` is `U: 'b` in the
163
167
// example above. So apply the substitution to
164
168
// get `T: 'a` (or `predicate`):
@@ -167,6 +171,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
167
171
tcx,
168
172
predicate. 0 ,
169
173
predicate. 1 ,
174
+ span,
170
175
required_predicates,
171
176
) ;
172
177
}
@@ -272,7 +277,7 @@ pub fn check_explicit_predicates<'tcx>(
272
277
) ;
273
278
let explicit_predicates = explicit_map. explicit_predicates_of ( tcx, def_id) ;
274
279
275
- for outlives_predicate in explicit_predicates. iter ( ) {
280
+ for ( outlives_predicate, & span ) in explicit_predicates {
276
281
debug ! ( "outlives_predicate = {:?}" , & outlives_predicate) ;
277
282
278
283
// Careful: If we are inferring the effects of a `dyn Trait<..>`
@@ -320,6 +325,6 @@ pub fn check_explicit_predicates<'tcx>(
320
325
321
326
let predicate = outlives_predicate. subst ( tcx, substs) ;
322
327
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) ;
324
329
}
325
330
}
0 commit comments