Add skeleton for double_parens lint.

This commit is contained in:
Theemathas Chirananthavat 2016-12-28 10:54:23 -08:00
parent e7352877c5
commit d76fa3dfd9
2 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,35 @@
use syntax::ast::*;
use rustc::lint::{EarlyContext, LintArray, LintPass, EarlyLintPass};
/// **What it does:** Checks for unnecessary double parentheses.
///
/// **Why is this bad?** This makes code harder to read and might indicate a
/// mistake.
///
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ((0))
/// foo((0))
/// ((1, 2))
/// ```
declare_lint! {
pub DOUBLE_PARENS, Warn,
"Warn on unnecessary double parentheses"
}
#[derive(Copy, Clone)]
pub struct DoubleParens;
impl LintPass for DoubleParens {
fn get_lints(&self) -> LintArray {
lint_array!(DOUBLE_PARENS)
}
}
impl EarlyLintPass for DoubleParens {
fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) {
// insert check here.
}
}

View file

@ -69,6 +69,7 @@ pub mod copies;
pub mod cyclomatic_complexity;
pub mod derive;
pub mod doc;
pub mod double_parens;
pub mod drop_ref;
pub mod entry;
pub mod enum_clike;
@ -283,6 +284,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
reg.register_late_lint_pass(box if_let_redundant_pattern_matching::Pass);
reg.register_late_lint_pass(box partialeq_ne_impl::Pass);
reg.register_early_lint_pass(box reference::Pass);
reg.register_early_lint_pass(box double_parens::DoubleParens);
reg.register_lint_group("clippy_restrictions", vec![
arithmetic::FLOAT_ARITHMETIC,
@ -355,6 +357,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
derive::DERIVE_HASH_XOR_EQ,
derive::EXPL_IMPL_CLONE_ON_COPY,
doc::DOC_MARKDOWN,
double_parens::DOUBLE_PARENS,
drop_ref::DROP_REF,
entry::MAP_ENTRY,
enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,