Skip to content

Commit 40402cb

Browse files
committed
Manual Debug impls are not needed since TypeCx: Debug
1 parent 15b4734 commit 40402cb

File tree

3 files changed

+4
-49
lines changed

3 files changed

+4
-49
lines changed

compiler/rustc_pattern_analysis/src/constructor.rs

+1-27
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ impl OpaqueId {
648648
/// `specialize_constructor` returns the list of fields corresponding to a pattern, given a
649649
/// constructor. `Constructor::apply` reconstructs the pattern from a pair of `Constructor` and
650650
/// `Fields`.
651+
#[derive(Debug)]
651652
pub enum Constructor<Cx: TypeCx> {
652653
/// Tuples and structs.
653654
Struct,
@@ -717,33 +718,6 @@ impl<Cx: TypeCx> Clone for Constructor<Cx> {
717718
}
718719
}
719720

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-
747721
impl<Cx: TypeCx> Constructor<Cx> {
748722
pub(crate) fn is_non_exhaustive(&self) -> bool {
749723
matches!(self, NonExhaustive)

compiler/rustc_pattern_analysis/src/pat.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ impl<'p, Cx: TypeCx> fmt::Debug for PatOrWild<'p, Cx> {
298298

299299
/// Same idea as `DeconstructedPat`, except this is a fictitious pattern built up for diagnostics
300300
/// purposes. As such they don't use interning and can be cloned.
301+
#[derive(Debug)]
301302
pub struct WitnessPat<Cx: TypeCx> {
302303
ctor: Constructor<Cx>,
303304
pub(crate) fields: Vec<WitnessPat<Cx>>,
@@ -310,16 +311,6 @@ impl<Cx: TypeCx> Clone for WitnessPat<Cx> {
310311
}
311312
}
312313

313-
impl<Cx: TypeCx> fmt::Debug for WitnessPat<Cx> {
314-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
315-
fmt.debug_struct("WitnessPat")
316-
.field("ctor", &self.ctor)
317-
.field("fields", &self.fields)
318-
.field("ty", &self.ty)
319-
.finish()
320-
}
321-
}
322-
323314
impl<Cx: TypeCx> WitnessPat<Cx> {
324315
pub(crate) fn new(ctor: Constructor<Cx>, fields: Vec<Self>, ty: Cx::Ty) -> Self {
325316
Self { ctor, fields, ty }

compiler/rustc_pattern_analysis/src/usefulness.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,7 @@ impl<'p, Cx: TypeCx> fmt::Debug for Matrix<'p, Cx> {
11981198
/// The final `Pair(Some(_), true)` is then the resulting witness.
11991199
///
12001200
/// See the top of the file for more detailed explanations and examples.
1201+
#[derive(Debug)]
12011202
struct WitnessStack<Cx: TypeCx>(Vec<WitnessPat<Cx>>);
12021203

12031204
impl<Cx: TypeCx> Clone for WitnessStack<Cx> {
@@ -1206,12 +1207,6 @@ impl<Cx: TypeCx> Clone for WitnessStack<Cx> {
12061207
}
12071208
}
12081209

1209-
impl<Cx: TypeCx> fmt::Debug for WitnessStack<Cx> {
1210-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1211-
fmt.debug_tuple("WitnessStack").field(&self.0).finish()
1212-
}
1213-
}
1214-
12151210
impl<Cx: TypeCx> WitnessStack<Cx> {
12161211
/// Asserts that the witness contains a single pattern, and returns it.
12171212
fn single_pattern(self) -> WitnessPat<Cx> {
@@ -1256,6 +1251,7 @@ impl<Cx: TypeCx> WitnessStack<Cx> {
12561251
///
12571252
/// Just as the `Matrix` starts with a single column, by the end of the algorithm, this has a single
12581253
/// column, which contains the patterns that are missing for the match to be exhaustive.
1254+
#[derive(Debug)]
12591255
struct WitnessMatrix<Cx: TypeCx>(Vec<WitnessStack<Cx>>);
12601256

12611257
impl<Cx: TypeCx> Clone for WitnessMatrix<Cx> {
@@ -1264,12 +1260,6 @@ impl<Cx: TypeCx> Clone for WitnessMatrix<Cx> {
12641260
}
12651261
}
12661262

1267-
impl<Cx: TypeCx> fmt::Debug for WitnessMatrix<Cx> {
1268-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1269-
fmt.debug_tuple("WitnessMatrix").field(&self.0).finish()
1270-
}
1271-
}
1272-
12731263
impl<Cx: TypeCx> WitnessMatrix<Cx> {
12741264
/// New matrix with no witnesses.
12751265
fn empty() -> Self {

0 commit comments

Comments
 (0)