Rustc suggests the same use
statement that caused the error when two modules share their name
#116970
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-resolve
Area: Name resolution
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
S-has-mcve
Status: A Minimal Complete and Verifiable Example has been found for this issue
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
I tried to reproduce the problem in the playground
Current output
The output for the playground code is the following:
The one I actually saw:
The second one is worse, because "no
LogLevelValue
inproto
" doesn't indicate that thisproto
comes is a differentproto
than the one in the suggestion. I think this happens because the modules aren't in the same file or crate, so I couldn't reproduce it in the playground.Desired output
Ideally,
rustc
should be able to notify the user that the error comes from the fact that there are two modules with the same name, instead of suggesting the same code as a fix.Rationale and extra context
rustc 1.73.0 (cc66ad468 2023-10-03)
Other cases
No response
Anything else?
Sorry if this is duplicated, but I couldn't find an issue regarding this problem
The text was updated successfully, but these errors were encountered: