Remove UnknownMetaItem error
This commit is contained in:
parent
25a6fca2df
commit
1da1a39c9a
13 changed files with 44 additions and 67 deletions
|
|
@ -213,10 +213,6 @@ attr_parsing_stability_outside_std = stability attributes may not be used outsid
|
|||
attr_parsing_suffixed_literal_in_attribute = suffixed literals are not allowed in attributes
|
||||
.help = instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
|
||||
|
||||
attr_parsing_unknown_meta_item =
|
||||
unknown meta item '{$item}'
|
||||
.label = expected one of {$expected}
|
||||
|
||||
attr_parsing_unknown_version_literal =
|
||||
unknown version literal format, assuming it refers to a future version
|
||||
|
||||
|
|
|
|||
|
|
@ -110,13 +110,12 @@ impl<S: Stage> SingleAttributeParser<S> for DeprecationParser {
|
|||
Some(get(cx, name, param.span(), param.args(), &suggestion)?);
|
||||
}
|
||||
_ => {
|
||||
cx.unknown_key(
|
||||
cx.expected_specific_argument(
|
||||
param.span(),
|
||||
param.path().to_string(),
|
||||
if features.deprecated_suggestion() {
|
||||
&["since", "note", "suggestion"]
|
||||
&[sym::since, sym::note, sym::suggestion]
|
||||
} else {
|
||||
&["since", "note"]
|
||||
&[sym::since, sym::note]
|
||||
},
|
||||
);
|
||||
return None;
|
||||
|
|
|
|||
|
|
@ -46,9 +46,8 @@ impl<S: Stage> SingleAttributeParser<S> for CustomMirParser {
|
|||
extract_value(cx, sym::dialect, arg, meta_item.span(), &mut dialect, &mut failed);
|
||||
} else if let Some(arg) = meta_item.word_is(sym::phase) {
|
||||
extract_value(cx, sym::phase, arg, meta_item.span(), &mut phase, &mut failed);
|
||||
} else if let Some(word) = meta_item.path().word() {
|
||||
let word = word.to_string();
|
||||
cx.unknown_key(meta_item.span(), word, &["dialect", "phase"]);
|
||||
} else if let Some(..) = meta_item.path().word() {
|
||||
cx.expected_specific_argument(meta_item.span(), &[sym::dialect, sym::phase]);
|
||||
failed = true;
|
||||
} else {
|
||||
cx.expected_name_value(meta_item.span(), None);
|
||||
|
|
|
|||
|
|
@ -315,11 +315,7 @@ pub(crate) fn parse_stability<S: Stage>(
|
|||
insert_value_into_option_or_error(cx, ¶m, &mut since, word.unwrap())?
|
||||
}
|
||||
_ => {
|
||||
cx.emit_err(session_diagnostics::UnknownMetaItem {
|
||||
span: param_span,
|
||||
item: param.path().to_string(),
|
||||
expected: &["feature", "since"],
|
||||
});
|
||||
cx.expected_specific_argument(param_span, &[sym::feature, sym::since]);
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
|
@ -426,11 +422,17 @@ pub(crate) fn parse_unstability<S: Stage>(
|
|||
insert_value_into_option_or_error(cx, ¶m, &mut old_name, word.unwrap())?
|
||||
}
|
||||
_ => {
|
||||
cx.emit_err(session_diagnostics::UnknownMetaItem {
|
||||
span: param.span(),
|
||||
item: param.path().to_string(),
|
||||
expected: &["feature", "reason", "issue", "soft", "implied_by", "old_name"],
|
||||
});
|
||||
cx.expected_specific_argument(
|
||||
param.span(),
|
||||
&[
|
||||
sym::feature,
|
||||
sym::reason,
|
||||
sym::issue,
|
||||
sym::soft,
|
||||
sym::implied_by,
|
||||
sym::old_name,
|
||||
],
|
||||
);
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ use crate::attributes::transparency::TransparencyParser;
|
|||
use crate::attributes::{AttributeParser as _, Combine, Single, WithoutArgs};
|
||||
use crate::parser::{ArgParser, RefPathParser};
|
||||
use crate::session_diagnostics::{
|
||||
AttributeParseError, AttributeParseErrorReason, ParsedDescription, UnknownMetaItem,
|
||||
AttributeParseError, AttributeParseErrorReason, ParsedDescription,
|
||||
};
|
||||
use crate::target_checking::AllowedTargets;
|
||||
|
||||
|
|
@ -425,15 +425,6 @@ impl<'f, 'sess: 'f, S: Stage> SharedContext<'f, 'sess, S> {
|
|||
}
|
||||
|
||||
impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
|
||||
pub(crate) fn unknown_key(
|
||||
&self,
|
||||
span: Span,
|
||||
found: String,
|
||||
options: &[&'static str],
|
||||
) -> ErrorGuaranteed {
|
||||
self.emit_err(UnknownMetaItem { span, item: found, expected: options })
|
||||
}
|
||||
|
||||
fn emit_parse_error(
|
||||
&self,
|
||||
span: Span,
|
||||
|
|
|
|||
|
|
@ -64,26 +64,6 @@ pub(crate) struct DocAttributeNotAttribute {
|
|||
pub attribute: Symbol,
|
||||
}
|
||||
|
||||
/// Error code: E0541
|
||||
pub(crate) struct UnknownMetaItem<'a> {
|
||||
pub span: Span,
|
||||
pub item: String,
|
||||
pub expected: &'a [&'a str],
|
||||
}
|
||||
|
||||
// Manual implementation to be able to format `expected` items correctly.
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnknownMetaItem<'_> {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
|
||||
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
|
||||
Diag::new(dcx, level, fluent::attr_parsing_unknown_meta_item)
|
||||
.with_span(self.span)
|
||||
.with_code(E0541)
|
||||
.with_arg("item", self.item)
|
||||
.with_arg("expected", expected.join(", "))
|
||||
.with_span_label(self.span, fluent::attr_parsing_label)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(attr_parsing_missing_since, code = E0542)]
|
||||
pub(crate) struct MissingSince {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#### Note: this error code is no longer emitted by the compiler.
|
||||
|
||||
An unknown meta item was used.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0541
|
||||
```compile_fail (no longer emitted)
|
||||
#[deprecated(
|
||||
since="1.0.0",
|
||||
// error: unknown meta item
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// Various checks that deprecation attributes are used correctly
|
||||
|
||||
mod bogus_attribute_types_1 {
|
||||
#[deprecated(since = "a", note = "a", reason)] //~ ERROR unknown meta item 'reason'
|
||||
#[deprecated(since = "a", note = "a", reason)] //~ ERROR malformed `deprecated` attribute input [E0539]
|
||||
fn f1() { }
|
||||
|
||||
#[deprecated(since = "a", note)] //~ ERROR malformed `deprecated` attribute input [E0539]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
error[E0541]: unknown meta item 'reason'
|
||||
--> $DIR/deprecation-sanity.rs:6:43
|
||||
error[E0539]: malformed `deprecated` attribute input
|
||||
--> $DIR/deprecation-sanity.rs:6:5
|
||||
|
|
||||
LL | #[deprecated(since = "a", note = "a", reason)]
|
||||
| ^^^^^^ expected one of `since`, `note`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------^^
|
||||
| |
|
||||
| valid arguments are `since` or `note`
|
||||
|
||||
error[E0539]: malformed `deprecated` attribute input
|
||||
--> $DIR/deprecation-sanity.rs:9:5
|
||||
|
|
@ -86,5 +88,5 @@ LL | #[deprecated = "hello"]
|
|||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0538, E0539, E0541, E0565.
|
||||
Some errors have detailed explanations: E0538, E0539, E0565.
|
||||
For more information about an error, try `rustc --explain E0538`.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#[stable(feature = "a", feature = "b", since = "1.0.0")] //~ ERROR malformed `stable` attribute input [E0538]
|
||||
fn f1() { }
|
||||
|
||||
#[stable(feature = "a", sinse = "1.0.0")] //~ ERROR unknown meta item 'sinse'
|
||||
#[stable(feature = "a", sinse = "1.0.0")] //~ ERROR malformed `stable` attribute input [E0539]
|
||||
fn f2() { }
|
||||
|
||||
#[unstable(feature = "a", issue = "no")]
|
||||
|
|
|
|||
|
|
@ -7,11 +7,14 @@ LL | #[stable(feature = "a", feature = "b", since = "1.0.0")]
|
|||
| | found `feature` used as a key more than once
|
||||
| help: must be of the form: `#[stable(feature = "name", since = "version")]`
|
||||
|
||||
error[E0541]: unknown meta item 'sinse'
|
||||
--> $DIR/stability-attribute-sanity-2.rs:10:25
|
||||
error[E0539]: malformed `stable` attribute input
|
||||
--> $DIR/stability-attribute-sanity-2.rs:10:1
|
||||
|
|
||||
LL | #[stable(feature = "a", sinse = "1.0.0")]
|
||||
| ^^^^^^^^^^^^^^^ expected one of `feature`, `since`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^---------------^^
|
||||
| | |
|
||||
| | valid arguments are `feature` or `since`
|
||||
| help: must be of the form: `#[stable(feature = "name", since = "version")]`
|
||||
|
||||
error[E0545]: `issue` must be a non-zero numeric string or "none"
|
||||
--> $DIR/stability-attribute-sanity-2.rs:13:27
|
||||
|
|
@ -23,5 +26,5 @@ LL | #[unstable(feature = "a", issue = "no")]
|
|||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0538, E0541, E0545.
|
||||
Some errors have detailed explanations: E0538, E0539, E0545.
|
||||
For more information about an error, try `rustc --explain E0538`.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
mod bogus_attribute_types_1 {
|
||||
#[stable(feature = "a", since = "4.4.4", reason)] //~ ERROR unknown meta item 'reason' [E0541]
|
||||
#[stable(feature = "a", since = "4.4.4", reason)] //~ ERROR malformed `stable` attribute input [E0539]
|
||||
fn f1() { }
|
||||
|
||||
#[stable(feature = "a", since)] //~ ERROR malformed `stable` attribute input [E0539]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
error[E0541]: unknown meta item 'reason'
|
||||
--> $DIR/stability-attribute-sanity.rs:8:46
|
||||
error[E0539]: malformed `stable` attribute input
|
||||
--> $DIR/stability-attribute-sanity.rs:8:5
|
||||
|
|
||||
LL | #[stable(feature = "a", since = "4.4.4", reason)]
|
||||
| ^^^^^^ expected one of `feature`, `since`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------^^
|
||||
| | |
|
||||
| | valid arguments are `feature` or `since`
|
||||
| help: must be of the form: `#[stable(feature = "name", since = "version")]`
|
||||
|
||||
error[E0539]: malformed `stable` attribute input
|
||||
--> $DIR/stability-attribute-sanity.rs:11:5
|
||||
|
|
@ -138,5 +141,5 @@ LL | #[stable(feature = "a", since = "1.0.0")]
|
|||
|
||||
error: aborting due to 20 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0539, E0541, E0542, E0543, E0544, E0546, E0547, E0549, E0711.
|
||||
Some errors have detailed explanations: E0539, E0542, E0543, E0544, E0546, E0547, E0549, E0711.
|
||||
For more information about an error, try `rustc --explain E0539`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue