Skip to content

Commit 20a2f5a

Browse files
committed
Check for intrinsic to fn ptr casts in unified coercions
Fixes #149143 by ensuring that when coercing multiple expressions to a unified type, the same "intrinsic to fn ptr" check is applied as for other coercions.
1 parent 2c0f486 commit 20a2f5a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12911291
ty::Closure(..) => {
12921292
Adjust::Pointer(PointerCoercion::ClosureFnPointer(a_sig.safety()))
12931293
}
1294-
ty::FnDef(..) => Adjust::Pointer(PointerCoercion::ReifyFnPointer),
1294+
ty::FnDef(def_id, ..) => {
1295+
// Intrinsics are not coercible to function pointers
1296+
if self.tcx.intrinsic(def_id).is_some() {
1297+
return Err(TypeError::IntrinsicCast);
1298+
}
1299+
Adjust::Pointer(PointerCoercion::ReifyFnPointer)
1300+
}
12951301
_ => span_bug!(cause.span, "should not try to coerce a {prev_ty} to a fn pointer"),
12961302
};
12971303
let next_adjustment = match new_ty.kind() {

0 commit comments

Comments
 (0)