resolve/expand: Misc cleanup
This commit is contained in:
parent
68f94e94ed
commit
dfb690eaa9
4 changed files with 10 additions and 16 deletions
|
@ -888,8 +888,10 @@ pub trait ResolverExpand {
|
|||
/// Some parent node that is close enough to the given macro call.
|
||||
fn lint_node_id(&mut self, expn_id: ExpnId) -> NodeId;
|
||||
|
||||
// Resolver interfaces for specific built-in macros.
|
||||
/// Does `#[derive(...)]` attribute with the given `ExpnId` have built-in `Copy` inside it?
|
||||
fn has_derive_copy(&self, expn_id: ExpnId) -> bool;
|
||||
fn add_derive_copy(&mut self, expn_id: ExpnId);
|
||||
/// Path resolution logic for `#[cfg_accessible(path)]`.
|
||||
fn cfg_accessible(&mut self, expn_id: ExpnId, path: &ast::Path) -> Result<bool, Indeterminate>;
|
||||
}
|
||||
|
||||
|
|
|
@ -1797,7 +1797,4 @@ impl<'feat> ExpansionConfig<'feat> {
|
|||
fn proc_macro_hygiene(&self) -> bool {
|
||||
self.features.map_or(false, |features| features.proc_macro_hygiene)
|
||||
}
|
||||
fn custom_inner_attributes(&self) -> bool {
|
||||
self.features.map_or(false, |features| features.custom_inner_attributes)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -286,7 +286,7 @@ impl<'a> ResolverExpand for Resolver<'a> {
|
|||
ext.helper_attrs.iter().map(|name| Ident::new(*name, span)),
|
||||
);
|
||||
if ext.is_derive_copy {
|
||||
self.add_derive_copy(invoc_id);
|
||||
self.containers_deriving_copy.insert(invoc_id);
|
||||
}
|
||||
ext
|
||||
}
|
||||
|
@ -351,10 +351,6 @@ impl<'a> ResolverExpand for Resolver<'a> {
|
|||
self.containers_deriving_copy.contains(&expn_id)
|
||||
}
|
||||
|
||||
fn add_derive_copy(&mut self, expn_id: ExpnId) {
|
||||
self.containers_deriving_copy.insert(expn_id);
|
||||
}
|
||||
|
||||
// The function that implements the resolution logic of `#[cfg_accessible(path)]`.
|
||||
// Returns true if the path can certainly be resolved in one of three namespaces,
|
||||
// returns false if the path certainly cannot be resolved in any of the three namespaces.
|
||||
|
|
Loading…
Add table
Reference in a new issue