mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-18 23:18:55 +00:00
Add skeleton for double_parens lint.
This commit is contained in:
parent
e7352877c5
commit
d76fa3dfd9
2 changed files with 38 additions and 0 deletions
35
clippy_lints/src/double_parens.rs
Normal file
35
clippy_lints/src/double_parens.rs
Normal 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.
|
||||||
|
}
|
||||||
|
}
|
|
@ -69,6 +69,7 @@ pub mod copies;
|
||||||
pub mod cyclomatic_complexity;
|
pub mod cyclomatic_complexity;
|
||||||
pub mod derive;
|
pub mod derive;
|
||||||
pub mod doc;
|
pub mod doc;
|
||||||
|
pub mod double_parens;
|
||||||
pub mod drop_ref;
|
pub mod drop_ref;
|
||||||
pub mod entry;
|
pub mod entry;
|
||||||
pub mod enum_clike;
|
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 if_let_redundant_pattern_matching::Pass);
|
||||||
reg.register_late_lint_pass(box partialeq_ne_impl::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 reference::Pass);
|
||||||
|
reg.register_early_lint_pass(box double_parens::DoubleParens);
|
||||||
|
|
||||||
reg.register_lint_group("clippy_restrictions", vec![
|
reg.register_lint_group("clippy_restrictions", vec![
|
||||||
arithmetic::FLOAT_ARITHMETIC,
|
arithmetic::FLOAT_ARITHMETIC,
|
||||||
|
@ -355,6 +357,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
|
||||||
derive::DERIVE_HASH_XOR_EQ,
|
derive::DERIVE_HASH_XOR_EQ,
|
||||||
derive::EXPL_IMPL_CLONE_ON_COPY,
|
derive::EXPL_IMPL_CLONE_ON_COPY,
|
||||||
doc::DOC_MARKDOWN,
|
doc::DOC_MARKDOWN,
|
||||||
|
double_parens::DOUBLE_PARENS,
|
||||||
drop_ref::DROP_REF,
|
drop_ref::DROP_REF,
|
||||||
entry::MAP_ENTRY,
|
entry::MAP_ENTRY,
|
||||||
enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
|
enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
|
||||||
|
|
Loading…
Add table
Reference in a new issue