Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
RalfJung opened this issue Jun 4, 2025 · 1 comment
Open

Comments

@RalfJung
Copy link
Member

RalfJung commented Jun 4, 2025

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

@petrochenkov
Copy link
Contributor

petrochenkov commented Jun 4, 2025

I think "literal" there has the same meaning as in "literally me".
In any case the snippet needs some updates because after rust-lang/rust#124141 we cannot really say that the macro will see "opaque AST".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants