Commit graph

302955 commits

Author SHA1 Message Date
Shoyu Vanilla (Flint)
2127c2df5d
Merge pull request #20586 from ChayimFriedman2/placeholder-ns
fix: Make sense of the mess that were (are) different kind of generics in the solver
2025-09-03 06:00:29 +00:00
Laurențiu Nicola
dfaff28ce1
Merge pull request #20587 from ChayimFriedman2/private-inherent
fix: Deduplicate methods in completion by function ID and not by name
2025-09-02 06:00:12 +00:00
Chayim Refael Friedman
dd75ad4369 Deduplicate methods in completion by function ID and not by name
Because duplicates can be found with traits. Worse, the inherent methods could be private, and we'll discover that only later. But even if they're not they're different methods, and its seems worthy to present them all to the user.
2025-09-02 08:16:36 +03:00
Chayim Refael Friedman
a324fe9569 Make sense of the mess that were (are) different kind of generics in the solver
To the extent possible.

Previously they were confused. Sometimes generic params were treated as `Param` and sometimes as `Placeholder`. A completely redundant (in the new solver) mapping of salsa::Id to ints to intern some info where we could just store it uninterned (not in Chalk though, for some weird reason).

Plus fix a cute bug in closure substitution that was caught by the assertions of Chalk but the next solver did not have such assertions. Do we need more assertions?
2025-09-02 06:39:32 +03:00
Chayim Refael Friedman
dada5f418d
Merge pull request #20579 from Elliot-Roberts/fix-double-target-option
fix: Avoid `--target` option being given twice to `rustc` when invoked through `cargo rustc` while fetching target data layout
2025-08-30 23:41:14 +00:00
Elliot Roberts
823101e089 Pass --target before -- for cargo rustc 2025-08-30 13:36:29 -07:00
Shoyu Vanilla (Flint)
fd996d0203
Merge pull request #20563 from ChayimFriedman2/ns-projection-dyn-auto-trait
fix: When mapping next-solver's `dyn` type, add `Self` (aka. bound var ^1.0) to auto traits' substitutions
2025-08-30 13:39:33 +00:00
David Barsky
9916ee3f94
Merge pull request #20569 from rust-lang/dependabot/cargo/tracing-subscriber-0.3.20
Bump tracing-subscriber from 0.3.19 to 0.3.20
2025-08-29 22:56:40 +00:00
dependabot[bot]
d396d2f797
Bump tracing-subscriber from 0.3.19 to 0.3.20
Bumps [tracing-subscriber](https://github.com/tokio-rs/tracing) from 0.3.19 to 0.3.20.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-subscriber-0.3.19...tracing-subscriber-0.3.20)

---
updated-dependencies:
- dependency-name: tracing-subscriber
  dependency-version: 0.3.20
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-29 20:55:43 +00:00
Lukas Wirth
37048a006a
Merge pull request #20560 from ChayimFriedman2/analysis-stats-improve
fix: Add progress bars to more places in analysis-stats
2025-08-29 07:30:59 +00:00
Chayim Refael Friedman
dce4f30104 When mapping next-solver's dyn type, add Self (aka. bound var ^1.0) to auto traits' substitutions
Chalk represents dyn types as a list of predicate, the self type should be there. The next solver represents them quite differently. The `Self` was forgotten for the auto trait case.
2025-08-28 23:53:55 +03:00
Chayim Refael Friedman
85d383f821
Merge pull request #20561 from ChayimFriedman2/no-table-for-you
minor: Don't require a full `InferenceTable` for `CastTy`
2025-08-28 16:38:39 +00:00
Chayim Refael Friedman
c36b75bdc8 Don't require a full InferenceTable for CastTy
A DB is enough.
2025-08-28 19:24:46 +03:00
Chayim Refael Friedman
0a5502208d Add progress bars to more places in analysis-stats
Namely, mir lowering, const eval and IDE things.
2025-08-28 18:54:46 +03:00
Chayim Refael Friedman
da33061e1c
Merge pull request #20553 from ChayimFriedman2/ns-highlight-attach
fix: Attach the db in one more place in highlighting
2025-08-27 22:40:07 +00:00
Chayim Refael Friedman
f31a378b0a Attach the db in one more place in highlighting 2025-08-28 01:25:09 +03:00
Laurențiu Nicola
54d36de91d
Merge pull request #20547 from ChayimFriedman2/highlight-related-unsafe-scope
fix: In highlight_related, when on an unsafe block, don't highlight unsafe operations of other unsafe blocks
2025-08-27 19:09:21 +00:00
Shoyu Vanilla (Flint)
035bed8b5c
Merge pull request #20527 from ChayimFriedman2/cache-next-solver
perf: Cache trait solving across queries in the same revision
2025-08-27 04:31:39 +00:00
Chayim Refael Friedman
28a248f4f3 In highlight_related, when on an unsafe block, don't highlight unsafe operations of other unsafe blocks 2025-08-26 21:46:04 +03:00
Laurențiu Nicola
ab5113a316
Merge pull request #20545 from ChayimFriedman2/ns-foreign
fix: Remove `SolverDefId::ForeignId`
2025-08-26 17:40:24 +00:00
Chayim Refael Friedman
83f22cc0f8 Remove SolverDefId::ForeignId
Replace it with normal `SolverDefId::TypeAliasId`.

The split caused a very funny bug where code was getting `TypeAliasId` where it expected `ForeignId`, because `TypeAliasId` had a `From` impl from `hir_def::TypeAliasId` and `ForeignId` had not, plus a careless `into()`.

I could've fixed this specific bug but opted to remove the split instead; currently, it just provides more room for bugs, as we don't have typed IDs for the solver anyway, and even when we'll have (hopefully), that doesn't seem like a very useful distinction, for example in hir-def foreign types are just `TypeAliasId` with some flags.

Constructing a test for this isn't trivial; the trivial test (creating a foreign type, even proving a trait bound for it) fails to fail before the change, probably because we don't use the new solver everywhere yet so we don't trigger this specific code path.
2025-08-26 19:33:46 +03:00
Shoyu Vanilla (Flint)
7375e2c961
Merge pull request #20399 from rust-lang/veykril/push-klrwvmzokqwu
Enable warning logs by default
2025-08-26 05:56:22 +00:00
Shoyu Vanilla (Flint)
36d8f4e954
Merge pull request #20534 from A4-Tacks/tog-macro-delim-semicolon
Fix ExprStmt delete semicolon for toggle_macro_delimiter
2025-08-26 05:55:08 +00:00
Shoyu Vanilla (Flint)
3b0352eaeb
Merge pull request #20509 from A4-Tacks/fix-move-guard-to-arm-indent
Fix indent for move_guard_to_arm_body
2025-08-26 05:52:06 +00:00
Shoyu Vanilla (Flint)
daeb54057f
Merge pull request #20520 from ChayimFriedman2/reborrow
feat: Add an option to remove reborrows from adjustment inlay hints
2025-08-26 05:48:34 +00:00
Shoyu Vanilla (Flint)
05a61993a2
Merge pull request #20537 from ChayimFriedman2/new-solver-normalize
fix: Normalize all types when finishing inference
2025-08-26 05:31:07 +00:00
Chayim Refael Friedman
69c25d1fec
Merge pull request #20423 from ShoyuVanilla/import-2024
Make import sorting order follow 2024 edition style
2025-08-25 19:19:31 +00:00
Chayim Refael Friedman
769f164179
Merge pull request #20528 from ShoyuVanilla/nightly-zscript
fix: Masquerade as nightly cargo when invoking flycheck with `-Zscript`
2025-08-25 19:12:47 +00:00
Chayim Refael Friedman
4b5bb18c57 Don't map Chalk's Normalize to next solver's NormalizesTo
`NormalizesTo` is a private predicate that should not be used outside the solver. For normalization, rustc uses `AliasRelate`, so replace with that.
2025-08-25 20:56:45 +03:00
Chayim Refael Friedman
aa49c0b8bb Normalize all types when finishing inference
The new solver does not eagerly normalize, but things after inference expect types to be normalized. rustc does the same.

Also, I'm afraid other things in r-a don't expect results of the solver to be unnormalized. We'll need to handle that.
2025-08-25 20:23:18 +03:00
Chayim Refael Friedman
a0aa1c1360 Cache trait solving across queries in the same revision
Caching trait solving can do a lot to speed. Unfortunately it also consume a huge amount of memory. Therefore, as part of the migration to the new solver Jack Huey disabled caching of trait solving (he made the query transparent).

The PR proposes a middle ground: do cache trait solving, but only for the same revision. This allows us to be safe because during a revision the inputs cannot change.

The result is hopefully much better performance to features that tend to do a bulk of trait solving, and also repeat the same query (e.g. inference then IDE features).

There is another limitation: results are only cached in the same thread, to remove the need for synchronization which will be expensive. More measurements are required to check whether it's better to use a synchronized global cache, or maybe stay with a thread-local cache but batch multiple feature requests (highlighting, inlay hints etc.) of the same file to the same thread.

Alongside the actual cache we store the revision, because we need to verify it (we can't eagerly clear caches when incrementing the revision), and also the address of the db to prevent multiple dbs from interleaving (this is mostly relevant in tests, although injected highlighting also uses a new db, therefore maybe it's better to move it to a separate thread).

This "games" analysis-stats to both be way faster and use way more memory; the former is because analysis-stats doesn't increment revisions, therefore all queries share the cache and hit ratio is way too good, the latter is because analysis-stats doesn't increment revisions and therefore the cache isn't cleared. Both are not representative of a typical IDE scenario.
2025-08-25 17:17:31 +03:00
A4-Tacks
56bc9c35b9
Fix ExprStmt delete semicolon for toggle_macro_delimiter 2025-08-25 16:45:12 +08:00
Shoyu Vanilla (Flint)
781e0268ee
Merge pull request #20529 from emmanuel-ferdman/master
Fix rust-analyzer-contributors reference
2025-08-24 15:23:18 +00:00
Emmanuel Ferdman
ca42d0775a
Fix rust-analyzer-contributors reference
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2025-08-24 08:04:00 -07:00
Shoyu Vanilla
5ddf6846d5 fix: Masquerade as nightly cargo when invoking flycheck with -Zscript 2025-08-24 23:17:23 +09:00
Shoyu Vanilla (Flint)
80f4a79023
Merge pull request #20523 from ChayimFriedman2/opaque-generics
fix: Fix opaque generics
2025-08-24 06:59:38 +00:00
Chayim Refael Friedman
31245cabec Fix opaque generics
The parent generics were incorrectly not considered for TAIT.

I'm not convinced we should follow rustc here, also there are items (opaques) with more than 1 parent (opaque -> fn/type alias -> impl/trait) and I'm not sure we properly account for that in all places, but for now I left it as-is.

Also fix a bug where lifetimes' indices were incorrect when there is a self param (they started from 0 instead of 1).
2025-08-24 08:49:40 +03:00
Chayim Refael Friedman
d50f0c72f9
Merge pull request #20507 from A4-Tacks/suggest-return-expr
Add ReturnExpr completion suggest
2025-08-24 00:46:49 +00:00
A4-Tacks
c92af4d232
Add ReturnExpr completion suggest 2025-08-24 08:26:25 +08:00
Chayim Refael Friedman
6de4860541
Merge pull request #20512 from A4-Tacks/arith-op-not-on-selected
replace_arith_op not applicable on selected
2025-08-24 00:17:09 +00:00
A4-Tacks
5e81912dae
replace_arith_op not applicable on selected 2025-08-24 07:57:50 +08:00
Chayim Refael Friedman
4715c6d41a Add an option to remove reborrows from adjustment inlay hints
Reborrows are consecutive deref then ref. Make it the default because reborrows are mostly useless to the programmer.

Also rename `rust-analyzer.inlayHints.expressionAdjustmentHints.enable: "reborrow"` to `rust-analyzer.inlayHints.expressionAdjustmentHints.enable: "borrows"`, as it's not about reborrows but about any ref/deref and it's confusing with the new setting.
2025-08-24 02:26:37 +03:00
Chayim Refael Friedman
086eeb0fb7
Merge pull request #20513 from A4-Tacks/let-in-let-chain
Add let in let-chain completion support
2025-08-23 22:17:27 +00:00
Chayim Refael Friedman
4b077a9f49
Merge pull request #20518 from A4-Tacks/fix-else-in-in-let
Fix `else` completion in `let _ = if x {} $0`
2025-08-23 22:07:13 +00:00
Chayim Refael Friedman
a9973f6398
Merge pull request #20511 from A4-Tacks/fix-conv-int-lit-on-selected
convert_integer_literal not on selected
2025-08-23 22:03:17 +00:00
A4-Tacks
183fbdc89b
Fix else completion in let _ = if x {} $0 2025-08-23 17:48:30 +08:00
A4-Tacks
c9fbcdcfcd
Add let in let-chain completion support
Example
---
```rust
fn f() {
    if true && $0 {}
}
```
->
```rust
fn f() {
    if true && let $1 = $0 {}
}
```
2025-08-22 21:58:49 +08:00
A4-Tacks
3868f8ad5c
fix: convert_integer_literal not on selected
`convert_integer_literal` can only convert the first literal,
it is not reasonable to apply it when selected

Example
---

```rust
fn main() {
    $01+1$0;
}
```

**Assist old outputs**:

```
Convert 1 to 0b1
Convert 1 to 0o1
Convert 1 to 0x1
Replace arithmetic with call to checked_*
Replace arithmetic with call to saturating_*
Replace arithmetic with call to wrapping_*
Extract into variable
Extract into constant
Extract into static
Extract into function
```

**Assist this PR outputs**:

```
Replace arithmetic with call to checked_*
Replace arithmetic with call to saturating_*
Replace arithmetic with call to wrapping_*
Extract into variable
Extract into constant
Extract into static
Extract into function
```
2025-08-22 17:13:30 +08:00
Shoyu Vanilla (Flint)
cf358c09ce
Merge pull request #20506 from Veykril/veykril/push-xlytslrrylzq
Fix panic in syntax_highlighting
2025-08-22 08:14:02 +00:00
Lukas Wirth
cf478a02c7 Fix panic in syntax_highlighting 2025-08-22 09:00:25 +02:00