Skip to content

Commit

Permalink
Rollup merge of rust-lang#103560 - zbyrn:issue-103358-fix, r=cjgillot
Browse files Browse the repository at this point in the history
Point only to the identifiers in the typo suggestions of shadowed names instead of the entire struct

Fixes rust-lang#103358.

As discussed in the issue, the `Span` of the candidate `Ident` for a typo replacement is stored alongside its `Symbol` in `TypoSuggestion`. Then, the span of the identifier is what the "you might have meant to refer to" note is pointed at, rather than the entire struct definition.

Comments in rust-lang#103111 and the issue both suggest that it is desirable to:
1. include names defined in the same crate as the typo,
2. ignore names defined elsewhere such as in `std`, _and_
3. include names introduced indirectly via `use`.

Since a name from another crate but introduced via `use` has non-local `def_id`, to achieve this, a suggestion is displayed if either the `def_id` of the suggested name is local, or the `span` of the suggested name is in the same file as the typo itself.

Some UI tests have also been modified to reflect this change.

r? `@cjgillot`
  • Loading branch information
Dylan-DPC committed Oct 30, 2022
2 parents e30f474 + 0be6db2 commit 591daa9
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 591daa9

Please sign in to comment.