@@ -5,6 +5,7 @@ use rustc::ty::query::Providers;
5
5
use rustc:: ty:: subst:: GenericArgKind ;
6
6
use rustc:: ty:: { self , CratePredicatesMap , TyCtxt } ;
7
7
use syntax:: symbol:: sym;
8
+ use syntax_pos:: Span ;
8
9
9
10
mod explicit;
10
11
mod implicit_infer;
@@ -23,7 +24,7 @@ pub fn provide(providers: &mut Providers<'_>) {
23
24
fn inferred_outlives_of (
24
25
tcx : TyCtxt < ' _ > ,
25
26
item_def_id : DefId ,
26
- ) -> & [ ty:: Predicate < ' _ > ] {
27
+ ) -> & [ ( ty:: Predicate < ' _ > , Span ) ] {
27
28
let id = tcx
28
29
. hir ( )
29
30
. as_local_hir_id ( item_def_id)
@@ -43,7 +44,7 @@ fn inferred_outlives_of(
43
44
if tcx. has_attr ( item_def_id, sym:: rustc_outlives) {
44
45
let mut pred: Vec < String > = predicates
45
46
. iter ( )
46
- . map ( |out_pred| match out_pred {
47
+ . map ( |( out_pred, _ ) | match out_pred {
47
48
ty:: Predicate :: RegionOutlives ( p) => p. to_string ( ) ,
48
49
ty:: Predicate :: TypeOutlives ( p) => p. to_string ( ) ,
49
50
err => bug ! ( "unexpected predicate {:?}" , err) ,
@@ -96,27 +97,43 @@ fn inferred_outlives_crate(
96
97
let predicates = global_inferred_outlives
97
98
. iter ( )
98
99
. map ( |( & def_id, set) | {
99
- let predicates = tcx. arena . alloc_from_iter ( set
100
+ let def_span = tcx. def_span ( def_id) ;
101
+ let generics = tcx. generics_of ( def_id) ;
102
+ let predicates = & * tcx. arena . alloc_from_iter ( set
100
103
. iter ( )
101
104
. filter_map (
102
105
|ty:: OutlivesPredicate ( kind1, region2) | match kind1. unpack ( ) {
103
106
GenericArgKind :: Type ( ty1) => {
104
- Some ( ty:: Predicate :: TypeOutlives ( ty:: Binder :: bind (
107
+ // FIXME(eddyb) compute `Span`s in `implicit_infer`.
108
+ let span = match & ty1. kind {
109
+ ty:: Param ( p) => {
110
+ tcx. def_span ( generics. type_param ( p, tcx) . def_id )
111
+ }
112
+ _ => def_span,
113
+ } ;
114
+ Some ( ( ty:: Predicate :: TypeOutlives ( ty:: Binder :: bind (
105
115
ty:: OutlivesPredicate ( ty1, region2)
106
- ) ) )
116
+ ) ) , span ) )
107
117
}
108
118
GenericArgKind :: Lifetime ( region1) => {
109
- Some ( ty:: Predicate :: RegionOutlives (
119
+ // FIXME(eddyb) compute `Span`s in `implicit_infer`.
120
+ let span = match region1 {
121
+ ty:: RegionKind :: ReEarlyBound ( p) => {
122
+ tcx. def_span ( generics. region_param ( p, tcx) . def_id )
123
+ }
124
+ _ => def_span,
125
+ } ;
126
+ Some ( ( ty:: Predicate :: RegionOutlives (
110
127
ty:: Binder :: bind ( ty:: OutlivesPredicate ( region1, region2) )
111
- ) )
128
+ ) , span ) )
112
129
}
113
130
GenericArgKind :: Const ( _) => {
114
131
// Generic consts don't impose any constraints.
115
132
None
116
133
}
117
134
} ,
118
135
) ) ;
119
- ( def_id, & * predicates)
136
+ ( def_id, predicates)
120
137
} ) . collect ( ) ;
121
138
122
139
tcx. arena . alloc ( ty:: CratePredicatesMap {
0 commit comments