@@ -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 ,
@@ -1941,7 +1941,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1941
1941
let attr_name = attr. ident ( ) . unwrap ( ) . name ;
1942
1942
// `#[cfg]` and `#[cfg_attr]` are special - they are
1943
1943
// 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 {
1945
1945
self . cx . sess . psess . buffer_lint (
1946
1946
UNUSED_ATTRIBUTES ,
1947
1947
attr. span ,
@@ -1965,11 +1965,10 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1965
1965
) -> ( bool , Option < ast:: MetaItem > ) {
1966
1966
let ( res, meta_item) = self . cfg ( ) . cfg_true ( & attr) ;
1967
1967
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) ) ;
1973
1972
}
1974
1973
1975
1974
( res, meta_item)
0 commit comments