Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09d4d49
commit 8cb7e85
Showing
6 changed files
with
199 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,72 @@ | ||
// run-rustfix | ||
|
||
#![deny(clippy::exhaustive_enums)] | ||
#![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)] | ||
#![allow(unused)] | ||
|
||
fn main() { | ||
// nop | ||
} | ||
|
||
#[non_exhaustive] | ||
pub mod enums { | ||
#[non_exhaustive] | ||
pub enum Exhaustive { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
} | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
} | ||
|
||
// no warning, already non_exhaustive | ||
#[non_exhaustive] | ||
pub enum NonExhaustive { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
} | ||
// no warning, already non_exhaustive | ||
#[non_exhaustive] | ||
pub enum NonExhaustive { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
} | ||
|
||
// no warning, private | ||
enum ExhaustivePrivate { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
} | ||
|
||
// no warning, private | ||
enum ExhaustivePrivate { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
// no warning, private | ||
#[non_exhaustive] | ||
enum NonExhaustivePrivate { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
} | ||
} | ||
|
||
// no warning, private | ||
#[non_exhaustive] | ||
enum NonExhaustivePrivate { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
pub mod structs { | ||
#[non_exhaustive] | ||
pub struct Exhaustive { | ||
foo: u8, | ||
bar: String, | ||
} | ||
|
||
// no warning, already non_exhaustive | ||
#[non_exhaustive] | ||
pub struct NonExhaustive { | ||
foo: u8, | ||
bar: String, | ||
} | ||
|
||
// no warning, private | ||
struct ExhaustivePrivate { | ||
foo: u8, | ||
bar: String, | ||
} | ||
|
||
// no warning, private | ||
#[non_exhaustive] | ||
struct NonExhaustivePrivate { | ||
foo: u8, | ||
bar: String, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,70 @@ | ||
// run-rustfix | ||
|
||
#![deny(clippy::exhaustive_enums)] | ||
#![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)] | ||
#![allow(unused)] | ||
|
||
fn main() { | ||
// nop | ||
} | ||
|
||
pub enum Exhaustive { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
} | ||
pub mod enums { | ||
pub enum Exhaustive { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
} | ||
|
||
// no warning, already non_exhaustive | ||
#[non_exhaustive] | ||
pub enum NonExhaustive { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
} | ||
// no warning, already non_exhaustive | ||
#[non_exhaustive] | ||
pub enum NonExhaustive { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
} | ||
|
||
// no warning, private | ||
enum ExhaustivePrivate { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
} | ||
|
||
// no warning, private | ||
enum ExhaustivePrivate { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
// no warning, private | ||
#[non_exhaustive] | ||
enum NonExhaustivePrivate { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
} | ||
} | ||
|
||
// no warning, private | ||
#[non_exhaustive] | ||
enum NonExhaustivePrivate { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Quux(String), | ||
pub mod structs { | ||
pub struct Exhaustive { | ||
foo: u8, | ||
bar: String, | ||
} | ||
|
||
// no warning, already non_exhaustive | ||
#[non_exhaustive] | ||
pub struct NonExhaustive { | ||
foo: u8, | ||
bar: String, | ||
} | ||
|
||
// no warning, private | ||
struct ExhaustivePrivate { | ||
foo: u8, | ||
bar: String, | ||
} | ||
|
||
// no warning, private | ||
#[non_exhaustive] | ||
struct NonExhaustivePrivate { | ||
foo: u8, | ||
bar: String, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,46 @@ | ||
error: enums should not be exhaustive | ||
--> $DIR/exhaustive_items.rs:10:1 | ||
--> $DIR/exhaustive_items.rs:11:5 | ||
| | ||
LL | / pub enum Exhaustive { | ||
LL | | Foo, | ||
LL | | Bar, | ||
LL | | Baz, | ||
LL | | Quux(String), | ||
LL | | } | ||
| |_^ | ||
LL | / pub enum Exhaustive { | ||
LL | | Foo, | ||
LL | | Bar, | ||
LL | | Baz, | ||
LL | | Quux(String), | ||
LL | | } | ||
| |_____^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/exhaustive_items.rs:3:9 | ||
--> $DIR/exhaustive_items.rs:3:35 | ||
| | ||
LL | #![deny(clippy::exhaustive_enums)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
help: try adding #[non_exhaustive] | ||
| | ||
LL | #[non_exhaustive] | ||
LL | #[non_exhaustive] | ||
LL | pub enum Exhaustive { | ||
LL | Foo, | ||
LL | Bar, | ||
LL | Baz, | ||
LL | Quux(String), | ||
LL | Foo, | ||
LL | Bar, | ||
LL | Baz, | ||
LL | Quux(String), | ||
... | ||
|
||
error: aborting due to previous error | ||
error: enums should not be exhaustive | ||
--> $DIR/exhaustive_items.rs:46:5 | ||
| | ||
LL | / pub struct Exhaustive { | ||
LL | | foo: u8, | ||
LL | | bar: String, | ||
LL | | } | ||
| |_____^ | ||
| | ||
help: try adding #[non_exhaustive] | ||
| | ||
LL | #[non_exhaustive] | ||
LL | pub struct Exhaustive { | ||
LL | foo: u8, | ||
LL | bar: String, | ||
LL | } | ||
| | ||
|
||
error: aborting due to 2 previous errors | ||
|