diff --git a/rust-version b/rust-version index ac50cd77052c..84526eacb7d8 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -f0f68778f798d6d34649745b41770829b17ba5b8 +39b841dfe36f90a7cd111e7f0c55f32594f6e578 diff --git a/src/diagnostics.rs b/src/diagnostics.rs index 12ad93a5289e..3f1f67218fdb 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -12,7 +12,7 @@ use crate::*; /// Details of premature program termination. pub enum TerminationInfo { Exit(i64), - Abort(Option), + Abort(String), UnsupportedInIsolation(String), ExperimentalUb { msg: String, url: String }, Deadlock, @@ -24,10 +24,8 @@ impl fmt::Display for TerminationInfo { match self { Exit(code) => write!(f, "the evaluated program completed with exit code {}", code), - Abort(None) => - write!(f, "the evaluated program aborted execution"), - Abort(Some(msg)) => - write!(f, "the evaluated program aborted execution: {}", msg), + Abort(msg) => + write!(f, "{}", msg), UnsupportedInIsolation(msg) => write!(f, "{}", msg), ExperimentalUb { msg, .. } => diff --git a/src/machine.rs b/src/machine.rs index 70f4bd722df7..4b9cad8420db 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -391,8 +391,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> { } #[inline(always)] - fn abort(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx, !> { - throw_machine_stop!(TerminationInfo::Abort(None)) + fn abort(_ecx: &mut InterpCx<'mir, 'tcx, Self>, msg: String) -> InterpResult<'tcx, !> { + throw_machine_stop!(TerminationInfo::Abort(msg)) } #[inline(always)] diff --git a/src/shims/foreign_items.rs b/src/shims/foreign_items.rs index 24fa119446e8..d588e2962a15 100644 --- a/src/shims/foreign_items.rs +++ b/src/shims/foreign_items.rs @@ -149,7 +149,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx throw_machine_stop!(TerminationInfo::Exit(code.into())); } "abort" => { - throw_machine_stop!(TerminationInfo::Abort(None)) + throw_machine_stop!(TerminationInfo::Abort("the program aborted execution".to_owned())) } _ => throw_unsup_format!("can't call (diverging) foreign function: {}", link_name), }, diff --git a/src/shims/intrinsics.rs b/src/shims/intrinsics.rs index 8f7ae6bebb52..956f3b5bde4f 100644 --- a/src/shims/intrinsics.rs +++ b/src/shims/intrinsics.rs @@ -419,7 +419,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx // Query type information - "assert_inhabited" | "assert_zero_valid" | "assert_uninit_valid" => { let &[] = check_arg_count(args)?; @@ -427,13 +426,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx let layout = this.layout_of(ty)?; // Abort here because the caller might not be panic safe. if layout.abi.is_uninhabited() { - throw_machine_stop!(TerminationInfo::Abort(Some(format!("attempted to instantiate uninhabited type `{}`", ty)))) + // Use this message even for the other intrinsics, as that's what codegen does + throw_machine_stop!(TerminationInfo::Abort(format!("aborted execution: attempted to instantiate uninhabited type `{}`", ty))) } if intrinsic_name == "assert_zero_valid" && !layout.might_permit_raw_init(this, /*zero:*/ true).unwrap() { - throw_machine_stop!(TerminationInfo::Abort(Some(format!("attempted to zero-initialize type `{}`, which is invalid", ty)))) + throw_machine_stop!(TerminationInfo::Abort(format!("aborted execution: attempted to zero-initialize type `{}`, which is invalid", ty))) } if intrinsic_name == "assert_uninit_valid" && !layout.might_permit_raw_init(this, /*zero:*/ false).unwrap() { - throw_machine_stop!(TerminationInfo::Abort(Some(format!("attempted to leave type `{}` uninitialized, which is invalid", ty)))) + throw_machine_stop!(TerminationInfo::Abort(format!("aborted execution: attempted to leave type `{}` uninitialized, which is invalid", ty))) } } diff --git a/tests/compile-fail/abort-terminator.rs b/tests/compile-fail/abort-terminator.rs index 1bfa289a52b4..73286a1759ba 100644 --- a/tests/compile-fail/abort-terminator.rs +++ b/tests/compile-fail/abort-terminator.rs @@ -1,4 +1,4 @@ -// error-pattern: the evaluated program aborted +// error-pattern: the program aborted #![feature(unwind_attributes)] #[unwind(aborts)] diff --git a/tests/compile-fail/intrinsics/uninit_uninhabited_type.rs b/tests/compile-fail/intrinsics/uninit_uninhabited_type.rs index deb3586c781e..2337ff0f6c26 100644 --- a/tests/compile-fail/intrinsics/uninit_uninhabited_type.rs +++ b/tests/compile-fail/intrinsics/uninit_uninhabited_type.rs @@ -1,4 +1,4 @@ -// error-pattern: the evaluated program aborted execution: attempted to instantiate uninhabited type `!` +// error-pattern: attempted to instantiate uninhabited type `!` #![feature(never_type)] #[allow(deprecated, invalid_value)] diff --git a/tests/compile-fail/intrinsics/zero_fn_ptr.rs b/tests/compile-fail/intrinsics/zero_fn_ptr.rs index 81dbf6c429b3..098a8e01347f 100644 --- a/tests/compile-fail/intrinsics/zero_fn_ptr.rs +++ b/tests/compile-fail/intrinsics/zero_fn_ptr.rs @@ -1,4 +1,4 @@ -// error-pattern: the evaluated program aborted execution: attempted to zero-initialize type `fn()`, which is invalid +// error-pattern: attempted to zero-initialize type `fn()`, which is invalid #[allow(deprecated, invalid_value)] fn main() { diff --git a/tests/compile-fail/panic/double_panic.rs b/tests/compile-fail/panic/double_panic.rs index 80d74f026232..b42c1aff1032 100644 --- a/tests/compile-fail/panic/double_panic.rs +++ b/tests/compile-fail/panic/double_panic.rs @@ -1,4 +1,4 @@ -// error-pattern: the evaluated program aborted +// error-pattern: the program aborted struct Foo; impl Drop for Foo { diff --git a/tests/compile-fail/panic/panic_abort1.rs b/tests/compile-fail/panic/panic_abort1.rs index 02f8f25880f3..095d9e3d75b0 100644 --- a/tests/compile-fail/panic/panic_abort1.rs +++ b/tests/compile-fail/panic/panic_abort1.rs @@ -1,4 +1,4 @@ -// error-pattern: the evaluated program aborted execution +// error-pattern: the program aborted execution // compile-flags: -C panic=abort fn main() { diff --git a/tests/compile-fail/panic/panic_abort2.rs b/tests/compile-fail/panic/panic_abort2.rs index 0d6808dd22e0..de177bc4e716 100644 --- a/tests/compile-fail/panic/panic_abort2.rs +++ b/tests/compile-fail/panic/panic_abort2.rs @@ -1,4 +1,4 @@ -// error-pattern: the evaluated program aborted execution +// error-pattern: the program aborted execution // compile-flags: -C panic=abort fn main() { diff --git a/tests/compile-fail/panic/panic_abort3.rs b/tests/compile-fail/panic/panic_abort3.rs index 6640a56c0be2..2d65da4fe341 100644 --- a/tests/compile-fail/panic/panic_abort3.rs +++ b/tests/compile-fail/panic/panic_abort3.rs @@ -1,4 +1,4 @@ -// error-pattern: the evaluated program aborted execution +// error-pattern: the program aborted execution // compile-flags: -C panic=abort fn main() { diff --git a/tests/compile-fail/panic/panic_abort4.rs b/tests/compile-fail/panic/panic_abort4.rs index d39b1794e676..41d32a604fed 100644 --- a/tests/compile-fail/panic/panic_abort4.rs +++ b/tests/compile-fail/panic/panic_abort4.rs @@ -1,4 +1,4 @@ -// error-pattern: the evaluated program aborted execution +// error-pattern: the program aborted execution // compile-flags: -C panic=abort fn main() {