@@ -551,11 +551,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
551
551
// attribute is expanded. Therefore, we don't need to configure the tokens
552
552
// Derive macros *can* see the results of cfg-expansion - they are handled
553
553
// specially in `fully_expand_fragment`
554
- cfg : StripUnconfigured {
555
- sess : & self . cx . sess ,
556
- features : self . cx . ecfg . features ,
557
- config_tokens : false ,
558
- } ,
559
554
cx : self . cx ,
560
555
invocations : Vec :: new ( ) ,
561
556
monotonic : self . monotonic ,
@@ -1537,12 +1532,20 @@ impl InvocationCollectorNode for AstLikeWrapper<P<ast::Expr>, OptExprTag> {
1537
1532
1538
1533
struct InvocationCollector < ' a , ' b > {
1539
1534
cx : & ' a mut ExtCtxt < ' b > ,
1540
- cfg : StripUnconfigured < ' a > ,
1541
1535
invocations : Vec < ( Invocation , Option < Lrc < SyntaxExtension > > ) > ,
1542
1536
monotonic : bool ,
1543
1537
}
1544
1538
1545
1539
impl < ' 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
+
1546
1549
fn collect ( & mut self , fragment_kind : AstFragmentKind , kind : InvocationKind ) -> AstFragment {
1547
1550
let expn_id = LocalExpnId :: fresh_empty ( ) ;
1548
1551
let vis = kind. placeholder_visibility ( ) ;
@@ -1682,7 +1685,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1682
1685
attr : ast:: Attribute ,
1683
1686
pos : usize ,
1684
1687
) -> bool {
1685
- let res = self . cfg . cfg_true ( & attr) ;
1688
+ let res = self . cfg ( ) . cfg_true ( & attr) ;
1686
1689
if res {
1687
1690
// FIXME: `cfg(TRUE)` attributes do not currently remove themselves during expansion,
1688
1691
// 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> {
1695
1698
1696
1699
fn expand_cfg_attr ( & self , node : & mut impl AstLike , attr : ast:: Attribute , pos : usize ) {
1697
1700
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 ) ) ;
1699
1702
} ) ;
1700
1703
}
1701
1704
@@ -1717,7 +1720,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1717
1720
continue ;
1718
1721
}
1719
1722
_ => {
1720
- Node :: pre_flat_map_node_collect_attr ( & self . cfg , & attr) ;
1723
+ Node :: pre_flat_map_node_collect_attr ( & self . cfg ( ) , & attr) ;
1721
1724
self . collect_attr ( ( attr, pos, derives) , node. to_annotatable ( ) , Node :: KIND )
1722
1725
. make_ast :: < Node > ( )
1723
1726
}
@@ -1881,7 +1884,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1881
1884
fn visit_expr ( & mut self , node : & mut P < ast:: Expr > ) {
1882
1885
// FIXME: Feature gating is performed inconsistently between `Expr` and `OptExpr`.
1883
1886
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) ;
1885
1888
}
1886
1889
self . visit_node ( node)
1887
1890
}
0 commit comments