Skip to content

Commit 98ceb90

Browse files
authored
Rollup merge of #74227 - erikdesjardins:layun, r=estebank
Remove an unwrap in layout computation A tiny improvement.
2 parents 063bbc4 + 23d7b3f commit 98ceb90

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/librustc_middle/ty/layout.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -774,12 +774,12 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
774774
(present_variants.next(), present_variants.next())
775775
};
776776
let present_first = match present_first {
777-
present_first @ Some(_) => present_first,
777+
Some(present_first) => present_first,
778778
// Uninhabited because it has no variants, or only absent ones.
779779
None if def.is_enum() => return tcx.layout_raw(param_env.and(tcx.types.never)),
780780
// If it's a struct, still compute a layout so that we can still compute the
781781
// field offsets.
782-
None => Some(VariantIdx::new(0)),
782+
None => VariantIdx::new(0),
783783
};
784784

785785
let is_struct = !def.is_enum() ||
@@ -791,7 +791,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
791791
// Struct, or univariant enum equivalent to a struct.
792792
// (Typechecking will reject discriminant-sizing attrs.)
793793

794-
let v = present_first.unwrap();
794+
let v = present_first;
795795
let kind = if def.is_enum() || variants[v].is_empty() {
796796
StructKind::AlwaysSized
797797
} else {

0 commit comments

Comments
 (0)