Use if_chain from crates.io

This commit is contained in:
Chris Wong 2016-12-29 12:20:08 +13:00
parent b2ff33fea6
commit c849d9efdf
4 changed files with 8 additions and 27 deletions

View file

@ -12,9 +12,9 @@ description = """
Compile-time HTML templates.
"""
[dependencies.maud]
path = "../maud"
version = "0.14.0"
[dependencies]
if_chain = "0.1"
maud = { path = "../maud", version = "0.14.0" }
[lib]
name = "maud_macros"

View file

@ -2,7 +2,10 @@
#![feature(plugin_registrar, quote)]
#![feature(slice_patterns)]
#![feature(rustc_private)]
#![recursion_limit = "1000"] // if_chain
#[macro_use]
extern crate if_chain;
#[macro_use]
extern crate rustc;
extern crate rustc_plugin;

View file

@ -31,7 +31,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DoctypeHtml {
// ... and the callee is `maud::PreEscaped`
if let ExprPath(ref qpath) = path_expr.node;
let def_id = cx.tcx.tables().qpath_def(qpath, path_expr.id).def_id();
if match_def_path(cx, def_id, &["maud", "PreEscaped", "{{constructor}}"]) {
if match_def_path(cx, def_id, &["maud", "PreEscaped", "{{constructor}}"]);
then {
cx.struct_span_lint(MAUD_DOCTYPE_HTML, expr.span,
"use `maud::DOCTYPE_HTML` instead").emit();
}

View file

@ -7,29 +7,6 @@ use rustc::lint::LateContext;
use rustc::ty;
use syntax::symbol::{InternedString, Symbol};
#[macro_export]
macro_rules! if_chain {
(let $pat:pat = $expr:expr; $($tt:tt)+) => {
{
let $pat = $expr;
if_chain! { $($tt)+ }
}
};
(if let $pat:pat = $expr:expr; $($tt:tt)+) => {
if let $pat = $expr {
if_chain! { $($tt)+ }
}
};
(if $expr:expr; $($tt:tt)+) => {
if $expr {
if_chain! { $($tt)+ }
}
};
($expr:expr) => {
$expr
};
}
/// Check if a `DefId`'s path matches the given absolute type path usage.
///
/// # Examples