fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
6.1 KiB202 linesraw
1error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
2  --> $DIR/single_match.rs:14:5
3   |
4LL | /     match x {
5LL | |         Some(y) => {
6LL | |             println!("{:?}", y);
7LL | |         },
8LL | |         _ => (),
9LL | |     };
10   | |_____^
11   |
12   = note: `-D clippy::single-match` implied by `-D warnings`
13   = help: to override `-D warnings` add `#[allow(clippy::single_match)]`
14help: try
15   |
16LL ~     if let Some(y) = x {
17LL +         println!("{:?}", y);
18LL ~     };
19   |
20
21error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
22  --> $DIR/single_match.rs:22:5
23   |
24LL | /     match x {
25LL | |         // Note the missing block braces.
26LL | |         // We suggest `if let Some(y) = x { .. }` because the macro
27LL | |         // is expanded before we can do anything.
28LL | |         Some(y) => println!("{:?}", y),
29LL | |         _ => (),
30LL | |     }
31   | |_____^ help: try: `if let Some(y) = x { println!("{:?}", y) }`
32
33error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
34  --> $DIR/single_match.rs:31:5
35   |
36LL | /     match z {
37LL | |         (2..=3, 7..=9) => dummy(),
38LL | |         _ => {},
39LL | |     };
40   | |_____^ help: try: `if let (2..=3, 7..=9) = z { dummy() }`
41
42error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
43  --> $DIR/single_match.rs:60:5
44   |
45LL | /     match x {
46LL | |         Some(y) => dummy(),
47LL | |         None => (),
48LL | |     };
49   | |_____^ help: try: `if let Some(y) = x { dummy() }`
50
51error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
52  --> $DIR/single_match.rs:65:5
53   |
54LL | /     match y {
55LL | |         Ok(y) => dummy(),
56LL | |         Err(..) => (),
57LL | |     };
58   | |_____^ help: try: `if let Ok(y) = y { dummy() }`
59
60error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
61  --> $DIR/single_match.rs:72:5
62   |
63LL | /     match c {
64LL | |         Cow::Borrowed(..) => dummy(),
65LL | |         Cow::Owned(..) => (),
66LL | |     };
67   | |_____^ help: try: `if let Cow::Borrowed(..) = c { dummy() }`
68
69error: you seem to be trying to use `match` for an equality check. Consider using `if`
70  --> $DIR/single_match.rs:93:5
71   |
72LL | /     match x {
73LL | |         "test" => println!(),
74LL | |         _ => (),
75LL | |     }
76   | |_____^ help: try: `if x == "test" { println!() }`
77
78error: you seem to be trying to use `match` for an equality check. Consider using `if`
79  --> $DIR/single_match.rs:106:5
80   |
81LL | /     match x {
82LL | |         Foo::A => println!(),
83LL | |         _ => (),
84LL | |     }
85   | |_____^ help: try: `if x == Foo::A { println!() }`
86
87error: you seem to be trying to use `match` for an equality check. Consider using `if`
88  --> $DIR/single_match.rs:112:5
89   |
90LL | /     match x {
91LL | |         FOO_C => println!(),
92LL | |         _ => (),
93LL | |     }
94   | |_____^ help: try: `if x == FOO_C { println!() }`
95
96error: you seem to be trying to use `match` for an equality check. Consider using `if`
97  --> $DIR/single_match.rs:117:5
98   |
99LL | /     match &&x {
100LL | |         Foo::A => println!(),
101LL | |         _ => (),
102LL | |     }
103   | |_____^ help: try: `if x == Foo::A { println!() }`
104
105error: you seem to be trying to use `match` for an equality check. Consider using `if`
106  --> $DIR/single_match.rs:123:5
107   |
108LL | /     match &x {
109LL | |         Foo::A => println!(),
110LL | |         _ => (),
111LL | |     }
112   | |_____^ help: try: `if x == &Foo::A { println!() }`
113
114error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
115  --> $DIR/single_match.rs:140:5
116   |
117LL | /     match x {
118LL | |         Bar::A => println!(),
119LL | |         _ => (),
120LL | |     }
121   | |_____^ help: try: `if let Bar::A = x { println!() }`
122
123error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
124  --> $DIR/single_match.rs:148:5
125   |
126LL | /     match x {
127LL | |         None => println!(),
128LL | |         _ => (),
129LL | |     };
130   | |_____^ help: try: `if let None = x { println!() }`
131
132error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
133  --> $DIR/single_match.rs:170:5
134   |
135LL | /     match x {
136LL | |         (Some(_), _) => {},
137LL | |         (None, _) => {},
138LL | |     }
139   | |_____^ help: try: `if let (Some(_), _) = x {}`
140
141error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
142  --> $DIR/single_match.rs:176:5
143   |
144LL | /     match x {
145LL | |         (Some(E::V), _) => todo!(),
146LL | |         (_, _) => {},
147LL | |     }
148   | |_____^ help: try: `if let (Some(E::V), _) = x { todo!() }`
149
150error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
151  --> $DIR/single_match.rs:182:5
152   |
153LL | /     match (Some(42), Some(E::V), Some(42)) {
154LL | |         (.., Some(E::V), _) => {},
155LL | |         (..) => {},
156LL | |     }
157   | |_____^ help: try: `if let (.., Some(E::V), _) = (Some(42), Some(E::V), Some(42)) {}`
158
159error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
160  --> $DIR/single_match.rs:254:5
161   |
162LL | /     match bar {
163LL | |         Some(v) => unsafe {
164LL | |             let r = &v as *const i32;
165LL | |             println!("{}", *r);
166LL | |         },
167LL | |         _ => {},
168LL | |     }
169   | |_____^
170   |
171help: try
172   |
173LL ~     if let Some(v) = bar { unsafe {
174LL +         let r = &v as *const i32;
175LL +         println!("{}", *r);
176LL +     } }
177   |
178
179error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
180  --> $DIR/single_match.rs:262:5
181   |
182LL | /     match bar {
183LL | |         #[rustfmt::skip]
184LL | |         Some(v) => {
185LL | |             unsafe {
186...  |
187LL | |         _ => {},
188LL | |     }
189   | |_____^
190   |
191help: try
192   |
193LL ~     if let Some(v) = bar {
194LL +         unsafe {
195LL +             let r = &v as *const i32;
196LL +             println!("{}", *r);
197LL +         }
198LL +     }
199   |
200
201error: aborting due to 18 previous errors
202