From 0de2546d5ed2ab0d5e186d918803a75b84647169 Mon Sep 17 00:00:00 2001 From: Naoki Ikeguchi Date: Sat, 1 Mar 2025 16:28:18 +0900 Subject: [PATCH] fix: remove usages of `gen` reserved keyword --- crates/biome_analyze/src/categories.rs | 4 ++-- crates/biome_configuration/src/analyzer/mod.rs | 4 ++-- crates/biome_configuration/src/bool.rs | 4 ++-- crates/biome_configuration/src/lib.rs | 4 ++-- crates/biome_configuration/src/overrides.rs | 4 ++-- crates/biome_diagnostics/src/display/backtrace.rs | 4 ++-- crates/biome_diagnostics/src/serde.rs | 4 ++-- crates/biome_diagnostics_categories/build.rs | 2 +- crates/biome_fs/src/path.rs | 8 ++++---- crates/biome_glob/src/editorconfig.rs | 4 ++-- crates/biome_glob/src/lib.rs | 4 ++-- .../src/grit_built_in_functions.rs | 4 ++-- .../src/grit_target_language.rs | 2 +- .../lint/correctness/no_undeclared_dependencies.rs | 2 +- .../src/lint/style/use_filenaming_convention.rs | 4 ++-- .../src/lint/style/use_naming_convention.rs | 14 +++++++------- crates/biome_js_analyze/src/react/hooks.rs | 2 +- .../biome_js_analyze/src/utils/restricted_regex.rs | 4 ++-- crates/biome_service/src/workspace.rs | 6 +++--- crates/biome_service/src/workspace_types.rs | 4 ++-- crates/biome_text_size/src/schemars_impls.rs | 10 +++++----- crates/biome_wasm/build.rs | 2 +- crates/tests_macros/src/lib.rs | 4 ++-- 23 files changed, 52 insertions(+), 52 deletions(-) diff --git a/crates/biome_analyze/src/categories.rs b/crates/biome_analyze/src/categories.rs index 1b0835a82e9e..17b576a742bc 100644 --- a/crates/biome_analyze/src/categories.rs +++ b/crates/biome_analyze/src/categories.rs @@ -375,8 +375,8 @@ impl schemars::JsonSchema for RuleCategories { String::from("RuleCategories") } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - >::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + >::json_schema(generator) } } diff --git a/crates/biome_configuration/src/analyzer/mod.rs b/crates/biome_configuration/src/analyzer/mod.rs index fd8f2f625501..d393aad47e29 100644 --- a/crates/biome_configuration/src/analyzer/mod.rs +++ b/crates/biome_configuration/src/analyzer/mod.rs @@ -541,8 +541,8 @@ impl schemars::JsonSchema for RuleSelector { fn schema_name() -> String { "RuleCode".to_string() } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - String::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + String::json_schema(generator) } } diff --git a/crates/biome_configuration/src/bool.rs b/crates/biome_configuration/src/bool.rs index 80625f979b08..fba2e884c8bc 100644 --- a/crates/biome_configuration/src/bool.rs +++ b/crates/biome_configuration/src/bool.rs @@ -106,7 +106,7 @@ impl schemars::JsonSchema for Bool { "Bool".to_string() } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - bool::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + bool::json_schema(generator) } } diff --git a/crates/biome_configuration/src/lib.rs b/crates/biome_configuration/src/lib.rs index de99188c6101..4aaf64d980f4 100644 --- a/crates/biome_configuration/src/lib.rs +++ b/crates/biome_configuration/src/lib.rs @@ -363,8 +363,8 @@ impl schemars::JsonSchema for Schema { "Schema".into() } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - String::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + String::json_schema(generator) } } diff --git a/crates/biome_configuration/src/overrides.rs b/crates/biome_configuration/src/overrides.rs index f04b67e29f78..86a9ed4146b3 100644 --- a/crates/biome_configuration/src/overrides.rs +++ b/crates/biome_configuration/src/overrides.rs @@ -96,8 +96,8 @@ impl schemars::JsonSchema for OverrideGlobs { fn schema_name() -> String { "OverrideGlobs".to_string() } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - Vec::::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + Vec::::json_schema(generator) } } diff --git a/crates/biome_diagnostics/src/display/backtrace.rs b/crates/biome_diagnostics/src/display/backtrace.rs index 3ec9912585e2..6751f5992965 100644 --- a/crates/biome_diagnostics/src/display/backtrace.rs +++ b/crates/biome_diagnostics/src/display/backtrace.rs @@ -97,8 +97,8 @@ impl schemars::JsonSchema for Backtrace { String::from("Backtrace") } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - >::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + >::json_schema(generator) } } diff --git a/crates/biome_diagnostics/src/serde.rs b/crates/biome_diagnostics/src/serde.rs index 73461f2564ab..73307144ccfc 100644 --- a/crates/biome_diagnostics/src/serde.rs +++ b/crates/biome_diagnostics/src/serde.rs @@ -365,8 +365,8 @@ impl schemars::JsonSchema for DiagnosticTags { String::from("DiagnosticTags") } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - >::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + >::json_schema(generator) } } diff --git a/crates/biome_diagnostics_categories/build.rs b/crates/biome_diagnostics_categories/build.rs index 890ae69bef01..a8b180d44d92 100644 --- a/crates/biome_diagnostics_categories/build.rs +++ b/crates/biome_diagnostics_categories/build.rs @@ -70,7 +70,7 @@ pub fn main() -> io::Result<()> { String::from("Category") } - fn json_schema(_gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { schemars::schema::Schema::Object(schemars::schema::SchemaObject { instance_type: Some(schemars::schema::InstanceType::String.into()), enum_values: Some(vec![#( #enum_variants.into() ),*]), diff --git a/crates/biome_fs/src/path.rs b/crates/biome_fs/src/path.rs index a1e3c7f81d7c..cb3b458237bd 100644 --- a/crates/biome_fs/src/path.rs +++ b/crates/biome_fs/src/path.rs @@ -138,8 +138,8 @@ impl schemars::JsonSchema for BiomePath { "BiomePath".to_string() } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - String::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + String::json_schema(generator) } } @@ -260,8 +260,8 @@ impl schemars::JsonSchema for FileKinds { String::from("FileKind") } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - >::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + >::json_schema(generator) } } diff --git a/crates/biome_glob/src/editorconfig.rs b/crates/biome_glob/src/editorconfig.rs index 05a92eda042e..b14ee3bf5904 100644 --- a/crates/biome_glob/src/editorconfig.rs +++ b/crates/biome_glob/src/editorconfig.rs @@ -158,8 +158,8 @@ impl schemars::JsonSchema for EditorconfigGlob { "Glob".to_string() } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - String::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + String::json_schema(generator) } } diff --git a/crates/biome_glob/src/lib.rs b/crates/biome_glob/src/lib.rs index fc09c2e929cc..5c6014c9184b 100644 --- a/crates/biome_glob/src/lib.rs +++ b/crates/biome_glob/src/lib.rs @@ -281,8 +281,8 @@ impl schemars::JsonSchema for Glob { "Glob".to_string() } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - String::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + String::json_schema(generator) } } diff --git a/crates/biome_grit_patterns/src/grit_built_in_functions.rs b/crates/biome_grit_patterns/src/grit_built_in_functions.rs index 267b803dfbf9..ebec6656e204 100644 --- a/crates/biome_grit_patterns/src/grit_built_in_functions.rs +++ b/crates/biome_grit_patterns/src/grit_built_in_functions.rs @@ -327,7 +327,7 @@ fn length_fn<'a>( None => { return Err(GritPatternError::new( "length() requires a list or string as the first argument", - )) + )); } } } @@ -443,7 +443,7 @@ fn random_fn<'a>( Ok(ResolvedPattern::from_constant(Constant::Integer(value))) } [None, None] => { - let value = state.get_rng().gen::(); + let value = state.get_rng().r#gen::(); Ok(ResolvedPattern::from_constant(Constant::Float(value))) } _ => Err(GritPatternError::new( diff --git a/crates/biome_grit_patterns/src/grit_target_language.rs b/crates/biome_grit_patterns/src/grit_target_language.rs index 205483de0eb5..0108848b8435 100644 --- a/crates/biome_grit_patterns/src/grit_target_language.rs +++ b/crates/biome_grit_patterns/src/grit_target_language.rs @@ -80,7 +80,7 @@ macro_rules! generate_target_language { "GritTargetLanguage".to_owned() } - fn json_schema(_gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + fn json_schema(_generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { schemars::schema::Schema::Object(schemars::schema::SchemaObject { enum_values: Some(vec![ $(serde_json::json!($name)),+ diff --git a/crates/biome_js_analyze/src/lint/correctness/no_undeclared_dependencies.rs b/crates/biome_js_analyze/src/lint/correctness/no_undeclared_dependencies.rs index 7b60d2982518..fedfaec0d2c9 100644 --- a/crates/biome_js_analyze/src/lint/correctness/no_undeclared_dependencies.rs +++ b/crates/biome_js_analyze/src/lint/correctness/no_undeclared_dependencies.rs @@ -124,7 +124,7 @@ impl schemars::JsonSchema for DependencyAvailability { "DependencyAvailability".to_owned() } - fn json_schema(_gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + fn json_schema(_generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { use schemars::schema::*; Schema::Object(SchemaObject { diff --git a/crates/biome_js_analyze/src/lint/style/use_filenaming_convention.rs b/crates/biome_js_analyze/src/lint/style/use_filenaming_convention.rs index dd5b08d7bfaf..c18dae324459 100644 --- a/crates/biome_js_analyze/src/lint/style/use_filenaming_convention.rs +++ b/crates/biome_js_analyze/src/lint/style/use_filenaming_convention.rs @@ -491,8 +491,8 @@ impl schemars::JsonSchema for FilenameCases { fn schema_name() -> String { "FilenameCases".to_string() } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - >::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + >::json_schema(generator) } } impl Default for FilenameCases { diff --git a/crates/biome_js_analyze/src/lint/style/use_naming_convention.rs b/crates/biome_js_analyze/src/lint/style/use_naming_convention.rs index 4b9b71e011d1..2c14a2f72dac 100644 --- a/crates/biome_js_analyze/src/lint/style/use_naming_convention.rs +++ b/crates/biome_js_analyze/src/lint/style/use_naming_convention.rs @@ -852,7 +852,7 @@ impl Rule for UseNamingConvention { "This "{format_args!("{convention_selector}")}" name"{trimmed_info}" should be in "{expected_case_names}"." }, )) - }, + } } } @@ -919,7 +919,7 @@ impl Rule for UseNamingConvention { return Some(JsRuleAction::new( ctx.metadata().action_category(ctx.category(), ctx.group()), ctx.metadata().applicability(), - markup! { "Rename this symbol in "{preferred_case.to_string()}"." }.to_owned(), + markup! { "Rename this symbol in "{preferred_case.to_string()}"." }.to_owned(), mutation, )); } @@ -1374,7 +1374,7 @@ impl Selector { } else { Some(Kind::IndexParameter.into()) } - }, + } AnyJsBindingDeclaration::JsNamespaceImportSpecifier(_) => Some(Selector::with_scope(Kind::ImportNamespace, Scope::Global)), AnyJsBindingDeclaration::JsFunctionDeclaration(_) | AnyJsBindingDeclaration::JsFunctionExpression(_) @@ -1854,8 +1854,8 @@ impl JsonSchema for Modifiers { "Modifiers".to_string() } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - >::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + >::json_schema(generator) } } impl From for Modifiers { @@ -2049,8 +2049,8 @@ impl JsonSchema for Formats { fn schema_name() -> String { "Formats".to_string() } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - >::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + >::json_schema(generator) } } diff --git a/crates/biome_js_analyze/src/react/hooks.rs b/crates/biome_js_analyze/src/react/hooks.rs index 1f9c10869c75..1c34bdcb88c3 100644 --- a/crates/biome_js_analyze/src/react/hooks.rs +++ b/crates/biome_js_analyze/src/react/hooks.rs @@ -275,7 +275,7 @@ impl JsonSchema for StableHookResult { "StableHookResult".to_owned() } - fn json_schema(_gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + fn json_schema(_generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { use schemars::schema::*; Schema::Object(SchemaObject { subschemas: Some(Box::new(SubschemaValidation { diff --git a/crates/biome_js_analyze/src/utils/restricted_regex.rs b/crates/biome_js_analyze/src/utils/restricted_regex.rs index 0c0a7e37e983..77b5a3f2a583 100644 --- a/crates/biome_js_analyze/src/utils/restricted_regex.rs +++ b/crates/biome_js_analyze/src/utils/restricted_regex.rs @@ -104,8 +104,8 @@ impl schemars::JsonSchema for RestrictedRegex { "Regex".to_string() } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - String::json_schema(gen) + fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + String::json_schema(generator) } } diff --git a/crates/biome_service/src/workspace.rs b/crates/biome_service/src/workspace.rs index e0c872811a3f..f3d1c4434311 100644 --- a/crates/biome_service/src/workspace.rs +++ b/crates/biome_service/src/workspace.rs @@ -77,7 +77,7 @@ use camino::Utf8Path; use core::str; use enumflags2::{bitflags, BitFlags}; #[cfg(feature = "schema")] -use schemars::{gen::SchemaGenerator, schema::Schema}; +use schemars::{r#gen::SchemaGenerator, schema::Schema}; use smallvec::SmallVec; use std::collections::HashMap; use std::time::Duration; @@ -492,8 +492,8 @@ impl schemars::JsonSchema for FeatureName { String::from("FeatureName") } - fn json_schema(gen: &mut SchemaGenerator) -> Schema { - >::json_schema(gen) + fn json_schema(generator: &mut SchemaGenerator) -> Schema { + >::json_schema(generator) } } diff --git a/crates/biome_service/src/workspace_types.rs b/crates/biome_service/src/workspace_types.rs index e39a6696ba80..9eda3b03675e 100644 --- a/crates/biome_service/src/workspace_types.rs +++ b/crates/biome_service/src/workspace_types.rs @@ -5,7 +5,7 @@ use std::collections::VecDeque; use biome_js_syntax::{AnyJsDeclaration, AnyTsTupleTypeElement}; use rustc_hash::FxHashSet; use schemars::{ - gen::{SchemaGenerator, SchemaSettings}, + r#gen::{SchemaGenerator, SchemaSettings}, schema::{InstanceType, RootSchema, Schema, SchemaObject, SingleOrVec}, JsonSchema, }; @@ -308,7 +308,7 @@ pub fn generate_type<'a>( match root_name { "Null" => return AnyTsType::TsVoidType(make::ts_void_type(make::token(T![void]))), "Boolean" => { - return AnyTsType::TsBooleanType(make::ts_boolean_type(make::token(T![boolean]))) + return AnyTsType::TsBooleanType(make::ts_boolean_type(make::token(T![boolean]))); } "String" => return AnyTsType::TsStringType(make::ts_string_type(make::token(T![string]))), _ => {} diff --git a/crates/biome_text_size/src/schemars_impls.rs b/crates/biome_text_size/src/schemars_impls.rs index 2fe534f7ffad..8dfb9f5f3a9b 100644 --- a/crates/biome_text_size/src/schemars_impls.rs +++ b/crates/biome_text_size/src/schemars_impls.rs @@ -6,17 +6,17 @@ //! bindings to the Workspace API use crate::{TextRange, TextSize}; -use schemars::{gen::SchemaGenerator, schema::Schema, JsonSchema}; +use schemars::{r#gen::SchemaGenerator, schema::Schema, JsonSchema}; impl JsonSchema for TextSize { fn schema_name() -> String { String::from("TextSize") } - fn json_schema(gen: &mut SchemaGenerator) -> Schema { + fn json_schema(generator: &mut SchemaGenerator) -> Schema { // TextSize is represented as a raw u32, see serde_impls.rs for the // actual implementation - ::json_schema(gen) + ::json_schema(generator) } } @@ -25,9 +25,9 @@ impl JsonSchema for TextRange { String::from("TextRange") } - fn json_schema(gen: &mut SchemaGenerator) -> Schema { + fn json_schema(generator: &mut SchemaGenerator) -> Schema { // TextSize is represented as (TextSize, TextSize), see serde_impls.rs // for the actual implementation - <(TextSize, TextSize)>::json_schema(gen) + <(TextSize, TextSize)>::json_schema(generator) } } diff --git a/crates/biome_wasm/build.rs b/crates/biome_wasm/build.rs index 7e291d1eaae2..770e4157be29 100644 --- a/crates/biome_wasm/build.rs +++ b/crates/biome_wasm/build.rs @@ -7,7 +7,7 @@ use biome_js_formatter::{context::JsFormatOptions, format_node}; use biome_rowan::AstNode; use biome_service::workspace_types::{generate_type, methods, ModuleQueue}; use quote::{format_ident, quote}; -use schemars::gen::{SchemaGenerator, SchemaSettings}; +use schemars::r#gen::{SchemaGenerator, SchemaSettings}; use std::{env, fs, io, path::PathBuf}; fn main() -> io::Result<()> { diff --git a/crates/tests_macros/src/lib.rs b/crates/tests_macros/src/lib.rs index b2a5d8fdad43..651864c579e7 100644 --- a/crates/tests_macros/src/lib.rs +++ b/crates/tests_macros/src/lib.rs @@ -179,7 +179,7 @@ impl Arguments { }) } - pub fn gen(&self) -> Result { + pub fn generate(&self) -> Result { let files = self.get_all_files()?; let mut modules = Modules::default(); @@ -247,7 +247,7 @@ impl syn::parse::Parse for Arguments { pub fn gen_tests(input: TokenStream) -> TokenStream { let args = syn::parse_macro_input!(input as Arguments); - match args.gen() { + match args.generate() { Ok(tokens) => tokens, Err(e) => abort!(e, "{}", e), }