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

Proc macro generating include! or include_str! is not expanded correctly if including files from the target folder #16343

Closed
tomasol opened this issue Jan 10, 2024 · 4 comments
Labels
A-proc-macro proc macro C-bug Category: bug

Comments

@tomasol
Copy link

tomasol commented Jan 10, 2024

rust-analyzer version: rust-analyzer version: 0.4.1801-standalone
rustc version: rustc 1.75.0 (82e1608df 2023-12-21)

Reproducer: https://github.com/tomasol/ra-proc-macro-including-target

I want to use a proc macro which include!s some generated rust files from the target directory. RA cannot expand the macro properly, but only when the included file resides in the target directory. Needed for fixing this issue in cargo-component

Comment from the issue:

From the output of RA:

File with cargo diagnostic not found in VFS: file not found: /Users/peterhuene/demo/target/bindings/proxy/bindings.rs

It seems, for whatever reason when loaded in a workspace, the VFS isn't populated with the bindings file, which I think means RA will give it an empty file to the proc-macro, ultimately resulting in an empty bindings macro.

When reproducing the issue there was no difference between the project being part of a workspace or not.

@tomasol tomasol added the C-bug Category: bug label Jan 10, 2024
@Veykril Veykril added the A-proc-macro proc macro label Jan 10, 2024
@Veetaha
Copy link
Contributor

Veetaha commented Jan 11, 2024

This definitely worked for me in the past, so this must be a regression after some commit in rust-analuzer. I'm sure, because suddenly big percentage of our code that uses code generation in build.rs with prost became entirely unanalyzed.

@Veykril
Copy link
Member

Veykril commented Jan 11, 2024

Yes this is a known regression (can't find the concrete issue right now) since #15959

@lnicola
Copy link
Member

lnicola commented Jan 11, 2024

#16109

@Veykril
Copy link
Member

Veykril commented Jan 11, 2024

That's the one, I thought I left a comment on the issue but I guess I didn't. Closing as duplicate, I think the issue OP reported is of the same cause.

@Veykril Veykril closed this as not planned Won't fix, can't repro, duplicate, stale Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-proc-macro proc macro C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

4 participants