Skip to content

Identify incorrect lifetimes using a number as identifier in the parser #58786

Closed
@estebank

Description

@estebank
error: character literal may only contain one codepoint
 --> src/main.rs:1:10
  |
1 | struct S<'1> { s: &'1 usize }
  |          ^^^^^^^^^^^
help: if you meant to write a `str` literal, use double quotes
  |
1 | struct S<"1> { s: &"1 usize }
  |          ^^^^^^^^^^^

error: unexpected close delimiter: `}`
 --> src/main.rs:1:29
  |
1 | struct S<'1> { s: &'1 usize }
  |                             ^ unexpected close delimiter

should instead be

error: lifetimes must be valid identifiers, not a numberic
 --> src/main.rs:1:10
  |
1 | struct S<'1> { s: &'1 usize }
  |          ^^        ^^ numbers are not a valid lifetime identifier
  |          |
  |          numbers are not a valid lifetime identifier
help: if you meant to write a valid lifetime, use a valid identifier
  |
1 | struct S<'a> { s: &'a usize }
  |          ^^        ^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsA-parserArea: The lexing & parsing of Rust source code to an ASTA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions