]> git.lizzy.rs Git - rust.git/blob - tests/ui/double_parens.rs
Add license header to Rust files
[rust.git] / tests / ui / double_parens.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10
11 #![feature(tool_lints)]
12
13
14 #![warn(clippy::double_parens)]
15 #![allow(dead_code)]
16
17 fn dummy_fn<T>(_: T) {}
18
19 struct DummyStruct;
20
21 impl DummyStruct {
22     fn dummy_method<T>(self, _: T) {}
23 }
24
25 fn simple_double_parens() -> i32 {
26     ((0))
27 }
28
29 fn fn_double_parens() {
30     dummy_fn((0));
31 }
32
33 fn method_double_parens(x: DummyStruct) {
34     x.dummy_method((0));
35 }
36
37 fn tuple_double_parens() -> (i32, i32) {
38     ((1, 2))
39 }
40
41 fn unit_double_parens() {
42     (())
43 }
44
45 fn fn_tuple_ok() {
46     dummy_fn((1, 2));
47 }
48
49 fn method_tuple_ok(x: DummyStruct) {
50     x.dummy_method((1, 2));
51 }
52
53 fn fn_unit_ok() {
54     dummy_fn(());
55 }
56
57 fn method_unit_ok(x: DummyStruct) {
58     x.dummy_method(());
59 }
60
61 // Issue #3206
62 fn inside_macro() {
63     assert_eq!((1, 2), (1, 2), "Error");
64     assert_eq!(((1, 2)), (1, 2), "Error");
65 }
66
67 fn main() {}