Skip to content

Do not suggets use _ when an item named _ exists #152812

@estebank

Description

@estebank

When an item has been named _ (notably, const _: () = (); is valid), we incorrectly include it as a valid import suggestion:

error[E0432]: unresolved import `X`
--> $DIR/underscore-bindings-disambiguators.rs:25:5
|
LL | use X as Y;
| -^^^^^
| |
| no `X` in the root
| help: a similar name exists in the module: `_`
error[E0432]: unresolved import `Z`
--> $DIR/underscore-bindings-disambiguators.rs:26:5
|
LL | use Z as W;
| -^^^^^
| |
| no `Z` in the root
| help: a similar name exists in the module: `_`

use _ is never valid, so the suggestion shouldn't be emitted.

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions