]> git.lizzy.rs Git - rust.git/blob - tests/ui/lint/unused/issue-54180-unused-ref-field.rs
Auto merge of #106989 - clubby789:is-zero-num, r=scottmcm
[rust.git] / tests / ui / lint / unused / issue-54180-unused-ref-field.rs
1 // run-rustfix
2
3 #![deny(unused)]
4
5 pub struct S {
6     pub f1: i32,
7 }
8
9 pub struct Point {
10     pub x: i32,
11     pub y: i32,
12 }
13
14 pub enum E {
15     Variant { field: String }
16 }
17
18 pub fn foo(arg: &E) {
19     match arg {
20         E::Variant { ref field } => (), //~ ERROR unused variable
21     }
22 }
23
24 fn main() {
25     let s = S { f1: 123 };
26     let S { ref f1 } = s; //~ ERROR unused variable
27
28     let points = vec![Point { x: 1, y: 2 }];
29     let _: i32 = points.iter().map(|Point { x, y }| y).sum(); //~ ERROR unused variable
30
31     match (Point { x: 1, y: 2 }) {
32         Point { y, ref mut x } => y, //~ ERROR unused variable
33     };
34 }