Skip to content

Commit 58fee52

Browse files
committed
is_union() instead of string comparsion
1 parent 02046a5 commit 58fee52

File tree

1 file changed

+3
-4
lines changed
  • src/librustc_typeck/check

1 file changed

+3
-4
lines changed

src/librustc_typeck/check/pat.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10201020
ty::Adt(adt, substs) => (substs, adt),
10211021
_ => span_bug!(pat.span, "struct pattern is not an ADT"),
10221022
};
1023-
let kind_name = adt.variant_descr();
10241023

10251024
// Index the struct fields' types.
10261025
let field_map = variant
@@ -1074,7 +1073,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10741073

10751074
if !inexistent_fields.is_empty() && !variant.recovered {
10761075
self.error_inexistent_fields(
1077-
kind_name,
1076+
adt.variant_descr(),
10781077
&inexistent_fields,
10791078
&mut unmentioned_fields,
10801079
variant,
@@ -1088,13 +1087,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10881087
pat.span,
10891088
E0638,
10901089
"`..` required with {} marked as non-exhaustive",
1091-
kind_name
1090+
adt.variant_descr()
10921091
)
10931092
.emit();
10941093
}
10951094

10961095
// Report an error if incorrect number of the fields were specified.
1097-
if kind_name == "union" {
1096+
if adt.is_union() {
10981097
if fields.len() != 1 {
10991098
tcx.sess
11001099
.struct_span_err(pat.span, "union patterns should have exactly one field")

0 commit comments

Comments
 (0)