Visit attributes of trait impl items during AST validation

This commit is contained in:
León Orell Valerian Liehr 2022-11-08 13:43:03 +01:00
parent 6b23a7e87f
commit 5ef85bbd7c
No known key found for this signature in database
GPG key ID: CD75E31CE2CFD7D9
3 changed files with 25 additions and 1 deletions

View file

@ -1051,6 +1051,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
walk_list!(this, visit_assoc_item, items, AssocCtxt::Impl); walk_list!(this, visit_assoc_item, items, AssocCtxt::Impl);
}); });
walk_list!(self, visit_attribute, &item.attrs);
return; // Avoid visiting again. return; // Avoid visiting again.
} }
ItemKind::Impl(box Impl { ItemKind::Impl(box Impl {
@ -1168,7 +1169,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
}); });
walk_list!(self, visit_assoc_item, items, AssocCtxt::Trait); walk_list!(self, visit_assoc_item, items, AssocCtxt::Trait);
walk_list!(self, visit_attribute, &item.attrs); walk_list!(self, visit_attribute, &item.attrs);
return; return; // Avoid visiting again
} }
ItemKind::Mod(unsafety, ref mod_kind) => { ItemKind::Mod(unsafety, ref mod_kind) => {
if let Unsafe::Yes(span) = unsafety { if let Unsafe::Yes(span) = unsafety {

View file

@ -0,0 +1,8 @@
#![feature(rustc_attrs)]
trait Foo {}
#[rustc_on_unimplemented] //~ ERROR malformed `rustc_on_unimplemented` attribute input
impl Foo for u32 {}
fn main() {}

View file

@ -0,0 +1,15 @@
error: malformed `rustc_on_unimplemented` attribute input
--> $DIR/issue-104140.rs:5:1
|
LL | #[rustc_on_unimplemented]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: the following are the possible correct uses
|
LL | #[rustc_on_unimplemented = "message"]
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LL | #[rustc_on_unimplemented(/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...")]
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error