about summary refs log tree commit diff
path: root/compiler/rustc_attr_parsing/src
diff options
context:
space:
mode:
authorJana Dönszelmann <jana@donsz.nl>2025-08-24 11:15:09 +0200
committerJana Dönszelmann <jana@donsz.nl>2025-09-09 15:16:02 -0700
commit0db2eb7734633fe55dacbb05dbc677a079301cab (patch)
tree54ad9446ad07828bf656967aaa56a4ba1ba7a1c5 /compiler/rustc_attr_parsing/src
parentb262cae8575589997d4f2a9bc166d99cc48e5eb1 (diff)
downloadrust-0db2eb7734633fe55dacbb05dbc677a079301cab.tar.gz
rust-0db2eb7734633fe55dacbb05dbc677a079301cab.zip
port `#[no_std]` to the new attribute parsing infrastructure
Diffstat (limited to 'compiler/rustc_attr_parsing/src')
-rw-r--r--compiler/rustc_attr_parsing/src/attributes/crate_level.rs11
-rw-r--r--compiler/rustc_attr_parsing/src/context.rs3
2 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs
index d2e28ed97aa..3ec847bcaae 100644
--- a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs
+++ b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs
@@ -188,3 +188,14 @@ impl<S: Stage> NoArgsAttributeParser<S> for NoCoreParser {
     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;
+    // FIXME: recursion limit is allowed on all targets and ignored,
+    //        even though it should only be valid on crates of course
+    const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
+    const CREATE: fn(Span) -> AttributeKind = AttributeKind::NoStd;
+    const TYPE: AttributeType = AttributeType::CrateLevel;
+}
diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs
index 3d532d432b5..2e6d840ab51 100644
--- a/compiler/rustc_attr_parsing/src/context.rs
+++ b/compiler/rustc_attr_parsing/src/context.rs
@@ -25,7 +25,7 @@ use crate::attributes::codegen_attrs::{
 };
 use crate::attributes::confusables::ConfusablesParser;
 use crate::attributes::crate_level::{
-    CrateNameParser, MoveSizeLimitParser, NoCoreParser, PatternComplexityLimitParser,
+    CrateNameParser, MoveSizeLimitParser, NoCoreParser, NoStdParser, PatternComplexityLimitParser,
     RecursionLimitParser, TypeLengthLimitParser,
 };
 use crate::attributes::deprecation::DeprecationParser;
@@ -225,6 +225,7 @@ attribute_parsers!(
         Single<WithoutArgs<NoCoreParser>>,
         Single<WithoutArgs<NoImplicitPreludeParser>>,
         Single<WithoutArgs<NoMangleParser>>,
+        Single<WithoutArgs<NoStdParser>>,
         Single<WithoutArgs<NonExhaustiveParser>>,
         Single<WithoutArgs<ParenSugarParser>>,
         Single<WithoutArgs<PassByValueParser>>,