about summary refs log tree commit diff
path: root/compiler/rustc_attr_parsing/src/attributes/crate_level.rs
diff options
context:
space:
mode:
authorJana Dönszelmann <jonathan@donsz.nl>2025-09-13 02:40:44 +0200
committerGitHub <noreply@github.com>2025-09-13 02:40:44 +0200
commit147e97ae68b224f3980ad818b29738c0bc7e4d88 (patch)
tree4a828ffb59e88d2b189ed4638d4e8debb22a4bf1 /compiler/rustc_attr_parsing/src/attributes/crate_level.rs
parent4ba1cf9ade4c8e2fa10676a50ee34594eb161837 (diff)
parentdbd3ef1332574ef074c147f3b9e3e74dd29cd7b5 (diff)
downloadrust-147e97ae68b224f3980ad818b29738c0bc7e4d88.tar.gz
rust-147e97ae68b224f3980ad818b29738c0bc7e4d88.zip
Rollup merge of #146389 - jdonszelmann:no-std, r=oli-obk
Convert `no_std` and `no_core` to the new attribute infrastructure

r? ```@oli-obk```

Also added a test for these, since we didn't have any and I was kind of surprised new diagnostics didn't break anything hehe
Diffstat (limited to 'compiler/rustc_attr_parsing/src/attributes/crate_level.rs')
-rw-r--r--compiler/rustc_attr_parsing/src/attributes/crate_level.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs
index d23a7ae72f8..0b2c05482bf 100644
--- a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs
+++ b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs
@@ -176,3 +176,27 @@ impl<S: Stage> SingleAttributeParser<S> for PatternComplexityLimitParser {
         })
     }
 }
+
+pub(crate) struct NoCoreParser;
+
+impl<S: Stage> NoArgsAttributeParser<S> for NoCoreParser {
+    const PATH: &[Symbol] = &[sym::no_core];
+    const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
+    // because it's a crate-level attribute, we already warn about it.
+    // Putting target limitations here would give duplicate warnings
+    const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
+    const CREATE: fn(Span) -> AttributeKind = AttributeKind::NoCore;
+    const TYPE: AttributeType = AttributeType::CrateLevel;
+}
+
+pub(crate) struct NoStdParser;
+
+impl<S: Stage> NoArgsAttributeParser<S> for NoStdParser {
+    const PATH: &[Symbol] = &[sym::no_std];
+    const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
+    // because it's a crate-level attribute, we already warn about it.
+    // Putting target limitations here would give duplicate warnings
+    const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
+    const CREATE: fn(Span) -> AttributeKind = AttributeKind::NoStd;
+    const TYPE: AttributeType = AttributeType::CrateLevel;
+}