about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDevin Ragotzy <devin.ragotzy@gmail.com>2021-10-01 21:20:00 -0400
committerDevin Ragotzy <devin.ragotzy@gmail.com>2021-10-02 17:50:53 -0400
commitf7a8980347f83d2602161e5617c5af4c06d80747 (patch)
treef8b835ce3fd38faa01719c67c56679a8a46c8063
parent8cbcc893a6ad5c02162a5dca24db44303bc05d6d (diff)
downloadrust-f7a8980347f83d2602161e5617c5af4c06d80747.tar.gz
rust-f7a8980347f83d2602161e5617c5af4c06d80747.zip
Reorder etc check for non_exhaustive_omitted_patterns
-rw-r--r--compiler/rustc_typeck/src/check/pat.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs
index 751ceef7b61..5d82051c23c 100644
--- a/compiler/rustc_typeck/src/check/pat.rs
+++ b/compiler/rustc_typeck/src/check/pat.rs
@@ -1286,13 +1286,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                     field.vis.is_accessible_from(tcx.parent_module(pat.hir_id).to_def_id(), tcx)
                 })
                 .collect();
-            if non_exhaustive && !accessible_unmentioned_fields.is_empty() {
-                self.lint_non_exhaustive_omitted_patterns(
-                    pat,
-                    &accessible_unmentioned_fields,
-                    adt_ty,
-                )
-            } else if !etc {
+
+            if !etc {
                 if accessible_unmentioned_fields.is_empty() {
                     unmentioned_err = Some(self.error_no_accessible_fields(pat, fields));
                 } else {
@@ -1303,6 +1298,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                         fields,
                     ));
                 }
+            } else if non_exhaustive && !accessible_unmentioned_fields.is_empty() {
+                self.lint_non_exhaustive_omitted_patterns(
+                    pat,
+                    &accessible_unmentioned_fields,
+                    adt_ty,
+                )
             }
         }
         match (inexistent_fields_err, unmentioned_err) {