-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Error message for question mark operator should message conversion #60917
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-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 lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-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.
I've been working with a lot of people who are either new to Rust or new to its latest features (like the question mark operator) and I'm noticing a lot of confusion around a specific error message.
Suppose you have the following code:
This gives you the error:
However, if you look at the actual code, it isn't obvious where the
Fromtrait is even being used.The documentation for the
Fromtrait actually does mention this briefly, though most people I encounter don't go as far as looking that up. The error message is pretty daunting if you're new to the language.I propose that we add something to the error message when we see that they are using the question mark:
This conveys exactly where the
Fromtrait is being used and why they may be running into this issue. You certainly don't have to use this exact wording. Feel free to use whatever fits. :)