From 66ddbcac986f099e309c28491c276de39340068a Mon Sep 17 00:00:00 2001
From: Chris Wong <lambda.fairy@gmail.com>
Date: Mon, 3 Sep 2018 19:23:22 +1200
Subject: [PATCH] Remove maud_lints

It's undocumented, it doesn't do much, and it keeps breaking.
---
 .travis.yml                      |  2 +-
 CONTRIBUTING.md                  |  3 ---
 Cargo.toml                       |  1 -
 maud/Cargo.toml                  |  3 ---
 maud/tests/basic_syntax.rs       |  3 ---
 maud/tests/control_structures.rs |  3 ---
 maud/tests/misc.rs               |  3 ---
 maud/tests/splices.rs            |  3 ---
 maud_extras/Cargo.toml           |  1 -
 maud_extras/lib.rs               |  3 ---
 maud_lints/Cargo.toml            | 22 -----------------
 maud_lints/src/doctype.rs        | 41 --------------------------------
 maud_lints/src/lib.rs            | 29 ----------------------
 maud_lints/src/util.rs           | 34 --------------------------
 14 files changed, 1 insertion(+), 150 deletions(-)
 delete mode 100644 maud_lints/Cargo.toml
 delete mode 100644 maud_lints/src/doctype.rs
 delete mode 100644 maud_lints/src/lib.rs
 delete mode 100644 maud_lints/src/util.rs

diff --git a/.travis.yml b/.travis.yml
index 9177105..588975f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,7 +13,7 @@ script:
   - (cd benchmarks && cargo bench --no-run)
   - |
     CLIPPY_STATUS=0
-    for package in maud_htmlescape maud_macros maud maud_lints maud_extras; do
+    for package in maud_htmlescape maud_macros maud maud_extras; do
       (cd $package && cargo clippy -- -D warnings) || CLIPPY_STATUS=$?
     done
     (exit $CLIPPY_STATUS)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e0f13e9..ea4ac66 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -9,12 +9,9 @@ Great to see that you want to help out! Here are some tips for getting started:
 * Most contributions should include tests – see the [existing test code] for how to write these.
 
 * Documentation on the proc macro interface can be found on [docs.rust-lang.org][proc_macro].
-    - The `maud_lints` crate uses internal compiler APIs; the documentation for these can be found on [Manishearth's site].
 
 Have fun! ☺️
 
 [easy issues]: https://github.com/lfairy/maud/issues?q=is%3Aissue+is%3Aopen+label%3A%22difficulty%3A+easy%22
 [existing test code]: https://github.com/lfairy/maud/tree/master/maud/tests
 [proc_macro]: https://doc.rust-lang.org/nightly/proc_macro/
-[compiler source]: https://github.com/rust-lang/rust/tree/master/src
-[Manishearth's site]: https://manishearth.github.io/rust-internals-docs/rustc/
diff --git a/Cargo.toml b/Cargo.toml
index efba499..13092b4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,7 +3,6 @@ members = [
     "maud_htmlescape",
     "maud_macros",
     "maud",
-    "maud_lints",
     "maud_extras",
 ]
 exclude = [
diff --git a/maud/Cargo.toml b/maud/Cargo.toml
index 84145b3..1a56fd0 100644
--- a/maud/Cargo.toml
+++ b/maud/Cargo.toml
@@ -19,9 +19,6 @@ iron = { version = ">= 0.5.1, < 0.7.0", optional = true }
 rocket = { version = "0.3", optional = true }
 actix-web = { version = ">= 0.6.12, < 0.8.0", optional = true }
 
-[dev-dependencies]
-maud_lints = { version = "0.18.1", path = "../maud_lints" }
-
 [badges]
 travis-ci = { repository = "lfairy/maud" }
 
diff --git a/maud/tests/basic_syntax.rs b/maud/tests/basic_syntax.rs
index 5ce1b7c..a0c7dc5 100644
--- a/maud/tests/basic_syntax.rs
+++ b/maud/tests/basic_syntax.rs
@@ -1,8 +1,5 @@
-#![feature(plugin)]
 #![feature(proc_macro_non_items)]
 
-#![plugin(maud_lints)]
-
 extern crate maud;
 
 use maud::{Markup, html};
diff --git a/maud/tests/control_structures.rs b/maud/tests/control_structures.rs
index 04b1329..c408c6b 100644
--- a/maud/tests/control_structures.rs
+++ b/maud/tests/control_structures.rs
@@ -1,8 +1,5 @@
-#![feature(plugin)]
 #![feature(proc_macro_non_items)]
 
-#![plugin(maud_lints)]
-
 extern crate maud;
 
 use maud::html;
diff --git a/maud/tests/misc.rs b/maud/tests/misc.rs
index 1cf728a..65b18bf 100644
--- a/maud/tests/misc.rs
+++ b/maud/tests/misc.rs
@@ -1,8 +1,5 @@
-#![feature(plugin)]
 #![feature(proc_macro_non_items)]
 
-#![plugin(maud_lints)]
-
 extern crate maud;
 
 use maud::html;
diff --git a/maud/tests/splices.rs b/maud/tests/splices.rs
index 0ae3203..adc5bf2 100644
--- a/maud/tests/splices.rs
+++ b/maud/tests/splices.rs
@@ -1,8 +1,5 @@
-#![feature(plugin)]
 #![feature(proc_macro_non_items)]
 
-#![plugin(maud_lints)]
-
 extern crate maud;
 
 use maud::html;
diff --git a/maud_extras/Cargo.toml b/maud_extras/Cargo.toml
index ffd0b40..a733309 100644
--- a/maud_extras/Cargo.toml
+++ b/maud_extras/Cargo.toml
@@ -10,7 +10,6 @@ description = "Extra bits and pieces for use in Maud templates."
 
 [dependencies]
 maud = { path = "../maud", features = ["iron"] }
-maud_lints = { path = "../maud_lints" }
 
 [lib]
 path = "lib.rs"
diff --git a/maud_extras/lib.rs b/maud_extras/lib.rs
index 59e2207..1f673cc 100644
--- a/maud_extras/lib.rs
+++ b/maud_extras/lib.rs
@@ -1,8 +1,5 @@
-#![feature(plugin)]
 #![feature(proc_macro_non_items)]
 
-#![plugin(maud_lints)]
-
 extern crate maud;
 
 use maud::{Markup, Render, html};
diff --git a/maud_lints/Cargo.toml b/maud_lints/Cargo.toml
deleted file mode 100644
index 227c4cb..0000000
--- a/maud_lints/Cargo.toml
+++ /dev/null
@@ -1,22 +0,0 @@
-[package]
-
-name = "maud_lints"
-# When releasing a new version, please update html_root_url in src/lib.rs
-version = "0.18.1"
-authors = ["Chris Wong <lambda.fairy@gmail.com>"]
-
-license = "MIT/Apache-2.0"
-documentation = "https://docs.rs/maud_lints/"
-homepage = "https://maud.lambda.xyz/"
-repository = "https://github.com/lfairy/maud"
-description = "Lint plugin for the Maud template engine."
-
-[dependencies]
-if_chain = "0.1"
-
-[lib]
-name = "maud_lints"
-plugin = true
-
-[badges]
-travis-ci = { repository = "lfairy/maud" }
diff --git a/maud_lints/src/doctype.rs b/maud_lints/src/doctype.rs
deleted file mode 100644
index f281f3d..0000000
--- a/maud_lints/src/doctype.rs
+++ /dev/null
@@ -1,41 +0,0 @@
-use rustc::hir::{Expr, ExprKind};
-use rustc::lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass};
-use syntax::ast::LitKind;
-
-use util::match_def_path;
-
-declare_lint! {
-    pub MAUD_DOCTYPE,
-    Warn,
-    "suggest using the maud::DOCTYPE constant"
-}
-
-pub struct Doctype;
-
-impl LintPass for Doctype {
-    fn get_lints(&self) -> LintArray {
-        lint_array![MAUD_DOCTYPE]
-    }
-}
-
-impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Doctype {
-    fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
-        if_chain! {
-            // It's a function call...
-            if let ExprKind::Call(ref path_expr, ref args) = expr.node;
-            // ... where the argument is a literal "<!doctype html>"
-            if let Some(first_arg) = args.first();
-            if let ExprKind::Lit(ref lit) = first_arg.node;
-            if let LitKind::Str(s, _) = lit.node;
-            if s.as_str().eq_ignore_ascii_case("<!doctype html>");
-            // ... and the callee is `maud::PreEscaped`
-            if let ExprKind::Path(ref qpath) = path_expr.node;
-            let def_id = cx.tables.qpath_def(qpath, path_expr.hir_id).def_id();
-            if match_def_path(cx, def_id, &["maud", "PreEscaped"]);
-            then {
-                cx.struct_span_lint(MAUD_DOCTYPE, expr.span,
-                                    "use `maud::DOCTYPE` instead").emit();
-            }
-        }
-    }
-}
diff --git a/maud_lints/src/lib.rs b/maud_lints/src/lib.rs
deleted file mode 100644
index 7c2c754..0000000
--- a/maud_lints/src/lib.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-#![feature(plugin_registrar)]
-#![feature(rustc_private)]
-#![feature(macro_at_most_once_rep)]
-#![recursion_limit = "1000"]  // if_chain
-
-#![doc(html_root_url = "https://docs.rs/maud_lints/0.18.1")]
-
-#[macro_use]
-extern crate if_chain;
-#[macro_use]
-extern crate rustc;
-extern crate rustc_plugin;
-extern crate syntax;
-extern crate syntax_pos;
-
-use rustc_plugin::Registry;
-
-#[macro_use]
-mod util;
-
-mod doctype;
-
-#[plugin_registrar]
-pub fn plugin_registrar(reg: &mut Registry) {
-    reg.register_late_lint_pass(Box::new(doctype::Doctype));
-    reg.register_lint_group("maud", vec![
-        doctype::MAUD_DOCTYPE,
-    ]);
-}
diff --git a/maud_lints/src/util.rs b/maud_lints/src/util.rs
deleted file mode 100644
index 6687f38..0000000
--- a/maud_lints/src/util.rs
+++ /dev/null
@@ -1,34 +0,0 @@
-//! Miscellaneous utilities for writing lints.
-//!
-//! Most of these are adapted from Clippy.
-
-use rustc::hir::def_id::DefId;
-use rustc::lint::LateContext;
-use rustc::ty;
-use syntax_pos::symbol::{LocalInternedString, Symbol};
-
-/// Check if a `DefId`'s path matches the given absolute type path usage.
-///
-/// # Examples
-/// ```rust,ignore
-/// match_def_path(cx, id, &["core", "option", "Option"])
-/// ```
-pub fn match_def_path(cx: &LateContext, def_id: DefId, path: &[&str]) -> bool {
-    struct AbsolutePathBuffer {
-        names: Vec<LocalInternedString>,
-    }
-
-    impl ty::item_path::ItemPathBuffer for AbsolutePathBuffer {
-        fn root_mode(&self) -> &ty::item_path::RootMode {
-            &ty::item_path::RootMode::Absolute
-        }
-
-        fn push(&mut self, text: &str) {
-            self.names.push(Symbol::intern(text).as_str());
-        }
-    }
-
-    let mut apb = AbsolutePathBuffer { names: vec![] };
-    cx.tcx.push_item_path(&mut apb, def_id);
-    apb.names.len() == path.len() && apb.names.iter().zip(path.iter()).all(|(a, &b)| &**a == b)
-}