remove if_let_chain

This commit is contained in:
Alex Burka 2017-10-23 15:20:58 -04:00
parent 2153d1e560
commit 24a2c14733
3 changed files with 6 additions and 57 deletions

View file

@ -28,6 +28,7 @@ toml = "0.4"
unicode-normalization = "0.1" unicode-normalization = "0.1"
pulldown-cmark = "0.0.15" pulldown-cmark = "0.0.15"
url = "1.5.0" url = "1.5.0"
if_chain = "0.1"
[features] [features]
debugging = [] debugging = []

View file

@ -11,6 +11,8 @@
#![feature(inclusive_range_syntax, range_contains)] #![feature(inclusive_range_syntax, range_contains)]
#![allow(unknown_lints, indexing_slicing, shadow_reuse, missing_docs_in_private_items)] #![allow(unknown_lints, indexing_slicing, shadow_reuse, missing_docs_in_private_items)]
#![recursion_limit="256"]
#[macro_use] #[macro_use]
extern crate rustc; extern crate rustc;
extern crate rustc_typeck; extern crate rustc_typeck;
@ -54,6 +56,9 @@ extern crate itertools;
extern crate pulldown_cmark; extern crate pulldown_cmark;
extern crate url; extern crate url;
#[macro_use]
extern crate if_chain;
macro_rules! declare_restriction_lint { macro_rules! declare_restriction_lint {
{ pub $name:tt, $description:tt } => { { pub $name:tt, $description:tt } => {
declare_lint! { pub $name, Allow, $description } declare_lint! { pub $name, Allow, $description }

View file

@ -37,63 +37,6 @@ pub use self::hir_utils::{SpanlessEq, SpanlessHash};
pub type MethodArgs = HirVec<P<Expr>>; 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; pub mod higher;
/// Returns true if the two spans come from differing expansions (i.e. one is /// Returns true if the two spans come from differing expansions (i.e. one is