mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Stop using IllFormedAttributeInputLint for must_use
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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())]
|
||||
|
||||
@@ -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,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() {}
|
||||
|
||||
@@ -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`.
|
||||
|
||||
Reference in New Issue
Block a user