Skip to content

Commit 3e70c8e

Browse files
committed
Use simple 'for i in x' loops instead of 'while let Some(x) = x.next()' loops on iterators. (clippy::while_let_on_iterator)
1 parent c2bbe33 commit 3e70c8e

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/librustc_mir/interpret/terminator.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
311311
// taking into account the `spread_arg`. If we could write
312312
// this is a single iterator (that handles `spread_arg`), then
313313
// `pass_argument` would be the loop body. It takes care to
314-
// not advance `caller_iter` for ZSTs.
315-
let mut locals_iter = body.args_iter();
316-
while let Some(local) = locals_iter.next() {
314+
// not advance `caller_iter` for ZSTs
315+
for local in body.args_iter() {
317316
let dest = self.eval_place(&mir::Place::from(local))?;
318317
if Some(local) == body.spread_arg {
319318
// Must be a tuple

src/librustdoc/html/markdown.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -869,12 +869,8 @@ pub fn plain_summary_line(md: &str) -> String {
869869
}
870870
}
871871
let mut s = String::with_capacity(md.len() * 3 / 2);
872-
let mut p = ParserWrapper { inner: Parser::new(md), is_in: 0, is_first: true };
873-
while let Some(t) = p.next() {
874-
if !t.is_empty() {
875-
s.push_str(&t);
876-
}
877-
}
872+
let p = ParserWrapper { inner: Parser::new(md), is_in: 0, is_first: true };
873+
p.into_iter().filter(|t| !t.is_empty()).for_each(|i| s.push_str(&i));
878874
s
879875
}
880876

0 commit comments

Comments
 (0)