Skip to content

Commit

Permalink
Rollup merge of rust-lang#74227 - erikdesjardins:layun, r=estebank
Browse files Browse the repository at this point in the history
Remove an unwrap in layout computation

A tiny improvement.
  • Loading branch information
Dylan-DPC committed Jul 14, 2020
2 parents 7adb86d + 23d7b3f commit 38fc369
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/librustc_middle/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() ||
Expand All @@ -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 {
Expand Down

0 comments on commit 38fc369

Please sign in to comment.