@@ -67,6 +67,7 @@ use rustc_middle::{
6767 ty:: { ResolverAstLowering , TyCtxt } ,
6868} ;
6969use rustc_session:: parse:: { add_feature_diagnostics, feature_err} ;
70+ use rustc_span:: hygiene:: MacroKind ;
7071use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
7172use rustc_span:: { DesugaringKind , Span , DUMMY_SP } ;
7273use smallvec:: SmallVec ;
@@ -152,6 +153,7 @@ trait ResolverAstLoweringExt {
152153 fn get_lifetime_res ( & self , id : NodeId ) -> Option < LifetimeRes > ;
153154 fn take_extra_lifetime_params ( & mut self , id : NodeId ) -> Vec < ( Ident , NodeId , LifetimeRes ) > ;
154155 fn remap_extra_lifetime_params ( & mut self , from : NodeId , to : NodeId ) ;
156+ fn decl_macro_kind ( & self , def_id : LocalDefId ) -> MacroKind ;
155157}
156158
157159impl ResolverAstLoweringExt for ResolverAstLowering {
@@ -215,6 +217,10 @@ impl ResolverAstLoweringExt for ResolverAstLowering {
215217 let lifetimes = self . extra_lifetime_params_map . remove ( & from) . unwrap_or_default ( ) ;
216218 self . extra_lifetime_params_map . insert ( to, lifetimes) ;
217219 }
220+
221+ fn decl_macro_kind ( & self , def_id : LocalDefId ) -> MacroKind {
222+ self . builtin_macro_kinds . get ( & def_id) . copied ( ) . unwrap_or ( MacroKind :: Bang )
223+ }
218224}
219225
220226/// Context of `impl Trait` in code, which determines whether it is allowed in an HIR subtree,
@@ -461,7 +467,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
461467 parent : LocalDefId ,
462468 node_id : ast:: NodeId ,
463469 data : DefPathData ,
464- def_kind : DefKind ,
465470 span : Span ,
466471 ) -> LocalDefId {
467472 debug_assert_ne ! ( node_id, ast:: DUMMY_NODE_ID ) ;
@@ -473,7 +478,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
473478 self . tcx. hir( ) . def_key( self . local_def_id( node_id) ) ,
474479 ) ;
475480
476- let def_id = self . tcx . at ( span) . create_def ( parent, data, def_kind ) . def_id ( ) ;
481+ let def_id = self . tcx . at ( span) . create_def ( parent, data) . def_id ( ) ;
477482
478483 debug ! ( "create_def: def_id_to_node_id[{:?}] <-> {:?}" , def_id, node_id) ;
479484 self . resolver . node_id_to_def_id . insert ( node_id, def_id) ;
@@ -775,7 +780,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
775780 self . current_hir_id_owner . def_id ,
776781 param,
777782 DefPathData :: LifetimeNs ( kw:: UnderscoreLifetime ) ,
778- DefKind :: LifetimeParam ,
779783 ident. span ,
780784 ) ;
781785 debug ! ( ?_def_id) ;
@@ -1188,7 +1192,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11881192 parent_def_id. def_id ,
11891193 node_id,
11901194 DefPathData :: AnonConst ,
1191- DefKind :: AnonConst ,
11921195 span,
11931196 ) ;
11941197
@@ -1426,7 +1429,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14261429 self . current_hir_id_owner . def_id ,
14271430 * def_node_id,
14281431 DefPathData :: TypeNs ( ident. name ) ,
1429- DefKind :: TyParam ,
14301432 span,
14311433 ) ;
14321434 let ( param, bounds, path) = self . lower_universal_param_and_bounds (
@@ -1580,7 +1582,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
15801582 self . current_hir_id_owner . def_id ,
15811583 opaque_ty_node_id,
15821584 DefPathData :: ImplTrait ,
1583- DefKind :: OpaqueTy ,
15841585 opaque_ty_span,
15851586 ) ;
15861587 debug ! ( ?opaque_ty_def_id) ;
@@ -1635,7 +1636,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16351636 opaque_ty_def_id,
16361637 duplicated_lifetime_node_id,
16371638 DefPathData :: LifetimeNs ( lifetime. ident . name ) ,
1638- DefKind :: LifetimeParam ,
16391639 lifetime. ident . span ,
16401640 ) ;
16411641 captured_to_synthesized_mapping. insert ( old_def_id, duplicated_lifetime_def_id) ;
@@ -2505,13 +2505,8 @@ impl<'hir> GenericArgsCtor<'hir> {
25052505 } ) ;
25062506 lcx. attrs . insert ( hir_id. local_id , std:: slice:: from_ref ( attr) ) ;
25072507
2508- let def_id = lcx. create_def (
2509- lcx. current_hir_id_owner . def_id ,
2510- id,
2511- DefPathData :: AnonConst ,
2512- DefKind :: AnonConst ,
2513- span,
2514- ) ;
2508+ let def_id =
2509+ lcx. create_def ( lcx. current_hir_id_owner . def_id , id, DefPathData :: AnonConst , span) ;
25152510 lcx. children . push ( ( def_id, hir:: MaybeOwner :: NonOwner ( hir_id) ) ) ;
25162511 self . args . push ( hir:: GenericArg :: Const ( hir:: ConstArg {
25172512 value : hir:: AnonConst { def_id, hir_id, body } ,
0 commit comments