sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Add `#[allow(clippy::use_self)]` for derived traits

Open GreenYun opened this issue 3 years ago • 1 comments

Bug Description

Warning messages are generated by clippy when deriving Type for enums if clippy::use-self is set to warning level, saying "unnecessary structure name repetition".

Minimal Reproduction

use sqlx::Type;

#[allow(unused)]
#[allow(clippy::use_self)]
#[derive(Type)]
#[sqlx(type_name = "lang")]
pub enum Lang {
    Chinese,
    English,
}

Info

  • SQLx version: 0.6.1
  • SQLx features enabled: macros, postgres, runtime-tokio-native-tls
  • Database server and version: Postgres 14.3
  • Operating system: Fedora 36
  • rustc --version: rustc 1.65.0-nightly (addacb587 2022-08-24)

GreenYun avatar Aug 25 '22 15:08 GreenYun

It's honestly rather annoying that Clippy lints generated code at all. It should be able to tell from the hygiene information which code the user wrote and which code they didn't, although I forget if derives are actually hygienic at all.

We also mark the generated impls with #[automatically_derived] which is about as explicit of a hint you can get.

That said, we should probably just mark generated code with #[allow(clippy::all)] instead of playing whack-a-mole with its pedantic lints.

abonander avatar Sep 03 '22 01:09 abonander