Skip to content

Commit e9c9657

Browse files
committed
miri engine: fix treatment of abort intrinsic
1 parent 54b7d21 commit e9c9657

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
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

0 commit comments

Comments
 (0)