Skip to content
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

Accidental triple colon diagnostics are worse than single colon diagnostics #130613

Closed
cyrgani opened this issue Sep 20, 2024 · 1 comment · Fixed by #130673
Closed

Accidental triple colon diagnostics are worse than single colon diagnostics #130613

cyrgani opened this issue Sep 20, 2024 · 1 comment · Fixed by #130673
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cyrgani
Copy link
Contributor

cyrgani commented Sep 20, 2024

Code

fn main() {
    String:::new();
}

Current output

error: expected identifier, found `:`
 --> src/main.rs:2:13
  |
2 |     String:::new();
  |             ^ expected identifier
  |
help: maybe write a path separator here
  |
2 |     String::::new();
  |             ~~

Desired output

error: path separator must be a double colon
 --> src/main.rs:2:11
  |
2 |     String:::new();
  |             ^
  |
help: use a double colon instead
  |
2 |     String::new();
  |            ~

Rationale and extra context

Current suggestion for ::: is not correct, but the one for : is, so the ::: version should be fixed.

Other cases

error: path separator must be a double colon
 --> src/main.rs:2:11
  |
2 |     String:new();
  |           ^
  |
help: use a double colon instead
  |
2 |     String::new();
  |            +

Rust Version

1.83 on playground

Anything else?

No response

@cyrgani cyrgani 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 Sep 20, 2024
@fmease fmease added A-parser Area: The parsing of Rust source code to an AST D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. labels Sep 20, 2024
@GrigorenkoPV
Copy link
Contributor

@rustbot claim

@bors bors closed this as completed in 52f146d Sep 22, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2024
Rollup merge of rust-lang#130673 - GrigorenkoPV:path-triple-colon, r=compiler-errors

Parser: recover from `:::` to `::`

Closes rust-lang#130613
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 parsing of Rust source code to an AST D-invalid-suggestion Diagnostics: A structured suggestion resulting in 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.

3 participants