From f9e45f27b166a7bd079532916d4a7e01f4fbaf27 Mon Sep 17 00:00:00 2001 From: louisgariepy Date: Sun, 28 Aug 2022 16:05:10 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Replace=20generated=20inner=20attrs?= =?UTF-8?q?=20with=20outer=20attrs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cornucopia_benches/generated_async.rs | 13 ++++++--- .../cornucopia_benches/generated_sync.rs | 13 ++++++--- codegen_test/src/cornucopia_async.rs | 13 ++++++--- codegen_test/src/cornucopia_sync.rs | 13 ++++++--- cornucopia/src/codegen.rs | 27 ++++++++++++------- examples/auto_build/src/cornucopia.rs | 13 ++++++--- examples/basic_async/src/cornucopia.rs | 13 ++++++--- examples/basic_sync/src/cornucopia.rs | 13 ++++++--- 8 files changed, 81 insertions(+), 37 deletions(-) diff --git a/bench/usage/cornucopia_benches/generated_async.rs b/bench/usage/cornucopia_benches/generated_async.rs index 74f3165e..24decb7a 100644 --- a/bench/usage/cornucopia_benches/generated_async.rs +++ b/bench/usage/cornucopia_benches/generated_async.rs @@ -1,9 +1,14 @@ // This file was generated with `cornucopia`. Do not modify. -#![allow(clippy::all, clippy::pedantic)] -#![allow(unused_variables)] -#![allow(unused_imports)] -#![allow(dead_code)] + +#[allow(clippy::all, clippy::pedantic)] +#[allow(unused_variables)] +#[allow(unused_imports)] +#[allow(dead_code)] pub mod types {} +#[allow(clippy::all, clippy::pedantic)] +#[allow(unused_variables)] +#[allow(unused_imports)] +#[allow(dead_code)] pub mod queries { pub mod bench { use cornucopia_async::GenericClient; diff --git a/bench/usage/cornucopia_benches/generated_sync.rs b/bench/usage/cornucopia_benches/generated_sync.rs index aa04d4ed..db25f73c 100644 --- a/bench/usage/cornucopia_benches/generated_sync.rs +++ b/bench/usage/cornucopia_benches/generated_sync.rs @@ -1,9 +1,14 @@ // This file was generated with `cornucopia`. Do not modify. -#![allow(clippy::all, clippy::pedantic)] -#![allow(unused_variables)] -#![allow(unused_imports)] -#![allow(dead_code)] + +#[allow(clippy::all, clippy::pedantic)] +#[allow(unused_variables)] +#[allow(unused_imports)] +#[allow(dead_code)] pub mod types {} +#[allow(clippy::all, clippy::pedantic)] +#[allow(unused_variables)] +#[allow(unused_imports)] +#[allow(dead_code)] pub mod queries { pub mod bench { use postgres::{fallible_iterator::FallibleIterator, GenericClient}; diff --git a/codegen_test/src/cornucopia_async.rs b/codegen_test/src/cornucopia_async.rs index 5cd1474e..b1bb656a 100644 --- a/codegen_test/src/cornucopia_async.rs +++ b/codegen_test/src/cornucopia_async.rs @@ -1,8 +1,9 @@ // This file was generated with `cornucopia`. Do not modify. -#![allow(clippy::all, clippy::pedantic)] -#![allow(unused_variables)] -#![allow(unused_imports)] -#![allow(dead_code)] + +#[allow(clippy::all, clippy::pedantic)] +#[allow(unused_variables)] +#[allow(unused_imports)] +#[allow(dead_code)] pub mod types { pub mod public { #[derive(serde::Serialize, Debug, postgres_types::FromSql, Clone, PartialEq)] @@ -839,6 +840,10 @@ pub mod types { } } } +#[allow(clippy::all, clippy::pedantic)] +#[allow(unused_variables)] +#[allow(unused_imports)] +#[allow(dead_code)] pub mod queries { pub mod copy { use cornucopia_async::GenericClient; diff --git a/codegen_test/src/cornucopia_sync.rs b/codegen_test/src/cornucopia_sync.rs index df3a0966..93bbbc05 100644 --- a/codegen_test/src/cornucopia_sync.rs +++ b/codegen_test/src/cornucopia_sync.rs @@ -1,8 +1,9 @@ // This file was generated with `cornucopia`. Do not modify. -#![allow(clippy::all, clippy::pedantic)] -#![allow(unused_variables)] -#![allow(unused_imports)] -#![allow(dead_code)] + +#[allow(clippy::all, clippy::pedantic)] +#[allow(unused_variables)] +#[allow(unused_imports)] +#[allow(dead_code)] pub mod types { pub mod public { #[derive(serde::Serialize, Debug, postgres_types::FromSql, Clone, PartialEq)] @@ -837,6 +838,10 @@ pub mod types { } } } +#[allow(clippy::all, clippy::pedantic)] +#[allow(unused_variables)] +#[allow(unused_imports)] +#[allow(dead_code)] pub mod queries { pub mod copy { use postgres::{fallible_iterator::FallibleIterator, GenericClient}; diff --git a/cornucopia/src/codegen.rs b/cornucopia/src/codegen.rs index ab1effd2..7de3f013 100644 --- a/cornucopia/src/codegen.rs +++ b/cornucopia/src/codegen.rs @@ -617,7 +617,14 @@ fn gen_type_modules( gen!(w, "pub mod {schema} {{ {tys_str} }}"); }); - gen!(w, "pub mod types {{ {modules_str} }}"); + gen!( + w, + "#[allow(clippy::all, clippy::pedantic)] + #[allow(unused_variables)] + #[allow(unused_imports)] + #[allow(dead_code)] + pub mod types {{ {modules_str} }}" + ); } pub(crate) fn generate(preparation: Preparation, settings: CodegenSettings) -> String { @@ -626,13 +633,7 @@ pub(crate) fn generate(preparation: Preparation, settings: CodegenSettings) -> S } else { "use postgres::{{fallible_iterator::FallibleIterator,GenericClient}};" }; - let mut buff = "// This file was generated with `cornucopia`. Do not modify. - #![allow(clippy::all, clippy::pedantic)] - #![allow(unused_variables)] - #![allow(unused_imports)] - #![allow(dead_code)] - " - .to_string(); + let mut buff = "// This file was generated with `cornucopia`. Do not modify.\n\n".to_string(); // Generate database type gen_type_modules(&mut buff, &preparation.types, settings); // Generate queries @@ -652,6 +653,14 @@ pub(crate) fn generate(preparation: Preparation, settings: CodegenSettings) -> S module.info.name ); }); - gen!(&mut buff, "pub mod queries {{ {} }}", query_modules); + gen!( + &mut buff, + "#[allow(clippy::all, clippy::pedantic)] + #[allow(unused_variables)] + #[allow(unused_imports)] + #[allow(dead_code)] + pub mod queries {{ {} }}", + query_modules + ); buff } diff --git a/examples/auto_build/src/cornucopia.rs b/examples/auto_build/src/cornucopia.rs index 9253130e..2778429f 100644 --- a/examples/auto_build/src/cornucopia.rs +++ b/examples/auto_build/src/cornucopia.rs @@ -1,9 +1,14 @@ // This file was generated with `cornucopia`. Do not modify. -#![allow(clippy::all, clippy::pedantic)] -#![allow(unused_variables)] -#![allow(unused_imports)] -#![allow(dead_code)] + +#[allow(clippy::all, clippy::pedantic)] +#[allow(unused_variables)] +#[allow(unused_imports)] +#[allow(dead_code)] pub mod types {} +#[allow(clippy::all, clippy::pedantic)] +#[allow(unused_variables)] +#[allow(unused_imports)] +#[allow(dead_code)] pub mod queries { pub mod module_1 { use cornucopia_async::GenericClient; diff --git a/examples/basic_async/src/cornucopia.rs b/examples/basic_async/src/cornucopia.rs index be57e017..509a5d13 100644 --- a/examples/basic_async/src/cornucopia.rs +++ b/examples/basic_async/src/cornucopia.rs @@ -1,8 +1,9 @@ // This file was generated with `cornucopia`. Do not modify. -#![allow(clippy::all, clippy::pedantic)] -#![allow(unused_variables)] -#![allow(unused_imports)] -#![allow(dead_code)] + +#[allow(clippy::all, clippy::pedantic)] +#[allow(unused_variables)] +#[allow(unused_imports)] +#[allow(dead_code)] pub mod types { pub mod public { #[derive( @@ -16,6 +17,10 @@ pub mod types { } } } +#[allow(clippy::all, clippy::pedantic)] +#[allow(unused_variables)] +#[allow(unused_imports)] +#[allow(dead_code)] pub mod queries { pub mod module_1 { use cornucopia_async::GenericClient; diff --git a/examples/basic_sync/src/cornucopia.rs b/examples/basic_sync/src/cornucopia.rs index b4916713..664b123f 100644 --- a/examples/basic_sync/src/cornucopia.rs +++ b/examples/basic_sync/src/cornucopia.rs @@ -1,8 +1,9 @@ // This file was generated with `cornucopia`. Do not modify. -#![allow(clippy::all, clippy::pedantic)] -#![allow(unused_variables)] -#![allow(unused_imports)] -#![allow(dead_code)] + +#[allow(clippy::all, clippy::pedantic)] +#[allow(unused_variables)] +#[allow(unused_imports)] +#[allow(dead_code)] pub mod types { pub mod public { #[derive( @@ -16,6 +17,10 @@ pub mod types { } } } +#[allow(clippy::all, clippy::pedantic)] +#[allow(unused_variables)] +#[allow(unused_imports)] +#[allow(dead_code)] pub mod queries { pub mod module_1 { use postgres::{fallible_iterator::FallibleIterator, GenericClient};