Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,28 +626,38 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
}

Rvalue::Cast(
CastKind::PointerCoercion(
CastKind::IntToInt
| CastKind::FloatToInt
| CastKind::FloatToFloat
| CastKind::IntToFloat
| CastKind::PtrToPtr
| CastKind::FnPtrToPtr
| CastKind::Transmute
| CastKind::BoxDerefTransmute
| CastKind::PointerCoercion(
PointerCoercion::MutToConstPointer
| PointerCoercion::ArrayToPointer
| PointerCoercion::UnsafeFnPointer
| PointerCoercion::ClosureFnPointer(_)
| PointerCoercion::ReifyFnPointer(_),
| PointerCoercion::ReifyFnPointer(_)
| PointerCoercion::Unsize,
_,
),
_,
_,
) => {
// These are all okay; they only change the type, not the data.
// Operations that are fully supported by const-eval.
}

// Special checks for special casts
Rvalue::Cast(CastKind::PointerExposeProvenance, _, _) => {
self.check_op(ops::RawPtrToIntCast);
}
Rvalue::Cast(CastKind::PointerWithExposedProvenance, _, _) => {
// Since no pointer can ever get exposed (rejected above), this is easy to support.
}

Rvalue::Cast(_, _, _) => {}
Rvalue::Cast(kind @ CastKind::Subtype, _, _) => {
span_bug!(self.span, "invalid CastKind for this MIR phase: {kind:?}");
}

Rvalue::UnaryOp(op, operand) => {
let ty = operand.ty(self.body, self.tcx);
Expand Down
Loading