@@ -5,6 +5,7 @@ use rustc::ty::query::Providers;
55use rustc:: ty:: subst:: GenericArgKind ;
66use rustc:: ty:: { self , CratePredicatesMap , TyCtxt } ;
77use syntax:: symbol:: sym;
8+ use syntax_pos:: Span ;
89
910mod explicit;
1011mod implicit_infer;
@@ -23,7 +24,7 @@ pub fn provide(providers: &mut Providers<'_>) {
2324fn inferred_outlives_of (
2425 tcx : TyCtxt < ' _ > ,
2526 item_def_id : DefId ,
26- ) -> & [ ty:: Predicate < ' _ > ] {
27+ ) -> & [ ( ty:: Predicate < ' _ > , Span ) ] {
2728 let id = tcx
2829 . hir ( )
2930 . as_local_hir_id ( item_def_id)
@@ -43,7 +44,7 @@ fn inferred_outlives_of(
4344 if tcx. has_attr ( item_def_id, sym:: rustc_outlives) {
4445 let mut pred: Vec < String > = predicates
4546 . iter ( )
46- . map ( |out_pred| match out_pred {
47+ . map ( |( out_pred, _ ) | match out_pred {
4748 ty:: Predicate :: RegionOutlives ( p) => p. to_string ( ) ,
4849 ty:: Predicate :: TypeOutlives ( p) => p. to_string ( ) ,
4950 err => bug ! ( "unexpected predicate {:?}" , err) ,
@@ -96,27 +97,43 @@ fn inferred_outlives_crate(
9697 let predicates = global_inferred_outlives
9798 . iter ( )
9899 . 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
100103 . iter ( )
101104 . filter_map (
102105 |ty:: OutlivesPredicate ( kind1, region2) | match kind1. unpack ( ) {
103106 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 (
105115 ty:: OutlivesPredicate ( ty1, region2)
106- ) ) )
116+ ) ) , span ) )
107117 }
108118 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 (
110127 ty:: Binder :: bind ( ty:: OutlivesPredicate ( region1, region2) )
111- ) )
128+ ) , span ) )
112129 }
113130 GenericArgKind :: Const ( _) => {
114131 // Generic consts don't impose any constraints.
115132 None
116133 }
117134 } ,
118135 ) ) ;
119- ( def_id, & * predicates)
136+ ( def_id, predicates)
120137 } ) . collect ( ) ;
121138
122139 tcx. arena . alloc ( ty:: CratePredicatesMap {
0 commit comments