fork/rust

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

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

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