-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Rustc suggests the same use statement that caused the error when two modules share their name #116970
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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
LogLevelValueinproto" doesn't indicate that thisprotocomes is a differentprotothan 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,
rustcshould 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