Skip to content

Unterminated char literal complains about lifetimes #101278

Closed
@estebank

Description

@estebank

Given the following code

let _ = ['1','2,'3'];

the current output is

error: lifetimes cannot start with a number
 --> src/main.rs:2:18
  |
2 |     let _ = ['1','2,'3'];
  |                  ^^

error: expected `while`, `for`, `loop` or `{` after a label
 --> src/main.rs:2:20
  |
2 |     let _ = ['1','2,'3'];
  |                    ^ expected `while`, `for`, `loop` or `{` after a label

It should instead recognize that a char literal was intended:

error: unterminated char literal
 --> src/main.rs:2:18
  |
2 |     let _ = ['1','2,'3'];
  |                  ^^
help: add a closing `'`
  |
2 |     let _ = ['1','2','3'];
  |                    +

https://internals.rust-lang.org/t/error-message-for-vec-1-2-3/17309

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.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