Skip to content

Commit 40f48ca

Browse files
committed
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 rust-lang/trait-system-refactor-initiative#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: rust-lang/rust#148602 (comment)
2 parents 13586cb + 816d6bd commit 40f48ca

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
689689
lval.write_cvalue(fx, res);
690690
}
691691
Rvalue::Cast(
692-
CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer, _),
692+
CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer(_), _),
693693
ref operand,
694694
to_ty,
695695
) => {

0 commit comments

Comments
 (0)