about summary refs log tree commit diff
path: root/compiler/rustc_attr_parsing/src/validate_attr.rs
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2025-09-14 16:17:51 +0800
committerJosh Triplett <josh@joshtriplett.org>2025-10-01 16:19:39 -0700
commit6bff1abf9d3c171d2380aacb8b4c6f52580192b3 (patch)
treea13db6b80e9dc6bc5614cea3033c99c9469884d3 /compiler/rustc_attr_parsing/src/validate_attr.rs
parent30d57abccf7d55e9dd4e36be583c55f6b0090302 (diff)
downloadrust-6bff1abf9d3c171d2380aacb8b4c6f52580192b3.tar.gz
rust-6bff1abf9d3c171d2380aacb8b4c6f52580192b3.zip
mbe: Support `unsafe` attribute rules
Diffstat (limited to 'compiler/rustc_attr_parsing/src/validate_attr.rs')
-rw-r--r--compiler/rustc_attr_parsing/src/validate_attr.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/compiler/rustc_attr_parsing/src/validate_attr.rs b/compiler/rustc_attr_parsing/src/validate_attr.rs
index 7a7624893bd..927417f89f8 100644
--- a/compiler/rustc_attr_parsing/src/validate_attr.rs
+++ b/compiler/rustc_attr_parsing/src/validate_attr.rs
@@ -207,10 +207,9 @@ pub fn check_attribute_safety(
             }
         }
 
-        // - Normal builtin attribute, or any non-builtin attribute
-        // - All non-builtin attributes are currently considered safe; writing `#[unsafe(..)]` is
-        //   not permitted on non-builtin attributes or normal builtin attributes
-        (Some(AttributeSafety::Normal) | None, Safety::Unsafe(unsafe_span)) => {
+        // - Normal builtin attribute
+        // - Writing `#[unsafe(..)]` is not permitted on normal builtin attributes
+        (Some(AttributeSafety::Normal), Safety::Unsafe(unsafe_span)) => {
             psess.dcx().emit_err(errors::InvalidAttrUnsafe {
                 span: unsafe_span,
                 name: attr_item.path.clone(),
@@ -224,9 +223,8 @@ pub fn check_attribute_safety(
         }
 
         // - Non-builtin attribute
-        // - No explicit `#[unsafe(..)]` written.
-        (None, Safety::Default) => {
-            // OK
+        (None, Safety::Unsafe(_) | Safety::Default) => {
+            // OK (not checked here)
         }
 
         (