diff options
| author | Jana Dönszelmann <jana@donsz.nl> | 2025-08-24 13:14:27 +0200 |
|---|---|---|
| committer | Jana Dönszelmann <jana@donsz.nl> | 2025-09-08 14:57:28 -0700 |
| commit | a38288bbe00f64204967819fd2cfe107a7902404 (patch) | |
| tree | 1f706e820cfe614ba69d65d41c8b6922acfce898 /compiler/rustc_attr_parsing/src | |
| parent | 92f24020967e4e1f1375dbb2d1ba85cd4430fc78 (diff) | |
| download | rust-a38288bbe00f64204967819fd2cfe107a7902404.tar.gz rust-a38288bbe00f64204967819fd2cfe107a7902404.zip | |
port `#[move_size_limit]` 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.rs | 26 | ||||
| -rw-r--r-- | compiler/rustc_attr_parsing/src/context.rs | 3 |
2 files changed, 28 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 e3654d49580..af19b9f552d 100644 --- a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs +++ b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs @@ -94,3 +94,29 @@ impl<S: Stage> SingleAttributeParser<S> for RecursionLimitParser { }) } } + +pub(crate) struct MoveSizeLimitParser; + +impl<S: Stage> SingleAttributeParser<S> for MoveSizeLimitParser { + const PATH: &[Symbol] = &[sym::move_size_limit]; + const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost; + const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error; + const TEMPLATE: AttributeTemplate = template!(NameValueStr: "N"); + + // FIXME: move size 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(&[Allow(Target::Crate)]); + + fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> { + let ArgParser::NameValue(nv) = args else { + cx.expected_name_value(cx.attr_span, None); + return None; + }; + + Some(AttributeKind::MoveSizeLimit { + limit: cx.parse_limit_int(nv)?, + attr_span: cx.attr_span, + limit_span: nv.value_span, + }) + } +} diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 5700668145b..4ec9df88e82 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -24,7 +24,7 @@ use crate::attributes::codegen_attrs::{ UsedParser, }; use crate::attributes::confusables::ConfusablesParser; -use crate::attributes::crate_level::{CrateNameParser, RecursionLimitParser}; +use crate::attributes::crate_level::{CrateNameParser, MoveSizeLimitParser, RecursionLimitParser}; use crate::attributes::deprecation::DeprecationParser; use crate::attributes::dummy::DummyParser; use crate::attributes::inline::{InlineParser, RustcForceInlineParser}; @@ -181,6 +181,7 @@ attribute_parsers!( Single<LinkOrdinalParser>, Single<LinkSectionParser>, Single<LinkageParser>, + Single<MoveSizeLimitParser>, Single<MustUseParser>, Single<OptimizeParser>, Single<PathAttributeParser>, |
