]> git.lizzy.rs Git - rust.git/commitdiff
we are on 2018 edition, use try block
authorRalf Jung <post@ralfj.de>
Mon, 9 Mar 2020 20:43:05 +0000 (21:43 +0100)
committerRalf Jung <post@ralfj.de>
Wed, 11 Mar 2020 18:44:23 +0000 (19:44 +0100)
src/librustc_mir/interpret/terminator.rs

index 2d1493febc4134b81f5c37740e62d8db45de1b6e..ef46038c3cbfc8670fcc0dc70bc963441051026c 100644 (file)
@@ -261,10 +261,9 @@ fn eval_fn_call(
                     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 @@ fn eval_fn_call(
                             throw_ub_format!("calling a returning function without a return place")
                         }
                     }
-                    Ok(())
-                })();
+                };
                 match res {
                     Err(err) => {
                         self.stack.pop();