rust/compiler/rustc_codegen_ssa/src
bors 97b131c900 Auto merge of #148602 - BoxyUwU:coercion_cleanup_uncontroversial, r=lcnr
misc coercion cleanups and handle safety correctly

r? lcnr

### "remove normalize call"

Fixes rust-lang/rust#132765

If the normalization fails we would sometimes get a `TypeError` containing inference variables created inside of the probe used by coercion. These would then get leaked out causing ICEs in diagnostics logic

### "leak check and lub for closure<->closure coerce-lubs of same defids"

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/233
```rust
fn peculiar() -> impl Fn(u8) -> u8 {
    return |x| x + 1
}
```
the `|x| x + 1` expr has a type of `Closure(?31t)` which we wind up inferring the RPIT to. The `CoerceMany` `ret_coercion` for the whole `peculiar` typeck has an expected type of `RPIT` (unnormalized). When we type check the `return |x| x + 1` expr we go from the never type to `Closure(?31t)` which then participates in the `ret_coercion` giving us a `coerce-lub(RPIT, Closure(?31t))`.

Normalizing `RPIT` gives us some `Closure(?50t)` where `?31t` and `?50t` have been unified with `?31t` as the root var. `resolve_vars_if_possible` doesn't resolve infer vars to their roots so these wind up with different structural identities so the fast path doesn't apply and we fall back to coercing to a `fn` ptr. cc rust-lang/rust#147193 which also fixes this

New solver probably just gets more inference variables here because canonicalization + generally different approach to normalization of opaques. Idk :3

### FCP worthy stuffy

there are some other FCP worthy things but they're in my FCP comment which also contains some analysis of the breaking nature of the previously listed changes in this PR: https://github.com/rust-lang/rust/pull/148602#issuecomment-3503497467
2025-12-05 11:46:41 +00:00
..
back Rollup merge of #149597 - jdonszelmann:revert-iterator-exactly-one, r=wafflelapkin 2025-12-04 09:22:14 +01:00
debuginfo Flatten ifs in rustc_codegen_ssa 2025-03-17 18:56:52 +00:00
mir account for safe target features in fndef<->closure and fndef<->fndef coerce-lubs 2025-12-03 14:55:41 +00:00
traits Add -Zannotate-moves for profiler visibility of move/copy operations 2025-11-06 15:39:45 -08:00
assert_module_sources.rs Print CGU reuse statistics when -Zprint-mono-items is enabled 2025-08-04 15:43:50 +02:00
base.rs Port the #![windows_subsystem] attribute to the new attribute system 2025-11-27 00:17:48 +01:00
codegen_attrs.rs Implement offload intrinsic 2025-11-25 20:04:27 +01:00
common.rs rustc_target: introduce Os 2025-11-11 18:55:40 -05:00
errors.rs Port the #![windows_subsystem] attribute to the new attribute system 2025-11-27 00:17:48 +01:00
lib.rs Port the #![windows_subsystem] attribute to the new attribute system 2025-11-27 00:17:48 +01:00
meth.rs Remove DynKind 2025-09-17 04:46:46 +02:00
mono_item.rs Port the #[linkage] attribute to the new attribute system 2025-08-13 21:01:37 +02:00
size_of_val.rs remove explicit deref of AbiAlign for most methods 2025-09-28 15:02:14 -07:00
target_features.rs Use rust rather than LLVM target features in the target spec 2025-11-25 14:39:42 +00:00