Skip to content

How to use rust-project.json to achieve the cfg test hack? #17226

Closed
@huang-jl

Description

@huang-jl

In issue #7225, there is a discussion about disable cfg(test) and there is a PR #12599 that only enables cfg(test) for local crates.

In PR #12599, it said:

"Local" here currently means anything that's not from the registry, so anything inside the workspace, but also path dependencies. So this isn't perfect, and users might still need to use rust-analyzer.cargo.unsetTest for these in some cases.

So I think if I need to manually disable cfg(test) for local path dependencies, I have to use the rust-analyzer.cargo.unsetTest features. After test, I find that it works as what I want.

But recently, there is a new PR #16726 that removes the rust-analyzer.cargo.unsetTest and it is related to project-rust.json. And I cannot use rust-analyzer.cargo.unsetTest in new release of RA.

So my questions is what is project-rust.json? Why can it replace the rust-analyzer.cargo.unsetTest for local path dependencies?

I cannot find any information of using project-rust.json, except the docs. But I still do not know how to use project-rust.json to achieve rust-analyzer.cargo.unsetTest. Is there any example of using project-rust.json that I can copy from?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-supportCategory: support questions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions