rust/tests/ui/double_parens.rs

52 lines
641 B
Rust
Raw Normal View History

2017-09-18 12:47:33 +02:00
2016-12-28 19:53:33 +01:00
#![warn(double_parens)]
2016-12-28 19:53:33 +01:00
#![allow(dead_code)]
fn dummy_fn<T>(_: T) {}
struct DummyStruct;
impl DummyStruct {
fn dummy_method<T>(self, _: T) {}
}
fn simple_double_parens() -> i32 {
2017-02-08 14:58:07 +01:00
((0))
2016-12-28 19:53:33 +01:00
}
fn fn_double_parens() {
2017-02-08 14:58:07 +01:00
dummy_fn((0));
2016-12-28 19:53:33 +01:00
}
fn method_double_parens(x: DummyStruct) {
2017-02-08 14:58:07 +01:00
x.dummy_method((0));
2016-12-28 19:53:33 +01:00
}
fn tuple_double_parens() -> (i32, i32) {
2017-02-08 14:58:07 +01:00
((1, 2))
2016-12-28 19:53:33 +01:00
}
fn unit_double_parens() {
2017-02-08 14:58:07 +01:00
(())
2016-12-28 19:53:33 +01: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(());
}
fn main() {}