bug! more uses of these in runtime stuff · rust-lang/rust@e04e351 (original) (raw)

File tree

3 files changed

lines changed

3 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -677,21 +677,22 @@ fn codegen_stmt<'tcx>(
677 677 CastKind::PointerCoercion(PointerCoercion::UnsafeFnPointer),
678 678 ref operand,
679 679 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,
690 680 ) => {
691 681 let to_layout = fx.layout_of(fx.monomorphize(to_ty));
692 682 let operand = codegen_operand(fx, operand);
693 683 lval.write_cvalue(fx, operand.cast_pointer_to(to_layout));
694 684 }
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 +}
695 696 Rvalue::Cast(
696 697 CastKind::IntToInt
697 698 | CastKind::FloatToFloat
Original file line number Diff line number Diff line change
@@ -456,8 +456,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
456 456 base::unsize_ptr(bx, lldata, operand.layout.ty, cast.ty, llextra);
457 457 OperandValue::Pair(lldata, llextra)
458 458 }
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
461 465 if bx.cx().is_backend_scalar_pair(operand.layout) =>
462 466 {
463 467 if let OperandValue::Pair(data_ptr, meta) = operand.val {
@@ -477,9 +481,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
477 481 base::cast_to_dyn_star(bx, lldata, operand.layout, cast.ty, llextra);
478 482 OperandValue::Pair(lldata, llextra)
479 483 }
480 - mir::CastKind::PointerCoercion(
481 -PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer,
482 -)
483 484 | mir::CastKind::IntToInt
484 485 | mir::CastKind::FloatToInt
485 486 | mir::CastKind::FloatToFloat
Original file line number Diff line number Diff line change
@@ -70,9 +70,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
70 70 CastKind::PointerCoercion(
71 71 PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer,
72 72 ) => {
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");
76 74 }
77 75
78 76 CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer) => {