@@ -33,7 +33,7 @@ use rustc_span::{ErrorGuaranteed, FileName, Ident, LocalExpnId, Span, sym};
33
33
use smallvec:: SmallVec ;
34
34
35
35
use crate :: base:: * ;
36
- use crate :: config:: StripUnconfigured ;
36
+ use crate :: config:: { StripUnconfigured , attr_into_trace } ;
37
37
use crate :: errors:: {
38
38
EmptyDelegationMac , GlobDelegationOutsideImpls , GlobDelegationTraitlessQpath , IncompleteParse ,
39
39
RecursionLimitReached , RemoveExprNotSupported , RemoveNodeNotSupported , UnsupportedKeyValue ,
@@ -2003,7 +2003,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
2003
2003
let attr_name = attr. ident ( ) . unwrap ( ) . name ;
2004
2004
// `#[cfg]` and `#[cfg_attr]` are special - they are
2005
2005
// 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 {
2007
2007
self . cx . sess . psess . buffer_lint (
2008
2008
UNUSED_ATTRIBUTES ,
2009
2009
attr. span ,
@@ -2027,11 +2027,10 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
2027
2027
) -> ( bool , Option < ast:: MetaItem > ) {
2028
2028
let ( res, meta_item) = self . cfg ( ) . cfg_true ( & attr) ;
2029
2029
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) ) ;
2035
2034
}
2036
2035
2037
2036
( res, meta_item)
0 commit comments