mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-15 16:33:49 +00:00
Remove duplicated if_let_chain! macro definition
This commit is contained in:
parent
cd3c649adb
commit
0e4259a827
46
src/utils.rs
46
src/utils.rs
@ -370,52 +370,6 @@ pub fn is_adjusted(cx: &LateContext, e: &Expr) -> bool {
|
||||
cx.tcx.tables.borrow().adjustments.get(&e.id).is_some()
|
||||
}
|
||||
|
||||
/// Produce a nested chain of if-lets and ifs from the patterns:
|
||||
///
|
||||
/// if_let_chain! {
|
||||
/// [
|
||||
/// Some(y) = x,
|
||||
/// y.len() == 2,
|
||||
/// Some(z) = y,
|
||||
/// ],
|
||||
/// {
|
||||
/// block
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// becomes
|
||||
///
|
||||
/// if let Some(y) = x {
|
||||
/// if y.len() == 2 {
|
||||
/// if let Some(z) = y {
|
||||
/// block
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
#[macro_export]
|
||||
macro_rules! if_let_chain {
|
||||
([let $pat:pat = $expr:expr, $($tt:tt)+], $block:block) => {
|
||||
if let $pat = $expr {
|
||||
if_let_chain!{ [$($tt)+], $block }
|
||||
}
|
||||
};
|
||||
([let $pat:pat = $expr:expr], $block:block) => {
|
||||
if let $pat = $expr {
|
||||
$block
|
||||
}
|
||||
};
|
||||
([$expr:expr, $($tt:tt)+], $block:block) => {
|
||||
if $expr {
|
||||
if_let_chain!{ [$($tt)+], $block }
|
||||
}
|
||||
};
|
||||
([$expr:expr], $block:block) => {
|
||||
if $expr {
|
||||
$block
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub struct LimitStack {
|
||||
stack: Vec<u64>,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user