diff options
| author | bors <bors@rust-lang.org> | 2023-06-10 05:07:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-06-10 05:07:53 +0000 |
| commit | d0ee1908ed791d3e91d2ad74ba502eaa203cff6d (patch) | |
| tree | 8715c876352c3cbb2564993a1b1ba51bddca1ee6 /compiler/rustc_resolve/src/diagnostics.rs | |
| parent | 29611778b708f95d153fa591a50ac8702dfc0fd5 (diff) | |
| parent | 5bd8ba84931628fc2fa3e1c75cc9b9762c449125 (diff) | |
| download | rust-d0ee1908ed791d3e91d2ad74ba502eaa203cff6d.tar.gz rust-d0ee1908ed791d3e91d2ad74ba502eaa203cff6d.zip | |
Auto merge of #112452 - MU001999:fix/issue-112439, r=petrochenkov
Make "consider importing" consistent for macros Fixes #112439
Diffstat (limited to 'compiler/rustc_resolve/src/diagnostics.rs')
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 15c8a690530..ca811c9ed7d 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1352,6 +1352,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { macro_kind: MacroKind, parent_scope: &ParentScope<'a>, ident: Ident, + krate: &Crate, ) { let is_expected = &|res: Res| res.macro_kind() == Some(macro_kind); let suggestion = self.early_lookup_typo_candidate( @@ -1364,13 +1365,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let import_suggestions = self.lookup_import_candidates(ident, Namespace::MacroNS, parent_scope, is_expected); + let (span, found_use) = match parent_scope.module.nearest_parent_mod().as_local() { + Some(def_id) => UsePlacementFinder::check(krate, self.def_id_to_node_id[def_id]), + None => (None, FoundUse::No), + }; show_candidates( self.tcx, err, - None, + span, &import_suggestions, Instead::No, - FoundUse::Yes, + found_use, DiagnosticMode::Normal, vec![], "", |
