Skip to content

rust-analyzer subtree update - #166381

Merged
rust-bors[bot] merged 60 commits into
rust-lang:mainfrom
lnicola:sync-from-ra
Nov 23, 2026
Merged

rust-bors[bot] merged 60 commits into
rust-lang:mainfrom
lnicola:sync-from-ra

Conversation

@lnicola

@lnicola lnicola commented Nov 23, 2026

Copy link
Copy Markdown
Member

A4-Tacks and others added 30 commits October 22, 2026 17:41
Example
---
**Before this PR**

```rust
use itertools::Itertools;
fn main() {
    [1, 2, 3].into_iter() // <- IntoIter<i32, 3>
        .merge_by([2, 4, 6], |a,b|a<b) // <- MergeBy<IntoIter<i32, 3>, IntoIter<i32, 3>, impl FnMut(&i32, &i32) -> bool>
        .next();
}
```

**After this PR**

```rust
use itertools::Itertools;
fn main() {
    [1, 2, 3].into_iter() // <- IntoIter<i32, 3>
        .merge_by([2, 4, 6], |a,b|a<b) // <- impl Iterator<Item = i32>
        .next();
}
```
This is the stored variant of Term, just like StoredGenericArg is the
stored variant of GenericArg.
This is heavily inspired from hir_def::hir::ExprOrPatId and its packed
variant, to wrap either a TypeRefId or a ConstRef.
This replaces InferenceResult::type_of_type_placeholder with
term_of_term_placeholder to additionally record which const a given
const or type placeholder gets resolved to.

Note that while surprising, TypeRef::Placeholder may indeed resolve to
a const because, except for arrays, the parser doesn't know ahead of
time if a _ will resolve to a type or a const.

In the case of an array, we have an Expr::Underscore:
```
let a: [_; _] = [4, 5, 6];
      //^ TypeRef::Placeholder which resolves to the type i32
         //^ Expr::Underscore which resolves to the const 3
```

But for a struct we have a TypeRef::Placeholder:
```
struct S<T, const N: usize>([T; N]);

let s: S<_, _> = S([1, 2, 3]);
       //^ TypeRef::Placeholder which resolves to the type i32
          //^ TypeRef::Placeholder which resolves to the const 3
```
This fixes SourceAnalyzer::type_of_type to replace const infer vars in
types with their resolved value.
add tests for `Pool` and fix ordering issue
Signed-off-by: hashcatHitman <[email protected]>
Signed-off-by: hashcatHitman <[email protected]>
Signed-off-by: hashcatHitman <[email protected]>
Example
---
**Before this PR**
```text
Roots Scanned 15/16: /home/user/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std 93%
```

**After this PR**

```text
Roots Scanned 15/16: library/std 93%
```
minor: short too long roots scanned std path
Previously, r-a didn't implement well-formedness (WF) checks on any types,
treating them all as ambiguous.

Unfortunately, we try to resolve obligations after essentially every
expression:

https://github.com/rust-lang/rust-analyzer/blob/ff7105dd728897503481c79727cd6ead881d80a6/crates/hir-ty/src/infer/expr.rs#L867

and when we resolve obligations, we collect all obligations and then
re-register ambiguous ones:

https://github.com/rust-lang/rust-analyzer/blob/ff7105dd728897503481c79727cd6ead881d80a6/crates/hir-ty/src/next_solver/fulfill.rs#L213

So given N expressions containing closures, we end up doing O(N^2)
work (1 obligation after the first expression, 2 obligations after the
second expression, etc).

Instead, treat all types as well-formed. This also allows
normalisation to work in more scenarios, hence one unit test now
showing a concrete type instead of `impl Trait`.

For reference, the WF implementation in rustc is here:

https://github.com/rust-lang/rust/blob/58cf8f9c35b355199727627d07ae34a4e2846d67/compiler/rustc_trait_selection/src/solve/delegate.rs#L338-L352

https://github.com/rust-lang/rust/blob/58cf8f9c35b355199727627d07ae34a4e2846d67/compiler/rustc_trait_selection/src/traits/wf.rs#L93-L125

AI disclosure: Initial investigation and implementation with an LLM,
but final implementation and review by me. Comments are written by me
or copied from rustc verbatim.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. labels Nov 23, 2026
@lnicola

lnicola commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

@bors r+ p=1 rollup=always

@rust-bors

rust-bors Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 6600391 has been tentatively approved by lnicola

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 23, 2026
@rust-bors

rust-bors Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

❌ Commit 6600391 has been unapproved because PR CI timed out after 7200s.

@JonathanBrouwer

Copy link
Copy Markdown
Member

Tools passed
@bors r=lnicola force

@rust-bors

rust-bors Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 6600391 has been approved by lnicola

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 23, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 23, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 23, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 23, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 23, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #164918 (Move lint validation to attribute parsing)
 - #166381 (`rust-analyzer` subtree update)
 - #166191 (Enable static-pie on all Musl targets)
 - #166250 (Add a reason suggestion for malformed lint attributes)
 - #166365 (Drop references to codebuild)

Failed merges:

 - #166374 (Undo accidental duplication checking for attributes on macro calls)
rust-bors Bot pushed a commit that referenced this pull request Nov 23, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #164918 (Move lint validation to attribute parsing)
 - #166381 (`rust-analyzer` subtree update)
 - #166191 (Enable static-pie on all Musl targets)
 - #166390 (Turn `gca` into a macro 2.0 that expands to `k#gca(..)`)
 - #165764 (view-types: handle field accesses)
 - #166250 (Add a reason suggestion for malformed lint attributes)

Failed merges:

 - #166374 (Undo accidental duplication checking for attributes on macro calls)
@rust-bors
rust-bors Bot merged commit b8e0835 into rust-lang:main Nov 23, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 23, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 23, 2026
Rollup merge of #166381 - lnicola:sync-from-ra, r=lnicola

`rust-analyzer` subtree update

Subtree update of `rust-analyzer` to rust-lang/rust-analyzer@3c62857.

Created using https://github.com/rust-lang/josh-sync.

r? @ghost
@lnicola
lnicola deleted the sync-from-ra branch November 23, 2026 18:31
@rust-timer

Copy link
Copy Markdown

Note

This PR was benchmarked as part of triage of its containing rollup: triage URL.

Finished benchmarking commit (6a86cae): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were not yet notified of this PR).

@rustbot label: +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.8% [-1.2%, -0.1%] 9
All ❌✅ (primary) - - 0

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

Results (secondary 3.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
6.6% [4.9%, 8.7%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.0% [-4.6%, -3.4%] 2
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Artifact size: 406.40 MiB -> 405.74 MiB (-0.16%)

@rustbot rustbot added the perf-regression Performance regression. label Nov 24, 2026
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Nov 26, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#164918 (Move lint validation to attribute parsing)
 - rust-lang/rust#166381 (`rust-analyzer` subtree update)
 - rust-lang/rust#166191 (Enable static-pie on all Musl targets)
 - rust-lang/rust#166390 (Turn `gca` into a macro 2.0 that expands to `k#gca(..)`)
 - rust-lang/rust#165764 (view-types: handle field accesses)
 - rust-lang/rust#166250 (Add a reason suggestion for malformed lint attributes)

Failed merges:

 - rust-lang/rust#166374 (Undo accidental duplication checking for attributes on macro calls)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.