about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/validate_attr.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-07-07 02:03:03 +0000
committerbors <bors@rust-lang.org>2025-07-07 02:03:03 +0000
commit0d11be5aabe0cd49609fff5fce57c4691a22fe55 (patch)
tree03e3b9aa605a15baee097a7d6566bf955f6aabd5 /compiler/rustc_parse/src/validate_attr.rs
parentca98d4d4b3114116203699c2734805547df86f9a (diff)
parent2992997f6fd0dc188c73b4df52ddf8c626b0d5a6 (diff)
downloadrust-0d11be5aabe0cd49609fff5fce57c4691a22fe55.tar.gz
rust-0d11be5aabe0cd49609fff5fce57c4691a22fe55.zip
Auto merge of #143556 - jhpratt:rollup-nid39y2, r=jhpratt
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#143206 (Align attr fixes)
 - rust-lang/rust#143236 (Stabilize `mixed_integer_ops_unsigned_sub`)
 - rust-lang/rust#143344 (Port `#[path]` to the new attribute parsing infrastructure )
 - rust-lang/rust#143359 (Link to 2024 edition page for `!` fallback changes)
 - rust-lang/rust#143456 (mbe: Change `unused_macro_rules` to a `DenseBitSet`)
 - rust-lang/rust#143529 (Renamed retain_mut to retain on LinkedList as mentioned in the ACP)
 - rust-lang/rust#143535 (Remove duplicate word)
 - rust-lang/rust#143544 (compiler: rename BareFn to FnPtr)
 - rust-lang/rust#143552 (lib: more eagerly return `self.len()` from `ceil_char_boundary`)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/validate_attr.rs')
-rw-r--r--compiler/rustc_parse/src/validate_attr.rs72
1 files changed, 36 insertions, 36 deletions
diff --git a/compiler/rustc_parse/src/validate_attr.rs b/compiler/rustc_parse/src/validate_attr.rs
index 8fdc06ee463..67b68e77d2b 100644
--- a/compiler/rustc_parse/src/validate_attr.rs
+++ b/compiler/rustc_parse/src/validate_attr.rs
@@ -267,6 +267,42 @@ pub fn check_builtin_meta_item(
     deny_unsafety: bool,
 ) {
     if !is_attr_template_compatible(&template, &meta.kind) {
+        // attrs with new parsers are locally validated so excluded here
+        if matches!(
+            name,
+            sym::inline
+                | sym::may_dangle
+                | sym::rustc_as_ptr
+                | sym::rustc_pub_transparent
+                | sym::rustc_const_stable_indirect
+                | sym::rustc_force_inline
+                | sym::rustc_confusables
+                | sym::rustc_skip_during_method_dispatch
+                | sym::rustc_pass_by_value
+                | sym::repr
+                | sym::align
+                | sym::deprecated
+                | sym::optimize
+                | sym::cold
+                | sym::target_feature
+                | sym::rustc_allow_const_fn_unstable
+                | sym::naked
+                | sym::no_mangle
+                | sym::non_exhaustive
+                | sym::path
+                | sym::ignore
+                | sym::must_use
+                | sym::track_caller
+                | sym::link_name
+                | sym::export_name
+                | sym::rustc_macro_transparency
+                | sym::link_section
+                | sym::rustc_layout_scalar_valid_range_start
+                | sym::rustc_layout_scalar_valid_range_end
+                | sym::no_implicit_prelude
+        ) {
+            return;
+        }
         emit_malformed_attribute(psess, style, meta.span, name, template);
     }
 
@@ -282,42 +318,6 @@ fn emit_malformed_attribute(
     name: Symbol,
     template: AttributeTemplate,
 ) {
-    // attrs with new parsers are locally validated so excluded here
-    if matches!(
-        name,
-        sym::inline
-            | sym::may_dangle
-            | sym::rustc_as_ptr
-            | sym::rustc_pub_transparent
-            | sym::rustc_const_stable_indirect
-            | sym::rustc_force_inline
-            | sym::rustc_confusables
-            | sym::rustc_skip_during_method_dispatch
-            | sym::rustc_pass_by_value
-            | sym::repr
-            | sym::align
-            | sym::deprecated
-            | sym::optimize
-            | sym::cold
-            | sym::target_feature
-            | sym::rustc_allow_const_fn_unstable
-            | sym::naked
-            | sym::no_mangle
-            | sym::non_exhaustive
-            | sym::ignore
-            | sym::must_use
-            | sym::track_caller
-            | sym::link_name
-            | sym::export_name
-            | sym::rustc_macro_transparency
-            | sym::link_section
-            | sym::rustc_layout_scalar_valid_range_start
-            | sym::rustc_layout_scalar_valid_range_end
-            | sym::no_implicit_prelude
-    ) {
-        return;
-    }
-
     // Some of previously accepted forms were used in practice,
     // report them as warnings for now.
     let should_warn = |name| matches!(name, sym::doc | sym::link | sym::test | sym::bench);