Rollup merge of #79185 - petrochenkov:derattr2, r=Aaron1011

expand/resolve: Pre-requisites to "Turn `#[derive]` into a regular macro attribute"

Miscellaneous refactorings and error reporting changes extracted from https://github.com/rust-lang/rust/pull/79078.

Unlike https://github.com/rust-lang/rust/pull/79078 this PR doesn't make any observable changes to the language or library.
r? ```@Aaron1011```
This commit is contained in:
Dylan DPC 2020-11-19 23:58:42 +01:00 committed by GitHub
commit 8216b359e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 480 additions and 653 deletions

View file

@ -312,14 +312,13 @@ impl<'a> Parser<'a> {
}
pub fn maybe_needs_tokens(attrs: &[ast::Attribute]) -> bool {
// One of the attributes may either itself be a macro, or apply derive macros (`derive`),
// or expand to macro attributes (`cfg_attr`).
attrs.iter().any(|attr| {
if let Some(ident) = attr.ident() {
attr.ident().map_or(true, |ident| {
ident.name == sym::derive
// This might apply a custom attribute/derive
|| ident.name == sym::cfg_attr
|| !rustc_feature::is_builtin_attr_name(ident.name)
} else {
true
}
|| ident.name == sym::cfg_attr
|| !rustc_feature::is_builtin_attr_name(ident.name)
})
})
}