Skip to content

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

Closed
@cyrgani

Description

@cyrgani

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

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions