Remove maud_lints
It's undocumented, it doesn't do much, and it keeps breaking.
This commit is contained in:
parent
f3d967c020
commit
66ddbcac98
14 changed files with 1 additions and 150 deletions
|
@ -13,7 +13,7 @@ script:
|
||||||
- (cd benchmarks && cargo bench --no-run)
|
- (cd benchmarks && cargo bench --no-run)
|
||||||
- |
|
- |
|
||||||
CLIPPY_STATUS=0
|
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=$?
|
(cd $package && cargo clippy -- -D warnings) || CLIPPY_STATUS=$?
|
||||||
done
|
done
|
||||||
(exit $CLIPPY_STATUS)
|
(exit $CLIPPY_STATUS)
|
||||||
|
|
|
@ -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.
|
* 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].
|
* 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! ☺️
|
Have fun! ☺️
|
||||||
|
|
||||||
[easy issues]: https://github.com/lfairy/maud/issues?q=is%3Aissue+is%3Aopen+label%3A%22difficulty%3A+easy%22
|
[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
|
[existing test code]: https://github.com/lfairy/maud/tree/master/maud/tests
|
||||||
[proc_macro]: https://doc.rust-lang.org/nightly/proc_macro/
|
[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/
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ members = [
|
||||||
"maud_htmlescape",
|
"maud_htmlescape",
|
||||||
"maud_macros",
|
"maud_macros",
|
||||||
"maud",
|
"maud",
|
||||||
"maud_lints",
|
|
||||||
"maud_extras",
|
"maud_extras",
|
||||||
]
|
]
|
||||||
exclude = [
|
exclude = [
|
||||||
|
|
|
@ -19,9 +19,6 @@ iron = { version = ">= 0.5.1, < 0.7.0", optional = true }
|
||||||
rocket = { version = "0.3", optional = true }
|
rocket = { version = "0.3", optional = true }
|
||||||
actix-web = { version = ">= 0.6.12, < 0.8.0", 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]
|
[badges]
|
||||||
travis-ci = { repository = "lfairy/maud" }
|
travis-ci = { repository = "lfairy/maud" }
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
#![feature(plugin)]
|
|
||||||
#![feature(proc_macro_non_items)]
|
#![feature(proc_macro_non_items)]
|
||||||
|
|
||||||
#![plugin(maud_lints)]
|
|
||||||
|
|
||||||
extern crate maud;
|
extern crate maud;
|
||||||
|
|
||||||
use maud::{Markup, html};
|
use maud::{Markup, html};
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
#![feature(plugin)]
|
|
||||||
#![feature(proc_macro_non_items)]
|
#![feature(proc_macro_non_items)]
|
||||||
|
|
||||||
#![plugin(maud_lints)]
|
|
||||||
|
|
||||||
extern crate maud;
|
extern crate maud;
|
||||||
|
|
||||||
use maud::html;
|
use maud::html;
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
#![feature(plugin)]
|
|
||||||
#![feature(proc_macro_non_items)]
|
#![feature(proc_macro_non_items)]
|
||||||
|
|
||||||
#![plugin(maud_lints)]
|
|
||||||
|
|
||||||
extern crate maud;
|
extern crate maud;
|
||||||
|
|
||||||
use maud::html;
|
use maud::html;
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
#![feature(plugin)]
|
|
||||||
#![feature(proc_macro_non_items)]
|
#![feature(proc_macro_non_items)]
|
||||||
|
|
||||||
#![plugin(maud_lints)]
|
|
||||||
|
|
||||||
extern crate maud;
|
extern crate maud;
|
||||||
|
|
||||||
use maud::html;
|
use maud::html;
|
||||||
|
|
|
@ -10,7 +10,6 @@ description = "Extra bits and pieces for use in Maud templates."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
maud = { path = "../maud", features = ["iron"] }
|
maud = { path = "../maud", features = ["iron"] }
|
||||||
maud_lints = { path = "../maud_lints" }
|
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
#![feature(plugin)]
|
|
||||||
#![feature(proc_macro_non_items)]
|
#![feature(proc_macro_non_items)]
|
||||||
|
|
||||||
#![plugin(maud_lints)]
|
|
||||||
|
|
||||||
extern crate maud;
|
extern crate maud;
|
||||||
|
|
||||||
use maud::{Markup, Render, html};
|
use maud::{Markup, Render, html};
|
||||||
|
|
|
@ -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" }
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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,
|
|
||||||
]);
|
|
||||||
}
|
|
|
@ -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)
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue