Confusing compiler suggestion with type/variable with underscore prefix #125650
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
Compiler explorer link: https://godbolt.org/z/heYWW481h
This kind of diagnostic happens when you have a variable or type name with an underscore prefix.
When you try to access the variable/type without the underscore, the compiler tries to get the programmer to change the name of the variable/type, instead of the usage of it.
The compiler output was improved in 1.78 with #121776/#121792 by @GuillaumeGomez.
I personally find the current output still confusing. It shows the suggested improvement of changing the type/variable name, without showing the original code. As the compiler tells me about an error in the usage, I expect the other code it shows me to be unmodified.
You also have to read very closely that it wants you to change the variable, and not the usage. As the original error is in the line with the usage, I expected Rust to tell me how to correct that line. To be fair, I was on rustc version
1.77
, but the error messages I am talking about here are from1.78
, for which I technically don't have first-hand-experience.Other cases
No response
Rust Version
Anything else?
No response
The text was updated successfully, but these errors were encountered: