]> git.lizzy.rs Git - rust.git/blob - tests/ui/double_parens.rs
Auto merge of #3635 - matthiaskrgr:revert_random_state_3603, r=xfix
[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 #![warn(clippy::double_parens)]
11 #![allow(dead_code)]
12 fn dummy_fn<T>(_: T) {}
13
14 struct DummyStruct;
15
16 impl DummyStruct {
17     fn dummy_method<T>(self, _: T) {}
18 }
19
20 fn simple_double_parens() -> i32 {
21     ((0))
22 }
23
24 fn fn_double_parens() {
25     dummy_fn((0));
26 }
27
28 fn method_double_parens(x: DummyStruct) {
29     x.dummy_method((0));
30 }
31
32 fn tuple_double_parens() -> (i32, i32) {
33     ((1, 2))
34 }
35
36 fn unit_double_parens() {
37     (())
38 }
39
40 fn fn_tuple_ok() {
41     dummy_fn((1, 2));
42 }
43
44 fn method_tuple_ok(x: DummyStruct) {
45     x.dummy_method((1, 2));
46 }
47
48 fn fn_unit_ok() {
49     dummy_fn(());
50 }
51
52 fn method_unit_ok(x: DummyStruct) {
53     x.dummy_method(());
54 }
55
56 // Issue #3206
57 fn inside_macro() {
58     assert_eq!((1, 2), (1, 2), "Error");
59     assert_eq!(((1, 2)), (1, 2), "Error");
60 }
61
62 fn main() {}