-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.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.
Description
Code
use std::fmt;
struct Hello;
impl fmt::Display for Hello {
fn fmt(&self, f: &fmt:Formatter) -> fmt::Result {
write!(f, "hello")
}
}
Current output
Compiling playground v0.0.1 (/playground)
error: expected parameter name, found `:`
--> src/lib.rs:6:26
|
6 | fn fmt(&self, f: &fmt:Formatter) -> fmt::Result {
| ^ expected parameter name
error: expected one of `!`, `(`, `)`, `,`, `::`, or `<`, found `:`
--> src/lib.rs:6:26
|
6 | fn fmt(&self, f: &fmt:Formatter) -> fmt::Result {
| ^
| |
| expected one of `!`, `(`, `)`, `,`, `::`, or `<`
| help: missing `,`
error[E0573]: expected type, found module `fmt`
--> src/lib.rs:6:23
|
6 | fn fmt(&self, f: &fmt:Formatter) -> fmt::Result {
| ^^^ not a type
error[E0050]: method `fmt` has 3 parameters but the declaration in trait `std::fmt::Display::fmt` has 2
--> src/lib.rs:6:12
|
6 | fn fmt(&self, f: &fmt:Formatter) -> fmt::Result {
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected 2 parameters, found 3
|
= note: `fmt` from trait: `fn(&Self, &mut Formatter<'_>) -> Result<(), std::fmt::Error>`
Some errors have detailed explanations: E0050, E0573.
For more information about an error, try `rustc --explain E0050`.
error: could not compile `playground` (lib) due to 4 previous errors
Desired output
Compiling playground v0.0.1 (/playground)
error: expected parameter name, found `:`
--> src/lib.rs:6:26
|
6 | fn fmt(&self, f: &fmt:Formatter) -> fmt::Result {
| ^ expected parameter name
error: expected one of `!`, `(`, `)`, `,`, `::`, or `<`, found `:`
--> src/lib.rs:6:26
|
6 | fn fmt(&self, f: &fmt:Formatter) -> fmt::Result {
| ^
| |
| expected one of `!`, `(`, `)`, `,`, `::`, or `<`
| help: missing `,`
error[E0573]: expected type, found module `fmt`
--> src/lib.rs:6:23
|
6 | fn fmt(&self, f: &fmt:Formatter) -> fmt::Result {
| ^^^ not a type
Some errors have detailed explanations: E0050, E0573.
For more information about an error, try `rustc --explain E0050`.
error: could not compile `playground` (lib) due to 4 previous errors
Rationale and extra context
When looking at rust-analyzer output or when just looking at the last few error messages, it's easy to see only the "too many arguments" error, and not the syntax error that points at the exact problem.
Other cases
No response
Rust Version
1.80.1
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.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.