@@ -225,8 +225,15 @@ pub enum TokenKind {
225225 /* Literals */
226226 Literal ( Lit ) ,
227227
228- /* Name components */
228+ /// Identifier token.
229+ /// Do not forget about `NtIdent` when you want to match on identifiers.
230+ /// It's recommended to use `Token::(ident,uninterpolate,uninterpolated_span)` to
231+ /// treat regular and interpolated identifiers in the same way.
229232 Ident ( ast:: Name , /* is_raw */ bool ) ,
233+ /// Lifetime identifier token.
234+ /// Do not forget about `NtLifetime` when you want to match on lifetime identifiers.
235+ /// It's recommended to use `Token::(lifetime,uninterpolate,uninterpolated_span)` to
236+ /// treat regular and interpolated lifetime identifiers in the same way.
230237 Lifetime ( ast:: Name ) ,
231238
232239 Interpolated ( Lrc < Nonterminal > ) ,
@@ -328,11 +335,12 @@ impl Token {
328335 mem:: replace ( self , Token :: dummy ( ) )
329336 }
330337
331- /// For interpolated tokens returns a span of the fragment to which the interpolated
332- /// token refers, for all other tokens this is just a regular span.
338+ /// For interpolated tokens, returns a span of the fragment to which the interpolated
339+ /// token refers. For all other tokens this is just a regular span.
333340 /// It is particularly important to use this for identifiers and lifetimes
334- /// for which spans affect name resolution. This also includes edition checks
335- /// for edition-specific keyword identifiers.
341+ /// for which spans affect name resolution and edition checks.
342+ /// Note that keywords are also identifiers, so they should use this
343+ /// if they keep spans or perform edition checks.
336344 pub fn uninterpolated_span ( & self ) -> Span {
337345 match & self . kind {
338346 Interpolated ( nt) => nt. span ( ) ,
@@ -453,6 +461,7 @@ impl Token {
453461 }
454462 }
455463
464+ // A convenience function for matching on identifiers during parsing.
456465 // Turns interpolated identifier (`$i: ident`) or lifetime (`$l: lifetime`) token
457466 // into the regular identifier or lifetime token it refers to,
458467 // otherwise returns the original token.
0 commit comments