Skip to content

Commit

Permalink
Fix Rust 2021 warning about panic!(...)
Browse files Browse the repository at this point in the history
See <rust-lang/rust#81645> for example
  • Loading branch information
tqdv committed Apr 11, 2021
1 parent f2ea145 commit 75f0035
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tear"
description = "Typed early returns and loop control + Syntax sugar for try!-like error handling"
version = "0.5.0"
version = "0.5.1"
authors = ["Tilwa Qendov <[email protected]>"]
edition = "2018"
license = "MIT OR Apache-2.0"
Expand Down
14 changes: 7 additions & 7 deletions src/twist_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ macro_rules! twist {
match $e {
$crate::Looping::Resume(v) => v,
$( $crate::Looping::Break { label: None } => { $crate::__unit!($bk); break; }, )?
$( $crate::Looping::Break { label: None } => { $crate::__unit!($bv); panic!($crate::BREAK_WITHOUT_VAL) }, )?
$( $crate::Looping::Break { label: None } => { $crate::__unit!($bx); panic!($crate::BREAK_WITHOUT_VAL) }, )?
$( $crate::Looping::Break { label: None } => { $crate::__unit!($bv); panic!("{}", $crate::BREAK_WITHOUT_VAL) }, )?
$( $crate::Looping::Break { label: None } => { $crate::__unit!($bx); panic!("{}", $crate::BREAK_WITHOUT_VAL) }, )?
$crate::Looping::Break { label: Some(l) } => {
match l {
$( x if x == $c => { break $l; }, )*
Expand All @@ -468,12 +468,12 @@ macro_rules! twist {
_ => panic!("Invalid label index in Looping::Continue object."),
};
},
$( $crate::Looping::BreakVal { label: None, .. } => { $crate::__unit!($bk); panic!($crate::BREAKVAL_IN_NOT_LOOP); }, )?
$( $crate::Looping::BreakVal { label: None, .. } => { $crate::__unit!($bk); panic!("{}", $crate::BREAKVAL_IN_NOT_LOOP); }, )?
$( $crate::Looping::BreakVal { label: None, value: v } => { $crate::__unit!($bv); break v; }, )?
$( $crate::Looping::BreakVal { label: None, value: v } => { // Unbox version
match v.downcast::<$bx>() {
Ok(v) => { break *v; },
_ => panic!(format!("At label None with type {}: {}", stringify!($bx), $crate::BAD_BREAKVAL_TYPE)),
_ => panic!("At label None with type {}: {}", stringify!($bx), $crate::BAD_BREAKVAL_TYPE),
};
}, )?
// Add explicit breakval type when it can't be infered by the labeled breaksvals
Expand All @@ -484,7 +484,7 @@ macro_rules! twist {
$( x if x == $bcount => { // Unbox version
match v.downcast::<$btype>() {
Ok(v) => { break $blabel *v; }, // We got a ref so dereference it
_ => panic!(format!("At label {} with type {}: {}", stringify!($blabel), stringify!($btype), $crate::BAD_BREAKVAL_TYPE)),
_ => panic!("At label {} with type {}: {}", stringify!($blabel), stringify!($btype), $crate::BAD_BREAKVAL_TYPE),
}
}, )*
_ => panic!("Invalid label index in Looping::BreakVal object."),
Expand All @@ -508,9 +508,9 @@ macro_rules! twist {
$( _ if $crate::__bool!($breaker) => unreachable!(), $crate::Looping::Resume::<_, $crate::BreakValError>(v) => v, )?
$( _ if $crate::__bool!($breakval) => unreachable!(), $crate::Looping::Resume(v) => v, )?
$( _ if $crate::__bool!($breaker) => unreachable!(), $crate::Looping::Break { .. } => break $($label)?, )?
$( _ if $crate::__bool!($breakval) => unreachable!(), $crate::Looping::Break { .. } => panic!($crate::BREAK_WITHOUT_VAL), )?
$( _ if $crate::__bool!($breakval) => unreachable!(), $crate::Looping::Break { .. } => panic!("{}", $crate::BREAK_WITHOUT_VAL), )?
$crate::Looping::Continue { .. } => continue $($($label)?)? $($($vlabel)?)?,
$( _ if $crate::__bool!($breaker) => unreachable!(), $crate::Looping::BreakVal { .. } => panic!($crate::BREAKVAL_IN_NOT_LOOP), )?
$( _ if $crate::__bool!($breaker) => unreachable!(), $crate::Looping::BreakVal { .. } => panic!("{}", $crate::BREAKVAL_IN_NOT_LOOP), )?
$( _ if $crate::__bool!($breakval) => unreachable!(), $crate::Looping::BreakVal { value: v, .. } => break $($vlabel)? v, )?
}
};
Expand Down

0 comments on commit 75f0035

Please sign in to comment.