From be42b04ee7769f5d0e9d040fb06ec2c60d9c5482 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 21 Nov 2022 16:51:16 +0000 Subject: [PATCH 1/4] Make alignment checks a future incompat lint --- src/machine.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/machine.rs b/src/machine.rs index e5b1eb2e48706..8f3c979f5ebab 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -24,6 +24,7 @@ use rustc_span::def_id::{CrateNum, DefId}; use rustc_span::Symbol; use rustc_target::abi::Size; use rustc_target::spec::abi::Abi; +use rustc_const_eval::const_eval::CheckAlignment; use crate::{ concurrency::{data_race, weak_memory}, @@ -752,8 +753,12 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> { const PANIC_ON_ALLOC_FAIL: bool = false; #[inline(always)] - fn enforce_alignment(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool { - ecx.machine.check_alignment != AlignmentCheck::None + fn enforce_alignment(ecx: &MiriInterpCx<'mir, 'tcx>) -> CheckAlignment { + if ecx.machine.check_alignment == AlignmentCheck::None { + CheckAlignment::No + } else { + CheckAlignment::Error + } } #[inline(always)] From 21b99baa3ffa3f1782707d1bb49204faabaeee53 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 22 Nov 2022 11:16:33 +0000 Subject: [PATCH 2/4] Move alignment failure error reporting to machine --- src/machine.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/machine.rs b/src/machine.rs index 8f3c979f5ebab..ab629e4711b10 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -22,7 +22,7 @@ use rustc_middle::{ }; use rustc_span::def_id::{CrateNum, DefId}; use rustc_span::Symbol; -use rustc_target::abi::Size; +use rustc_target::abi::{Size, Align}; use rustc_target::spec::abi::Abi; use rustc_const_eval::const_eval::CheckAlignment; @@ -766,6 +766,15 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> { ecx.machine.check_alignment == AlignmentCheck::Int } + fn alignment_check_failed( + _ecx: &InterpCx<'mir, 'tcx, Self>, + has: Align, + required: Align, + _check: CheckAlignment, + ) -> InterpResult<'tcx, ()> { + throw_ub!(AlignmentCheckFailed { has, required }) + } + #[inline(always)] fn enforce_validity(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool { ecx.machine.validate From 44580098aed45b554140428a545625a20301efd3 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 16 Dec 2022 12:19:21 +0100 Subject: [PATCH 3/4] Preparing for merge from rustc --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index 5f1a4428febc1..e6c238023e407 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -e1c91213ff80af5b87a197b784b40bcbc8cf3add +a803f313fdf8f6eb2d674d7dfb3694a2b437ee1e From 3e3e5e624a8ff932e373f219f35de574f25048da Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 16 Dec 2022 14:19:48 +0100 Subject: [PATCH 4/4] fmt --- src/machine.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/machine.rs b/src/machine.rs index 32ae3fad57001..e5a748453e881 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -9,6 +9,7 @@ use rand::rngs::StdRng; use rand::SeedableRng; use rustc_ast::ast::Mutability; +use rustc_const_eval::const_eval::CheckAlignment; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; #[allow(unused)] use rustc_data_structures::static_assert_size; @@ -22,9 +23,8 @@ use rustc_middle::{ }; use rustc_span::def_id::{CrateNum, DefId}; use rustc_span::Symbol; -use rustc_target::abi::{Size, Align}; +use rustc_target::abi::{Align, Size}; use rustc_target::spec::abi::Abi; -use rustc_const_eval::const_eval::CheckAlignment; use crate::{ concurrency::{data_race, weak_memory},