diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-14 07:39:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-14 07:39:06 -0700 |
| commit | 98ceb9027972233f46ad001990b725e18c5a5a60 (patch) | |
| tree | a773f2f958ebdd258dbd9c7a3ec2b621e1e39505 | |
| parent | 063bbc485eca78d734b4987688b9277b2bc0bc6e (diff) | |
| parent | 23d7b3f6f1a345ad95f0812c85613627164b6c39 (diff) | |
| download | rust-98ceb9027972233f46ad001990b725e18c5a5a60.tar.gz rust-98ceb9027972233f46ad001990b725e18c5a5a60.zip | |
Rollup merge of #74227 - erikdesjardins:layun, r=estebank
Remove an unwrap in layout computation A tiny improvement.
| -rw-r--r-- | src/librustc_middle/ty/layout.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/librustc_middle/ty/layout.rs b/src/librustc_middle/ty/layout.rs index 66ad923b8c0..82daae7d921 100644 --- a/src/librustc_middle/ty/layout.rs +++ b/src/librustc_middle/ty/layout.rs @@ -774,12 +774,12 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { (present_variants.next(), present_variants.next()) }; let present_first = match present_first { - present_first @ Some(_) => present_first, + Some(present_first) => present_first, // Uninhabited because it has no variants, or only absent ones. None if def.is_enum() => return tcx.layout_raw(param_env.and(tcx.types.never)), // If it's a struct, still compute a layout so that we can still compute the // field offsets. - None => Some(VariantIdx::new(0)), + None => VariantIdx::new(0), }; let is_struct = !def.is_enum() || @@ -791,7 +791,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { // Struct, or univariant enum equivalent to a struct. // (Typechecking will reject discriminant-sizing attrs.) - let v = present_first.unwrap(); + let v = present_first; let kind = if def.is_enum() || variants[v].is_empty() { StructKind::AlwaysSized } else { |
