Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions compiler/rustc_resolve/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,16 +1107,22 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// If such resolution is successful and gives the same result
// (e.g. if the macro is re-imported), then silence the lint.
let no_macro_rules = self.arenas.alloc_macro_rules_scope(MacroRulesScope::Empty);
let ident = path.segments[0].ident;
let fallback_binding = self.reborrow().resolve_ident_in_scope_set(
path.segments[0].ident,
ident,
ScopeSet::Macro(MacroKind::Bang),
&ParentScope { macro_rules: no_macro_rules, ..*parent_scope },
None,
false,
None,
None,
);
if fallback_binding.ok().and_then(|b| b.res().opt_def_id()) != Some(def_id) {
if let Ok(fallback_binding) = fallback_binding
&& fallback_binding.res().opt_def_id() == Some(def_id)
{
// Silence `unused_imports` on the fallback import as well.
self.get_mut().record_use(ident, fallback_binding, Used::Other);
} else {
let location = match parent_scope.module.kind {
ModuleKind::Def(kind, def_id, name) => {
if let Some(name) = name {
Expand Down
1 change: 1 addition & 0 deletions tests/ui/attributes/key-value-expansion-scope-pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//@ check-pass
//@ edition:2018

#![warn(unused_imports)]
#![doc = in_root!()]

macro_rules! in_root { () => { "" } }
Expand Down
Loading