From a39875b4dd90be99d870b9b341a516c313076313 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 19 Mar 2020 09:07:43 +0100 Subject: do not 'return' in 'throw_' macros --- src/librustc/mir/interpret/mod.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/librustc') diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index 0b5bb7f3c03..c5182228e9d 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)*)))? }; } -- cgit 1.4.1-3-g733a5 From e46b3c2a530316ae9c64ac03ec13e32e0b25e19e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 20 Mar 2020 23:28:01 +0100 Subject: more type annotations to help inference --- src/librustc/mir/interpret/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/librustc') diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index c5182228e9d..dfe5adb1bbf 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -49,7 +49,7 @@ macro_rules! err_exhaust { // In the `throw_*` macros, avoid `return` to make them work with `try {}`. #[macro_export] macro_rules! throw_unsup { - ($($tt:tt)*) => { Err(err_unsup!($($tt)*))? }; + ($($tt:tt)*) => { Err::(err_unsup!($($tt)*))? }; } #[macro_export] @@ -59,12 +59,12 @@ macro_rules! throw_unsup_format { #[macro_export] macro_rules! throw_inval { - ($($tt:tt)*) => { Err(err_inval!($($tt)*))? }; + ($($tt:tt)*) => { Err::(err_inval!($($tt)*))? }; } #[macro_export] macro_rules! throw_ub { - ($($tt:tt)*) => { Err(err_ub!($($tt)*))? }; + ($($tt:tt)*) => { Err::(err_ub!($($tt)*))? }; } #[macro_export] @@ -74,13 +74,13 @@ macro_rules! throw_ub_format { #[macro_export] macro_rules! throw_exhaust { - ($($tt:tt)*) => { Err(err_exhaust!($($tt)*))? }; + ($($tt:tt)*) => { Err::(err_exhaust!($($tt)*))? }; } #[macro_export] macro_rules! throw_machine_stop { ($($tt:tt)*) => { - Err($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)))? + Err::($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)))? }; } -- cgit 1.4.1-3-g733a5