450 Commits

Author SHA1 Message Date
Chayim Refael Friedman
9aa5e45689 Merge pull request #21424 from cormacrelf/support-more-runnable-kinds
Support more runnable kinds in project JSON
2026-03-22 21:38:17 +00:00
Chayim Refael Friedman
633f271c60 Merge pull request #21423 from cormacrelf/project-json-compatibility
Project json compatibility improvements
2026-03-22 21:27:49 +00:00
Laurențiu Nicola
7e440b1d07 Tweak pre-release check for beta 2026-03-06 07:18:44 +02:00
Laurențiu Nicola
ba09b3315e Use -Zlockfile-path on every 1.95 nightly 2026-02-27 08:53:39 +02:00
Shoyu Vanilla (Flint)
039106d136 Merge pull request #21540 from J3m3/align-optional-fields
minor: clean up `project_json::CrateData` and its corresponding docs
2026-02-19 04:39:04 +00:00
Shoyu Vanilla
a5be1f3f70 Append -Zlockfile-path 2026-02-19 02:31:15 +09:00
Shoyu Vanilla
c7c2bef32c Switch to env var CARGO_RESOLVER_LOCKFILE_PATH for copied lockfiles for toolchains >= 1.95.0 2026-02-19 02:31:15 +09:00
Lukas Wirth
85b60ac340 internal: Remove Edition::CURRENT_FIXME 2026-02-07 13:14:17 +01:00
Jesung Yang
385a0d9daa Remove unncecessary #[serde(default)]
Remove `#[serde(default)]` from optional fields. Fields of type `Option`
are automatically deserialized to `None` when the corresponding keys are
missing in `rust-project.json`, making the explicit attribute redundant.
2026-01-28 14:29:44 +09:00
Lukas Wirth
fcdcf05730 fix: Do not show sysroot dependencies in symbol search 2026-01-18 09:53:09 +01:00
Wilfred Hughes
9c0d88cc07 internal: Include private definitions in generated rustdoc
rust-analyzer has handy prebuilt `cargo doc` output at
https://rust-lang.github.io/rust-analyzer/ide/

However, it doesn't include private definitions, which makes it less
useful when trying to learn unfamiliar parts of the codebase.

Instead, pass `--document-private-items` so the HTML includes
information on private types and modules too. rustdoc renders these
with a padlock icon, so it's still clear that they're private.

This change also exposes some more rustdoc warnings, which I've fixed.
2026-01-09 12:01:54 +00:00
Cormac Relf
7657739584 Support more runnable kinds for project json
Allows project JSON users  to run a whole module of tests, benchmarks, doctests.
2026-01-09 14:19:23 +11:00
Cormac Relf
fa181ab80f A comment to help ProjectJsonData stay backwards-compatible
Makes clear to future editors of this code that they should add #[serde(default)]
to new fields.
2026-01-09 14:19:23 +11:00
Cormac Relf
2969b3bf57 Add unknown runnable kind for forwards compatibility 2026-01-09 14:19:23 +11:00
Cormac Relf
967277d357 Privatise some fields and structs in project_json
These are not used outside of the project-model crate, ie. instantly converted to other structures.
2026-01-09 14:19:23 +11:00
Cormac Relf
d8b74b7eb4 Add a test for parsing BuildData and RunnableData json 2026-01-09 14:17:28 +11:00
Cormac Relf
a7eb8c0889 doc: Update docs for runnables to include run/flycheck 2026-01-08 10:19:23 +11:00
Cormac Relf
67099fc243 project-model: Introduce RunnableKind::Flycheck
We need to distinguish from RunnableKind::Check, which is
human-readable.
2026-01-08 10:19:23 +11:00
Cormac Relf
f9b91f0801 project-model: Return crate by reference 2026-01-08 10:19:23 +11:00
Cormac Relf
4dff38c964 project-model: Don't do O(n) clones as well as O(n) search 2026-01-08 10:19:23 +11:00
Cormac Relf
490d5ceadf project-model: Helpers for traversing dep graph in ProjectJson
Needed for all_workspace_dependencies_for_package implementation.
2026-01-08 10:19:23 +11:00
Jesung Yang
7f6858fd09 feat: introduce crate_attrs field in rust-project.json
Since the commit 50384460c6
("Rewrite method resolution to follow rustc more closely"), the method
resolution logic has changed: rust-analyzer only looks up inherent
methods for primitive types in sysroot crates.

Unfortunately, this change broke at least one project that relies on
`rust-project.json`: Rust-for-Linux. Its auto-generated
`rust-project.json` directly embeds `core`, `alloc`, and `std` in the
`crates` list without defining `sysroot_src`. Consequently,
rust-analyzer fails to identify them as sysroot crates, breaking IDE
support for primitive methods (e.g., `0_i32.rotate_left(0)`).

However, specifying `sysroot_src` creates a new issue: it implicitly
adds `std` as a dependency to all kernel module crates, which are
actually compiled with `-Zcrate-attr=no_std`. Since rust-analyzer cannot
see compiler flags passed outside of the project definition, we need a
method to explicitly specify `#![no_std]` or, more generally,
crate-level attributes through the project configuration.

To resolve this, extend the `rust-project.json` format with a new
`crate_attrs` field. This allows users to specify crate-level attributes
such as `#![no_std]` directly into the configuration, enabling
rust-analyzer to respect them when analyzing crates.

References:
- The original Zulip discussion:
  https://rust-lang.zulipchat.com/#narrow/channel/185405-t-compiler.2Frust-analyzer/topic/Primitive.20type.20inherent.20method.20lookup.20fails/with/562983853
2025-12-18 01:27:43 +00:00
Shoyu Vanilla
564034e3ec fix: Prefix json target file with workspace root for sysroot metadata 2025-12-15 23:22:19 +09:00
The rustc-josh-sync Cronjob Bot
f6c67ed0a4 Format code 2025-12-15 04:30:49 +00:00
Jieyou Xu
acb575c6ab rust-analyzer: prep crates for testing against in-tree rustc_private 2025-12-11 20:22:49 +08:00
Wilfred Hughes
86bc07e91a Fix rustdoc warnings and add CI
rustdoc has a separate environment variable for banning warnings, so
set that in the GitHub action configuration.

https://github.com/rust-lang/cargo/issues/8424#issuecomment-1070988443

Fix all the rustdoc warnings on unknown types or functions. I've
updated references wherever it's obvious, otherwise I've replaced the
rustdoc link with plain backticks.

There were also some cases where rustdoc links referred to private
APIs. I've disabled the rustdoc private API warning in those crates.
2025-12-01 13:06:15 +00:00
Lukas Wirth
4a2b38f49f Merge pull request #21098 from Aditya-PS-05/fix/include-bin-targets-outside-pkg-root
fix: include all target types with paths outside package root
2025-11-23 18:02:36 +00:00
Aditya-PS-05
85fcca685f fix: sort and dedup include paths to prevent VFS issues 2025-11-23 20:45:57 +05:30
Louis Maddox
2443cce41a fix: no unused tracing/attributes feature
- Discussed in https://github.com/rust-lang/rust-analyzer/issues/21107
- Avoids activating an `attributes` feature to crates that do not use it
- Updates the 6 crates that use attributes feature to specify it in
  their Cargo.toml: {hir,hir-def,hir-ty,ide-assists,ide-db,project-model}
2025-11-23 13:37:42 +00:00
Aditya-PS-05
0b89a81c91 fix: Include all target types with paths outside package root 2025-11-22 19:30:31 +05:30
Michael Gruenewald
cdc32667ed Fix tool_path 2025-11-21 17:06:37 +01:00
Shoyu Vanilla
8d180806af fix: Parse cargo config files with origins 2025-11-19 01:20:50 +09:00
Shoyu Vanilla
66706b399f Add toml as a dependency of project-model and unify version 2025-11-19 01:15:04 +09:00
Lukas Wirth
5d7a7a3e13 Drop span maps on a background thread 2025-11-17 14:24:31 +01:00
Lukas Wirth
917734c43b Reduce cargo tool probing in crate graph construction 2025-11-17 13:49:43 +01:00
Lukas Wirth
2c171f8f07 Give rayon workers better names 2025-11-17 13:05:05 +01:00
Shoyu Vanilla
f09b0a89a4 fix: Canonicalize custom-target.json paths when fetching sysroot metadata 2025-11-04 03:00:29 +09:00
Shoyu Vanilla
5f3539a566 fix: Resolve target-dir more precisely 2025-10-28 03:54:00 +09:00
yukang
76f9b4e36c Use tracing error when received compiler message for unknown package 2025-10-25 09:14:35 +08:00
Daniel Paoliello
554381f805 Allow env vars set in cargo.extraEnv to be resolved by the env! macro 2025-10-21 11:00:27 -07:00
Shoyu Vanilla
5c537596f5 fix: Report metadata errors for sysroot 2025-10-20 01:55:52 +09:00
Shoyu Vanilla
dcab2ad02b fix: Run cargo metadata on sysroot with cwd=sysroot 2025-10-19 18:31:26 +09:00
Chayim Refael Friedman
428405da33 Prevent rustup from automatically installing toolchains
By setting RUSTUP_AUTO_INSTALL=0.
2025-09-30 19:02:10 +03:00
Shoyu Vanilla
de3ad58b73 fix: Make flycheck clearing dependency-aware 2025-09-20 01:35:35 +09:00
Chayim Refael Friedman
6315e315ad Expand target info to include the architecture
And make it easier to expand it more in the future, if needed.
2025-09-09 13:47:26 +03:00
Elliot Roberts
32e2b60d86 Pass --target before -- for cargo rustc 2025-08-30 13:36:29 -07:00
BenjaminBrienen
98322abfd7 remove duplicate field in Debug 2025-08-08 23:46:28 +02:00
Lukas Wirth
34ce0b5063 Slim down compile time artifact progress reports 2025-08-05 10:45:54 +02:00
Lukas Wirth
6b09fbf881 fix: Consider all produced artifacts for proc-macro dylib search 2025-07-27 23:21:42 +02:00
Lukas Wirth
b398bc6af7 Cleanup unstable flags handling 2025-07-27 22:39:01 +02:00