Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/mir/borrowck.rs')
| -rw-r--r-- | crates/hir-ty/src/mir/borrowck.rs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/crates/hir-ty/src/mir/borrowck.rs b/crates/hir-ty/src/mir/borrowck.rs index 78d94bafc0..186921ae7a 100644 --- a/crates/hir-ty/src/mir/borrowck.rs +++ b/crates/hir-ty/src/mir/borrowck.rs @@ -53,7 +53,7 @@ fn all_mir_bodies( match db.mir_body_for_closure(c) { Ok(body) => { cb(body.clone()); - body.closures.iter().map(|&it| for_closure(db, it, cb)).collect() + body.closures.iter().try_for_each(|&it| for_closure(db, it, cb)) } Err(e) => Err(e), } @@ -61,7 +61,7 @@ fn all_mir_bodies( match db.mir_body(def) { Ok(body) => { cb(body.clone()); - body.closures.iter().map(|&it| for_closure(db, it, &mut cb)).collect() + body.closures.iter().try_for_each(|&it| for_closure(db, it, &mut cb)) } Err(e) => Err(e), } @@ -257,7 +257,7 @@ fn ever_initialized_map( for statement in &block.statements { match &statement.kind { StatementKind::Assign(p, _) => { - if p.projection.lookup(&body.projection_store).len() == 0 && p.local == l { + if p.projection.lookup(&body.projection_store).is_empty() && p.local == l { is_ever_initialized = true; } } @@ -295,21 +295,15 @@ fn ever_initialized_map( | TerminatorKind::Return | TerminatorKind::Unreachable => (), TerminatorKind::Call { target, cleanup, destination, .. } => { - if destination.projection.lookup(&body.projection_store).len() == 0 + if destination.projection.lookup(&body.projection_store).is_empty() && destination.local == l { is_ever_initialized = true; } - target - .into_iter() - .chain(cleanup.into_iter()) - .for_each(|&it| process(it, is_ever_initialized)); + target.iter().chain(cleanup).for_each(|&it| process(it, is_ever_initialized)); } TerminatorKind::Drop { target, unwind, place: _ } => { - iter::once(target) - .into_iter() - .chain(unwind.into_iter()) - .for_each(|&it| process(it, is_ever_initialized)); + iter::once(target).chain(unwind).for_each(|&it| process(it, is_ever_initialized)); } TerminatorKind::DropAndReplace { .. } | TerminatorKind::Assert { .. } @@ -318,7 +312,6 @@ fn ever_initialized_map( | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } => { never!("We don't emit these MIR terminators yet"); - () } } } @@ -452,7 +445,7 @@ fn mutability_of_locals( for arg in args.iter() { record_usage_for_operand(arg, &mut result); } - if destination.projection.lookup(&body.projection_store).len() == 0 { + if destination.projection.lookup(&body.projection_store).is_empty() { if ever_init_map.get(destination.local).copied().unwrap_or_default() { push_mut_span(destination.local, MirSpan::Unknown, &mut result); } else { |