Skip to content

Comments

fix: impl Trait inside macro parsed incorrectly#6640

Open
tvsfx wants to merge 2 commits intorust-lang:mainfrom
tvsfx:tvsfx/impl-trait-in-macro
Open

fix: impl Trait inside macro parsed incorrectly#6640
tvsfx wants to merge 2 commits intorust-lang:mainfrom
tvsfx:tvsfx/impl-trait-in-macro

Conversation

@tvsfx
Copy link

@tvsfx tvsfx commented Aug 18, 2025

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
Copy link
Author

tvsfx commented Aug 19, 2025

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.

@jieyouxu jieyouxu added S-waiting-on-review Status: awaiting review from the assignee but also interested parties. F-impacts-stable-unformatted-code Expected formatting impact: affects stable + unformatted code (caution) and removed pr-not-reviewed labels Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-impacts-stable-unformatted-code Expected formatting impact: affects stable + unformatted code (caution) S-waiting-on-review Status: awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants