|
151 | 151 | use std::cmp::{self, max, min, Ordering};
|
152 | 152 | use std::fmt;
|
153 | 153 | use std::iter::once;
|
154 |
| -use std::mem; |
155 | 154 |
|
156 | 155 | use smallvec::SmallVec;
|
157 | 156 |
|
@@ -648,6 +647,7 @@ impl OpaqueId {
|
648 | 647 | /// `specialize_constructor` returns the list of fields corresponding to a pattern, given a
|
649 | 648 | /// constructor. `Constructor::apply` reconstructs the pattern from a pair of `Constructor` and
|
650 | 649 | /// `Fields`.
|
| 650 | +#[derive(Debug)] |
651 | 651 | pub enum Constructor<Cx: TypeCx> {
|
652 | 652 | /// Tuples and structs.
|
653 | 653 | Struct,
|
@@ -717,74 +717,6 @@ impl<Cx: TypeCx> Clone for Constructor<Cx> {
|
717 | 717 | }
|
718 | 718 | }
|
719 | 719 |
|
720 |
| -impl<Cx: TypeCx> fmt::Debug for Constructor<Cx> { |
721 |
| - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
722 |
| - match self { |
723 |
| - Constructor::Struct => f.debug_tuple("Struct").finish(), |
724 |
| - Constructor::Variant(idx) => f.debug_tuple("Variant").field(idx).finish(), |
725 |
| - Constructor::Ref => f.debug_tuple("Ref").finish(), |
726 |
| - Constructor::Slice(slice) => f.debug_tuple("Slice").field(slice).finish(), |
727 |
| - Constructor::UnionField => f.debug_tuple("UnionField").finish(), |
728 |
| - Constructor::Bool(b) => f.debug_tuple("Bool").field(b).finish(), |
729 |
| - Constructor::IntRange(range) => f.debug_tuple("IntRange").field(range).finish(), |
730 |
| - Constructor::F32Range(lo, hi, end) => { |
731 |
| - f.debug_tuple("F32Range").field(lo).field(hi).field(end).finish() |
732 |
| - } |
733 |
| - Constructor::F64Range(lo, hi, end) => { |
734 |
| - f.debug_tuple("F64Range").field(lo).field(hi).field(end).finish() |
735 |
| - } |
736 |
| - Constructor::Str(value) => f.debug_tuple("Str").field(value).finish(), |
737 |
| - Constructor::Opaque(inner) => f.debug_tuple("Opaque").field(inner).finish(), |
738 |
| - Constructor::Or => f.debug_tuple("Or").finish(), |
739 |
| - Constructor::Wildcard => f.debug_tuple("Wildcard").finish(), |
740 |
| - Constructor::NonExhaustive => f.debug_tuple("NonExhaustive").finish(), |
741 |
| - Constructor::Hidden => f.debug_tuple("Hidden").finish(), |
742 |
| - Constructor::Missing => f.debug_tuple("Missing").finish(), |
743 |
| - } |
744 |
| - } |
745 |
| -} |
746 |
| - |
747 |
| -impl<Cx: TypeCx> PartialEq for Constructor<Cx> { |
748 |
| - fn eq(&self, other: &Self) -> bool { |
749 |
| - (mem::discriminant(self) == mem::discriminant(other)) |
750 |
| - && match (self, other) { |
751 |
| - (Constructor::Struct, Constructor::Struct) => true, |
752 |
| - (Constructor::Variant(self_variant), Constructor::Variant(other_variant)) => { |
753 |
| - self_variant == other_variant |
754 |
| - } |
755 |
| - (Constructor::Ref, Constructor::Ref) => true, |
756 |
| - (Constructor::Slice(self_slice), Constructor::Slice(other_slice)) => { |
757 |
| - self_slice == other_slice |
758 |
| - } |
759 |
| - (Constructor::UnionField, Constructor::UnionField) => true, |
760 |
| - (Constructor::Bool(self_b), Constructor::Bool(other_b)) => self_b == other_b, |
761 |
| - (Constructor::IntRange(self_range), Constructor::IntRange(other_range)) => { |
762 |
| - self_range == other_range |
763 |
| - } |
764 |
| - ( |
765 |
| - Constructor::F32Range(self_lo, self_hi, self_end), |
766 |
| - Constructor::F32Range(other_lo, other_hi, other_end), |
767 |
| - ) => self_lo == other_lo && self_hi == other_hi && self_end == other_end, |
768 |
| - ( |
769 |
| - Constructor::F64Range(self_lo, self_hi, self_end), |
770 |
| - Constructor::F64Range(other_lo, other_hi, other_end), |
771 |
| - ) => self_lo == other_lo && self_hi == other_hi && self_end == other_end, |
772 |
| - (Constructor::Str(self_value), Constructor::Str(other_value)) => { |
773 |
| - self_value == other_value |
774 |
| - } |
775 |
| - (Constructor::Opaque(self_inner), Constructor::Opaque(other_inner)) => { |
776 |
| - self_inner == other_inner |
777 |
| - } |
778 |
| - (Constructor::Or, Constructor::Or) => true, |
779 |
| - (Constructor::Wildcard, Constructor::Wildcard) => true, |
780 |
| - (Constructor::NonExhaustive, Constructor::NonExhaustive) => true, |
781 |
| - (Constructor::Hidden, Constructor::Hidden) => true, |
782 |
| - (Constructor::Missing, Constructor::Missing) => true, |
783 |
| - _ => unreachable!(), |
784 |
| - } |
785 |
| - } |
786 |
| -} |
787 |
| - |
788 | 720 | impl<Cx: TypeCx> Constructor<Cx> {
|
789 | 721 | pub(crate) fn is_non_exhaustive(&self) -> bool {
|
790 | 722 | matches!(self, NonExhaustive)
|
|
0 commit comments