1
Fork 0

Rollup merge of #80920 - rylev:check_attr-refactor, r=davidtwco

Visit more targets when validating attributes

This begins to address #80048, allowing for additional validation of attributes.

There are more refactorings that can be done, though I think they should be tackled in additional PRs:
* ICE when a builtin attribute is encountered that is not checked
* Move some of the attr checking done `ast_validation` into `rustc_passes`
  * note that this requires a bit of additional refactoring, especially of extern items which currently parse attributes (and thus are a part of the AST) but do not possess attributes in their HIR representation.
* Rename `Target` to `AttributeTarget`
* Refactor attribute validation completely to go through `Visitor::visit_attribute`.
  * This would require at a minimum passing `Target` into this method which might be too big of a refactoring to be worth it.
  * It's also likely not possible to do all the validation this way as some validation requires knowing what other attributes a target has.

r? `@davidtwco`
This commit is contained in:
Dylan DPC 2021-02-14 16:54:42 +01:00 committed by GitHub
commit ac1d26bcd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 17 deletions

View file

@ -54,6 +54,7 @@ pub enum Target {
ForeignTy,
GenericParam(GenericParamKind),
MacroDef,
Param,
}
impl Display for Target {
@ -96,6 +97,7 @@ impl Display for Target {
GenericParamKind::Const => "const parameter",
},
Target::MacroDef => "macro def",
Target::Param => "function param",
}
)
}