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.rs34
1 files changed, 12 insertions, 22 deletions
diff --git a/crates/hir-ty/src/mir/borrowck.rs b/crates/hir-ty/src/mir/borrowck.rs
index e79c87a02f..f7d043fc4e 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),
}
@@ -159,7 +159,7 @@ fn moved_out_of_ref(db: &dyn HirDatabase, body: &MirBody) -> Vec<MovedOutOfRef>
| TerminatorKind::FalseUnwind { .. }
| TerminatorKind::Goto { .. }
| TerminatorKind::UnwindResume
- | TerminatorKind::GeneratorDrop
+ | TerminatorKind::CoroutineDrop
| TerminatorKind::Abort
| TerminatorKind::Return
| TerminatorKind::Unreachable
@@ -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,30 +295,23 @@ 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 { .. }
| TerminatorKind::Yield { .. }
- | TerminatorKind::GeneratorDrop
+ | TerminatorKind::CoroutineDrop
| TerminatorKind::FalseEdge { .. }
| TerminatorKind::FalseUnwind { .. } => {
never!("We don't emit these MIR terminators yet");
- ()
}
}
}
@@ -346,11 +339,8 @@ fn push_mut_span(local: LocalId, span: MirSpan, result: &mut ArenaMap<LocalId, M
}
fn record_usage(local: LocalId, result: &mut ArenaMap<LocalId, MutabilityReason>) {
- match &mut result[local] {
- it @ MutabilityReason::Unused => {
- *it = MutabilityReason::Not;
- }
- _ => (),
+ if let it @ MutabilityReason::Unused = &mut result[local] {
+ *it = MutabilityReason::Not;
};
}
@@ -439,7 +429,7 @@ fn mutability_of_locals(
| TerminatorKind::Unreachable
| TerminatorKind::FalseEdge { .. }
| TerminatorKind::FalseUnwind { .. }
- | TerminatorKind::GeneratorDrop
+ | TerminatorKind::CoroutineDrop
| TerminatorKind::Drop { .. }
| TerminatorKind::DropAndReplace { .. }
| TerminatorKind::Assert { .. }
@@ -452,7 +442,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 {