From 7e46b881a3c9141b9d11259baec125bcfd5a5ed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Mon, 9 Dec 2024 07:57:34 +0900 Subject: [PATCH] fix clippy issues --- src/mdx_plugin_recma_jsx_rewrite.rs | 16 ++++++++-------- src/swc_util_build_jsx.rs | 4 ++-- src/swc_utils.rs | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/mdx_plugin_recma_jsx_rewrite.rs b/src/mdx_plugin_recma_jsx_rewrite.rs index 5140297..ab50db2 100644 --- a/src/mdx_plugin_recma_jsx_rewrite.rs +++ b/src/mdx_plugin_recma_jsx_rewrite.rs @@ -160,7 +160,7 @@ struct State<'a> { explicit_jsxs: FxHashSet, } -impl<'a> State<'a> { +impl State<'_> { /// Open a new scope. fn enter(&mut self, info: Option) { self.scopes.push(Scope { @@ -202,7 +202,7 @@ impl<'a> State<'a> { // ```jsx // props.components // ``` - if is_props_receiving_fn(&info.name) { + if is_props_receiving_fn(info.name.as_deref()) { let member = MemberExpr { obj: Box::new(create_ident_expression("props")), prop: MemberProp::Ident(create_ident("components")), @@ -552,7 +552,7 @@ impl<'a> State<'a> { } /// Reference a component or object name. - fn ref_dynamic(&mut self, path: &[String], component: bool, position: &Option) { + fn ref_dynamic(&mut self, path: &[String], component: bool, position: Option<&Position>) { let scope = self.current_top_level_info().expect("expected scope"); let name = path.join("."); let existing = scope.dynamic.iter_mut().find(|d| d.name == name); @@ -565,7 +565,7 @@ impl<'a> State<'a> { let dynamic = Dynamic { name, component, - position: position.clone(), + position: position.cloned(), }; scope.dynamic.push(dynamic); @@ -592,7 +592,7 @@ impl<'a> State<'a> { // If there is a top-level, non-global, scope which is a function: if let Some(info) = self.current_top_level_info() { // Rewrite only if we can rewrite. - if is_props_receiving_fn(&info.name) || self.provider { + if is_props_receiving_fn(info.name.as_deref()) || self.provider { debug_assert!(!ids.is_empty(), "expected non-empty ids"); let explicit_jsx = self.explicit_jsxs.contains(&span); let mut path = ids.to_owned(); @@ -611,7 +611,7 @@ impl<'a> State<'a> { // Component or object not in scope. let mut index = 1; while index <= path.len() { - self.ref_dynamic(&path[0..index], index == ids.len(), &position); + self.ref_dynamic(&path[0..index], index == ids.len(), position.as_ref()); index += 1; } } @@ -691,7 +691,7 @@ impl<'a> State<'a> { } } -impl<'a> VisitMut for State<'a> { +impl VisitMut for State<'_> { noop_visit_mut_type!(); /// Rewrite JSX identifiers. @@ -999,7 +999,7 @@ fn create_error_helper(development: bool, path: Option) -> ModuleItem { } /// Check if this function is a props receiving component: it’s one of ours. -fn is_props_receiving_fn(name: &Option) -> bool { +fn is_props_receiving_fn(name: Option<&str>) -> bool { if let Some(name) = name { name == "_createMdxContent" || name == "MDXContent" } else { diff --git a/src/swc_util_build_jsx.rs b/src/swc_util_build_jsx.rs index db61954..bbc63fa 100644 --- a/src/swc_util_build_jsx.rs +++ b/src/swc_util_build_jsx.rs @@ -173,7 +173,7 @@ struct State<'a> { fragment_expression: Expr, } -impl<'a> State<'a> { +impl State<'_> { /// Turn an attribute value into an expression. fn jsx_attribute_value_to_expression( &mut self, @@ -590,7 +590,7 @@ impl<'a> State<'a> { } } -impl<'a> VisitMut for State<'a> { +impl VisitMut for State<'_> { noop_visit_mut_type!(); /// Visit expressions, rewriting JSX, and walking deeper. diff --git a/src/swc_utils.rs b/src/swc_utils.rs index 1124b57..37d873e 100644 --- a/src/swc_utils.rs +++ b/src/swc_utils.rs @@ -116,7 +116,7 @@ pub struct RewriteStopsContext<'a> { pub location: Option<&'a Location>, } -impl<'a> VisitMut for RewriteStopsContext<'a> { +impl VisitMut for RewriteStopsContext<'_> { noop_visit_mut_type!(); /// Rewrite spans.