Skip to content

Commit 64bba35

Browse files
committed
bug! more uses of these in runtime stuff
1 parent 55fc6bd commit 64bba35

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

compiler/rustc_codegen_cranelift/src/base.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -677,21 +677,22 @@ fn codegen_stmt<'tcx>(
677677
CastKind::PointerCoercion(PointerCoercion::UnsafeFnPointer),
678678
ref operand,
679679
to_ty,
680-
)
681-
| Rvalue::Cast(
682-
CastKind::PointerCoercion(PointerCoercion::MutToConstPointer),
683-
ref operand,
684-
to_ty,
685-
)
686-
| Rvalue::Cast(
687-
CastKind::PointerCoercion(PointerCoercion::ArrayToPointer),
688-
ref operand,
689-
to_ty,
690680
) => {
691681
let to_layout = fx.layout_of(fx.monomorphize(to_ty));
692682
let operand = codegen_operand(fx, operand);
693683
lval.write_cvalue(fx, operand.cast_pointer_to(to_layout));
694684
}
685+
Rvalue::Cast(
686+
CastKind::PointerCoercion(
687+
PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer,
688+
),
689+
..,
690+
) => {
691+
bug!(
692+
"{:?} is for borrowck, and should never appear in codegen",
693+
to_place_and_rval.1
694+
);
695+
}
695696
Rvalue::Cast(
696697
CastKind::IntToInt
697698
| CastKind::FloatToFloat

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
456456
base::unsize_ptr(bx, lldata, operand.layout.ty, cast.ty, llextra);
457457
OperandValue::Pair(lldata, llextra)
458458
}
459-
mir::CastKind::PointerCoercion(PointerCoercion::MutToConstPointer)
460-
| mir::CastKind::PtrToPtr
459+
mir::CastKind::PointerCoercion(
460+
PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer,
461+
) => {
462+
bug!("{kind:?} is for borrowck, and should never appear in codegen");
463+
}
464+
mir::CastKind::PtrToPtr
461465
if bx.cx().is_backend_scalar_pair(operand.layout) =>
462466
{
463467
if let OperandValue::Pair(data_ptr, meta) = operand.val {
@@ -477,9 +481,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
477481
base::cast_to_dyn_star(bx, lldata, operand.layout, cast.ty, llextra);
478482
OperandValue::Pair(lldata, llextra)
479483
}
480-
mir::CastKind::PointerCoercion(
481-
PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer,
482-
)
483484
| mir::CastKind::IntToInt
484485
| mir::CastKind::FloatToInt
485486
| mir::CastKind::FloatToFloat

compiler/rustc_const_eval/src/interpret/cast.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
7070
CastKind::PointerCoercion(
7171
PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer,
7272
) => {
73-
// These are NOPs, but can be wide pointers.
74-
let v = self.read_immediate(src)?;
75-
self.write_immediate(*v, dest)?;
73+
bug!("{cast_kind:?} casts are for borrowck only, not runtime MIR");
7674
}
7775

7876
CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer) => {

0 commit comments

Comments
 (0)