diff options
| author | Caleb Zulawski <caleb.zulawski@gmail.com> | 2025-09-16 02:23:24 -0400 |
|---|---|---|
| committer | Caleb Zulawski <caleb.zulawski@gmail.com> | 2025-09-23 20:47:34 -0400 |
| commit | f5c6c9542ecfab74e654f9b7f1150d486560ae43 (patch) | |
| tree | 2453dd1ffbee52a2687dbde5fcdc535dd37613f8 /compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs | |
| parent | 9d82de19dfae60e55c291f5f28e28cfc2c1b9630 (diff) | |
| download | rust-f5c6c9542ecfab74e654f9b7f1150d486560ae43.tar.gz rust-f5c6c9542ecfab74e654f9b7f1150d486560ae43.zip | |
Add an attribute to check the number of lanes in a SIMD vector after monomorphization
Unify zero-length and oversized SIMD errors
Diffstat (limited to 'compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs')
| -rw-r--r-- | compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index a995549fc7c..cf2f5c6c790 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -49,3 +49,21 @@ impl<S: Stage> SingleAttributeParser<S> for RustcObjectLifetimeDefaultParser { Some(AttributeKind::RustcObjectLifetimeDefault) } } + +pub(crate) struct RustcSimdMonomorphizeLaneLimitParser; + +impl<S: Stage> SingleAttributeParser<S> for RustcSimdMonomorphizeLaneLimitParser { + const PATH: &[Symbol] = &[sym::rustc_simd_monomorphize_lane_limit]; + const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; + const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct)]); + const TEMPLATE: AttributeTemplate = template!(NameValueStr: "N"); + + 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::RustcSimdMonomorphizeLaneLimit(cx.parse_limit_int(nv)?)) + } +} |
