rust-lang / rust-lang/rust-analyzer
linkedProjects: support using different cargo configurations / targets
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I am having some difficulties with the linkedProjects feature of RA. Let me explain, what I am
trying to do.
My code base is structured like this:
.
├── Cargo.toml
├── cross
│ ├── Cargo.toml
│ ├── kernel
│ └── target-specs
├── libs
│ ├── allocator
│ └── noheap
└── xtask
├── Cargo.toml
└── src
Note, that the top level Cargo.toml and the cross/Cargo.toml are separate workspaces.
To support that project layout, I use the following settings.json (for vscode):
{
"rust-analyzer.cargo.target": "riscv64imac-unknown-none-elf",
"rust-analyzer.linkedProjects": [
"Cargo.toml",
"cross/Cargo.toml",
]
}
I use two separate workspaces, because I want to build code for two targets at the same time.
The top level workspace is build by default for the host machine target. It contains a custom xtask crate,
which functions as a cargo-wrapper, which is used to execute some external tools (essentially for
post processing build artifacts from the cross/ workspace.
There is also a libs/ folder, containing code shared among the cross/ and root workspaces.
The cross/ workspace is by default cross compiled to a different architecture (RISC-V, and arm
bare-metal targets).
Unfortunately, rust-analyzer is not aware, that it should process the two workspaces for different targets
and also different features. Putting a default target into the relevant .cargo/config files does not work.
With the rust-analyzer vscode settings, I can only specify the target for all loaded projects at once with the
rust-analyzer.cargo.target config.
Is it possible, to specify the used cargo target and features for every linked workspace separately?
If not, should this feature be added? Right now, the RA project model is already very flexible (as I understand),
so supporting this may be too difficult.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from rust-analyzer's linkedProjects handling and the rust-analyzer.cargo.target and feature settings described in the issue. Determine how each linked Cargo.toml is configured, then verify that separate targets and features can be assigned per workspace and that both workspaces are analyzed accordingly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, vscode
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100