Skip to content

set current working directory for procedural macros #11079

Closed
@matklad

Description

@matklad

In

https://github.com/rust-analyzer/rust-analyzer/blob/8dc3a270f6a893a592db1a5fe3cf8752521987e1/crates/proc_macro_srv/src/cli.rs#L8-L24

nothing sets currend dir explicitly, it gets inherited. This is wrong, as proc-macros generally can look at pwd. Note that this is per-macro thing -- we run a single expander process, but each crates' macros want to see their own pwd.

I think we need to add current_dir to this struct:

https://github.com/rust-analyzer/rust-analyzer/blob/8dc3a270f6a893a592db1a5fe3cf8752521987e1/crates/proc_macro_api/src/msg.rs#L31-L52

and call std::env::set_env when serving a request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macromacro expansionC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions