Skip to content

Commit 92e470a

Browse files
committed
Move constructor into the branch that actually uses it
1 parent ea68ce7 commit 92e470a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

compiler/rustc_mir_build/src/thir/pattern/usefulness.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -806,11 +806,6 @@ fn is_useful<'p, 'tcx>(
806806

807807
debug_assert!(rows.iter().all(|r| r.len() == v.len()));
808808

809-
let ty = v.head().ty();
810-
let is_non_exhaustive = cx.is_foreign_non_exhaustive_enum(ty);
811-
debug!("v.head: {:?}, v.span: {:?}", v.head(), v.head().span());
812-
let pcx = PatCtxt { cx, ty, span: v.head().span(), is_top_level, is_non_exhaustive };
813-
814809
// If the first pattern is an or-pattern, expand it.
815810
let mut ret = Usefulness::new_not_useful(witness_preference);
816811
if v.head().is_or_pat() {
@@ -832,6 +827,11 @@ fn is_useful<'p, 'tcx>(
832827
}
833828
}
834829
} else {
830+
let ty = v.head().ty();
831+
let is_non_exhaustive = cx.is_foreign_non_exhaustive_enum(ty);
832+
debug!("v.head: {:?}, v.span: {:?}", v.head(), v.head().span());
833+
let pcx = PatCtxt { cx, ty, span: v.head().span(), is_top_level, is_non_exhaustive };
834+
835835
let v_ctor = v.head().ctor();
836836
debug!(?v_ctor);
837837
if let Constructor::IntRange(ctor_range) = &v_ctor {

0 commit comments

Comments
 (0)