Skip to content

Can we avoid the need for the hard cut operator? #2301

Description

@Nadrieril

The Notation section says:

The hard cut operator is necessary because some tokens in Rust begin with a prefix that is itself a valid token. [...] Without the cut, if c"\0" failed to lex as a C string literal (because null bytes are not allowed in C strings), the parser could backtrack and lex it as two tokens [...]

My question is: why do we exclude null bytes in string literals as part of lexing instead of as a separate "c strings may not contain null bytes" rule? Could this make an observable different to e.g. macros? I'd quite like to remove that operator to make the grammar simpler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions