Skip to content

E0050 emitted unexpectedly on missing : #129273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lolbinarycat opened this issue Aug 19, 2024 · 1 comment · Fixed by #136808
Open

E0050 emitted unexpectedly on missing : #129273

lolbinarycat opened this issue Aug 19, 2024 · 1 comment · Fixed by #136808
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST D-confusing Diagnostics: Confusing error or lint that should be reworked. D-papercut Diagnostics: An error or lint that needs small tweaks. D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lolbinarycat
Copy link
Contributor

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

@lolbinarycat lolbinarycat added 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. labels Aug 19, 2024
@estebank estebank added A-parser Area: The lexing & parsing of Rust source code to an AST D-confusing Diagnostics: Confusing error or lint that should be reworked. D-papercut Diagnostics: An error or lint that needs small tweaks. D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. labels Aug 19, 2024
@chenyukang chenyukang self-assigned this Jan 17, 2025
@bors bors closed this as completed in f06b75d Feb 16, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 16, 2025
Rollup merge of rust-lang#136808 - chenyukang:yukang-fix-arg-list-error-129273, r=estebank

Try to recover from path sep error in type parsing

Fixes rust-lang#129273

Error using `:` in the argument list may mess up the parser.

case `tests/ui/suggestions/struct-field-type-including-single-colon` also changed, seems it's  the same meaning, should be OK.

r? `@estebank`
@jieyouxu
Copy link
Member

jieyouxu commented Apr 24, 2025

Reopening this issue due to revert #140228 to address #140227.

@jieyouxu jieyouxu reopened this Apr 24, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 24, 2025
…covery, r=jieyouxu

Revert overzealous parse recovery for single colons in paths

Basically manually reverts rust-lang#136808, cc `@chenyukang` `@estebank.`

Reopens rust-lang#129273.
Fixes [after beta backport] rust-lang#140227.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 24, 2025
…covery, r=jieyouxu

Revert overzealous parse recovery for single colons in paths

Basically manually reverts rust-lang#136808, cc ``@chenyukang`` ``@estebank.``

Reopens rust-lang#129273.
Fixes [after beta backport] rust-lang#140227.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 24, 2025
Rollup merge of rust-lang#140228 - fmease:revert-overzealous-colon-recovery, r=jieyouxu

Revert overzealous parse recovery for single colons in paths

Basically manually reverts rust-lang#136808, cc ``@chenyukang`` ``@estebank.``

Reopens rust-lang#129273.
Fixes [after beta backport] rust-lang#140227.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST D-confusing Diagnostics: Confusing error or lint that should be reworked. D-papercut Diagnostics: An error or lint that needs small tweaks. D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants