@@ -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 ,
@@ -1941,7 +1941,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
19411941 let attr_name = attr. ident ( ) . unwrap ( ) . name ;
19421942 // `#[cfg]` and `#[cfg_attr]` are special - they are
19431943 // eagerly evaluated.
1944- if attr_name != sym:: cfg && attr_name != sym:: cfg_attr {
1944+ if attr_name != sym:: cfg_trace && attr_name != sym:: cfg_attr_trace {
19451945 self . cx . sess . psess . buffer_lint (
19461946 UNUSED_ATTRIBUTES ,
19471947 attr. span ,
@@ -1965,11 +1965,10 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
19651965 ) -> ( bool , Option < ast:: MetaItem > ) {
19661966 let ( res, meta_item) = self . cfg ( ) . cfg_true ( & attr) ;
19671967 if res {
1968- // FIXME: `cfg(TRUE)` attributes do not currently remove themselves during expansion,
1969- // and some tools like rustdoc and clippy rely on that. Find a way to remove them
1970- // while keeping the tools working.
1971- self . cx . expanded_inert_attrs . mark ( & attr) ;
1972- node. visit_attrs ( |attrs| attrs. insert ( pos, attr) ) ;
1968+ // A trace attribute left in AST in place of the original `cfg` attribute.
1969+ // It can later be used by lints or other diagnostics.
1970+ let trace_attr = attr_into_trace ( attr, sym:: cfg_trace) ;
1971+ node. visit_attrs ( |attrs| attrs. insert ( pos, trace_attr) ) ;
19731972 }
19741973
19751974 ( res, meta_item)
0 commit comments