@@ -551,11 +551,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
551551 // attribute is expanded. Therefore, we don't need to configure the tokens
552552 // Derive macros *can* see the results of cfg-expansion - they are handled
553553 // specially in `fully_expand_fragment`
554- cfg : StripUnconfigured {
555- sess : & self . cx . sess ,
556- features : self . cx . ecfg . features ,
557- config_tokens : false ,
558- } ,
559554 cx : self . cx ,
560555 invocations : Vec :: new ( ) ,
561556 monotonic : self . monotonic ,
@@ -1537,12 +1532,20 @@ impl InvocationCollectorNode for AstLikeWrapper<P<ast::Expr>, OptExprTag> {
15371532
15381533struct InvocationCollector < ' a , ' b > {
15391534 cx : & ' a mut ExtCtxt < ' b > ,
1540- cfg : StripUnconfigured < ' a > ,
15411535 invocations : Vec < ( Invocation , Option < Lrc < SyntaxExtension > > ) > ,
15421536 monotonic : bool ,
15431537}
15441538
15451539impl < ' a , ' b > InvocationCollector < ' a , ' b > {
1540+ fn cfg ( & self ) -> StripUnconfigured < ' _ > {
1541+ StripUnconfigured {
1542+ sess : & self . cx . sess ,
1543+ features : self . cx . ecfg . features ,
1544+ config_tokens : false ,
1545+ lint_node_id : self . cx . current_expansion . lint_node_id ,
1546+ }
1547+ }
1548+
15461549 fn collect ( & mut self , fragment_kind : AstFragmentKind , kind : InvocationKind ) -> AstFragment {
15471550 let expn_id = LocalExpnId :: fresh_empty ( ) ;
15481551 let vis = kind. placeholder_visibility ( ) ;
@@ -1682,7 +1685,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
16821685 attr : ast:: Attribute ,
16831686 pos : usize ,
16841687 ) -> bool {
1685- let res = self . cfg . cfg_true ( & attr) ;
1688+ let res = self . cfg ( ) . cfg_true ( & attr) ;
16861689 if res {
16871690 // FIXME: `cfg(TRUE)` attributes do not currently remove themselves during expansion,
16881691 // and some tools like rustdoc and clippy rely on that. Find a way to remove them
@@ -1695,7 +1698,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
16951698
16961699 fn expand_cfg_attr ( & self , node : & mut impl AstLike , attr : ast:: Attribute , pos : usize ) {
16971700 node. visit_attrs ( |attrs| {
1698- attrs. splice ( pos..pos, self . cfg . expand_cfg_attr ( attr, false ) ) ;
1701+ attrs. splice ( pos..pos, self . cfg ( ) . expand_cfg_attr ( attr, false ) ) ;
16991702 } ) ;
17001703 }
17011704
@@ -1717,7 +1720,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
17171720 continue ;
17181721 }
17191722 _ => {
1720- Node :: pre_flat_map_node_collect_attr ( & self . cfg , & attr) ;
1723+ Node :: pre_flat_map_node_collect_attr ( & self . cfg ( ) , & attr) ;
17211724 self . collect_attr ( ( attr, pos, derives) , node. to_annotatable ( ) , Node :: KIND )
17221725 . make_ast :: < Node > ( )
17231726 }
@@ -1881,7 +1884,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
18811884 fn visit_expr ( & mut self , node : & mut P < ast:: Expr > ) {
18821885 // FIXME: Feature gating is performed inconsistently between `Expr` and `OptExpr`.
18831886 if let Some ( attr) = node. attrs . first ( ) {
1884- self . cfg . maybe_emit_expr_attr_err ( attr) ;
1887+ self . cfg ( ) . maybe_emit_expr_attr_err ( attr) ;
18851888 }
18861889 self . visit_node ( node)
18871890 }
0 commit comments