parent
f858430b51
commit
aa2c586e36
2 changed files with 11 additions and 11 deletions
maud_macros/src/lints
|
@ -5,20 +5,20 @@ use super::util::match_def_path;
|
||||||
use syntax::ast::LitKind;
|
use syntax::ast::LitKind;
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
pub MAUD_DOCTYPE_HTML,
|
pub MAUD_DOCTYPE,
|
||||||
Warn,
|
Warn,
|
||||||
"suggest using the maud::DOCTYPE_HTML constant"
|
"suggest using the maud::DOCTYPE constant"
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DoctypeHtml;
|
pub struct Doctype;
|
||||||
|
|
||||||
impl LintPass for DoctypeHtml {
|
impl LintPass for Doctype {
|
||||||
fn get_lints(&self) -> LintArray {
|
fn get_lints(&self) -> LintArray {
|
||||||
lint_array![MAUD_DOCTYPE_HTML]
|
lint_array![MAUD_DOCTYPE]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DoctypeHtml {
|
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Doctype {
|
||||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||||
if_chain! {
|
if_chain! {
|
||||||
// It's a function call...
|
// It's a function call...
|
||||||
|
@ -33,8 +33,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DoctypeHtml {
|
||||||
let def_id = cx.tables.qpath_def(qpath, path_expr.id).def_id();
|
let def_id = cx.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 {
|
then {
|
||||||
cx.struct_span_lint(MAUD_DOCTYPE_HTML, expr.span,
|
cx.struct_span_lint(MAUD_DOCTYPE, expr.span,
|
||||||
"use `maud::DOCTYPE_HTML` instead").emit();
|
"use `maud::DOCTYPE` instead").emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,12 +3,12 @@ use rustc_plugin::Registry;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
pub mod doctype_html;
|
mod doctype;
|
||||||
|
|
||||||
pub fn register_lints(reg: &mut Registry) {
|
pub fn register_lints(reg: &mut Registry) {
|
||||||
reg.register_late_lint_pass(Box::new(doctype_html::DoctypeHtml));
|
reg.register_late_lint_pass(Box::new(doctype::Doctype));
|
||||||
|
|
||||||
reg.register_lint_group("maud", vec![
|
reg.register_lint_group("maud", vec![
|
||||||
doctype_html::MAUD_DOCTYPE_HTML,
|
doctype::MAUD_DOCTYPE,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue