Skip to content

Rollup of 6 pull requests#153988

Closed
Zalathar wants to merge 13 commits intorust-lang:mainfrom
Zalathar:rollup-JXPkvPW
Closed

Rollup of 6 pull requests#153988
Zalathar wants to merge 13 commits intorust-lang:mainfrom
Zalathar:rollup-JXPkvPW

Conversation

@Zalathar
Copy link
Member

Successful merges:

Failed merges:

r? @ghost

Create a similar rollup

homersimpsons and others added 13 commits March 13, 2026 17:30
…the pattern of a let binding

Consts and unit structs in patterns can be confusing if they are mistaken for new bindings. We already provide some context for unit structs and consts that come from the current crate, we now also point at those from foreign crates, and we properly skip cases where the pattern has type parameters which can't be confused with a new binding. Make new binding suggestion verbose.
variances_of currently used search_for_cycle_permutation, which can fail and abort when constructed error result value does not match query input.
This commit changes variances_of to receive a def_id which means it can compute a value without using search_for_cycle_permutation, avoiding the possible abort.

Fixes rust-lang#127971
…names, r=mati865

suggest valid features when target feature is invalid

I run into this quite frequently, where I remember some part of a feature name but not the exact name. Now this emits suggestions like

```
error: the feature named `+avx512` is not valid for this target
  --> $DIR/invalid-attribute.rs:127:18
   |
LL | #[target_feature(enable = "+avx512")]
   |                  ^^^^^^^^^^^^^^^^^^ `+avx512` is not valid for this target
   |
   = help: valid names are: `avx512f`, `avx2`, `avx512bw`, `avx512cd`, and `avx512dq` and 74 more
```
…alueFormat-x86_64-gnu, r=marcoieni

Fix LegacyKeyValueFormat report from docker build: x86_64-gnu

Part of rust-lang#152305

r? @marcoieni
…up, r=nnethercote

Fix hypothetical ICE in `variances_of`

A cleanup based on rust-lang#153694.

~~This PR changes panic messages in `fn_sig`'s `value_from_cycle_error` to more fitting ones.~~ Also this PR makes `variances_of`'s `value_from_cycle_error` to utilize new query key argument instead of extracting it from `CycleError`.

Closes rust-lang#127971

r? @nnethercote
…xyUwU

Don't look for non-type-level assoc consts when checking trait object types

On main, when looking for assoc items that weren't specified in a given trait object type (via binding), we comb through all (eligible) assoc consts whether type-level or not even though you're not allowed to bind non-type-level assoc consts.

That's usually fine because traits containing (eligible) non-type-level assoc consts are dyn incompatible, so the trait object type is ~already considered ill-formed. Therefore, in PR rust-lang#150843, I saved myself the extra effort, esp. since back then it was more annoying to check if the const item was declared type-level.

<sub>(More concretely: In bodies, we check for all dyn compatibility violations when lowering the trait object type, so we will bail out early with an error; in contrast, item signatures / non-bodies get wfchecked (`WellFormed` obligation) after lowering which includes dyn compatiblity checking (`DynCompatible` obligation); however to reduce the amount of diags, during lowering if there are any unspecified assoc items, we'll check them for dyn compatibility and bail out early if any of them tests negative.)</sub>

Now, we obviously don't wfcheck the defsite of (eager) type aliases which breaks the assumption that such trait object types get rejected. This led to the regression found in rust-lang#153731: The ill-formed trait object type doesn't get rejected (as is expected) but we now require the single (non-type-level) assoc const to be bound in the dyn-Trait which we didn't do before. The actual error talks about dyn incompatibility due to the aforementioned extra check that's usually there to contain the number of diags.

Fixes [after beta backport] rust-lang#153731.
Point at unit structs on foreign crates in type errors when they are the pattern of a binding

Consts and unit structs in patterns can be confusing if they are mistaken for new bindings. We already provide some context for unit structs and consts that come from the current crate, we now also point at those from foreign crates, and we properly skip cases where the pattern has type parameters which can't be confused with a new binding. So not suggest making a new binding when other suggestions are already emitted, as the likelihood of the other suggestions being what the user intended is higher. Make new binding suggestion verbose.

Fix rust-lang#129792.

```
error[E0308]: mismatched types
 --> fi.rs:8:9
  |
1 | struct percentage;
  | ----------------- unit struct defined here
...
8 |     let percentage = 4i32;
  |         ^^^^^^^^^^   ---- this expression has type `i32`
  |         |
  |         expected `i32`, found `percentage`
  |         `percentage` is interpreted as a unit struct, not a new binding
help: introduce a new binding instead
  |
8 -     let percentage = 4i32;
8 +     let other_percentage = 4i32;
  |
```
…nstraint-suggestion, r=estebank

Suppress self-referential associated type constraint suggestion

Fixes rust-lang#112104

When comparing `Option<&I::Item>` against `Option<I::Item>`, the compiler decomposes the mismatch into `expected = &<I as Iterator>::Item` vs `found = <I as Iterator>::Item`. ARM 2 in `note_and_explain_type_err` matches because `found` is a projection, and would suggest `Item = &<I as Iterator>::Item` — constraining the associated type to something that contains itself.

ARM 1 (`expected_projection`) already guards against this with `found.contains(expected)`. ARM 2 was missing the symmetric check. This adds `expected.contains(found)` to the match guard.

Before:
```rust
help: consider constraining the associated type `<I as Iterator>::Item` to `&<I as Iterator>::Item`
  |
1 | fn foo<I: Iterator<Item = &<I as Iterator>::Item>>(iter: &mut I) {
  |                   +++++++++++++++++++++++++++++++
```

After: bogus suggestion is gone, and the existing `.as_ref()` suggestion from `hir_typeck` still fires correctly.

r? @estebank
@rust-bors rust-bors bot added the rollup A PR which is a rollup label Mar 17, 2026
@rustbot rustbot added A-CI Area: Our Github Actions CI A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-testsuite Area: The testsuite used to check the correctness of rustc PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Mar 17, 2026
@Zalathar Zalathar closed this Mar 17, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 17, 2026
@Zalathar Zalathar deleted the rollup-JXPkvPW branch March 17, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: Our Github Actions CI A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-testsuite Area: The testsuite used to check the correctness of rustc PG-exploit-mitigations Project group: Exploit mitigations rollup A PR which is a rollup T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants