rust-lang / rust-lang/reference

Macro docs use term "literal token" which is undefined and confusing

Open
#1,840 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

From https://doc.rust-lang.org/nightly/reference/macros-by-example.html#r-macro.decl.transcription.fragment:

When forwarding a matched fragment to another macro-by-example, matchers in the second macro will see an opaque AST of the fragment type. The second macro can’t use literal tokens to match the fragments in the matcher, only a fragment specifier of the same type. The ident, lifetime, and tt fragment types are an exception, and can be matched by literal tokens.

I don't know what a "literal token" is, but it's apparently not the same as a token of kind literal (i.e., $foo:literal), so the term is confusing and also not properly introduced.

Cc @petrochenkov

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 at the Rust Reference's macros-by-example transcription section linked in the issue and compare "literal token" with the literal fragment kind and the other fragment specifiers. Review the surrounding macro-matching terminology, then revise the explanation so the term is introduced and its distinction from literal fragments is clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.