diff --git a/packages/next-swc/crates/next-custom-transforms/src/transforms/optimize_barrel.rs b/packages/next-swc/crates/next-custom-transforms/src/transforms/optimize_barrel.rs index 7224c9d7359b0..c590e498734cc 100644 --- a/packages/next-swc/crates/next-custom-transforms/src/transforms/optimize_barrel.rs +++ b/packages/next-swc/crates/next-custom-transforms/src/transforms/optimize_barrel.rs @@ -264,8 +264,7 @@ impl Fold for OptimizeBarrel { span: DUMMY_SP, src: Box::new(Str { span: DUMMY_SP, - value: format!("__barrel_optimize__?names=__PLACEHOLDER__!=!{}", src) - .into(), + value: format!("__barrel_optimize__?names=__PLACEHOLDER__!=!{src}").into(), raw: None, }), with: None, diff --git a/packages/next-swc/crates/next-custom-transforms/src/transforms/page_config.rs b/packages/next-swc/crates/next-custom-transforms/src/transforms/page_config.rs index 495eb0abaff31..4af30192677a1 100644 --- a/packages/next-swc/crates/next-custom-transforms/src/transforms/page_config.rs +++ b/packages/next-swc/crates/next-custom-transforms/src/transforms/page_config.rs @@ -55,7 +55,7 @@ impl Fold for PageConfig { type_ann: None, }), init: Some(Box::new(Expr::Lit(Lit::Str(Str { - value: format!("{} {}", STRING_LITERAL_DROP_BUNDLE, timestamp).into(), + value: format!("{STRING_LITERAL_DROP_BUNDLE} {timestamp}").into(), span: DUMMY_SP, raw: None, })))), @@ -171,8 +171,8 @@ impl Fold for PageConfig { impl PageConfig { fn handle_error(&mut self, details: &str, span: Span) { if self.is_page_file { - let message = format!("Invalid page config export found. {} \ - See: https://nextjs.org/docs/messages/invalid-page-config", details); + let message = format!("Invalid page config export found. {details} \ + See: https://nextjs.org/docs/messages/invalid-page-config"); HANDLER.with(|handler| handler.struct_span_err(span, &message).emit()); } } diff --git a/packages/next-swc/crates/next-custom-transforms/src/transforms/page_static_info/collect_exported_const_visitor.rs b/packages/next-swc/crates/next-custom-transforms/src/transforms/page_static_info/collect_exported_const_visitor.rs index 2310425c2a5b0..dd17e788ccaed 100644 --- a/packages/next-swc/crates/next-custom-transforms/src/transforms/page_static_info/collect_exported_const_visitor.rs +++ b/packages/next-swc/crates/next-custom-transforms/src/transforms/page_static_info/collect_exported_const_visitor.rs @@ -101,8 +101,7 @@ fn extract_value(ctx: &ExprCtx, init: &Expr, id: String) -> Option { Some(elem) => { if elem.spread.is_some() { return Some(Const::Unsupported(format!( - "Unsupported spread operator in the Array Expression at \"{}\"", - id + "Unsupported spread operator in the Array Expression at \"{id}\"" ))); } @@ -139,8 +138,7 @@ fn extract_value(ctx: &ExprCtx, init: &Expr, id: String) -> Option { PropName::Str(s) => s.value.as_ref(), _ => { return Some(Const::Unsupported(format!( - "Unsupported key type in the Object Expression at \"{}\"", - id + "Unsupported key type in the Object Expression at \"{id}\"" ))) } }, @@ -148,12 +146,11 @@ fn extract_value(ctx: &ExprCtx, init: &Expr, id: String) -> Option { ), _ => { return Some(Const::Unsupported(format!( - "Unsupported spread operator in the Object Expression at \"{}\"", - id + "Unsupported spread operator in the Object Expression at \"{id}\"" ))) } }; - let new_value = extract_value(ctx, value, format!("{}.{}", id, key)); + let new_value = extract_value(ctx, value, format!("{id}.{key}")); if let Some(Const::Unsupported(msg)) = new_value { return Some(Const::Unsupported(msg)); } @@ -169,8 +166,7 @@ fn extract_value(ctx: &ExprCtx, init: &Expr, id: String) -> Option { // [TODO] should we add support for `${'e'}d${'g'}'e'`? if !tpl.exprs.is_empty() { Some(Const::Unsupported(format!( - "Unsupported template literal with expressions at \"{}\".", - id + "Unsupported template literal with expressions at \"{id}\"." ))) } else { Some( @@ -196,15 +192,13 @@ fn extract_value(ctx: &ExprCtx, init: &Expr, id: String) -> Option { )) }) .unwrap_or(Const::Unsupported(format!( - "Unsupported node type at \"{}\"", - id + "Unsupported node type at \"{id}\"" ))), ) } } _ => Some(Const::Unsupported(format!( - "Unsupported node type at \"{}\"", - id + "Unsupported node type at \"{id}\"" ))), } } diff --git a/packages/next-swc/crates/next-custom-transforms/src/transforms/react_server_components.rs b/packages/next-swc/crates/next-custom-transforms/src/transforms/react_server_components.rs index 3feddac24b8a8..8cbab9c34be43 100644 --- a/packages/next-swc/crates/next-custom-transforms/src/transforms/react_server_components.rs +++ b/packages/next-swc/crates/next-custom-transforms/src/transforms/react_server_components.rs @@ -239,7 +239,7 @@ fn report_error(app_dir: &Option, filepath: &str, error_kind: RSCErrorK "react-dom/server" => "You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials".to_string(), // If importing "next/router", we should tell them to use "next/navigation". "next/router" => r#"You have a Server Component that imports next/router. Use next/navigation instead.\nLearn more: https://nextjs.org/docs/app/api-reference/functions/use-router"#.to_string(), - _ => format!(r#"You're importing a component that imports {}. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials\n\n"#, source) + _ => format!(r#"You're importing a component that imports {source}. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials\n\n"#) }; (msg, span) @@ -257,9 +257,9 @@ fn report_error(app_dir: &Option, filepath: &str, error_kind: RSCErrorK .unwrap_or_default(); let msg = if !is_app_dir { - format!("You're importing a component that needs \"{}\". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/react-essentials#server-components\n\n", source) + format!("You're importing a component that needs \"{source}\". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/react-essentials#server-components\n\n") } else { - format!("You're importing a component that needs \"{}\". That only works in a Server Component but one of its parents is marked with \"use client\", so it's a Client Component.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials\n\n", source) + format!("You're importing a component that needs \"{source}\". That only works in a Server Component but one of its parents is marked with \"use client\", so it's a Client Component.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials\n\n") }; (msg, span) } @@ -267,19 +267,19 @@ fn report_error(app_dir: &Option, filepath: &str, error_kind: RSCErrorK let msg = if source == "Component" { "You’re importing a class component. It only works in a Client Component but none of its parents are marked with \"use client\", so they're Server Components by default.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials#client-components\n\n".to_string() } else { - format!("You're importing a component that needs `{}`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `\"use client\"` directive.\n\n Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components\n\n", source) + format!("You're importing a component that needs `{source}`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `\"use client\"` directive.\n\n Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components\n\n") }; (msg,span) }, RSCErrorKind::NextRscErrErrorFileServerComponent(span) => { ( - format!("{} must be a Client Component. Add the \"use client\" directive the top of the file to resolve this issue.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials#client-components\n\n", filepath), + format!("{filepath} must be a Client Component. Add the \"use client\" directive the top of the file to resolve this issue.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials#client-components\n\n"), span ) }, RSCErrorKind::NextRscErrClientMetadataExport((source, span)) => { - (format!("You are attempting to export \"{}\" from a component marked with \"use client\", which is disallowed. Either remove the export, or the \"use client\" directive. Read more: https://nextjs.org/docs/getting-started/react-essentials#the-use-client-directive\n\n", source), span) + (format!("You are attempting to export \"{source}\" from a component marked with \"use client\", which is disallowed. Either remove the export, or the \"use client\" directive. Read more: https://nextjs.org/docs/getting-started/react-essentials#the-use-client-directive\n\n"), span) }, RSCErrorKind::NextRscErrConflictMetadataExport(span) => ( "\"metadata\" and \"generateMetadata\" cannot be exported at the same time, please keep one of them. Read more: https://nextjs.org/docs/app/api-reference/file-conventions/metadata\n\n".to_string(), @@ -287,7 +287,7 @@ fn report_error(app_dir: &Option, filepath: &str, error_kind: RSCErrorK ), //NEXT_RSC_ERR_INVALID_API RSCErrorKind::NextRscErrInvalidApi((source, span)) => ( - format!("\"{}\" is not supported in app/. Read more: https://nextjs.org/docs/app/building-your-application/data-fetching\n\n", source), span + format!("\"{source}\" is not supported in app/. Read more: https://nextjs.org/docs/app/building-your-application/data-fetching\n\n"), span ), }; @@ -833,7 +833,7 @@ pub fn server_components_assert( }; let filename = match filename { - FileName::Custom(path) => format!("<{}>", path), + FileName::Custom(path) => format!("<{path}>"), _ => filename.to_string(), }; ReactServerComponentValidator::new(is_react_server_layer, filename, app_dir) @@ -855,7 +855,7 @@ pub fn server_components( is_react_server_layer, comments, filepath: match filename { - FileName::Custom(path) => format!("<{}>", path), + FileName::Custom(path) => format!("<{path}>"), _ => filename.to_string(), }, app_dir, diff --git a/packages/next-swc/crates/next-custom-transforms/src/transforms/server_actions.rs b/packages/next-swc/crates/next-custom-transforms/src/transforms/server_actions.rs index f22733d511678..83549a6f45168 100644 --- a/packages/next-swc/crates/next-custom-transforms/src/transforms/server_actions.rs +++ b/packages/next-swc/crates/next-custom-transforms/src/transforms/server_actions.rs @@ -202,7 +202,7 @@ impl ServerActions { let mut pats = vec![]; for i in 0..ids_from_closure.len() { pats.push(Some(Pat::Ident( - Ident::new(format!("$$ACTION_ARG_{}", i).into(), DUMMY_SP).into(), + Ident::new(format!("$$ACTION_ARG_{i}").into(), DUMMY_SP).into(), ))); } let decryption_decl = VarDecl { @@ -326,7 +326,7 @@ impl ServerActions { let mut pats = vec![]; for i in 0..ids_from_closure.len() { pats.push(Some(Pat::Ident( - Ident::new(format!("$$ACTION_ARG_{}", i).into(), DUMMY_SP).into(), + Ident::new(format!("$$ACTION_ARG_{i}").into(), DUMMY_SP).into(), ))); } let decryption_decl = VarDecl { @@ -1228,7 +1228,7 @@ fn retain_names_from_declared_idents(child_names: &mut Vec, current_declar } fn gen_ident(cnt: &mut u32) -> JsWord { - let id: JsWord = format!("$$ACTION_{}", cnt).into(); + let id: JsWord = format!("$$ACTION_{cnt}").into(); *cnt += 1; id } @@ -1402,9 +1402,8 @@ fn remove_server_directive_index_in_module( .struct_span_err( *span, format!( - "Did you mean \"use server\"? \"{}\" is not a supported \ - directive name.", - value + "Did you mean \"use server\"? \"{value}\" is not a supported \ + directive name." ) .as_str(), ) @@ -1507,9 +1506,8 @@ fn remove_server_directive_index_in_fn( .struct_span_err( *span, format!( - "Did you mean \"use server\"? \"{}\" is not a supported \ - directive name.", - value + "Did you mean \"use server\"? \"{value}\" is not a supported \ + directive name." ) .as_str(), ) @@ -1635,7 +1633,7 @@ impl VisitMut for ClosureReplacer<'_> { if let Some(index) = self.index(e) { *e = Expr::Ident(Ident::new( // $$ACTION_ARG_0 - format!("$$ACTION_ARG_{}", index).into(), + format!("$$ACTION_ARG_{index}").into(), DUMMY_SP, )); } @@ -1651,7 +1649,7 @@ impl VisitMut for ClosureReplacer<'_> { key: PropName::Ident(i.clone()), value: Box::new(Expr::Ident(Ident::new( // $$ACTION_ARG_0 - format!("$$ACTION_ARG_{}", index).into(), + format!("$$ACTION_ARG_{index}").into(), DUMMY_SP, ))), }))); diff --git a/scripts/send-trace-to-jaeger/src/main.rs b/scripts/send-trace-to-jaeger/src/main.rs index 146ce99ac41b4..e42da87a1cb0b 100644 --- a/scripts/send-trace-to-jaeger/src/main.rs +++ b/scripts/send-trace-to-jaeger/src/main.rs @@ -19,10 +19,7 @@ where /// Log the url to view the trace in the browser. fn log_web_url(jaeger_web_ui_url: &str, trace_id: &str) { - println!( - "Jaeger trace will be available on {}/trace/{}", - jaeger_web_ui_url, trace_id - ) + println!("Jaeger trace will be available on {jaeger_web_ui_url}/trace/{trace_id}") } /// Send trace JSON to Jaeger using ZipKin API. @@ -45,7 +42,7 @@ fn send_json_to_zipkin(zipkin_api: &str, value: String) { fn pad_zeros(num: u64) -> String { let mut num_str = num.to_string(); while num_str.len() < 16 { - num_str = format!("0{}", num_str); + num_str = format!("0{num_str}"); } num_str } @@ -54,9 +51,9 @@ fn main() { let service_name = "nextjs"; let ipv4 = "127.0.0.1"; let port = 9411; - let zipkin_url = format!("http://{}:{}", ipv4, port); - let jaeger_web_ui_url = format!("http://{}:16686", ipv4); - let zipkin_api = format!("{}/api/v2/spans", zipkin_url); + let zipkin_url = format!("http://{ipv4}:{port}"); + let jaeger_web_ui_url = format!("http://{ipv4}:16686"); + let zipkin_api = format!("{zipkin_url}/api/v2/spans"); let mut logged_url = false; let mut local_endpoint = Map::new(); @@ -100,7 +97,7 @@ fn main() { }) .collect::(), Err(e) => { - println!("{}", e); + println!("{e}"); continue; } };