]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/try-removing-the-field.rs
Rollup merge of #106751 - clubby789:const-intrinsic, r=GuillaumeGomez
[rust.git] / tests / ui / suggestions / try-removing-the-field.rs
1 // run-pass
2
3 #![allow(dead_code)]
4
5 struct Foo {
6     foo: i32,
7     bar: (),
8     baz: (),
9 }
10
11 fn use_foo(x: Foo) -> i32 {
12     let Foo { foo, bar, .. } = x; //~ WARNING unused variable: `bar`
13                                   //~| help: try removing the field
14     return foo;
15 }
16
17 // issue #105028, suggest removing the field only for shorthand
18 fn use_match(x: Foo) {
19     match x {
20         Foo { foo: unused, .. } => { //~ WARNING unused variable
21                                      //~| help: if this is intentional, prefix it with an underscore
22         }
23     }
24
25     match x {
26         Foo { foo, .. } => { //~ WARNING unused variable
27                              //~| help: try removing the field
28         }
29     }
30 }
31
32 fn main() {}