From 0656cdecf71aba09179e8349a3d0b7249b813a4d Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Mon, 28 Oct 2024 09:06:33 -0600 Subject: [PATCH] Fewer String types. --- crates/biome_analyze/src/lib.rs | 2 +- crates/biome_analyze/src/rule.rs | 4 ++-- crates/biome_analyze/src/signals.rs | 2 +- crates/biome_analyze/src/suppression_action.rs | 2 +- crates/biome_css_analyze/src/suppression_action.rs | 2 +- crates/biome_graphql_analyze/src/suppression_action.rs | 2 +- crates/biome_js_analyze/src/suppression_action.rs | 2 +- crates/biome_js_transform/src/lib.rs | 2 +- crates/biome_json_analyze/src/suppression_action.rs | 2 +- crates/biome_migrate/src/lib.rs | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/biome_analyze/src/lib.rs b/crates/biome_analyze/src/lib.rs index 6602027a8aa2..9d935477a258 100644 --- a/crates/biome_analyze/src/lib.rs +++ b/crates/biome_analyze/src/lib.rs @@ -787,7 +787,7 @@ pub struct SuppressionCommentEmitterPayload<'a, L: Language> { /// The original range of the diagnostic where the rule was triggered pub diagnostic_text_range: &'a TextRange, /// Explanation for the suppression to be used with `--suppress` and `--reason` - pub suppression_reason: String, + pub suppression_reason: &'a str, } type SignalHandler<'a, L, Break> = &'a mut dyn FnMut(&dyn AnalyzerSignal) -> ControlFlow; diff --git a/crates/biome_analyze/src/rule.rs b/crates/biome_analyze/src/rule.rs index c5e0b024f1c7..3e87b45128f3 100644 --- a/crates/biome_analyze/src/rule.rs +++ b/crates/biome_analyze/src/rule.rs @@ -881,7 +881,7 @@ pub trait Rule: RuleMeta + Sized { ctx: &RuleContext, text_range: &TextRange, suppression_action: &dyn SuppressionAction>, - suppression_reason: Option, + suppression_reason: Option<&str>, ) -> Option>> where Self: 'static, @@ -902,7 +902,7 @@ pub trait Rule: RuleMeta + Sized { mutation: &mut mutation, token_offset: token, diagnostic_text_range: text_range, - suppression_reason: suppression_reason.unwrap_or("".to_string()), + suppression_reason: suppression_reason.unwrap_or(""), }); Some(SuppressAction { diff --git a/crates/biome_analyze/src/signals.rs b/crates/biome_analyze/src/signals.rs index e532db333172..db756d897ce1 100644 --- a/crates/biome_analyze/src/signals.rs +++ b/crates/biome_analyze/src/signals.rs @@ -409,7 +409,7 @@ where &ctx, &text_range, self.suppression_action, - self.suppression_reason.clone(), + self.suppression_reason.as_deref(), ) { let action = AnalyzerAction { rule_name: Some((::NAME, R::METADATA.name)), diff --git a/crates/biome_analyze/src/suppression_action.rs b/crates/biome_analyze/src/suppression_action.rs index 3f4629ddc518..77359a95f085 100644 --- a/crates/biome_analyze/src/suppression_action.rs +++ b/crates/biome_analyze/src/suppression_action.rs @@ -78,7 +78,7 @@ pub trait SuppressionAction { mutation: &mut BatchMutation, apply_suppression: ApplySuppression, suppression_text: &str, - suppression_reason: String, + suppression_reason: &str, ); } diff --git a/crates/biome_css_analyze/src/suppression_action.rs b/crates/biome_css_analyze/src/suppression_action.rs index 25f29e8ff5d6..40025ca101e7 100644 --- a/crates/biome_css_analyze/src/suppression_action.rs +++ b/crates/biome_css_analyze/src/suppression_action.rs @@ -41,7 +41,7 @@ impl SuppressionAction for CssSuppressionAction { mutation: &mut BatchMutation, apply_suppression: ApplySuppression, suppression_text: &str, - suppression_reason: String, + suppression_reason: &str, ) { let ApplySuppression { token_to_apply_suppression, diff --git a/crates/biome_graphql_analyze/src/suppression_action.rs b/crates/biome_graphql_analyze/src/suppression_action.rs index 08f997e6f5a2..bb6da195ec9d 100644 --- a/crates/biome_graphql_analyze/src/suppression_action.rs +++ b/crates/biome_graphql_analyze/src/suppression_action.rs @@ -39,7 +39,7 @@ impl SuppressionAction for GraphqlSuppressionAction { mutation: &mut BatchMutation, apply_suppression: ApplySuppression, suppression_text: &str, - suppression_reason: String, + suppression_reason: &str, ) { let ApplySuppression { token_to_apply_suppression, diff --git a/crates/biome_js_analyze/src/suppression_action.rs b/crates/biome_js_analyze/src/suppression_action.rs index 4cd8a996b7ca..43d21b9001c3 100644 --- a/crates/biome_js_analyze/src/suppression_action.rs +++ b/crates/biome_js_analyze/src/suppression_action.rs @@ -129,7 +129,7 @@ impl SuppressionAction for JsSuppressionAction { mutation: &mut BatchMutation, apply_suppression: ApplySuppression, suppression_text: &str, - suppression_reason: String, + suppression_reason: &str, ) { let ApplySuppression { token_to_apply_suppression, diff --git a/crates/biome_js_transform/src/lib.rs b/crates/biome_js_transform/src/lib.rs index 62b855f8d70c..f6a8255cf56b 100644 --- a/crates/biome_js_transform/src/lib.rs +++ b/crates/biome_js_transform/src/lib.rs @@ -66,7 +66,7 @@ where _: &mut BatchMutation, _: ApplySuppression, _: &str, - _: String, + _: &str, ) { unreachable!("") } diff --git a/crates/biome_json_analyze/src/suppression_action.rs b/crates/biome_json_analyze/src/suppression_action.rs index 70decf433c9d..9d28e9ee1f48 100644 --- a/crates/biome_json_analyze/src/suppression_action.rs +++ b/crates/biome_json_analyze/src/suppression_action.rs @@ -20,7 +20,7 @@ impl SuppressionAction for JsonSuppressionAction { _mutation: &mut BatchMutation, _apply_suppression: ApplySuppression, _suppression_text: &str, - _suppression_reason: String, + _suppression_reason: &str, ) { unreachable!("find_token_to_apply_suppression return None") } diff --git a/crates/biome_migrate/src/lib.rs b/crates/biome_migrate/src/lib.rs index 9e744a3f5062..08262ccbba92 100644 --- a/crates/biome_migrate/src/lib.rs +++ b/crates/biome_migrate/src/lib.rs @@ -74,7 +74,7 @@ where _: &mut BatchMutation, _: ApplySuppression, _: &str, - _: String, + _: &str, ) { unreachable!("") }