launchbadge / sqlx

🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, and SQLite.
Apache License 2.0
13.43k stars 1.28k forks source link

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

Open GreenYun opened 2 years ago

GreenYun commented 2 years ago

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

abonander commented 2 years ago

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.