Skip to content

Commit 8cbcc89

Browse files
committed
Fix ICE caused by non_exaustive_omitted_patterns struct lint
1 parent f03eb6b commit 8cbcc89

File tree

1 file changed

+7
-3
lines changed
  • compiler/rustc_typeck/src/check

1 file changed

+7
-3
lines changed

compiler/rustc_typeck/src/check/pat.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1286,8 +1286,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12861286
field.vis.is_accessible_from(tcx.parent_module(pat.hir_id).to_def_id(), tcx)
12871287
})
12881288
.collect();
1289-
if non_exhaustive {
1290-
self.non_exhaustive_reachable_pattern(pat, &accessible_unmentioned_fields, adt_ty)
1289+
if non_exhaustive && !accessible_unmentioned_fields.is_empty() {
1290+
self.lint_non_exhaustive_omitted_patterns(
1291+
pat,
1292+
&accessible_unmentioned_fields,
1293+
adt_ty,
1294+
)
12911295
} else if !etc {
12921296
if accessible_unmentioned_fields.is_empty() {
12931297
unmentioned_err = Some(self.error_no_accessible_fields(pat, fields));
@@ -1626,7 +1630,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16261630
/// is not exhaustive enough.
16271631
///
16281632
/// Nb: the partner lint for enums lives in `compiler/rustc_mir_build/src/thir/pattern/usefulness.rs`.
1629-
fn non_exhaustive_reachable_pattern(
1633+
fn lint_non_exhaustive_omitted_patterns(
16301634
&self,
16311635
pat: &Pat<'_>,
16321636
unmentioned_fields: &[(&ty::FieldDef, Ident)],

0 commit comments

Comments
 (0)