about summary refs log tree commit diff
path: root/src/librustc
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-03-21 08:51:21 +0100
committerGitHub <noreply@github.com>2020-03-21 08:51:21 +0100
commit16f607f65a387bbb7894e6f0c847847e77897dde (patch)
tree4f06bbbc1d6a1981b2c8c17e13fc5d46072daec2 /src/librustc
parent569272ac05c6cae7fd64c31396bbdcb7aacd6aab (diff)
parente46b3c2a530316ae9c64ac03ec13e32e0b25e19e (diff)
Rollup merge of #70138 - RalfJung:throw-not-return, r=oli-obk
do not 'return' in 'throw_' macros

In https://github.com/rust-lang/rust/pull/69839 we turned a closure into a `try` block, but it turns out that does not work with our `throw_` macros, which `return` so they skip the `try`.

Here we fix that. For some reason that means we also have to remove some `;`.

r? @oli-obk
Diffstat (limited to 'src/librustc')
-rw-r--r--src/librustc/mir/interpret/mod.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs
index 0b5bb7f3c03..dfe5adb1bbf 100644
--- a/src/librustc/mir/interpret/mod.rs
+++ b/src/librustc/mir/interpret/mod.rs
@@ -46,9 +46,10 @@ macro_rules! err_exhaust {
     };
 }
 
+// In the `throw_*` macros, avoid `return` to make them work with `try {}`.
 #[macro_export]
 macro_rules! throw_unsup {
-    ($($tt:tt)*) => { return Err(err_unsup!($($tt)*).into()) };
+    ($($tt:tt)*) => { Err::<!, _>(err_unsup!($($tt)*))? };
 }
 
 #[macro_export]
@@ -58,12 +59,12 @@ macro_rules! throw_unsup_format {
 
 #[macro_export]
 macro_rules! throw_inval {
-    ($($tt:tt)*) => { return Err(err_inval!($($tt)*).into()) };
+    ($($tt:tt)*) => { Err::<!, _>(err_inval!($($tt)*))? };
 }
 
 #[macro_export]
 macro_rules! throw_ub {
-    ($($tt:tt)*) => { return Err(err_ub!($($tt)*).into()) };
+    ($($tt:tt)*) => { Err::<!, _>(err_ub!($($tt)*))? };
 }
 
 #[macro_export]
@@ -73,13 +74,13 @@ macro_rules! throw_ub_format {
 
 #[macro_export]
 macro_rules! throw_exhaust {
-    ($($tt:tt)*) => { return Err(err_exhaust!($($tt)*).into()) };
+    ($($tt:tt)*) => { Err::<!, _>(err_exhaust!($($tt)*))? };
 }
 
 #[macro_export]
 macro_rules! throw_machine_stop {
     ($($tt:tt)*) => {
-        return Err($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)).into())
+        Err::<!, _>($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)))?
     };
 }