rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

fix: `impl Trait` inside macro parsed incorrectly

Open tvsfx opened this issue 4 months ago • 1 comments

This PR is probably (?) too blunt an approach, but it does illustrate how one could go about fixing #6036. Adds a test for illustration purposes.

tvsfx avatar Aug 18 '25 18:08 tvsfx

Issue #3004 seems to be the only regression (surprisingly), but I'm not sure how my change caused this.

Mismatch at tests/source/macros.rs:1032:
 
 fn issue3004() {
     foo!(|_| { () });
-    stringify!((foo+));
+    stringify!(( foo+ ));
 }

EDIT: I misinterpreted the parse_item method's return value; I think the other parsers (for Ty and Pat) should be tried when it returns None, cause that means that the parsed argument starts with a token that's invalid for an Item. I pushed a commit that does this, and it should make tests pass.

tvsfx avatar Aug 19 '25 07:08 tvsfx