Auto merge of #12153 - GuillaumeGomez:non-exhaustive, r=llogiq

Don't emit `derive_partial_eq_without_eq` lint if the type has the `non_exhaustive` attribute

Part of https://github.com/rust-lang/rust-clippy/issues/9063.

If a type has a field/variant with the `#[non_exhaustive]` attribute or the type itself has it, then do no emit the `derive_partial_eq_without_eq` lint.

changelog: Don't emit `derive_partial_eq_without_eq` lint if the type has the `non_exhaustive` attribute
This commit is contained in:
bors 2024-01-22 18:20:12 +00:00
commit a8017ae131
4 changed files with 78 additions and 1 deletions

View file

@ -121,4 +121,36 @@ pub fn _from_mod() -> _hidden::InPubFn {
#[derive(PartialEq)]
struct InternalTy;
// This is a `non_exhaustive` type so should not warn.
#[derive(Debug, PartialEq)]
#[non_exhaustive]
pub struct MissingEqNonExhaustive {
foo: u32,
bar: String,
}
// This is a `non_exhaustive` type so should not warn.
#[derive(Debug, PartialEq)]
pub struct MissingEqNonExhaustive1 {
foo: u32,
#[non_exhaustive]
bar: String,
}
// This is a `non_exhaustive` type so should not warn.
#[derive(Debug, PartialEq)]
#[non_exhaustive]
pub enum MissingEqNonExhaustive2 {
Foo,
Bar,
}
// This is a `non_exhaustive` type so should not warn.
#[derive(Debug, PartialEq)]
pub enum MissingEqNonExhaustive3 {
Foo,
#[non_exhaustive]
Bar,
}
fn main() {}

View file

@ -121,4 +121,36 @@ pub fn _from_mod() -> _hidden::InPubFn {
#[derive(PartialEq)]
struct InternalTy;
// This is a `non_exhaustive` type so should not warn.
#[derive(Debug, PartialEq)]
#[non_exhaustive]
pub struct MissingEqNonExhaustive {
foo: u32,
bar: String,
}
// This is a `non_exhaustive` type so should not warn.
#[derive(Debug, PartialEq)]
pub struct MissingEqNonExhaustive1 {
foo: u32,
#[non_exhaustive]
bar: String,
}
// This is a `non_exhaustive` type so should not warn.
#[derive(Debug, PartialEq)]
#[non_exhaustive]
pub enum MissingEqNonExhaustive2 {
Foo,
Bar,
}
// This is a `non_exhaustive` type so should not warn.
#[derive(Debug, PartialEq)]
pub enum MissingEqNonExhaustive3 {
Foo,
#[non_exhaustive]
Bar,
}
fn main() {}