Skip to content

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

@tomasol

Description

@tomasol

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions