From fbe644ae90e7d4476035100e6ba8cbf032ff1d9e Mon Sep 17 00:00:00 2001 From: Danny Goldberg Date: Thu, 5 Oct 2023 13:30:34 -0400 Subject: [PATCH] Add clippy::pedantic for star import To fix: ``` warning: usage of wildcard import --> src/models/schema_gen.rs:174:9 | 174 | use diesel::sql_types::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `diesel::sql_types::{Nullable, Text, Timestamptz, Uuid, Varchar}` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports ``` For now, I added a `patch_file` to my `diesel.toml` configuration, but I figured it'd be nicer for all if it's added automatically. Or perhaps there's a better way that a reviewer will recommend :) --- diesel_cli/src/print_schema.rs | 1 + .../postgres/expected.snap | 1 + .../postgres/expected.snap | 1 + .../postgres/expected.snap | 1 + .../print_schema_respects_type_name_case/postgres/expected.rs | 1 + .../print_schema_respects_type_name_case/postgres/expected.snap | 1 + .../postgres/expected.snap | 1 + .../print_schema_type_renaming/postgres/expected.snap | 1 + .../print_schema_with_enum_set_types/mysql/expected.snap | 1 + .../print_schema_with_enum_set_types/postgres/expected.snap | 1 + examples/postgres/custom_types/src/schema.rs | 1 + 11 files changed, 11 insertions(+) diff --git a/diesel_cli/src/print_schema.rs b/diesel_cli/src/print_schema.rs index b11d1ee84846..dbe7f4768bd5 100644 --- a/diesel_cli/src/print_schema.rs +++ b/diesel_cli/src/print_schema.rs @@ -555,6 +555,7 @@ impl<'a> Display for TableDefinition<'a> { { if already_imported_custom_types.insert(&ct.rust_name) { if !has_written_import { + writeln!(out, "#[allow(clippy::pedantic)]")?; writeln!(out, "use diesel::sql_types::*;")?; } writeln!(out, "use super::sql_types::{};", ct.rust_name)?; diff --git a/diesel_cli/tests/print_schema/print_schema_custom_types_check_default_derives/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_custom_types_check_default_derives/postgres/expected.snap index d18919f3ecdd..d8f26c3fbf4a 100644 --- a/diesel_cli/tests/print_schema/print_schema_custom_types_check_default_derives/postgres/expected.snap +++ b/diesel_cli/tests/print_schema/print_schema_custom_types_check_default_derives/postgres/expected.snap @@ -24,6 +24,7 @@ pub mod sql_types { } diesel::table! { + #[allow(clippy::pedantic)] use diesel::sql_types::*; use super::sql_types::MyType; use super::sql_types::MyType2; diff --git a/diesel_cli/tests/print_schema/print_schema_custom_types_overriding_derives_works/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_custom_types_overriding_derives_works/postgres/expected.snap index 539046949762..520c34ab75d2 100644 --- a/diesel_cli/tests/print_schema/print_schema_custom_types_overriding_derives_works/postgres/expected.snap +++ b/diesel_cli/tests/print_schema/print_schema_custom_types_overriding_derives_works/postgres/expected.snap @@ -24,6 +24,7 @@ pub mod sql_types { } diesel::table! { + #[allow(clippy::pedantic)] use diesel::sql_types::*; use super::sql_types::MyType; use super::sql_types::MyType2; diff --git a/diesel_cli/tests/print_schema/print_schema_default_is_to_generate_custom_types/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_default_is_to_generate_custom_types/postgres/expected.snap index 757c3d1ffe6b..f4e10a82c442 100644 --- a/diesel_cli/tests/print_schema/print_schema_default_is_to_generate_custom_types/postgres/expected.snap +++ b/diesel_cli/tests/print_schema/print_schema_default_is_to_generate_custom_types/postgres/expected.snap @@ -24,6 +24,7 @@ pub mod sql_types { } diesel::table! { + #[allow(clippy::pedantic)] use diesel::sql_types::*; use super::sql_types::MyType; use super::sql_types::MyType2; diff --git a/diesel_cli/tests/print_schema/print_schema_respects_type_name_case/postgres/expected.rs b/diesel_cli/tests/print_schema/print_schema_respects_type_name_case/postgres/expected.rs index e0c58fabfec8..776538150831 100644 --- a/diesel_cli/tests/print_schema/print_schema_respects_type_name_case/postgres/expected.rs +++ b/diesel_cli/tests/print_schema/print_schema_respects_type_name_case/postgres/expected.rs @@ -20,6 +20,7 @@ pub mod sql_types { } diesel::table! { + #[allow(clippy::pedantic)] use diesel::sql_types::*; use super::sql_types::MyType; use super::sql_types::MyType2; diff --git a/diesel_cli/tests/print_schema/print_schema_respects_type_name_case/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_respects_type_name_case/postgres/expected.snap index 845b8000ea10..93acfc1e518b 100644 --- a/diesel_cli/tests/print_schema/print_schema_respects_type_name_case/postgres/expected.snap +++ b/diesel_cli/tests/print_schema/print_schema_respects_type_name_case/postgres/expected.snap @@ -24,6 +24,7 @@ pub mod sql_types { } diesel::table! { + #[allow(clippy::pedantic)] use diesel::sql_types::*; use super::sql_types::MyType; use super::sql_types::MyType2; diff --git a/diesel_cli/tests/print_schema/print_schema_specifying_schema_name_with_custom_type/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_specifying_schema_name_with_custom_type/postgres/expected.snap index bf6bfed0a835..f0e26d41ed7d 100644 --- a/diesel_cli/tests/print_schema/print_schema_specifying_schema_name_with_custom_type/postgres/expected.snap +++ b/diesel_cli/tests/print_schema/print_schema_specifying_schema_name_with_custom_type/postgres/expected.snap @@ -18,6 +18,7 @@ pub mod custom_schema { } diesel::table! { + #[allow(clippy::pedantic)] use diesel::sql_types::*; use super::sql_types::MyEnum; diff --git a/diesel_cli/tests/print_schema/print_schema_type_renaming/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_type_renaming/postgres/expected.snap index 61e680a517e6..61f63bec62b5 100644 --- a/diesel_cli/tests/print_schema/print_schema_type_renaming/postgres/expected.snap +++ b/diesel_cli/tests/print_schema/print_schema_type_renaming/postgres/expected.snap @@ -17,6 +17,7 @@ pub mod sql_types { } diesel::table! { + #[allow(clippy::pedantic)] use diesel::sql_types::*; use super::sql_types::UserJob; diff --git a/diesel_cli/tests/print_schema/print_schema_with_enum_set_types/mysql/expected.snap b/diesel_cli/tests/print_schema/print_schema_with_enum_set_types/mysql/expected.snap index cfa188fcfc1b..58f7de68a11e 100644 --- a/diesel_cli/tests/print_schema/print_schema_with_enum_set_types/mysql/expected.snap +++ b/diesel_cli/tests/print_schema/print_schema_with_enum_set_types/mysql/expected.snap @@ -26,6 +26,7 @@ pub mod sql_types { } diesel::table! { + #[allow(clippy::pedantic)] use diesel::sql_types::*; use super::sql_types::Users1UserStateEnum; use super::sql_types::Users1EnabledFeaturesSet; diff --git a/diesel_cli/tests/print_schema/print_schema_with_enum_set_types/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_with_enum_set_types/postgres/expected.snap index f0a0fc7b6423..207dd38430c9 100644 --- a/diesel_cli/tests/print_schema/print_schema_with_enum_set_types/postgres/expected.snap +++ b/diesel_cli/tests/print_schema/print_schema_with_enum_set_types/postgres/expected.snap @@ -24,6 +24,7 @@ pub mod sql_types { } diesel::table! { + #[allow(clippy::pedantic)] use diesel::sql_types::*; use super::sql_types::SomeEnum; use super::sql_types::SomeEnum2; diff --git a/examples/postgres/custom_types/src/schema.rs b/examples/postgres/custom_types/src/schema.rs index 69b72bdc0d36..88adab937916 100644 --- a/examples/postgres/custom_types/src/schema.rs +++ b/examples/postgres/custom_types/src/schema.rs @@ -7,6 +7,7 @@ pub mod sql_types { } diesel::table! { + #[allow(clippy::pedantic)] use diesel::sql_types::*; use super::sql_types::Language;