+ let ty = cx.tables.expr_ty(ex);
+ if !ty.is_enum() {
+ // If there isn't a nice closed set of possible values that can be conveniently enumerated,
+ // don't complain about not enumerating the mall.
+ return;
+ }
+
+ // First pass - check for violation, but don't do much book-keeping because this is hopefully
+ // the uncommon case, and the book-keeping is slightly expensive.
+ let mut wildcard_span = None;
+ let mut wildcard_ident = None;
+ for arm in arms {
+ for pat in &arm.pats {
+ if let PatKind::Wild = pat.node {
+ wildcard_span = Some(pat.span);
+ } else if let PatKind::Binding(_, _, ident, None) = pat.node {
+ wildcard_span = Some(pat.span);
+ wildcard_ident = Some(ident);
+ }
+ }
+ }
+
+ if let Some(wildcard_span) = wildcard_span {
+ // Accumulate the variants which should be put in place of the wildcard because they're not
+ // already covered.
+
+ let mut missing_variants = vec![];
+ if let TyKind::Adt(def, _) = ty.sty {
+ for variant in &def.variants {
+ missing_variants.push(variant);
+ }
+ }
+