@@ -56,6 +56,7 @@ use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
5656use rustc_hir:: def_id:: { CRATE_DEF_ID , LOCAL_CRATE , LocalDefId } ;
5757use rustc_hir:: {
5858 self as hir, ConstArg , GenericArg , HirId , ItemLocalMap , LangItem , ParamName , TraitCandidate ,
59+ TySource ,
5960} ;
6061use rustc_index:: { Idx , IndexSlice , IndexVec } ;
6162use rustc_macros:: extension;
@@ -1165,7 +1166,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11651166 bounds,
11661167 TaggedRef :: new ( lifetime_bound, TraitObjectSyntax :: None ) ,
11671168 ) ;
1168- return hir:: Ty { kind, span : self . lower_span ( t. span ) , hir_id : self . next_id ( ) } ;
1169+ return hir:: Ty {
1170+ kind,
1171+ span : self . lower_span ( t. span ) ,
1172+ hir_id : self . next_id ( ) ,
1173+ source : TySource :: Other ,
1174+ } ;
11691175 }
11701176
11711177 let id = self . lower_node_id ( t. id ) ;
@@ -1182,7 +1188,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11821188 }
11831189
11841190 fn ty ( & mut self , span : Span , kind : hir:: TyKind < ' hir > ) -> hir:: Ty < ' hir > {
1185- hir:: Ty { hir_id : self . next_id ( ) , kind, span : self . lower_span ( span) }
1191+ hir:: Ty {
1192+ hir_id : self . next_id ( ) ,
1193+ kind,
1194+ span : self . lower_span ( span) ,
1195+ source : TySource :: Other ,
1196+ }
11861197 }
11871198
11881199 fn ty_tup ( & mut self , span : Span , tys : & ' hir [ hir:: Ty < ' hir > ] ) -> hir:: Ty < ' hir > {
@@ -1227,7 +1238,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12271238 let lifetime = self . lower_lifetime ( & region) ;
12281239 let kind = hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) ) ;
12291240 let span = self . lower_span ( t. span ) ;
1230- let arg = hir:: Ty { kind, span, hir_id : self . next_id ( ) } ;
1241+ let arg = hir:: Ty { kind, span, hir_id : self . next_id ( ) , source : TySource :: Other } ;
12311242 let args = self . arena . alloc ( hir:: GenericArgs {
12321243 args : self . arena . alloc ( [ hir:: GenericArg :: Type ( self . arena . alloc ( arg) ) ] ) ,
12331244 constraints : & [ ] ,
@@ -1388,7 +1399,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13881399 TyKind :: Dummy => panic ! ( "`TyKind::Dummy` should never be lowered" ) ,
13891400 } ;
13901401
1391- hir:: Ty { kind, span : self . lower_span ( t. span ) , hir_id : self . lower_node_id ( t. id ) }
1402+ hir:: Ty {
1403+ kind,
1404+ span : self . lower_span ( t. span ) ,
1405+ hir_id : self . lower_node_id ( t. id ) ,
1406+ source : TySource :: Other ,
1407+ }
13921408 }
13931409
13941410 /// Lowers a `ReturnPositionOpaqueTy` (`-> impl Trait`) or a `TypeAliasesOpaqueTy` (`type F =
@@ -2354,7 +2370,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23542370 }
23552371 }
23562372
2357- fn ty_path ( & mut self , mut hir_id : HirId , span : Span , qpath : hir:: QPath < ' hir > ) -> hir:: Ty < ' hir > {
2373+ fn ty_path ( & mut self , hir_id : HirId , span : Span , qpath : hir:: QPath < ' hir > ) -> hir:: Ty < ' hir > {
2374+ self . ty_path_with_source ( hir_id, span, qpath, TySource :: Other )
2375+ }
2376+
2377+ fn ty_path_with_source (
2378+ & mut self ,
2379+ mut hir_id : HirId ,
2380+ span : Span ,
2381+ qpath : hir:: QPath < ' hir > ,
2382+ source : TySource ,
2383+ ) -> hir:: Ty < ' hir > {
23582384 let kind = match qpath {
23592385 hir:: QPath :: Resolved ( None , path) => {
23602386 // Turn trait object paths into `TyKind::TraitObject` instead.
@@ -2381,7 +2407,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23812407 _ => hir:: TyKind :: Path ( qpath) ,
23822408 } ;
23832409
2384- hir:: Ty { hir_id, kind, span : self . lower_span ( span) }
2410+ hir:: Ty { hir_id, kind, span : self . lower_span ( span) , source }
23852411 }
23862412
23872413 /// Invoked to create the lifetime argument(s) for an elided trait object
0 commit comments