From f18c18cd15f180b5067069ec6f10530515715f3d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 9 May 2026 12:15:21 +0900 Subject: refactor(console): accept format args directly in console_writeln! macros Eliminate the nested &console_format!(...) boilerplate at every call site by teaching console_writeln!, console_write!, console_writeln_error!, and console_write_error! to accept a format literal + variadic args directly, matching the println!/eprintln! ergonomics. Propagate the format string span into generated code so rustc errors point to the right location. Co-Authored-By: Claude Sonnet 4.6 --- crates/mozart/src/commands/dump_autoload.rs | 37 ++++++++++------------------- 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'crates/mozart/src/commands/dump_autoload.rs') diff --git a/crates/mozart/src/commands/dump_autoload.rs b/crates/mozart/src/commands/dump_autoload.rs index 0d12220..f2db011 100644 --- a/crates/mozart/src/commands/dump_autoload.rs +++ b/crates/mozart/src/commands/dump_autoload.rs @@ -1,7 +1,7 @@ use clap::Args; use mozart_autoload::AutoloadGeneratorExt; use mozart_core::composer::{AutoloadDumpOptions, Composer, PlatformRequirementFilter}; -use mozart_core::{console_format, console_writeln}; +use mozart_core::console_writeln; #[derive(Args, Default)] pub struct DumpAutoloadArgs { @@ -69,9 +69,7 @@ pub async fn execute( missing = true; console_writeln!( console, - &console_format!( - r#"Not all dependencies are installed. Make sure to run a "composer install" to install missing dependencies"# - ), + r#"Not all dependencies are installed. Make sure to run a "composer install" to install missing dependencies"#, ); break; } @@ -99,16 +97,14 @@ pub async fn execute( console_writeln!( console, - &console_format!( - "{}", - if class_map_authoritative { - "Generating optimized autoload files (authoritative)" - } else if optimize { - "Generating optimized autoload files" - } else { - "Generating autoload files" - } - ), + "{}", + if class_map_authoritative { + "Generating optimized autoload files (authoritative)" + } else if optimize { + "Generating optimized autoload files" + } else { + "Generating autoload files" + } ); let dev_mode = if args.dev { @@ -148,22 +144,15 @@ pub async fn execute( if class_map_authoritative { console_writeln!( console, - &console_format!( - "Generated optimized autoload files (authoritative) containing {number_of_classes} classes", - ), + "Generated optimized autoload files (authoritative) containing {number_of_classes} classes", ); } else if optimize { console_writeln!( console, - &console_format!( - "Generated optimized autoload files containing {number_of_classes} classes", - ), + "Generated optimized autoload files containing {number_of_classes} classes", ); } else { - console_writeln!( - console, - &console_format!("Generated autoload files"), - ); + console_writeln!(console, "Generated autoload files"); } if missing_dependencies || args.strict_psr && class_map.has_psr_violations() { -- cgit v1.3.1