2018-07-28 10:34:52 -05:00
|
|
|
#![warn(clippy::double_parens)]
|
2020-10-23 15:16:59 -05:00
|
|
|
#![allow(dead_code, clippy::eq_op)]
|
2019-02-28 00:02:45 -06:00
|
|
|
#![feature(custom_inner_attributes)]
|
|
|
|
#![rustfmt::skip]
|
|
|
|
|
2016-12-28 12:53:33 -06:00
|
|
|
fn dummy_fn<T>(_: T) {}
|
|
|
|
|
|
|
|
struct DummyStruct;
|
|
|
|
|
|
|
|
impl DummyStruct {
|
|
|
|
fn dummy_method<T>(self, _: T) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn simple_double_parens() -> i32 {
|
2017-02-08 07:58:07 -06:00
|
|
|
((0))
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: consider removing unnecessary double parentheses
|
|
|
|
//~| NOTE: `-D clippy::double-parens` implied by `-D warnings`
|
2016-12-28 12:53:33 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn fn_double_parens() {
|
2017-02-08 07:58:07 -06:00
|
|
|
dummy_fn((0));
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: consider removing unnecessary double parentheses
|
2016-12-28 12:53:33 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn method_double_parens(x: DummyStruct) {
|
2017-02-08 07:58:07 -06:00
|
|
|
x.dummy_method((0));
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: consider removing unnecessary double parentheses
|
2016-12-28 12:53:33 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn tuple_double_parens() -> (i32, i32) {
|
2017-02-08 07:58:07 -06:00
|
|
|
((1, 2))
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: consider removing unnecessary double parentheses
|
2016-12-28 12:53:33 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn unit_double_parens() {
|
2017-02-08 07:58:07 -06:00
|
|
|
(())
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: consider removing unnecessary double parentheses
|
2016-12-28 12:53:33 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
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(());
|
|
|
|
}
|
|
|
|
|
2018-09-22 10:20:34 -05:00
|
|
|
// Issue #3206
|
|
|
|
fn inside_macro() {
|
|
|
|
assert_eq!((1, 2), (1, 2), "Error");
|
|
|
|
assert_eq!(((1, 2)), (1, 2), "Error");
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: consider removing unnecessary double parentheses
|
2018-09-22 10:20:34 -05:00
|
|
|
}
|
|
|
|
|
2016-12-28 12:53:33 -06:00
|
|
|
fn main() {}
|