Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong macro expansion #18571

Open
feois opened this issue Nov 29, 2024 · 4 comments
Open

Wrong macro expansion #18571

feois opened this issue Nov 29, 2024 · 4 comments
Labels
A-macro macro expansion C-bug Category: bug

Comments

@feois
Copy link

feois commented Nov 29, 2024

rust-analyzer version: 0.3.2196-standalone

rustc version: (eg. output of rustc -V)

editor or extension: v0.3.2196

relevant settings: all unset

repository link (if public, optional): rust-enumeration

code snippet to reproduce: I do not know how to make a minimized reproducible example. tests/test.rs reports an error with "cannot define inherent impl on foreign type" and "unexpected token in input" from the macro invocation in line 56~60. However, cargo test runs fine without reporting any error. While attempting to reproduce the issue, you may need to modify the file (e.g. enter a new line and delete it) as the error may not be reported. Attempting to inline macro will result in missing tokens. I do not know if this is only reproducible on my machine.

@feois feois added the C-bug Category: bug label Nov 29, 2024
@feois
Copy link
Author

feois commented Nov 30, 2024

The error reported now changes to a compile error only raised by my macro in the latest commit, however I am pretty sure (as the author of the macro) that the error should not be raised, evidenced by the fact that cargo test or cargo check both do not report any errors.

Old commit
Latest commit (by the time of writing)

I am now pretty certain this is an error in rust-analyzer's macro expansion, thus I am changing the issue title.

@feois feois changed the title Cannot define inherent impl on foreign type Wrong macro expansion Nov 30, 2024
@flodiebold
Copy link
Member

You can use the "Rust Analyzer: Expand macro recursively" function to see what RA expands the macro to and try to find what's wrong there.

@flodiebold flodiebold added the A-macro macro expansion label Nov 30, 2024
@feois
Copy link
Author

feois commented Nov 30, 2024

You can use the "Rust Analyzer: Expand macro recursively" function to see what RA expands the macro to and try to find what's wrong there.

I know but all I can infer is that rust-analyzer has issues with macro expansions, but I can't identify what issue it is as I am not knowledgeable enough in how rust-analyzer operates that I cannot provide any meaningful insights other than rust-analyzer has problems expanding my macros ¯\_(ツ)_/¯

@flodiebold
Copy link
Member

You know your macro though, so hopefully could be able to tell what part of the expansion is wrong? 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants