Skip to content

Commit a84d8a8

Browse files
committed
Auto merge of #1260 - RalfJung:unreachable, r=RalfJung
Implement unreachable intrinsic Fixes #1254
2 parents 5d8229e + 962e210 commit a84d8a8

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

src/machine.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ impl MemoryExtra {
106106
pub fn init_extern_statics<'tcx, 'mir>(
107107
this: &mut MiriEvalContext<'mir, 'tcx>,
108108
) -> InterpResult<'tcx> {
109-
let target_os = this.tcx.sess.target.target.target_os.as_str();
110-
match target_os {
109+
match this.tcx.sess.target.target.target_os.as_str() {
111110
"linux" => {
112111
// "__cxa_thread_atexit_impl"
113112
// This should be all-zero, pointer-sized.

src/shims/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
802802

803803
this.check_no_isolation("mkdir")?;
804804

805-
let _mode = if this.tcx.sess.target.target.target_os.as_str() == "macos" {
805+
let _mode = if this.tcx.sess.target.target.target_os == "macos" {
806806
u32::from(this.read_scalar(mode_op)?.not_undef()?.to_u16()?)
807807
} else {
808808
this.read_scalar(mode_op)?.to_u32()?

src/shims/intrinsics.rs

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
3636
let (dest, ret) = match ret {
3737
None => match intrinsic_name {
3838
"miri_start_panic" => return this.handle_miri_start_panic(args, unwind),
39+
"unreachable" => throw_ub!(Unreachable),
3940
_ => throw_unsup_format!("unimplemented (diverging) intrinsic: {}", intrinsic_name),
4041
},
4142
Some(p) => p,

tests/compile-fail/unreachable.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// error-pattern: entering unreachable code
2+
fn main() {
3+
unsafe { std::hint::unreachable_unchecked() }
4+
}

0 commit comments

Comments
 (0)