mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
Allow trailing commas in if_let_chain
This commit is contained in:
parent
f3fdbd0d89
commit
07dc709ba4
1 changed files with 11 additions and 0 deletions
|
@ -55,6 +55,7 @@ pub const STRING_PATH: [&'static str; 3] = ["collections", "string", "String"];
|
|||
pub const TRANSMUTE_PATH: [&'static str; 3] = ["core", "intrinsics", "transmute"];
|
||||
pub const VEC_FROM_ELEM_PATH: [&'static str; 3] = ["std", "vec", "from_elem"];
|
||||
pub const VEC_PATH: [&'static str; 3] = ["collections", "vec", "Vec"];
|
||||
pub const BOX_PATH: [&'static str; 3] = ["std", "boxed", "Box"];
|
||||
|
||||
/// Produce a nested chain of if-lets and ifs from the patterns:
|
||||
///
|
||||
|
@ -90,6 +91,11 @@ macro_rules! if_let_chain {
|
|||
$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 }
|
||||
|
@ -100,6 +106,11 @@ macro_rules! if_let_chain {
|
|||
$block
|
||||
}
|
||||
};
|
||||
([$expr:expr,], $block:block) => {
|
||||
if $expr {
|
||||
$block
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// Returns true if the two spans come from differing expansions (i.e. one is from a macro and one
|
||||
|
|
Loading…
Reference in a new issue