diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-06-07 15:21:01 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-07 15:21:01 +0900 |
| commit | 7fcfe0568042467c57129a3a82d42e09719c439c (patch) | |
| tree | 172e4d63b1fc0404dde8ce84ed8235f8d25165df | |
| parent | ac6e239b3bdc7b05b160f8431f17f53ba4d84c86 (diff) | |
| parent | 63c8cbd3c94bb9c71cc7c23715a982582973fab1 (diff) | |
| download | rust-7fcfe0568042467c57129a3a82d42e09719c439c.tar.gz rust-7fcfe0568042467c57129a3a82d42e09719c439c.zip | |
Rollup merge of #85973 - LingMan:indentation, r=jyn514
Replace a `match` with an `if let` Seems like a better fit here and saves one level of indentation. `@rustbot` modify labels +C-cleanup +T-compiler
| -rw-r--r-- | compiler/rustc_mir/src/transform/remove_zsts.rs | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/compiler/rustc_mir/src/transform/remove_zsts.rs b/compiler/rustc_mir/src/transform/remove_zsts.rs index a0f225e6de6..40b1a8a2da9 100644 --- a/compiler/rustc_mir/src/transform/remove_zsts.rs +++ b/compiler/rustc_mir/src/transform/remove_zsts.rs @@ -16,32 +16,29 @@ impl<'tcx> MirPass<'tcx> for RemoveZsts { let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut(); for block in basic_blocks.iter_mut() { for statement in block.statements.iter_mut() { - match statement.kind { - StatementKind::Assign(box (place, _)) => { - let place_ty = place.ty(local_decls, tcx).ty; - if !maybe_zst(place_ty) { - continue; - } - let layout = match tcx.layout_of(param_env.and(place_ty)) { - Ok(layout) => layout, - Err(_) => continue, - }; - if !layout.is_zst() { - continue; - } - if involves_a_union(place, local_decls, tcx) { - continue; - } - if tcx.consider_optimizing(|| { - format!( - "RemoveZsts - Place: {:?} SourceInfo: {:?}", - place, statement.source_info - ) - }) { - statement.make_nop(); - } + if let StatementKind::Assign(box (place, _)) = statement.kind { + let place_ty = place.ty(local_decls, tcx).ty; + if !maybe_zst(place_ty) { + continue; + } + let layout = match tcx.layout_of(param_env.and(place_ty)) { + Ok(layout) => layout, + Err(_) => continue, + }; + if !layout.is_zst() { + continue; + } + if involves_a_union(place, local_decls, tcx) { + continue; + } + if tcx.consider_optimizing(|| { + format!( + "RemoveZsts - Place: {:?} SourceInfo: {:?}", + place, statement.source_info + ) + }) { + statement.make_nop(); } - _ => {} } } } |
