429 Commits

Author SHA1 Message Date
Jesung Yang
7f6858fd09 feat: introduce crate_attrs field in rust-project.json
Since the commit 50384460c68f
("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
Lukas Wirth
df85aac1d4 Copy lockfile when building build scripts 2025-07-27 20:28:22 +02:00
Lukas Wirth
7950da3940 internal: Better type proc macro dylib build data state 2025-07-27 19:37:16 +02:00
Shoyu Vanilla
d5379d3103 Use TempDir for copied lockfiles 2025-07-23 23:39:46 +09:00
Shoyu Vanilla
d6bdcf2f08 Further decrease number of cargo metadata invokes 2025-07-15 22:49:16 +09:00
Shoyu Vanilla
8dad658bea chore: Cleanup cargo config queries 2025-07-15 22:49:16 +09:00
Lukas Wirth
4ee90e97f6 Improve flycheck and build script progress reporting 2025-07-04 11:52:09 +02:00
Lukas Wirth
4183bcdcde
Merge pull request #20148 from ShoyuVanilla/sysroot-no-deps
fix: Honor `rust-analyzer.cargo.noDeps` option when fetching sysroot metadata
2025-07-04 08:03:25 +00:00
Lukas Wirth
292ab7cf95
Merge pull request #20159 from Veykril/push-kyssnlrxlwsl
Always couple `--compile-time-deps` with
2025-07-03 11:03:36 +00:00
Lukas Wirth
2219f8e175 Always couple --compile-time-deps with
`--all-targets` coupled with `--compile-time-deps` will never actually build binaries and so it won't fail for targets where libtest is missing
2025-07-03 12:52:32 +02:00
Lukas Wirth
d1149cba49 fix: Do not warn about proc-macro srv when sysroot is missing 2025-07-03 11:51:31 +02:00
Lukas Wirth
e54759083a Restructure proc-macro loading erros, differentiate hard error property on kind 2025-07-03 09:28:53 +02:00
Shoyu Vanilla
224b84f843 fix: Honor rust-analyzer.cargo.noDeps option when fetching sysroot metadata 2025-07-03 00:16:05 +09:00
Lukas Wirth
f055cbce1a Do not append --compile-time-deps to overwritten build script commands 2025-06-29 09:07:55 +02:00
Laurențiu Nicola
c6633fa1f2
Merge pull request #20101 from ShoyuVanilla/comp-time-deps-sooner
minor: Decrease minimal toolchain version for `comp-time-deps` to `1.89.0`
2025-06-26 05:05:51 +00:00
Shoyu Vanilla
89a0a28d4f minor: Decrease minimal toolchain version for comp-time-deps by 0.1 2025-06-26 01:20:35 +09:00
Vincent Esche
3e6509f18b Unify formatting of progress messages 2025-06-25 16:41:08 +02:00
Lukas Wirth
aee96c7f17 Drop rustc workspace loading error, if we don't needs its sources 2025-06-25 12:09:54 +02:00
Lukas Wirth
b50d527931
Merge pull request #20036 from Veykril/push-yquvoyrxkksx
Do not default to 'static for trait object lifetimes
2025-06-24 06:59:54 +00:00
Lukas Wirth
2b05bd7d7e Do not default to 'static for trait object lifetimes
We lack trait object default lifetime elision, so `'static` can be wrong at times, confusing the user
2025-06-24 08:49:24 +02:00
Lukas Wirth
95dce2be51
Merge pull request #20062 from ChayimFriedman2/doctests
minor: Don't run doctests
2025-06-24 06:47:24 +00:00
Lukas Wirth
937cd5292e
Merge pull request #20072 from Veykril/push-sorvvvzskywv
fix: Respect `.cargo/config.toml` `build.target-dir`
2025-06-24 05:50:47 +00:00