Address review comments
This commit is contained in:
parent
41c65992c5
commit
d3411d3ee8
@ -338,7 +338,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
|
||||
},
|
||||
FutureIncompatibleInfo {
|
||||
id: LintId::of(ILL_FORMED_ATTRIBUTE_INPUT),
|
||||
reference: "issue #57321 <https://github.com/rust-lang/rust/issues/57321>",
|
||||
reference: "issue #57571 <https://github.com/rust-lang/rust/issues/57571>",
|
||||
edition: None,
|
||||
},
|
||||
]);
|
||||
|
@ -717,6 +717,8 @@ pub enum AttributeGate {
|
||||
Ungated,
|
||||
}
|
||||
|
||||
/// A template that the attribute input must match.
|
||||
/// Only top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is considered now.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct AttributeTemplate {
|
||||
word: bool,
|
||||
@ -725,6 +727,7 @@ pub struct AttributeTemplate {
|
||||
}
|
||||
|
||||
impl AttributeTemplate {
|
||||
/// Check that the given meta-item is compatible with this template.
|
||||
fn compatible(&self, meta_item_kind: &ast::MetaItemKind) -> bool {
|
||||
match meta_item_kind {
|
||||
ast::MetaItemKind::Word => self.word,
|
||||
@ -735,10 +738,10 @@ impl AttributeTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
/// A convenience macro for constructing attribute templates.
|
||||
/// E.g. `template!(Word, List: "description")` means that the attribute
|
||||
/// supports forms `#[attr]` and `#[attr(description)]`.
|
||||
macro_rules! template {
|
||||
(@ $word: expr, $list: expr, $name_value_str: expr) => { AttributeTemplate {
|
||||
word: $word, list: $list, name_value_str: $name_value_str
|
||||
} };
|
||||
(Word) => { template!(@ true, None, None) };
|
||||
(List: $descr: expr) => { template!(@ false, Some($descr), None) };
|
||||
(NameValueStr: $descr: expr) => { template!(@ false, None, Some($descr)) };
|
||||
@ -750,6 +753,9 @@ macro_rules! template {
|
||||
(Word, List: $descr1: expr, NameValueStr: $descr2: expr) => {
|
||||
template!(@ true, Some($descr1), Some($descr2))
|
||||
};
|
||||
(@ $word: expr, $list: expr, $name_value_str: expr) => { AttributeTemplate {
|
||||
word: $word, list: $list, name_value_str: $name_value_str
|
||||
} };
|
||||
}
|
||||
|
||||
impl AttributeGate {
|
||||
@ -1084,7 +1090,8 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, Attribu
|
||||
is an experimental feature",
|
||||
cfg_fn!(fundamental))),
|
||||
|
||||
("proc_macro_derive", Normal, template!(List: "TraitName, attributes(name1, name2, ...)"),
|
||||
("proc_macro_derive", Normal, template!(List: "TraitName, \
|
||||
/*opt*/ attributes(name1, name2, ...)"),
|
||||
Ungated),
|
||||
|
||||
("rustc_copy_clone_marker", Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
|
@ -6,7 +6,7 @@ LL | #[inline = "2100"] fn f() { }
|
||||
|
|
||||
= note: #[warn(ill_formed_attribute_input)] on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #57321 <https://github.com/rust-lang/rust/issues/57321>
|
||||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
|
||||
|
||||
error[E0518]: attribute should be applied to function or closure
|
||||
--> $DIR/issue-43106-gating-of-inline.rs:11:1
|
||||
|
@ -6,7 +6,7 @@ LL | #[doc] //~ WARN attribute must be of the form
|
||||
|
|
||||
= note: #[warn(ill_formed_attribute_input)] on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #57321 <https://github.com/rust-lang/rust/issues/57321>
|
||||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
|
||||
|
||||
warning: attribute must be of the form `#[ignore]` or `#[ignore = "reason"]`
|
||||
--> $DIR/malformed-regressions.rs:4:1
|
||||
@ -15,7 +15,7 @@ LL | #[ignore()] //~ WARN attribute must be of the form
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #57321 <https://github.com/rust-lang/rust/issues/57321>
|
||||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
|
||||
|
||||
warning: attribute must be of the form `#[inline]` or `#[inline(always|never)]`
|
||||
--> $DIR/malformed-regressions.rs:5:1
|
||||
@ -24,7 +24,7 @@ LL | #[inline = ""] //~ WARN attribute must be of the form
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #57321 <https://github.com/rust-lang/rust/issues/57321>
|
||||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
|
||||
|
||||
warning: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...",
|
||||
/*opt*/ cfg = "...")]`
|
||||
@ -34,7 +34,7 @@ LL | #[link] //~ WARN attribute must be of the form
|
||||
| ^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #57321 <https://github.com/rust-lang/rust/issues/57321>
|
||||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
|
||||
|
||||
warning: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...",
|
||||
/*opt*/ cfg = "...")]`
|
||||
@ -44,5 +44,5 @@ LL | #[link = ""] //~ WARN attribute must be of the form
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #57321 <https://github.com/rust-lang/rust/issues/57321>
|
||||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
|
||||
|
||||
|
@ -34,13 +34,13 @@ error: attribute must have either one or two arguments
|
||||
LL | #[proc_macro_derive(l, attributes(m), n)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: attribute must be of the form `#[proc_macro_derive(TraitName, attributes(name1, name2, ...))]`
|
||||
error: attribute must be of the form `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]`
|
||||
--> $DIR/attribute.rs:8:1
|
||||
|
|
||||
LL | #[proc_macro_derive]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: attribute must be of the form `#[proc_macro_derive(TraitName, attributes(name1, name2, ...))]`
|
||||
error: attribute must be of the form `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]`
|
||||
--> $DIR/attribute.rs:14:1
|
||||
|
|
||||
LL | #[proc_macro_derive = "foo"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user