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