Replace a match
with an if let
Seems like a better fit here and saves one level of indentation.
This commit is contained in:
parent
835150e702
commit
63c8cbd3c9
1 changed files with 22 additions and 25 deletions
|
@ -16,32 +16,29 @@ impl<'tcx> MirPass<'tcx> for RemoveZsts {
|
||||||
let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();
|
let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();
|
||||||
for block in basic_blocks.iter_mut() {
|
for block in basic_blocks.iter_mut() {
|
||||||
for statement in block.statements.iter_mut() {
|
for statement in block.statements.iter_mut() {
|
||||||
match statement.kind {
|
if let StatementKind::Assign(box (place, _)) = statement.kind {
|
||||||
StatementKind::Assign(box (place, _)) => {
|
let place_ty = place.ty(local_decls, tcx).ty;
|
||||||
let place_ty = place.ty(local_decls, tcx).ty;
|
if !maybe_zst(place_ty) {
|
||||||
if !maybe_zst(place_ty) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
let layout = match tcx.layout_of(param_env.and(place_ty)) {
|
||||||
let layout = match tcx.layout_of(param_env.and(place_ty)) {
|
Ok(layout) => layout,
|
||||||
Ok(layout) => layout,
|
Err(_) => continue,
|
||||||
Err(_) => continue,
|
};
|
||||||
};
|
if !layout.is_zst() {
|
||||||
if !layout.is_zst() {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
if involves_a_union(place, local_decls, tcx) {
|
||||||
if involves_a_union(place, local_decls, tcx) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
if tcx.consider_optimizing(|| {
|
||||||
if tcx.consider_optimizing(|| {
|
format!(
|
||||||
format!(
|
"RemoveZsts - Place: {:?} SourceInfo: {:?}",
|
||||||
"RemoveZsts - Place: {:?} SourceInfo: {:?}",
|
place, statement.source_info
|
||||||
place, statement.source_info
|
)
|
||||||
)
|
}) {
|
||||||
}) {
|
statement.make_nop();
|
||||||
statement.make_nop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue