Skip to content

Commit

Permalink
Add test for double_parens lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
theemathas committed Dec 28, 2016
1 parent 96d2483 commit e735287
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/compile-fail/double_parens.rs
@@ -0,0 +1,51 @@
#![feature(plugin)]
#![plugin(clippy)]

#![deny(double_parens)]
#![allow(dead_code)]

fn dummy_fn<T>(_: T) {}

struct DummyStruct;

impl DummyStruct {
fn dummy_method<T>(self, _: T) {}
}

fn simple_double_parens() -> i32 {
((0)) //~ERROR Consider removing unnecessary double parentheses
}

fn fn_double_parens() {
dummy_fn((0)); //~ERROR Consider removing unnecessary double parentheses
}

fn method_double_parens(x: DummyStruct) {
x.dummy_method((0)); //~ERROR Consider removing unnecessary double parentheses
}

fn tuple_double_parens() -> (i32, i32) {
((1, 2)) //~ERROR Consider removing unnecessary double parentheses
}

fn unit_double_parens() {
(()) //~ERROR Consider removing unnecessary double parentheses
}

fn fn_tuple_ok() {
dummy_fn((1, 2));
}

fn method_tuple_ok(x: DummyStruct) {
x.dummy_method((1, 2));
}

fn fn_unit_ok() {
dummy_fn(());
}

fn method_unit_ok(x: DummyStruct) {
x.dummy_method(());
}

fn main() {}

0 comments on commit e735287

Please sign in to comment.