mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
remove if_let_chain
This commit is contained in:
parent
2153d1e560
commit
24a2c14733
3 changed files with 6 additions and 57 deletions
|
@ -28,6 +28,7 @@ toml = "0.4"
|
|||
unicode-normalization = "0.1"
|
||||
pulldown-cmark = "0.0.15"
|
||||
url = "1.5.0"
|
||||
if_chain = "0.1"
|
||||
|
||||
[features]
|
||||
debugging = []
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#![feature(inclusive_range_syntax, range_contains)]
|
||||
#![allow(unknown_lints, indexing_slicing, shadow_reuse, missing_docs_in_private_items)]
|
||||
|
||||
#![recursion_limit="256"]
|
||||
|
||||
#[macro_use]
|
||||
extern crate rustc;
|
||||
extern crate rustc_typeck;
|
||||
|
@ -54,6 +56,9 @@ extern crate itertools;
|
|||
extern crate pulldown_cmark;
|
||||
extern crate url;
|
||||
|
||||
#[macro_use]
|
||||
extern crate if_chain;
|
||||
|
||||
macro_rules! declare_restriction_lint {
|
||||
{ pub $name:tt, $description:tt } => {
|
||||
declare_lint! { pub $name, Allow, $description }
|
||||
|
|
|
@ -37,63 +37,6 @@ pub use self::hir_utils::{SpanlessEq, SpanlessHash};
|
|||
|
||||
pub type MethodArgs = HirVec<P<Expr>>;
|
||||
|
||||
/// Produce a nested chain of if-lets and ifs from the patterns:
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// if_let_chain! {[
|
||||
/// let Some(y) = x,
|
||||
/// y.len() == 2,
|
||||
/// let Some(z) = y,
|
||||
/// ], {
|
||||
/// block
|
||||
/// }}
|
||||
/// ```
|
||||
///
|
||||
/// becomes
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// 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
|
||||
}
|
||||
};
|
||||
([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
|
||||
}
|
||||
};
|
||||
([$expr:expr,], $block:block) => {
|
||||
if $expr {
|
||||
$block
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub mod higher;
|
||||
|
||||
/// Returns true if the two spans come from differing expansions (i.e. one is
|
||||
|
|
Loading…
Reference in a new issue