Skip to content

Commit 3a92966

Browse files
committed
submodules: update clippy from fc96aa0 to 341c96a
Changes: ```` rustup rust-lang/rust#60586 Add test for rust-lang#771. Clean up while_loop tests ````
1 parent 23c76da commit 3a92966

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

clippy_lints/src/utils/author.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ fn desugaring_name(des: hir::MatchSource) -> String {
684684
"MatchSource::IfLetDesugar {{ contains_else_clause: {} }}",
685685
contains_else_clause
686686
),
687+
hir::MatchSource::AwaitDesugar => "MatchSource::AwaitDesugar".to_string(),
687688
}
688689
}
689690

clippy_lints/src/utils/sugg.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ impl<'a> Sugg<'a> {
165165
| ast::ExprKind::Array(..)
166166
| ast::ExprKind::While(..)
167167
| ast::ExprKind::WhileLet(..)
168+
| ast::ExprKind::Await(..)
168169
| ast::ExprKind::Err => Sugg::NonParen(snippet),
169170
ast::ExprKind::Range(.., RangeLimits::HalfOpen) => Sugg::BinOp(AssocOp::DotDot, snippet),
170171
ast::ExprKind::Range(.., RangeLimits::Closed) => Sugg::BinOp(AssocOp::DotDotEq, snippet),

tests/ui/while_loop.rs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ fn refutable() {
169169
for &(1, 2, 3) in b {}
170170
for &Option::None in b.next() {}
171171
// */
172+
}
172173

174+
fn nested_loops() {
175+
let a = [42, 1337];
173176
let mut y = a.iter();
174177
loop {
175178
// x is reused, so don't lint here
@@ -189,7 +192,9 @@ fn refutable() {
189192
// use a for loop here
190193
}
191194
}
195+
}
192196

197+
fn issue1948() {
193198
// should not trigger clippy::while_let_loop lint because break passes an expression
194199
let a = Some(10);
195200
let b = loop {
@@ -199,31 +204,52 @@ fn refutable() {
199204
break None;
200205
}
201206
};
207+
}
202208

209+
fn issue1121() {
203210
use std::collections::HashSet;
204211
let mut values = HashSet::new();
205212
values.insert(1);
206213

207214
while let Some(&value) = values.iter().next() {
208215
values.remove(&value);
209216
}
217+
}
210218

219+
fn issue2965() {
211220
// This should not cause an ICE and suggest:
212221
//
213222
// for _ in values.iter() {}
214223
//
215-
// See #2965
224+
use std::collections::HashSet;
225+
let mut values = HashSet::new();
226+
values.insert(1);
227+
216228
while let Some(..) = values.iter().next() {
217229
values.remove(&1);
218230
}
231+
}
219232

220-
// Issue 3670
221-
{
222-
let array = [Some(0), None, Some(1)];
223-
let mut iter = array.iter();
233+
fn issue3670() {
234+
let array = [Some(0), None, Some(1)];
235+
let mut iter = array.iter();
224236

225-
while let Some(elem) = iter.next() {
226-
let _ = elem.or_else(|| *iter.next()?);
237+
while let Some(elem) = iter.next() {
238+
let _ = elem.or_else(|| *iter.next()?);
239+
}
240+
}
241+
242+
fn issue771() {
243+
let mut a = 100;
244+
let b = Some(true);
245+
loop {
246+
if a > 10 {
247+
break;
248+
}
249+
250+
match b {
251+
Some(_) => a = 0,
252+
None => break,
227253
}
228254
}
229255
}

tests/ui/while_loop.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ LL | loop {}
100100
= note: `-D clippy::empty-loop` implied by `-D warnings`
101101

102102
error: this loop could be written as a `for` loop
103-
--> $DIR/while_loop.rs:188:29
103+
--> $DIR/while_loop.rs:191:29
104104
|
105105
LL | while let Some(v) = y.next() {
106106
| ^^^^^^^^ help: try: `for v in y { .. }`
107107

108108
error: this loop could be written as a `for` loop
109-
--> $DIR/while_loop.rs:216:26
109+
--> $DIR/while_loop.rs:228:26
110110
|
111111
LL | while let Some(..) = values.iter().next() {
112112
| ^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in values.iter() { .. }`

0 commit comments

Comments
 (0)