Skip to content

Commit f2af2cf

Browse files
authored
Rollup merge of #69960 - RalfJung:abort, r=oli-obk
miri engine: fix treatment of abort intrinsic I screwed up in #69830 and added `abort` to the wrong block of intrinsics, namely the one that actually has a return place. So that branch was never actually reached. r? @oli-obk
2 parents 77263db + 13ea774 commit f2af2cf

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/librustc_mir/interpret/intrinsics.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,15 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
8484
let substs = instance.substs;
8585
let intrinsic_name = self.tcx.item_name(instance.def_id());
8686

87-
// We currently do not handle any intrinsics that are *allowed* to diverge,
88-
// but `transmute` could lack a return place in case of UB.
87+
// First handle intrinsics without return place.
8988
let (dest, ret) = match ret {
90-
Some(p) => p,
9189
None => match intrinsic_name {
92-
sym::transmute => throw_ub!(Unreachable),
90+
sym::transmute => throw_ub_format!("transmuting to uninhabited type"),
91+
sym::abort => M::abort(self)?,
92+
// Unsupported diverging intrinsic.
9393
_ => return Ok(false),
9494
},
95+
Some(p) => p,
9596
};
9697

9798
// Keep the patterns in this match ordered the same as the list in
@@ -103,10 +104,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
103104
self.write_scalar(location.ptr, dest)?;
104105
}
105106

106-
sym::abort => {
107-
M::abort(self)?;
108-
}
109-
110107
sym::min_align_of
111108
| sym::pref_align_of
112109
| sym::needs_drop

src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: any use of this value will cause an error
44
LL | unsafe { std::mem::transmute(()) }
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66
| |
7-
| entering unreachable code
7+
| transmuting to uninhabited type
88
| inside call to `foo` at $DIR/validate_uninhabited_zsts.rs:14:26
99
...
1010
LL | const FOO: [Empty; 3] = [foo(); 3];

0 commit comments

Comments
 (0)