Commit graph

20064 commits

Author SHA1 Message Date
Laurențiu Nicola
c88fb5036a
Merge pull request #20652 from ChayimFriedman2/cli-diags
internal: Improve `rust-analyzer diagnostics`
2025-09-15 05:42:46 +00:00
Shoyu Vanilla (Flint)
03e383098b
Merge pull request #20665 from ChayimFriedman2/error-notable
fix: Don't mark unknown type as implementing every notable trait
2025-09-15 05:39:17 +00:00
Chayim Refael Friedman
91f32ed180 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
55b8d4e6ff Don't mark unknown type as implementing every notable trait
Because the new solver, will return "yes" for them (which is a good thing).
2025-09-15 07:57:19 +03:00
Chayim Refael Friedman
5025bfa146 Improve rust-analyzer diagnostics
In my experience the `processing <module>` messages make it harder to search for the actual diagnostics, so remove them and instead print the filename only if there is a diagnostic.

Also allow choosing the minimum severity.
2025-09-14 23:22:57 +03:00
Chayim Refael Friedman
d6d3c4b2ea
Merge pull request #20654 from ShoyuVanilla/predicates
fix: Infinite loop while elaborting predicates
2025-09-14 11:20:04 +00:00
Shoyu Vanilla
9f850ceb33 fix: Infinite loop while elaborting predicates 2025-09-14 20:08:40 +09:00
Shoyu Vanilla (Flint)
c2e1012fd8
Merge pull request #20635 from iorizu/fix-double-flycheck
fix: Don't trigger two flychecks when saving files that are part of targets
2025-09-14 09:11:30 +00:00
A4-Tacks
8a574ca862
Fix extra semicolon before else in let-stmt
Example
---
```rust
fn main() {
    let x = if true {
        ()
    } $0 else {};
}
```

**Before this PR**:

```rust
fn main() {
    let x = if true {
        ()
    } else if $1 {
        $0
    }; else {};
}
```

**After this PR**:

```rust
fn main() {
    let x = if true {
        ()
    } else if $1 {
        $0
    } else {};
}
```
2025-09-12 20:56:59 +08:00
Ifeanyi Orizu
68217c79b2 Minor refactoring 2025-09-11 10:38:34 -05:00
Shoyu Vanilla (Flint)
fa2f5f9efa
Merge pull request #20642 from ChayimFriedman2/wasm-safe
fix: Make `#[target_feature]` always safe on WASM
2025-09-11 05:09:26 +00:00
Laurențiu Nicola
7f38c057dc
Merge pull request #20653 from A4-Tacks/gen-function-empty-gen-param
Fix empty generic param list for generate_function
2025-09-11 05:08:00 +00:00
A4-Tacks
2d87bc3e6b
Fix empty generic param list for generate_function
Example
---
```rust
struct Foo<S>(S);
impl<S> Foo<S> {
    fn foo(&self) {
        self.bar()$0;
    }
}
```

**Before this PR**:

```rust
struct Foo<S>(S);
impl<S> Foo<S> {
    fn foo(&self) {
        self.bar();
    }

    fn bar<>(&self) ${0:-> _} {
        todo!()
    }
}
```

**After this PR**:

```rust
struct Foo<S>(S);
impl<S> Foo<S> {
    fn foo(&self) {
        self.bar();
    }

    fn bar(&self) ${0:-> _} {
        todo!()
    }
}
```
2025-09-11 10:23:02 +08:00
Shoyu Vanilla (Flint)
1800ec1931
Merge pull request #20649 from ChayimFriedman2/cast-unknown
fix: Always coerce in a cast, even when there are unknown types
2025-09-10 02:27:53 +00:00
Chayim Refael Friedman
b2b33f9faa Always coerce in a cast, even when there are unknown types
This cause the relationships between inference vars to get recorded.
2025-09-10 04:57:10 +03:00
Shoyu Vanilla (Flint)
84097a17bf
Merge pull request #20645 from ChayimFriedman2/update-rustc
internal: Upgrade rustc crates
2025-09-10 01:45:46 +00:00
Shoyu Vanilla (Flint)
98d863c8b1
Merge pull request #20647 from ChayimFriedman2/ns-projections
fix: Fix normalization in the new solver
2025-09-10 01:32:49 +00:00
Chayim Refael Friedman
4a4b77f1c7 Properly handle normalization
Previously normalization was broken, which caused a lot of fake errors.

This fix most type mismatches of the new solver, and it also reverts many test regressions.

The downside is that now `chalk_ir::TyKind::AssociatedType`/`chalk_ir::TyKind::Alias` cannot be trusted anymore with their roles, namely: `AssociatedType` is always fully normalized and `Alias` only if it can possibly be normalized further. That seems okay as the new solver does not have this distinction at all (due to it being a lazy normalizer), so this will only hold for the migration time. This does mean we have to change some APIs, notably `hir::Type::walk()` and `TyFingerprint`, to treat `Alias` the same as `AssociatedType`.

Another small thing this commit does is to isolate processing of user-written types (currently involving replacing error types and normalizing, but in the future validation will also be needed) to separate functions.
2025-09-10 03:32:06 +03:00
Chayim Refael Friedman
1acb4c2c16 An associated type is not a projection!
More correctly, a `TyKind::AssociatedType` is not the same as `TyKind::Projection`.

We used to map next-solver `TyKind::Alias` to Chalk's `TyKind::AssociatedType`. This is very incorrect, as `AssociatedType` is assumed to be fully normalized, and caused a lot of type mismatches.

Unfortunately fixing this causes a lot of stack overflows, because the next solver doesn't have something akin to `AssociatedType` so we normalize again and again. The reason is that is the lazy-normalization nature of the next solver, which means we need to stop normalizing everything. This will be fixed in the next commit.
2025-09-10 00:53:15 +03:00
Chayim Refael Friedman
8407376006 Adopt even more custom types in the new solver
A lot of simplification and fun.
2025-09-10 00:48:33 +03:00
Chayim Refael Friedman
ce2f518b53 Upgrade rustc crates and handle changes to canonicalization
They have to do with diagnostics, we could probably not support them but we will also someday want good diagnostics.

The code is mostly copied from rustc.
2025-09-10 00:48:33 +03:00
David Barsky
8764ecfe99
Merge pull request #20613 from A4-Tacks/diag-unresolved-field-fixes-ws
Fix indent for unresolved_field fixes
2025-09-09 18:49:52 +00:00
David Barsky
54c8cd51a1
Merge pull request #20639 from ChayimFriedman2/update-test-abs
fix: Resolve paths to snapshot test libraries absolutely
2025-09-09 17:16:50 +00:00
Shoyu Vanilla
69140ec44c Fix failing tests and fill-in missing details 2025-09-10 01:43:22 +09:00
jackh726
0fad52401e WIP switch inference table to next-solver 2025-09-09 22:45:14 +09:00
Chayim Refael Friedman
d6638e9bd2 Make #[target_feature] safe always on WASM
Even when the feature isn't enabled, as it's not UB to invoke an undefined feature in WASM (just a trap).
2025-09-09 13:49:11 +03:00
Chayim Refael Friedman
74a8f7451e 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
Chayim Refael Friedman
a69ac55399 Resolve paths to snapshot test libraries absolutely
That is, resolve them globally, not from the test's location.

This *should* result in more robust resolution; for example, previously the code failed to detect the presence of snapshot testing if the snapshot library was renamed in the dependency or was an indirect dependency.
2025-09-09 10:38:20 +03:00
Chayim Refael Friedman
d09f3d85a5
Merge pull request #20624 from A4-Tacks/fix-syn-lifetime-bounds
Fix LifetimeParam::lifetime_bounds invalid implement
2025-09-09 07:35:19 +00:00
A4-Tacks
2079d1126b
Fix LifetimeParam::lifetime_bounds invalid implement
Lifetime node example:

```
LIFETIME_PARAM@15..21
  LIFETIME@15..17
    LIFETIME_IDENT@15..17 "'a"
  COLON@17..18 ":"
  WHITESPACE@18..19 " "
  TYPE_BOUND_LIST@19..21
    TYPE_BOUND@19..21
      LIFETIME@19..21
        LIFETIME_IDENT@19..21 "'b"
```
2025-09-09 15:22:12 +08:00
Jakub Beránek
a1a1ed25f2
Add a FAQ entry about RA and Cargo interaction 2025-09-09 09:12:09 +02:00
Jakub Beránek
e8206d0b88
Update documentation about how to build the RA book 2025-09-09 08:37:02 +02:00
Ifeanyi Orizu
17943cc47a Skip flycheck for workspace if it is already being checked 2025-09-08 16:13:42 -05:00
Chayim Refael Friedman
152c0d6686
Merge pull request #20632 from rmehri01/navigation-on-prims
feat: support navigation on primitives
2025-09-08 20:12:04 +00:00
Ryan Mehri
2ffa8510a7 make TryToNav take Semantics instead of RootDatabase 2025-09-08 15:59:46 -04:00
Ryan Mehri
fc4450b1f1 add test 2025-09-08 14:33:25 -04:00
Ryan Mehri
a6a53ace86 impl TryToNav for BuiltinType instead 2025-09-08 14:23:52 -04:00
Chayim Refael Friedman
1e1886ac60
Merge pull request #20633 from Wilfred/improve_intro
Clarify intro in README and manual
2025-09-08 18:21:54 +00:00
Wilfred Hughes
224428d8fd Clarify intro in README and manual
The first sentence a new user should see should ideally answer the
questions:

* What is rust-analyzer?
* Why might I want to use it?

The vast majority of users will be interested in using rust-analyzer
inside their favourite editor. We should clarify that rust-analyzer is
an LSP implementation and that it supports all the classic IDE
features.

Whilst it's also true that rust-analyzer is modular and organised into
libraries, the first impression should (I think) focus on an overview
and the primary use case.
2025-09-08 19:10:14 +01:00
Ryan Mehri
bb5b153b7b feat: support navigation on primitives 2025-09-08 11:16:11 -04:00
Wilfred Hughes
a21866a563 Remove support for register_attr
This was removed in rustc in 2022: https://github.com/rust-lang/rust/pull/101123

Closes #20525.
2025-09-08 15:56:56 +01:00
Laurențiu Nicola
c9e5e40c4e
Merge pull request #20620 from A4-Tacks/let-else-completion
fix: add `else` keyword completion after `let` statements
2025-09-08 06:03:00 +00:00
Laurențiu Nicola
1fa24ce6e0
Merge pull request #20626 from A4-Tacks/make-record-ws
Improve make::struct_ field_list whitespace
2025-09-08 05:52:57 +00:00
A4-Tacks
6da8094b13
Improve make::struct_ field_list whitespace
Example
---
**Before this PR**:

```rust
struct Variant{
    field: u32
}
```

**After this PR**:

```rust
struct Variant {
    field: u32
}
```
2025-09-07 22:19:52 +08:00
A4-Tacks
a5bb60b19c
Add allow else keyword completion in LetStmt
Example
---
```rust
fn foo() {
    let _ = 2 el$0
}
```
->
```rust
fn foo() {
    let _ = 2 else {
        $0
    };
}
```
2025-09-06 13:09:07 +08:00
A4-Tacks
b9b235acb0
Fix indent for unresolved_field fixes
Examples
---
```rust
mod indent {
    struct Foo {}

    fn foo() {
        let foo = Foo{};
        foo.bar$0;
    }
}
```

**Before this PR**:

```rust
mod indent {
    struct Foo {        bar: ()
}

    fn foo() {
        let foo = Foo{};
        foo.bar;
    }
}
```

**After this PR**:

```rust
mod indent {
    struct Foo {
        bar: ()
    }

    fn foo() {
        let foo = Foo{};
        foo.bar;
    }
}
```

---
New field list add newline

```rust
mod indent {
    struct Foo;

    fn foo() {
        Foo.bar$0;
    }
}
```

**Before this PR**:

```rust
mod indent {
    struct Foo{ bar: () }

    fn foo() {
        Foo.bar;
    }
}
```

**After this PR**:

```rust
mod indent {
    struct Foo {
        bar: (),
    }

    fn foo() {
        Foo.bar;
    }
}
```
2025-09-05 15:57:51 +08:00
Shoyu Vanilla (Flint)
3b7313b4d4
Merge pull request #20609 from ChayimFriedman2/update-rustc
internal: Upgrade rustc crates
2025-09-05 03:18:14 +00:00
Chayim Refael Friedman
7ff5a3d277 Upgrade rustc crates
The main changes are (there are some other small changes):

 - Using a specific type for trait IDs in the new solver, allowing us to simplify a lot of code.
 - Add `BoundConst` similar to `BoundTy` and `BoundRegion` (previously consts used `BoundVar` directly), due to a new trait requirement.
2025-09-04 22:36:31 +03:00
Chayim Refael Friedman
a5872e98f8
Merge pull request #20607 from ChayimFriedman2/ns-dyn-mismatch
internal: Add a regression test for a fixed new trait solver bug
2025-09-04 09:34:45 +00:00
Chayim Refael Friedman
d5cb7e7c7c Add a regression test for a fixed new trait solver bug
Not sure what exactly fixed it, but why not.
2025-09-04 12:18:22 +03:00