about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-03-25 06:57:00 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-03-25 07:02:30 +0100
commit58fee523cfe1e242cbf8776bb8513fb8325bc0ab (patch)
tree4a13a9ef89fdc076f351c82d04a05cb5e948db25 /src
parent02046a5d402c789c006d0da7662f800fe3c45faf (diff)
is_union() instead of string comparsion
Diffstat (limited to 'src')
-rw-r--r--src/librustc_typeck/check/pat.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs
index 0d38fa98bd7..d3b1ea8778d 100644
--- a/src/librustc_typeck/check/pat.rs
+++ b/src/librustc_typeck/check/pat.rs
@@ -1020,7 +1020,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             ty::Adt(adt, substs) => (substs, adt),
             _ => span_bug!(pat.span, "struct pattern is not an ADT"),
         };
-        let kind_name = adt.variant_descr();
 
         // Index the struct fields' types.
         let field_map = variant
@@ -1074,7 +1073,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
 
         if !inexistent_fields.is_empty() && !variant.recovered {
             self.error_inexistent_fields(
-                kind_name,
+                adt.variant_descr(),
                 &inexistent_fields,
                 &mut unmentioned_fields,
                 variant,
@@ -1088,13 +1087,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 pat.span,
                 E0638,
                 "`..` required with {} marked as non-exhaustive",
-                kind_name
+                adt.variant_descr()
             )
             .emit();
         }
 
         // Report an error if incorrect number of the fields were specified.
-        if kind_name == "union" {
+        if adt.is_union() {
             if fields.len() != 1 {
                 tcx.sess
                     .struct_span_err(pat.span, "union patterns should have exactly one field")