@@ -54,7 +54,7 @@ use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId};
54
54
use rustc_hir:: lints:: DelayedLint ;
55
55
use rustc_hir:: {
56
56
self as hir, AngleBrackets , ConstArg , GenericArg , HirId , ItemLocalMap , LangItem ,
57
- LifetimeSource , LifetimeSyntax , ParamName , TraitCandidate ,
57
+ LifetimeSource , LifetimeSyntax , ParamName , TraitCandidate , TySource ,
58
58
} ;
59
59
use rustc_index:: { Idx , IndexSlice , IndexVec } ;
60
60
use rustc_macros:: extension;
@@ -1220,7 +1220,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1220
1220
bounds,
1221
1221
TaggedRef :: new ( lifetime_bound, TraitObjectSyntax :: None ) ,
1222
1222
) ;
1223
- return hir:: Ty { kind, span : self . lower_span ( t. span ) , hir_id : self . next_id ( ) } ;
1223
+ return hir:: Ty {
1224
+ kind,
1225
+ span : self . lower_span ( t. span ) ,
1226
+ hir_id : self . next_id ( ) ,
1227
+ source : TySource :: Other ,
1228
+ } ;
1224
1229
}
1225
1230
1226
1231
let id = self . lower_node_id ( t. id ) ;
@@ -1237,7 +1242,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1237
1242
}
1238
1243
1239
1244
fn ty ( & mut self , span : Span , kind : hir:: TyKind < ' hir > ) -> hir:: Ty < ' hir > {
1240
- hir:: Ty { hir_id : self . next_id ( ) , kind, span : self . lower_span ( span) }
1245
+ hir:: Ty {
1246
+ hir_id : self . next_id ( ) ,
1247
+ kind,
1248
+ span : self . lower_span ( span) ,
1249
+ source : TySource :: Other ,
1250
+ }
1241
1251
}
1242
1252
1243
1253
fn ty_tup ( & mut self , span : Span , tys : & ' hir [ hir:: Ty < ' hir > ] ) -> hir:: Ty < ' hir > {
@@ -1258,7 +1268,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1258
1268
let lifetime = self . lower_ty_direct_lifetime ( t, * region) ;
1259
1269
let kind = hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) ) ;
1260
1270
let span = self . lower_span ( t. span ) ;
1261
- let arg = hir:: Ty { kind, span, hir_id : self . next_id ( ) } ;
1271
+ let arg = hir:: Ty { kind, span, hir_id : self . next_id ( ) , source : TySource :: Other } ;
1262
1272
let args = self . arena . alloc ( hir:: GenericArgs {
1263
1273
args : self . arena . alloc ( [ hir:: GenericArg :: Type ( self . arena . alloc ( arg) ) ] ) ,
1264
1274
constraints : & [ ] ,
@@ -1423,7 +1433,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1423
1433
TyKind :: Dummy => panic ! ( "`TyKind::Dummy` should never be lowered" ) ,
1424
1434
} ;
1425
1435
1426
- hir:: Ty { kind, span : self . lower_span ( t. span ) , hir_id : self . lower_node_id ( t. id ) }
1436
+ hir:: Ty {
1437
+ kind,
1438
+ span : self . lower_span ( t. span ) ,
1439
+ hir_id : self . lower_node_id ( t. id ) ,
1440
+ source : TySource :: Other ,
1441
+ }
1427
1442
}
1428
1443
1429
1444
fn lower_ty_direct_lifetime (
@@ -2421,7 +2436,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2421
2436
}
2422
2437
}
2423
2438
2424
- fn ty_path ( & mut self , mut hir_id : HirId , span : Span , qpath : hir:: QPath < ' hir > ) -> hir:: Ty < ' hir > {
2439
+ fn ty_path ( & mut self , hir_id : HirId , span : Span , qpath : hir:: QPath < ' hir > ) -> hir:: Ty < ' hir > {
2440
+ self . ty_path_with_source ( hir_id, span, qpath, TySource :: Other )
2441
+ }
2442
+
2443
+ fn ty_path_with_source (
2444
+ & mut self ,
2445
+ mut hir_id : HirId ,
2446
+ span : Span ,
2447
+ qpath : hir:: QPath < ' hir > ,
2448
+ source : TySource ,
2449
+ ) -> hir:: Ty < ' hir > {
2425
2450
let kind = match qpath {
2426
2451
hir:: QPath :: Resolved ( None , path) => {
2427
2452
// Turn trait object paths into `TyKind::TraitObject` instead.
@@ -2448,7 +2473,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2448
2473
_ => hir:: TyKind :: Path ( qpath) ,
2449
2474
} ;
2450
2475
2451
- hir:: Ty { hir_id, kind, span : self . lower_span ( span) }
2476
+ hir:: Ty { hir_id, kind, span : self . lower_span ( span) , source }
2452
2477
}
2453
2478
2454
2479
/// Invoked to create the lifetime argument(s) for an elided trait object
0 commit comments