Skip to content

Commit 56d5367

Browse files
Add rust-analyzer setup for out-of-tree rustc_private crates
1 parent 0642476 commit 56d5367

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/rustc-driver/remarks-on-perma-unstable-features.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,29 @@ For custom-built toolchains or environments not using rustup, additional configu
4949
```
5050
3. **Check version compatibility**: Ensure your LLVM version is compatible with your Rust toolchain
5151

52+
### Configuring `rust-analyzer` for Out-of-Tree Projects
53+
54+
When developing out-of-tree projects that use `rustc_private` crates, you can configure `rust-analyzer` to recognize these crates.
55+
56+
#### Configuration Steps
57+
58+
1. **Set rust-analyzer configuration**
59+
Configure `rust-analyzer.rustc.source` to `"discover"` in your editor settings.
60+
For VS Code, add to `rust_analyzer_settings.json`:
61+
```json
62+
{
63+
"rust-analyzer.rustc.source": "discover"
64+
}
65+
```
66+
2. **Add metadata to Cargo.toml**
67+
Add the following to the `Cargo.toml` of every crate that uses `rustc_private`:
68+
```toml
69+
[package.metadata.rust-analyzer]
70+
rustc_private = true
71+
```
72+
73+
This configuration allows `rust-analyzer` to properly recognize and provide IDE support for `rustc_private` crates in out-of-tree projects.
74+
5275
### Additional Resources
5376

5477
- [GitHub Issue #137421](https://github.com/rust-lang/rust/issues/137421): Explains that `rustc_private` linker failures often occur because `llvm-tools` is not installed

0 commit comments

Comments
 (0)