rust-lang / rust-lang/reference

Can we avoid the need for the hard cut operator?

Open
#2,301 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.6k
Forks
607
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Notation section linked in the issue and read the surrounding grammar discussion, then review the three existing comments for the unresolved rationale. Determine whether removing the hard cut changes observable parsing or macro behavior; done means reaching a documented decision and updating the Reference grammar if the change is accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.