diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-10-08 14:38:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-08 14:38:18 +0200 |
| commit | c731646d6aea3969cc4a0eb343c73cac9389c75d (patch) | |
| tree | f02f537ee5ee120e9eaf813c31e9e33657ec6a11 /compiler/rustc_const_eval | |
| parent | 6bcdf8aa7435a3c72a7ea3f5e54b67f5faec9264 (diff) | |
| parent | d59c7ff000db581bd03c2da79046af431678fab8 (diff) | |
| download | rust-c731646d6aea3969cc4a0eb343c73cac9389c75d.tar.gz rust-c731646d6aea3969cc4a0eb343c73cac9389c75d.zip | |
Rollup merge of #102675 - ouz-a:mir-technical-debt, r=oli-obk
Remove `mir::CastKind::Misc` As discussed in #97649 `mir::CastKind::Misc` is not clear, this PR addresses that by creating a new enum variant for every valid cast. r? ````@oli-obk````
Diffstat (limited to 'compiler/rustc_const_eval')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/cast.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/check_consts/check.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/validate.rs | 16 |
3 files changed, 11 insertions, 11 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/cast.rs b/compiler/rustc_const_eval/src/interpret/cast.rs index cbe98548025..764224fd007 100644 --- a/compiler/rustc_const_eval/src/interpret/cast.rs +++ b/compiler/rustc_const_eval/src/interpret/cast.rs @@ -42,8 +42,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let res = self.pointer_from_exposed_address_cast(&src, cast_ty)?; self.write_immediate(res, dest)?; } - - Misc => { + // FIXME: We shouldn't use `misc_cast` for these but handle them separately. + IntToInt | FloatToInt | FloatToFloat | IntToFloat | FnPtrToPtr | PtrToPtr => { let src = self.read_immediate(src)?; let res = self.misc_cast(&src, cast_ty)?; self.write_immediate(res, dest)?; diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 5eaddf682c3..80ca412b32a 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -553,7 +553,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { unimplemented!() } - Rvalue::Cast(CastKind::Misc, _, _) => {} + Rvalue::Cast(_, _, _) => {} Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf, _) => {} Rvalue::ShallowInitBox(_, _) => {} diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index 23276e60982..87b7c55bf7f 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -557,7 +557,14 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { } Rvalue::Cast(kind, operand, target_type) => { match kind { - CastKind::Misc => { + CastKind::DynStar => { + // FIXME(dyn-star): make sure nothing needs to be done here. + } + // Nothing to check here + CastKind::PointerFromExposedAddress + | CastKind::PointerExposeAddress + | CastKind::Pointer(_) => {} + _ => { let op_ty = operand.ty(self.body, self.tcx); if op_ty.is_enum() { self.fail( @@ -568,13 +575,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ); } } - CastKind::DynStar => { - // FIXME(dyn-star): make sure nothing needs to be done here. - } - // Nothing to check here - CastKind::PointerFromExposedAddress - | CastKind::PointerExposeAddress - | CastKind::Pointer(_) => {} } } Rvalue::Repeat(_, _) |
