122 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
Chayim Refael Friedman
71b3bca7a1 Support the new lowering of format_args!() 2025-12-10 19:20:48 +02: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
Shoyu Vanilla (Flint)
3f76561803
Merge pull request #20967 from A4-Tacks/replace-eager-lazy-and-then
Fix not applicable on `and` for replace_method_eager_lazy
2025-11-24 01:49:11 +00:00
Aditya-PS-05
f39579c04e update minicore 2025-11-21 19:05:36 +05:30
Chayim Refael Friedman
50384460c6 Rewrite method resolution to follow rustc more closely
It cannot be exactly the same, because we have needs rustc doesn't have (namely, accurate enumeration of all methods, not just with a specific name, for completions etc., while rustc also needs a best-effort implementation for diagnostics) but it is closer than the previous impl.

In addition we rewrite the closely related handling of operator inference and impl collection.

This in turn necessitate changing some other parts of inference in order to retain behavior. As a result, the behavior more closely matches rustc and is also more correct.

This fixes 2 type mismatches on self (1 remains) and 4 diagnostics (1 remains), plus some unknown types.
2025-11-05 18:43:36 +02:00
A4-Tacks
93baf96f25
Fix not applicable on and for replace_method_eager_lazy
Supports:

- and <-> and_then
- then_some <-> then

Example
---
```rust
fn foo() {
    let foo = Some("foo");
    return foo.and$0(Some("bar"));
}
```

**Before this PR**

Assist not applicable

**After this PR**

```rust
fn foo() {
    let foo = Some("foo");
    return foo.and_then(|| Some("bar"));
}
```
2025-11-04 16:42:19 +08:00
Chayim Refael Friedman
81e621af0b Improve fixture support
Support more features beside highlighting, and support items from minicore.
2025-10-16 22:06:16 +03:00
Chayim Refael Friedman
7d1860807e Port a bunch of stuff from rustc and fix a bunch of type mismatches/diagnostics
This started from porting coercion, but ended with porting much more.
2025-09-15 18:56:17 +03:00
Chayim Refael Friedman
40487c6a60 Add regression tests to some S-blocked-on-new-solver issues
That were fixed by the migration.
2025-09-15 08:25:17 +03: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
Lukas Wirth
a9450ebba3
Merge pull request #20329 from jackh726/next-trait-solver-querify
Switch from Chalk to the next trait solver
2025-08-13 06:10:45 +00:00
jackh726
9418a3f2df Implement next trait solver 2025-08-09 16:08:58 +00:00
A4-Tacks
d5afd99903
Add write! and writeln! to minicore 2025-08-09 00:09:56 +08:00
bors
f2840cd6c8 Auto merge of #144114 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2025-07-18 08:44:14 +00:00
Deadbeef
8444e5bc09 parse const trait Trait 2025-07-17 18:06:26 +08:00
A4-Tacks
6598a38174
Add AsMut to minicore prelude::v1 2025-07-16 21:27:39 +08:00
Lukas Wirth
2691c11104
Merge pull request #20132 from A4-Tacks/asmut-borrow-minicore
Add AsMut, Borrow and BorrowMut to minicore and famous_defs
2025-07-06 08:01:54 +00:00
A4-Tacks
439f2d24cd
Fix Borrow and BorrowMut define from beta std 2025-07-05 21:49:56 +08:00
Chayim Refael Friedman
9c4a7705b1 Fix some things with builtin derives
1. Err on unions on derive where it's required.
 2. Err on `#[derive(Default)]` on enums without `#[default]` variant.
 3. Don't add where bounds `T: Default` when expanding `Default` on enums (structs need that, enums not).

Also, because I was annoyed by that, in minicore, add a way to filter on multiple flags in the line-filter (`// :`). This is required for the `Debug` and `Hash` derives, because the derive should be in the prelude but the trait not.
2025-07-03 23:05:56 +03:00
A4-Tacks
edcfa4afa1
Fix AsMut::as_mut name 2025-07-02 21:55:55 +08:00
A4-Tacks
cb000ad313
Add AsMut Borrow BorrowMut to minicore and famous_defs 2025-07-01 15:26:45 +08:00
Chayim Refael Friedman
a6c1fa01d9
Merge pull request #20100 from ShoyuVanilla/ignore-sized-hierarchy
Backport new sized-hierarchy trait bounds in old ways
2025-06-26 20:37:18 +00:00
Shoyu Vanilla
953e9d1c36 Backport new sized-hierarchy trait bounds in old ways 2025-06-26 23:22:26 +09:00
Lukas Wirth
5924b38e3d Parse new const trait syntax 2025-06-26 11:08:30 +02:00
Lukas Wirth
d3e6dcd3ca Adjust minicore for Sized Hierarchy changes 2025-06-25 21:51:51 +09:00
Chayim Refael Friedman
de312d0c71 Don't run doctests 2025-06-23 00:50:22 +03:00
Shoyu Vanilla
4f8767d790 Minic rustc's new format_args! expansion 2025-06-22 13:22:28 +09:00
Shoyu Vanilla
c13859903c Implement region negation to minicore and add a flag fmt_before_1_89_0 2025-06-22 12:01:19 +09:00
Lukas Wirth
1c68d83569
Merge pull request #19657 from ChayimFriedman2/better-offset-of
feat: Better support `offset_of!()`
2025-04-22 13:28:34 +00:00
Chayim Refael Friedman
7b8200ba8d The new diagnostic has found a bug lurking in minicore
It's cute, isn't it?
2025-04-22 14:55:43 +03:00
Chayim Refael Friedman
8d824c7828 Resolve offset_of!() in IDE 2025-04-22 00:33:06 +03:00
Lukas Wirth
500ea05aef chore: Bump dependencies 2025-03-23 08:46:10 +01:00
Lukas Wirth
d4122434dd chore: Remove unused dependencies 2025-03-23 08:08:17 +01:00
Lukas Wirth
a505420751 chore: Bump Edition::CURRENT to 2024 2025-03-17 12:29:19 +01:00
Thalia Archibald
0811ca0a61 Use size_of from the prelude instead of imported
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the
prelude instead of importing or qualifying them.

These functions were added to all preludes in Rust 1.80.
2025-03-05 00:48:44 -08:00
Thalia Archibald
0aa623e108 minicore: Add size_of to prelude and add rust_2024 prelude 2025-03-05 00:30:38 -08:00
Lukas Wirth
716e9fdb8d Fix test_keyword_highlighting test 2025-03-01 18:29:47 +01:00
BenjaminBrienen
b19ef6b046 fix doc tests 2025-02-27 14:58:46 +01:00
BenjaminBrienen
bd7375a58f enable doctest 2025-02-27 14:58:46 +01:00
Giga Bowser
b4f2d62952 internal: Improve reporting of intersecting changes 2025-02-25 11:46:45 -05:00
Lukas Wirth
09db657439
Merge pull request #19127 from ChayimFriedman2/different-generic-args
feat: Refactor path lowering and serve a new path diagnostic
2025-02-17 08:30:10 +00:00
Chayim Refael Friedman
55c04ab371 Refactor path lowering
And add a new diagnostic for non-`Fn` parenthesized generic args.

Path lowering started to look like a mess, with each function carrying additional parameters for the diagnostic callback (since paths can occur both in type and in expression/pattern position, and their diagnostic handling is different) and the segment index, for the diagnostics report. So I refactored it from stateless functions on `TyLoweringContext` into stateful struct, `PathLoweringContext`, that tracks the process of lowering a path from resolution til assoc types selection.
2025-02-16 19:44:50 +02:00
jyn
66253b6553 fix target dir test 2025-02-09 16:34:01 -05:00
Shoyu Vanilla
f4dfbc38c8 feat: Implement arbitrary-self-types 2025-01-24 22:50:59 +09:00
Lukas Wirth
b2f822b074
Merge pull request #18934 from 1hakusai1/goto_definition_from_into
feat: Add the ability to jump from `into` to `from` definitions
2025-01-20 13:46:47 +00:00
Chayim Refael Friedman
cec9fa1606 Add smart completions that skip await or iter() and into_iter()
E.g. complete `await.foo()`.
2025-01-15 22:32:07 +02:00
1hakusai1
b6d63615d2 Fix wrong fixture 2025-01-15 21:28:37 +09:00
1hakusai1
dc075fd692 Add test cases 2025-01-15 20:43:28 +09:00
Lukas Wirth
bf669dab84 Re-implement rust string highlighting via tool attribute 2025-01-10 13:49:35 +01:00