@@ -56,7 +56,7 @@ use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
56
56
use rustc_hir:: def_id:: { CRATE_DEF_ID , LOCAL_CRATE , LocalDefId } ;
57
57
use rustc_hir:: {
58
58
self as hir, ConstArg , GenericArg , HirId , ItemLocalMap , LangItem , LifetimeSource ,
59
- LifetimeSyntax , ParamName , TraitCandidate ,
59
+ LifetimeSyntax , ParamName , TraitCandidate , TySource ,
60
60
} ;
61
61
use rustc_index:: { Idx , IndexSlice , IndexVec } ;
62
62
use rustc_macros:: extension;
@@ -1172,7 +1172,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1172
1172
bounds,
1173
1173
TaggedRef :: new ( lifetime_bound, TraitObjectSyntax :: None ) ,
1174
1174
) ;
1175
- return hir:: Ty { kind, span : self . lower_span ( t. span ) , hir_id : self . next_id ( ) } ;
1175
+ return hir:: Ty {
1176
+ kind,
1177
+ span : self . lower_span ( t. span ) ,
1178
+ hir_id : self . next_id ( ) ,
1179
+ source : TySource :: Other ,
1180
+ } ;
1176
1181
}
1177
1182
1178
1183
let id = self . lower_node_id ( t. id ) ;
@@ -1189,7 +1194,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1189
1194
}
1190
1195
1191
1196
fn ty ( & mut self , span : Span , kind : hir:: TyKind < ' hir > ) -> hir:: Ty < ' hir > {
1192
- hir:: Ty { hir_id : self . next_id ( ) , kind, span : self . lower_span ( span) }
1197
+ hir:: Ty {
1198
+ hir_id : self . next_id ( ) ,
1199
+ kind,
1200
+ span : self . lower_span ( span) ,
1201
+ source : TySource :: Other ,
1202
+ }
1193
1203
}
1194
1204
1195
1205
fn ty_tup ( & mut self , span : Span , tys : & ' hir [ hir:: Ty < ' hir > ] ) -> hir:: Ty < ' hir > {
@@ -1210,7 +1220,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1210
1220
let lifetime = self . lower_ty_direct_lifetime ( t, * region) ;
1211
1221
let kind = hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) ) ;
1212
1222
let span = self . lower_span ( t. span ) ;
1213
- let arg = hir:: Ty { kind, span, hir_id : self . next_id ( ) } ;
1223
+ let arg = hir:: Ty { kind, span, hir_id : self . next_id ( ) , source : TySource :: Other } ;
1214
1224
let args = self . arena . alloc ( hir:: GenericArgs {
1215
1225
args : self . arena . alloc ( [ hir:: GenericArg :: Type ( self . arena . alloc ( arg) ) ] ) ,
1216
1226
constraints : & [ ] ,
@@ -1375,7 +1385,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1375
1385
TyKind :: Dummy => panic ! ( "`TyKind::Dummy` should never be lowered" ) ,
1376
1386
} ;
1377
1387
1378
- hir:: Ty { kind, span : self . lower_span ( t. span ) , hir_id : self . lower_node_id ( t. id ) }
1388
+ hir:: Ty {
1389
+ kind,
1390
+ span : self . lower_span ( t. span ) ,
1391
+ hir_id : self . lower_node_id ( t. id ) ,
1392
+ source : TySource :: Other ,
1393
+ }
1379
1394
}
1380
1395
1381
1396
fn lower_ty_direct_lifetime (
@@ -2378,7 +2393,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2378
2393
}
2379
2394
}
2380
2395
2381
- fn ty_path ( & mut self , mut hir_id : HirId , span : Span , qpath : hir:: QPath < ' hir > ) -> hir:: Ty < ' hir > {
2396
+ fn ty_path ( & mut self , hir_id : HirId , span : Span , qpath : hir:: QPath < ' hir > ) -> hir:: Ty < ' hir > {
2397
+ self . ty_path_with_source ( hir_id, span, qpath, TySource :: Other )
2398
+ }
2399
+
2400
+ fn ty_path_with_source (
2401
+ & mut self ,
2402
+ mut hir_id : HirId ,
2403
+ span : Span ,
2404
+ qpath : hir:: QPath < ' hir > ,
2405
+ source : TySource ,
2406
+ ) -> hir:: Ty < ' hir > {
2382
2407
let kind = match qpath {
2383
2408
hir:: QPath :: Resolved ( None , path) => {
2384
2409
// Turn trait object paths into `TyKind::TraitObject` instead.
@@ -2405,7 +2430,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2405
2430
_ => hir:: TyKind :: Path ( qpath) ,
2406
2431
} ;
2407
2432
2408
- hir:: Ty { hir_id, kind, span : self . lower_span ( span) }
2433
+ hir:: Ty { hir_id, kind, span : self . lower_span ( span) , source }
2409
2434
}
2410
2435
2411
2436
/// Invoked to create the lifetime argument(s) for an elided trait object
0 commit comments