diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:03:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:03:36 +0000 |
commit | 17d40c6057c88f4c432b0d7bac88e1b84cb7e67f (patch) | |
tree | 3f66c4a5918660bb8a758ab6cda5ff8ee4f6cdcd /compiler/rustc_resolve/src/macros.rs | |
parent | Adding upstream version 1.64.0+dfsg1. (diff) | |
download | rustc-upstream/1.65.0+dfsg1.tar.xz rustc-upstream/1.65.0+dfsg1.zip |
Adding upstream version 1.65.0+dfsg1.upstream/1.65.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_resolve/src/macros.rs')
-rw-r--r-- | compiler/rustc_resolve/src/macros.rs | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 070fb9c72..dafa10e9e 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -112,47 +112,32 @@ fn fast_print_path(path: &ast::Path) -> Symbol { } } -/// The code common between processing `#![register_tool]` and `#![register_attr]`. -fn registered_idents( - sess: &Session, - attrs: &[ast::Attribute], - attr_name: Symbol, - descr: &str, -) -> FxHashSet<Ident> { - let mut registered = FxHashSet::default(); - for attr in sess.filter_by_name(attrs, attr_name) { +pub(crate) fn registered_tools(sess: &Session, attrs: &[ast::Attribute]) -> FxHashSet<Ident> { + let mut registered_tools = FxHashSet::default(); + for attr in sess.filter_by_name(attrs, sym::register_tool) { for nested_meta in attr.meta_item_list().unwrap_or_default() { match nested_meta.ident() { Some(ident) => { - if let Some(old_ident) = registered.replace(ident) { - let msg = format!("{} `{}` was already registered", descr, ident); + if let Some(old_ident) = registered_tools.replace(ident) { + let msg = format!("{} `{}` was already registered", "tool", ident); sess.struct_span_err(ident.span, &msg) .span_label(old_ident.span, "already registered here") .emit(); } } None => { - let msg = format!("`{}` only accepts identifiers", attr_name); + let msg = format!("`{}` only accepts identifiers", sym::register_tool); let span = nested_meta.span(); sess.struct_span_err(span, &msg).span_label(span, "not an identifier").emit(); } } } } - registered -} - -pub(crate) fn registered_attrs_and_tools( - sess: &Session, - attrs: &[ast::Attribute], -) -> (FxHashSet<Ident>, FxHashSet<Ident>) { - let registered_attrs = registered_idents(sess, attrs, sym::register_attr, "attribute"); - let mut registered_tools = registered_idents(sess, attrs, sym::register_tool, "tool"); // We implicitly add `rustfmt` and `clippy` to known tools, // but it's not an error to register them explicitly. let predefined_tools = [sym::clippy, sym::rustfmt]; registered_tools.extend(predefined_tools.iter().cloned().map(Ident::with_dummy_span)); - (registered_attrs, registered_tools) + registered_tools } // Some feature gates for inner attributes are reported as lints for backward compatibility. @@ -456,7 +441,7 @@ impl<'a> ResolverExpand for Resolver<'a> { } PathResult::Indeterminate => indeterminate = true, // We can only be sure that a path doesn't exist after having tested all the - // posibilities, only at that time we can return false. + // possibilities, only at that time we can return false. PathResult::Failed { .. } => {} PathResult::Module(_) => panic!("unexpected path resolution"), } |