Skip to content

Commit 9681422

Browse files
committed
we are on 2018 edition, use try block
1 parent d8f8168 commit 9681422

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/librustc_mir/interpret/terminator.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
261261
StackPopCleanup::Goto { ret: ret.map(|p| p.1), unwind },
262262
)?;
263263

264-
// We want to pop this frame again in case there was an error, to put
265-
// the blame in the right location. Until the 2018 edition is used in
266-
// the compiler, we have to do this with an immediately invoked function.
267-
let res = (|| {
264+
// If an error is raised here, pop the frame again to get an accurate backtrace.
265+
// To this end, we wrap it all in a `try` block.
266+
let res: InterpResult<'tcx> = try {
268267
trace!(
269268
"caller ABI: {:?}, args: {:#?}",
270269
caller_abi,
@@ -363,8 +362,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
363362
throw_ub_format!("calling a returning function without a return place")
364363
}
365364
}
366-
Ok(())
367-
})();
365+
};
368366
match res {
369367
Err(err) => {
370368
self.stack.pop();

0 commit comments

Comments
 (0)