Skip to content

Commit dfb690e

Browse files
committed
resolve/expand: Misc cleanup
1 parent 68f94e9 commit dfb690e

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

compiler/rustc_expand/src/base.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,8 +888,10 @@ pub trait ResolverExpand {
888888
/// Some parent node that is close enough to the given macro call.
889889
fn lint_node_id(&mut self, expn_id: ExpnId) -> NodeId;
890890

891+
// Resolver interfaces for specific built-in macros.
892+
/// Does `#[derive(...)]` attribute with the given `ExpnId` have built-in `Copy` inside it?
891893
fn has_derive_copy(&self, expn_id: ExpnId) -> bool;
892-
fn add_derive_copy(&mut self, expn_id: ExpnId);
894+
/// Path resolution logic for `#[cfg_accessible(path)]`.
893895
fn cfg_accessible(&mut self, expn_id: ExpnId, path: &ast::Path) -> Result<bool, Indeterminate>;
894896
}
895897

compiler/rustc_expand/src/expand.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,7 +1797,4 @@ impl<'feat> ExpansionConfig<'feat> {
17971797
fn proc_macro_hygiene(&self) -> bool {
17981798
self.features.map_or(false, |features| features.proc_macro_hygiene)
17991799
}
1800-
fn custom_inner_attributes(&self) -> bool {
1801-
self.features.map_or(false, |features| features.custom_inner_attributes)
1802-
}
18031800
}

compiler/rustc_parse/src/parser/attr.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,13 @@ impl<'a> Parser<'a> {
312312
}
313313

314314
pub fn maybe_needs_tokens(attrs: &[ast::Attribute]) -> bool {
315+
// One of the attributes may either itself be a macro, or apply derive macros (`derive`),
316+
// or expand to macro attributes (`cfg_attr`).
315317
attrs.iter().any(|attr| {
316-
if let Some(ident) = attr.ident() {
318+
attr.ident().map_or(true, |ident| {
317319
ident.name == sym::derive
318-
// This might apply a custom attribute/derive
319-
|| ident.name == sym::cfg_attr
320-
|| !rustc_feature::is_builtin_attr_name(ident.name)
321-
} else {
322-
true
323-
}
320+
|| ident.name == sym::cfg_attr
321+
|| !rustc_feature::is_builtin_attr_name(ident.name)
322+
})
324323
})
325324
}

compiler/rustc_resolve/src/macros.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl<'a> ResolverExpand for Resolver<'a> {
286286
ext.helper_attrs.iter().map(|name| Ident::new(*name, span)),
287287
);
288288
if ext.is_derive_copy {
289-
self.add_derive_copy(invoc_id);
289+
self.containers_deriving_copy.insert(invoc_id);
290290
}
291291
ext
292292
}
@@ -351,10 +351,6 @@ impl<'a> ResolverExpand for Resolver<'a> {
351351
self.containers_deriving_copy.contains(&expn_id)
352352
}
353353

354-
fn add_derive_copy(&mut self, expn_id: ExpnId) {
355-
self.containers_deriving_copy.insert(expn_id);
356-
}
357-
358354
// The function that implements the resolution logic of `#[cfg_accessible(path)]`.
359355
// Returns true if the path can certainly be resolved in one of three namespaces,
360356
// returns false if the path certainly cannot be resolved in any of the three namespaces.

0 commit comments

Comments
 (0)