@@ -33,7 +33,7 @@ use rustc_span::{ErrorGuaranteed, FileName, Ident, LocalExpnId, Span, sym};
3333use smallvec:: SmallVec ;
3434
3535use crate :: base:: * ;
36- use crate :: config:: StripUnconfigured ;
36+ use crate :: config:: { StripUnconfigured , attr_into_trace } ;
3737use crate :: errors:: {
3838 EmptyDelegationMac , GlobDelegationOutsideImpls , GlobDelegationTraitlessQpath , IncompleteParse ,
3939 RecursionLimitReached , RemoveExprNotSupported , RemoveNodeNotSupported , UnsupportedKeyValue ,
@@ -2003,7 +2003,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
20032003 let attr_name = attr. ident ( ) . unwrap ( ) . name ;
20042004 // `#[cfg]` and `#[cfg_attr]` are special - they are
20052005 // eagerly evaluated.
2006- if attr_name != sym:: cfg && attr_name != sym:: cfg_attr_trace {
2006+ if attr_name != sym:: cfg_trace && attr_name != sym:: cfg_attr_trace {
20072007 self . cx . sess . psess . buffer_lint (
20082008 UNUSED_ATTRIBUTES ,
20092009 attr. span ,
@@ -2027,11 +2027,10 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
20272027 ) -> ( bool , Option < ast:: MetaItem > ) {
20282028 let ( res, meta_item) = self . cfg ( ) . cfg_true ( & attr) ;
20292029 if res {
2030- // FIXME: `cfg(TRUE)` attributes do not currently remove themselves during expansion,
2031- // and some tools like rustdoc and clippy rely on that. Find a way to remove them
2032- // while keeping the tools working.
2033- self . cx . expanded_inert_attrs . mark ( & attr) ;
2034- node. visit_attrs ( |attrs| attrs. insert ( pos, attr) ) ;
2030+ // A trace attribute left in AST in place of the original `cfg` attribute.
2031+ // It can later be used by lints or other diagnostics.
2032+ let trace_attr = attr_into_trace ( attr, sym:: cfg_trace) ;
2033+ node. visit_attrs ( |attrs| attrs. insert ( pos, trace_attr) ) ;
20352034 }
20362035
20372036 ( res, meta_item)
0 commit comments