]> git.lizzy.rs Git - rust.git/commit
Perform 'deep recollection' in test helper macros
authorAaron Hill <aa1ronham@gmail.com>
Sun, 21 Mar 2021 04:17:19 +0000 (00:17 -0400)
committerAaron Hill <aa1ronham@gmail.com>
Sun, 21 Mar 2021 04:41:12 +0000 (00:41 -0400)
commit6d7294a00c3f831ed7d60a530911bff67f4e54ba
tree4ab5bd0b59be4d3b716b2d1feddfbef390b54fcb
parent61edfd591cedff66fca639c02f66984f6271e5a6
Perform 'deep recollection' in test helper macros

Currently, the print helper macro performs 'recollection' by doing
`token_stream.into_iter().collect()`. However, this will not affect
nonterminals that occur nested inside delimited groups, since the
wrapping delimited group will be left untouched.

This commit adds 'deep recollection', which recursively recollects every
delimited group in the token stream. As with normal recollection, we
only print out something if deep recollection results in a different
stringified token stream.

This is useful for catching bugs where we update the AST of a
nonterminal (which affects pretty-printing), but do not update the
attatched `TokenStream`
src/test/ui/proc-macro/auxiliary/test-macros.rs
src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout
src/test/ui/proc-macro/nodelim-groups.stdout