don't lint enums, update note in lint description
This commit is contained in:
parent
f74ec6b1b8
commit
a859b0e6df
3 changed files with 13 additions and 258 deletions
|
|
@ -97,140 +97,12 @@ impl fmt::Debug for MultiExprDebugImpl {
|
|||
}
|
||||
}
|
||||
|
||||
enum SingleVariantEnumUnnamed {
|
||||
A(u8),
|
||||
}
|
||||
|
||||
// ok
|
||||
impl fmt::Debug for SingleVariantEnumUnnamed {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::A(n) => formatter.debug_tuple("A").field(&n).finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum MultiVariantEnum {
|
||||
A(u8),
|
||||
B { a: u8, b: String },
|
||||
C,
|
||||
}
|
||||
|
||||
impl fmt::Debug for MultiVariantEnum {
|
||||
// match arm Self::B ignores `b`
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::A(n) => formatter.debug_tuple("A").field(&n).finish(),
|
||||
Self::B { a, b } => formatter.debug_struct("B").field("a", &a).finish(),
|
||||
Self::C => formatter.debug_struct("C").finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum MultiVariantEnumOk {
|
||||
A(u8),
|
||||
B { a: u8, b: String },
|
||||
C,
|
||||
}
|
||||
|
||||
// ok
|
||||
impl fmt::Debug for MultiVariantEnumOk {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::A(n) => formatter.debug_tuple("A").field(&n).finish(),
|
||||
Self::B { a, b } => formatter.debug_struct("B").field("a", &a).field("b", &b).finish(),
|
||||
Self::C => formatter.debug_struct("C").finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum MultiVariantEnumNonExhaustive {
|
||||
A(u8),
|
||||
B { a: u8, b: String },
|
||||
C,
|
||||
}
|
||||
|
||||
// ok
|
||||
impl fmt::Debug for MultiVariantEnumNonExhaustive {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::A(n) => formatter.debug_tuple("A").field(&n).finish(),
|
||||
Self::B { a, b } => formatter.debug_struct("B").field("b", &b).finish_non_exhaustive(),
|
||||
Self::C => formatter.debug_struct("C").finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum MultiVariantRest {
|
||||
A(u8),
|
||||
B { a: u8, b: String },
|
||||
C,
|
||||
}
|
||||
|
||||
impl fmt::Debug for MultiVariantRest {
|
||||
// `a` field ignored due to rest pattern
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::A(n) => formatter.debug_tuple("A").field(&n).finish(),
|
||||
Self::B { b, .. } => formatter.debug_struct("B").field("b", &b).finish(),
|
||||
Self::C => formatter.debug_struct("C").finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum MultiVariantRestNonExhaustive {
|
||||
A(u8),
|
||||
B { a: u8, b: String },
|
||||
C,
|
||||
}
|
||||
|
||||
// ok
|
||||
impl fmt::Debug for MultiVariantRestNonExhaustive {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::A(n) => formatter.debug_tuple("A").field(&n).finish(),
|
||||
Self::B { b, .. } => formatter.debug_struct("B").field("b", &b).finish_non_exhaustive(),
|
||||
Self::C => formatter.debug_struct("C").finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum Wildcard {
|
||||
A(u8),
|
||||
B(String),
|
||||
}
|
||||
|
||||
// ok
|
||||
impl fmt::Debug for Wildcard {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::A(n) => formatter.debug_tuple("A").field(&n).finish(),
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum Empty {}
|
||||
|
||||
// ok
|
||||
impl fmt::Debug for Empty {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct DerivedStruct {
|
||||
a: u8,
|
||||
b: i32,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum DerivedEnum {
|
||||
A(i32),
|
||||
B { a: String },
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust-clippy/pull/10616#discussion_r1166846953
|
||||
|
||||
struct Inner {
|
||||
|
|
|
|||
|
|
@ -69,45 +69,5 @@ LL | b: String,
|
|||
= help: consider including all fields in this `Debug` impl
|
||||
= help: consider calling `.finish_non_exhaustive()` if you intend to ignore fields
|
||||
|
||||
error: manual `Debug` impl does not include all fields
|
||||
--> $DIR/missing_fields_in_debug.rs:119:1
|
||||
|
|
||||
LL | / impl fmt::Debug for MultiVariantEnum {
|
||||
LL | | // match arm Self::B ignores `b`
|
||||
LL | | fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
LL | | match self {
|
||||
... |
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
note: the field referenced by this binding is unused
|
||||
--> $DIR/missing_fields_in_debug.rs:124:26
|
||||
|
|
||||
LL | Self::B { a, b } => formatter.debug_struct("B").field("a", &a).finish(),
|
||||
| ^
|
||||
= help: consider including all fields in this `Debug` impl
|
||||
= help: consider calling `.finish_non_exhaustive()` if you intend to ignore fields
|
||||
|
||||
error: manual `Debug` impl does not include all fields
|
||||
--> $DIR/missing_fields_in_debug.rs:170:1
|
||||
|
|
||||
LL | / impl fmt::Debug for MultiVariantRest {
|
||||
LL | | // `a` field ignored due to rest pattern
|
||||
LL | | fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
LL | | match self {
|
||||
... |
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
note: more unused fields here due to rest pattern `..`
|
||||
--> $DIR/missing_fields_in_debug.rs:175:13
|
||||
|
|
||||
LL | Self::B { b, .. } => formatter.debug_struct("B").field("b", &b).finish(),
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
= help: consider including all fields in this `Debug` impl
|
||||
= help: consider calling `.finish_non_exhaustive()` if you intend to ignore fields
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue