diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-03-27 13:11:17 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-27 13:11:17 -0400 |
| commit | 3a8621d681ab14db5cf928b2122c97872d57e291 (patch) | |
| tree | 929206f8977bc63eaa4d6c4c364eb6cb1fb37a23 /compiler/rustc_parse/src | |
| parent | ecb170afc878648c3ae355dbd596c8e4b6f7ebdc (diff) | |
| parent | 92d802eda669d69481b99139523008df1c456ba8 (diff) | |
| download | rust-3a8621d681ab14db5cf928b2122c97872d57e291.tar.gz rust-3a8621d681ab14db5cf928b2122c97872d57e291.zip | |
Rollup merge of #138844 - petrochenkov:cfgtrace2, r=nnethercote
expand: Leave traces when expanding `cfg` attributes This is the same as https://github.com/rust-lang/rust/pull/138515, but for `cfg(true)` instead of `cfg_attr`. The difference is that `cfg(true)`s already left "traces" after themselves - the `cfg` attributes themselves, with `expanded_inert_attrs` set to true, with full tokens, available to proc macros. This is not a reasonably expected behavior, but it could not be removed without a replacement, because a [major rustdoc feature](https://github.com/rust-lang/rfcs/pull/3631) and a number of clippy lints rely on it. This PR implements a replacement. This needs a crater run, because it changes observable behavior (in an intended way) - proc macros can no longer see expanded `cfg(true)` attributes. (Some minor unnecessary special casing for `sym::cfg_attr` is also removed in this PR.) r? `@nnethercote`
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/validate_attr.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/compiler/rustc_parse/src/validate_attr.rs b/compiler/rustc_parse/src/validate_attr.rs index 9ecde2a9eb5..6bbd650dcdf 100644 --- a/compiler/rustc_parse/src/validate_attr.rs +++ b/compiler/rustc_parse/src/validate_attr.rs @@ -16,7 +16,8 @@ use rustc_span::{Span, Symbol, sym}; use crate::{errors, parse_in}; pub fn check_attr(psess: &ParseSess, attr: &Attribute) { - if attr.is_doc_comment() || attr.has_name(sym::cfg_attr_trace) { + if attr.is_doc_comment() || attr.has_name(sym::cfg_trace) || attr.has_name(sym::cfg_attr_trace) + { return; } @@ -215,11 +216,7 @@ pub fn check_builtin_meta_item( template: AttributeTemplate, deny_unsafety: bool, ) { - // Some special attributes like `cfg` must be checked - // before the generic check, so we skip them here. - let should_skip = |name| name == sym::cfg; - - if !should_skip(name) && !is_attr_template_compatible(&template, &meta.kind) { + if !is_attr_template_compatible(&template, &meta.kind) { emit_malformed_attribute(psess, style, meta.span, name, template); } |
