Manual Debug
impls are not needed since TypeCx: Debug
This commit is contained in:
parent
15b473451c
commit
40402cbada
@ -648,6 +648,7 @@ impl OpaqueId {
|
|||||||
/// `specialize_constructor` returns the list of fields corresponding to a pattern, given a
|
/// `specialize_constructor` returns the list of fields corresponding to a pattern, given a
|
||||||
/// constructor. `Constructor::apply` reconstructs the pattern from a pair of `Constructor` and
|
/// constructor. `Constructor::apply` reconstructs the pattern from a pair of `Constructor` and
|
||||||
/// `Fields`.
|
/// `Fields`.
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum Constructor<Cx: TypeCx> {
|
pub enum Constructor<Cx: TypeCx> {
|
||||||
/// Tuples and structs.
|
/// Tuples and structs.
|
||||||
Struct,
|
Struct,
|
||||||
@ -717,33 +718,6 @@ impl<Cx: TypeCx> Clone for Constructor<Cx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Cx: TypeCx> fmt::Debug for Constructor<Cx> {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
match self {
|
|
||||||
Constructor::Struct => f.debug_tuple("Struct").finish(),
|
|
||||||
Constructor::Variant(idx) => f.debug_tuple("Variant").field(idx).finish(),
|
|
||||||
Constructor::Ref => f.debug_tuple("Ref").finish(),
|
|
||||||
Constructor::Slice(slice) => f.debug_tuple("Slice").field(slice).finish(),
|
|
||||||
Constructor::UnionField => f.debug_tuple("UnionField").finish(),
|
|
||||||
Constructor::Bool(b) => f.debug_tuple("Bool").field(b).finish(),
|
|
||||||
Constructor::IntRange(range) => f.debug_tuple("IntRange").field(range).finish(),
|
|
||||||
Constructor::F32Range(lo, hi, end) => {
|
|
||||||
f.debug_tuple("F32Range").field(lo).field(hi).field(end).finish()
|
|
||||||
}
|
|
||||||
Constructor::F64Range(lo, hi, end) => {
|
|
||||||
f.debug_tuple("F64Range").field(lo).field(hi).field(end).finish()
|
|
||||||
}
|
|
||||||
Constructor::Str(value) => f.debug_tuple("Str").field(value).finish(),
|
|
||||||
Constructor::Opaque(inner) => f.debug_tuple("Opaque").field(inner).finish(),
|
|
||||||
Constructor::Or => f.debug_tuple("Or").finish(),
|
|
||||||
Constructor::Wildcard => f.debug_tuple("Wildcard").finish(),
|
|
||||||
Constructor::NonExhaustive => f.debug_tuple("NonExhaustive").finish(),
|
|
||||||
Constructor::Hidden => f.debug_tuple("Hidden").finish(),
|
|
||||||
Constructor::Missing => f.debug_tuple("Missing").finish(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<Cx: TypeCx> Constructor<Cx> {
|
impl<Cx: TypeCx> Constructor<Cx> {
|
||||||
pub(crate) fn is_non_exhaustive(&self) -> bool {
|
pub(crate) fn is_non_exhaustive(&self) -> bool {
|
||||||
matches!(self, NonExhaustive)
|
matches!(self, NonExhaustive)
|
||||||
|
@ -298,6 +298,7 @@ impl<'p, Cx: TypeCx> fmt::Debug for PatOrWild<'p, Cx> {
|
|||||||
|
|
||||||
/// Same idea as `DeconstructedPat`, except this is a fictitious pattern built up for diagnostics
|
/// Same idea as `DeconstructedPat`, except this is a fictitious pattern built up for diagnostics
|
||||||
/// purposes. As such they don't use interning and can be cloned.
|
/// purposes. As such they don't use interning and can be cloned.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct WitnessPat<Cx: TypeCx> {
|
pub struct WitnessPat<Cx: TypeCx> {
|
||||||
ctor: Constructor<Cx>,
|
ctor: Constructor<Cx>,
|
||||||
pub(crate) fields: Vec<WitnessPat<Cx>>,
|
pub(crate) fields: Vec<WitnessPat<Cx>>,
|
||||||
@ -310,16 +311,6 @@ impl<Cx: TypeCx> Clone for WitnessPat<Cx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Cx: TypeCx> fmt::Debug for WitnessPat<Cx> {
|
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
fmt.debug_struct("WitnessPat")
|
|
||||||
.field("ctor", &self.ctor)
|
|
||||||
.field("fields", &self.fields)
|
|
||||||
.field("ty", &self.ty)
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<Cx: TypeCx> WitnessPat<Cx> {
|
impl<Cx: TypeCx> WitnessPat<Cx> {
|
||||||
pub(crate) fn new(ctor: Constructor<Cx>, fields: Vec<Self>, ty: Cx::Ty) -> Self {
|
pub(crate) fn new(ctor: Constructor<Cx>, fields: Vec<Self>, ty: Cx::Ty) -> Self {
|
||||||
Self { ctor, fields, ty }
|
Self { ctor, fields, ty }
|
||||||
|
@ -1198,6 +1198,7 @@ impl<'p, Cx: TypeCx> fmt::Debug for Matrix<'p, Cx> {
|
|||||||
/// The final `Pair(Some(_), true)` is then the resulting witness.
|
/// The final `Pair(Some(_), true)` is then the resulting witness.
|
||||||
///
|
///
|
||||||
/// See the top of the file for more detailed explanations and examples.
|
/// See the top of the file for more detailed explanations and examples.
|
||||||
|
#[derive(Debug)]
|
||||||
struct WitnessStack<Cx: TypeCx>(Vec<WitnessPat<Cx>>);
|
struct WitnessStack<Cx: TypeCx>(Vec<WitnessPat<Cx>>);
|
||||||
|
|
||||||
impl<Cx: TypeCx> Clone for WitnessStack<Cx> {
|
impl<Cx: TypeCx> Clone for WitnessStack<Cx> {
|
||||||
@ -1206,12 +1207,6 @@ impl<Cx: TypeCx> Clone for WitnessStack<Cx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Cx: TypeCx> fmt::Debug for WitnessStack<Cx> {
|
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
fmt.debug_tuple("WitnessStack").field(&self.0).finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<Cx: TypeCx> WitnessStack<Cx> {
|
impl<Cx: TypeCx> WitnessStack<Cx> {
|
||||||
/// Asserts that the witness contains a single pattern, and returns it.
|
/// Asserts that the witness contains a single pattern, and returns it.
|
||||||
fn single_pattern(self) -> WitnessPat<Cx> {
|
fn single_pattern(self) -> WitnessPat<Cx> {
|
||||||
@ -1256,6 +1251,7 @@ impl<Cx: TypeCx> WitnessStack<Cx> {
|
|||||||
///
|
///
|
||||||
/// Just as the `Matrix` starts with a single column, by the end of the algorithm, this has a single
|
/// Just as the `Matrix` starts with a single column, by the end of the algorithm, this has a single
|
||||||
/// column, which contains the patterns that are missing for the match to be exhaustive.
|
/// column, which contains the patterns that are missing for the match to be exhaustive.
|
||||||
|
#[derive(Debug)]
|
||||||
struct WitnessMatrix<Cx: TypeCx>(Vec<WitnessStack<Cx>>);
|
struct WitnessMatrix<Cx: TypeCx>(Vec<WitnessStack<Cx>>);
|
||||||
|
|
||||||
impl<Cx: TypeCx> Clone for WitnessMatrix<Cx> {
|
impl<Cx: TypeCx> Clone for WitnessMatrix<Cx> {
|
||||||
@ -1264,12 +1260,6 @@ impl<Cx: TypeCx> Clone for WitnessMatrix<Cx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Cx: TypeCx> fmt::Debug for WitnessMatrix<Cx> {
|
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
fmt.debug_tuple("WitnessMatrix").field(&self.0).finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<Cx: TypeCx> WitnessMatrix<Cx> {
|
impl<Cx: TypeCx> WitnessMatrix<Cx> {
|
||||||
/// New matrix with no witnesses.
|
/// New matrix with no witnesses.
|
||||||
fn empty() -> Self {
|
fn empty() -> Self {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user