Stop using IllFormedAttributeInputLint for must_use

This commit is contained in:
Jonathan Brouwer
2025-12-13 13:37:12 +01:00
parent 6a7ed1353d
commit 69a59e8e87
7 changed files with 26 additions and 29 deletions
-5
View File
@@ -50,11 +50,6 @@ attr_parsing_expects_feature_list =
attr_parsing_expects_features =
`{$name}` expects feature names
attr_parsing_ill_formed_attribute_input = {$num_suggestions ->
[1] attribute must be of the form {$suggestions}
*[other] valid forms for the attribute are {$suggestions}
}
attr_parsing_import_name_type_raw =
import name type can only be used with link kind `raw-dylib`
@@ -1,7 +1,4 @@
use rustc_errors::DiagArgValue;
use super::prelude::*;
use crate::session_diagnostics::IllFormedAttributeInputLint;
pub(crate) struct MustUseParser;
@@ -45,14 +42,7 @@ fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<Attrib
Some(value_str)
}
ArgParser::List(_) => {
let suggestions = cx.suggestions();
cx.emit_err(IllFormedAttributeInputLint {
num_suggestions: suggestions.len(),
suggestions: DiagArgValue::StrListSepByAnd(
suggestions.into_iter().map(|s| format!("`{s}`").into()).collect(),
),
span: cx.attr_span,
});
cx.expected_name_value(cx.attr_span, None);
return None;
}
},
@@ -380,15 +380,6 @@ pub(crate) struct UnusedMultiple {
pub name: Symbol,
}
#[derive(Diagnostic)]
#[diag(attr_parsing_ill_formed_attribute_input)]
pub(crate) struct IllFormedAttributeInputLint {
#[primary_span]
pub span: Span,
pub num_suggestions: usize,
pub suggestions: DiagArgValue,
}
#[derive(Diagnostic)]
#[diag(attr_parsing_null_on_export, code = E0648)]
pub(crate) struct NullOnExport {
+1 -1
View File
@@ -59,7 +59,7 @@
#[cold = 1]
//~^ ERROR malformed
#[must_use()]
//~^ ERROR valid forms for the attribute are
//~^ ERROR malformed
#[no_mangle = 1]
//~^ ERROR malformed
#[unsafe(naked())]
+11 -1
View File
@@ -314,11 +314,21 @@ LL | #[cold = 1]
| | didn't expect any arguments here
| help: must be of the form: `#[cold]`
error: valid forms for the attribute are `#[must_use = "reason"]` and `#[must_use]`
error[E0539]: malformed `must_use` attribute input
--> $DIR/malformed-attrs.rs:61:1
|
LL | #[must_use()]
| ^^^^^^^^^^^^^
|
= note: for more information, visit <https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[must_use()]
LL + #[must_use = "reason"]
|
LL - #[must_use()]
LL + #[must_use]
|
error[E0565]: malformed `no_mangle` attribute input
--> $DIR/malformed-attrs.rs:63:1
+1 -1
View File
@@ -1,4 +1,4 @@
#[must_use()] //~ ERROR valid forms for the attribute are `#[must_use = "reason"]` and `#[must_use]`
#[must_use()] //~ ERROR malformed
struct Test;
fn main() {}
+12 -1
View File
@@ -1,8 +1,19 @@
error: valid forms for the attribute are `#[must_use = "reason"]` and `#[must_use]`
error[E0539]: malformed `must_use` attribute input
--> $DIR/malformed-must_use.rs:1:1
|
LL | #[must_use()]
| ^^^^^^^^^^^^^
|
= note: for more information, visit <https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[must_use()]
LL + #[must_use = "reason"]
|
LL - #[must_use()]
LL + #[must_use]
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0539`.