From 6153fa0f88befd0f1c925a582b630b7412964aba Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 11 Jan 2026 12:12:41 +0100 Subject: [PATCH] Fix that `cfg` attribute was incorrectly not a parsed attribute --- compiler/rustc_attr_parsing/src/interface.rs | 12 +++++++++++- compiler/rustc_passes/src/check_attr.rs | 2 -- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/interface.rs b/compiler/rustc_attr_parsing/src/interface.rs index e38fffa6587c..7602e3c4598a 100644 --- a/compiler/rustc_attr_parsing/src/interface.rs +++ b/compiler/rustc_attr_parsing/src/interface.rs @@ -442,7 +442,17 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> { /// Returns whether there is a parser for an attribute with this name pub fn is_parsed_attribute(path: &[Symbol]) -> bool { - Late::parsers().accepters.contains_key(path) || EARLY_PARSED_ATTRIBUTES.contains(&path) + /// The list of attributes that are parsed attributes, + /// even though they don't have a parser in `Late::parsers()` + const SPECIAL_ATTRIBUTES: &[&[Symbol]] = &[ + // Cfg attrs are removed after being early-parsed, so don't need to be in the parser list + &[sym::cfg], + &[sym::cfg_attr], + ]; + + Late::parsers().accepters.contains_key(path) + || EARLY_PARSED_ATTRIBUTES.contains(&path) + || SPECIAL_ATTRIBUTES.contains(&path) } fn lower_attr_args(&self, args: &ast::AttrArgs, lower_span: impl Fn(Span) -> Span) -> AttrArgs { diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 2d3c5c7e48a0..75a30497b228 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -338,8 +338,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | sym::warn | sym::deny | sym::forbid - | sym::cfg - | sym::cfg_attr // need to be fixed | sym::patchable_function_entry // FIXME(patchable_function_entry) | sym::deprecated_safe // FIXME(deprecated_safe)