Skip to content

Commit 0e2aae1

Browse files
committed
Add some comments about token spans.
Information that took me a while to work out.
1 parent 54c1da2 commit 0e2aae1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

compiler/rustc_ast/src/token.rs

+6
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ pub enum TokenKind {
333333
/// - It prevents `Token` from implementing `Copy`.
334334
/// It adds complexity and likely slows things down. Please don't add new
335335
/// occurrences of this token kind!
336+
///
337+
/// Note: the span here is for the LHS macro parameter declaration, e.g.
338+
/// `$id:ident`, `$t:ty`. (The span covers the metavariable name, the `:`,
339+
/// and the fragment specifier kind.)
336340
Interpolated(Lrc<(Nonterminal, Span)>),
337341

338342
/// A doc comment token.
@@ -857,6 +861,8 @@ pub enum Nonterminal {
857861
NtPat(P<ast::Pat>),
858862
NtExpr(P<ast::Expr>),
859863
NtTy(P<ast::Ty>),
864+
/// The span in the `Ident` is for the identifier passed in to the macro,
865+
/// e.g. the `blah` in `foo!(blah)`.
860866
NtIdent(Ident, IdentIsRaw),
861867
NtLifetime(Ident),
862868
NtLiteral(P<ast::Expr>),

0 commit comments

Comments
 (0)