rustbot · GitHub

When extracting an expression selected inside a macro token tree, the assist descends into the macro expansion for semantic analysis. The expanded syntax may not preserve whitespace and comments from the original macro input, so the generated initializer could contain invalid text such as &mutbar or iftrue.

This keeps using the expanded expression for semantic analysis and replacement mapping, while building the initializer from the original source text covered by the final replacement range.

Regression tests cover required whitespace in &mut bar and if true, source formatting inside token-tree macros, and parenthesized expressions.

Fixes #22767.

Read the original on github.com ↗