Skip to content

Wrong definition of identifiers in Rust Reference #28706

@matklad

Description

@matklad

Rust reference says:

An identifier is any nonempty Unicode2 string of the following form:

  • The first character has property XID_start
  • The remaining characters have property XID_continue

The problem with this is that _ (LOW LINE) is not XID_start (reference: http://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt), but _ignored is a valid Rust identifier. Rust lexer explicitly tests for the _ https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/lexer/mod.rs#L1399.

I guess the correct wording would be (keeping in mind that _ by itself is not a valid identifier):

EIther
   * The first character has property XID_start
   * The remaining characters have property XID_continue
Or
   * The first character is _
   * The second character has property XID_continue
   * The remaining characters have property XID_continue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions