diff options
| author | Ralf Jung <post@ralfj.de> | 2020-03-09 21:43:05 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2020-03-11 19:44:23 +0100 |
| commit | 968142294385228fdc8af954dcd5be013404fba5 (patch) | |
| tree | 1952e71eefde84fb9ee117a96959eb64bbbc6868 | |
| parent | d8f81680a1232638df81e684b60ac60f3e0318f7 (diff) | |
we are on 2018 edition, use try block
| -rw-r--r-- | src/librustc_mir/interpret/terminator.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index 2d1493febc4..ef46038c3cb 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -261,10 +261,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { StackPopCleanup::Goto { ret: ret.map(|p| p.1), unwind }, )?; - // We want to pop this frame again in case there was an error, to put - // the blame in the right location. Until the 2018 edition is used in - // the compiler, we have to do this with an immediately invoked function. - let res = (|| { + // If an error is raised here, pop the frame again to get an accurate backtrace. + // To this end, we wrap it all in a `try` block. + let res: InterpResult<'tcx> = try { trace!( "caller ABI: {:?}, args: {:#?}", caller_abi, @@ -363,8 +362,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { throw_ub_format!("calling a returning function without a return place") } } - Ok(()) - })(); + }; match res { Err(err) => { self.stack.pop(); |
