Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Lowering doc-comments

This phase of processing converts an input sequence of fine-grained tokens to a new sequence of fine-grained tokens.

The new sequence is the same as the input sequence, except that each Line_comment or Block_comment token whose style is inner doc or outer doc is replaced with the following sequence:

  • Punctuation with mark #
  • Whitespace
  • Punctuation with mark ! (omitted if the comment token's style is outer doc)
  • Punctuation with mark [
  • Ident with represented ident doc
  • Punctuation with mark =
  • Whitespace
  • Raw_string_literal with the comment token's body as the represented string and empty suffix
  • Punctuation with mark ]

Note: the whitespace tokens aren't observable by anything currently described in this writeup, but they explain the spacing in the tokens that proc-macros see.