diff options
| author | León Orell Valerian Liehr <me@fmease.dev> | 2025-07-24 15:08:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-24 15:08:28 +0200 |
| commit | 6dc41520e96879d9d2507d81032c1a95da65e81e (patch) | |
| tree | ca5c34accb0d7abdef01bc9101f1fd59ff393b4f /compiler/rustc_attr_parsing/src | |
| parent | 237098c92ddd3079643d4c8098b1d6ae39847282 (diff) | |
| parent | af06bb925f2a3cd24ab2c623d75b5ea2847dc171 (diff) | |
| download | rust-6dc41520e96879d9d2507d81032c1a95da65e81e.tar.gz rust-6dc41520e96879d9d2507d81032c1a95da65e81e.zip | |
Rollup merge of #144358 - JonathanBrouwer:fix-stability-malformed, r=oli-obk
Stop using the old `validate_attr` logic for stability attributes I think this was accidentally missed when implementing the stability attributes? r? `````@oli-obk````` cc `````@jdonszelmann`````
Diffstat (limited to 'compiler/rustc_attr_parsing/src')
| -rw-r--r-- | compiler/rustc_attr_parsing/src/attributes/stability.rs | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/compiler/rustc_attr_parsing/src/attributes/stability.rs b/compiler/rustc_attr_parsing/src/attributes/stability.rs index 59337749c87..c54fc6b41f8 100644 --- a/compiler/rustc_attr_parsing/src/attributes/stability.rs +++ b/compiler/rustc_attr_parsing/src/attributes/stability.rs @@ -74,8 +74,15 @@ impl<S: Stage> AttributeParser<S> for StabilityParser { template!(NameValueStr: "deprecation message"), |this, cx, args| { reject_outside_std!(cx); - this.allowed_through_unstable_modules = - args.name_value().and_then(|i| i.value_as_str()) + let Some(nv) = args.name_value() else { + cx.expected_name_value(cx.attr_span, None); + return; + }; + let Some(value_str) = nv.value_as_str() else { + cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit())); + return; + }; + this.allowed_through_unstable_modules = Some(value_str); }, ), ]; @@ -247,7 +254,12 @@ pub(crate) fn parse_stability<S: Stage>( let mut feature = None; let mut since = None; - for param in args.list()?.mixed() { + let ArgParser::List(list) = args else { + cx.expected_list(cx.attr_span); + return None; + }; + + for param in list.mixed() { let param_span = param.span(); let Some(param) = param.meta_item() else { cx.emit_err(session_diagnostics::UnsupportedLiteral { @@ -322,7 +334,13 @@ pub(crate) fn parse_unstability<S: Stage>( let mut is_soft = false; let mut implied_by = None; let mut old_name = None; - for param in args.list()?.mixed() { + + let ArgParser::List(list) = args else { + cx.expected_list(cx.attr_span); + return None; + }; + + for param in list.mixed() { let Some(param) = param.meta_item() else { cx.emit_err(session_diagnostics::UnsupportedLiteral { span: param.span(), |
