]> git.lizzy.rs Git - rust.git/blob - tests/ui/rest_pat_in_fully_bound_structs.rs
Auto merge of #9684 - kraktus:ref_option_ref, r=xFrednet
[rust.git] / tests / ui / rest_pat_in_fully_bound_structs.rs
1 #![warn(clippy::rest_pat_in_fully_bound_structs)]
2
3 struct A {
4     a: i32,
5     b: i64,
6     c: &'static str,
7 }
8
9 macro_rules! foo {
10     ($param:expr) => {
11         match $param {
12             A { a: 0, b: 0, c: "", .. } => {},
13             _ => {},
14         }
15     };
16 }
17
18 fn main() {
19     let a_struct = A { a: 5, b: 42, c: "A" };
20
21     match a_struct {
22         A { a: 5, b: 42, c: "", .. } => {}, // Lint
23         A { a: 0, b: 0, c: "", .. } => {},  // Lint
24         _ => {},
25     }
26
27     match a_struct {
28         A { a: 5, b: 42, .. } => {},
29         A { a: 0, b: 0, c: "", .. } => {}, // Lint
30         _ => {},
31     }
32
33     // No lint
34     match a_struct {
35         A { a: 5, .. } => {},
36         A { a: 0, b: 0, .. } => {},
37         _ => {},
38     }
39
40     // No lint
41     foo!(a_struct);
42
43     #[non_exhaustive]
44     struct B {
45         a: u32,
46         b: u32,
47         c: u64,
48     }
49
50     let b_struct = B { a: 5, b: 42, c: 342 };
51
52     match b_struct {
53         B { a: 5, b: 42, .. } => {},
54         B { a: 0, b: 0, c: 128, .. } => {}, // No Lint
55         _ => {},
56     }
57 }