Skip to content

Commit 0b936d2

Browse files
committed
Add check to only output 'you might have meant' when the candidate name is in the same crate
1 parent be61f02 commit 0b936d2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compiler/rustc_resolve/src/late/diagnostics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
691691
let is_expected = &|res| source.is_expected(res);
692692
let ident_span = path.last().map_or(span, |ident| ident.ident.span);
693693
let typo_sugg = self.lookup_typo_candidate(path, source.namespace(), is_expected);
694-
if let TypoCandidate::Shadowed(res, Some(sugg_span)) = typo_sugg {
694+
let is_local = &|res: Res| res.opt_def_id().map_or(false, |id| id.is_local());
695+
if let TypoCandidate::Shadowed(res, Some(sugg_span)) = typo_sugg && is_local(res) {
695696
err.span_label(
696697
sugg_span,
697698
format!("you might have meant to refer to this {}", res.descr()),

0 commit comments

Comments
 (0)