rust-lang / rust-lang/reference

Lack of precedence in OR clause causes lexical ambiguity for comments

Open
#2,079 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

/**/* */*/, in its entirety, is a valid BLOCK_COMMENT_OR_DOC if and only if the outer comment is interpreted as an OUTER_BLOCK_DOC AFAICT. The beginning of the stream also matches as a BLOCK_COMMENT however, which will match only /**/, leaving the rest as remaining tokens (which appears to be the compiler's current behavior).

The notation gives precedence to sequences over the OR operator but does not define precedence when multiple branches are candidates.

I believe the latter may be too notable of a change over updating the comment syntax here, but I'm also unsure the likelihood this was an assumption never actually written which should be included. I also know the comment syntax is also incredibly verbose. I'm happy to leave that question to those with experience.

Also, apologies if I did make a mistake or miss something. I'd be happy to hear why this is invalid :)

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 linked BLOCK_COMMENT_OR_DOC, OUTER_BLOCK_DOC, and BLOCK_COMMENT grammar, then review the linked notation rules for how competing alternatives are resolved. Reproduce the compiler behavior for /**/* */ and compare it with the documented grammar. Done means reaching and documenting a clear resolution for the precedence ambiguity.

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
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.