From 44eb684ffc0db9caf0292159d3300723a7a786e9 Mon Sep 17 00:00:00 2001 From: Raphael Amorim Date: Wed, 2 Jul 2025 21:58:53 +0200 Subject: [PATCH] update rust --- Cargo.lock | 24 +++++++++--------- Cargo.toml | 18 ++++++------- copa/benches/parser_benchmark.rs | 15 +++++------ copa/examples/advanced_benchmark.rs | 25 ++++++++----------- copa/examples/benchmark_comparison.rs | 20 +++++++-------- copa/examples/parselog.rs | 22 ++++++---------- corcovado/src/channel.rs | 4 +-- corcovado/src/event_imp.rs | 4 +-- corcovado/src/sys/unix/ready.rs | 2 +- frontends/rioterm/src/application.rs | 6 ++--- frontends/rioterm/src/context/mod.rs | 2 +- frontends/rioterm/src/context/title.rs | 2 +- frontends/rioterm/src/renderer/navigation.rs | 4 +-- frontends/rioterm/src/router/routes/dialog.rs | 4 +-- .../rioterm/src/router/routes/welcome.rs | 2 +- frontends/rioterm/src/screen/mod.rs | 2 +- .../advance_until_terminated_benchmark.rs | 2 ++ rio-backend/examples/batch_utf8_benchmark.rs | 2 ++ .../examples/enhanced_batched_parser_test.rs | 2 ++ .../examples/parser_comparison_benchmark.rs | 2 ++ rio-backend/examples/rio_usage_benchmark.rs | 2 ++ rio-backend/examples/simd_performance_test.rs | 3 +++ rio-backend/examples/utf8_benchmark.rs | 2 ++ rio-backend/src/ansi/sixel.rs | 18 +++---------- rio-backend/src/config/mod.rs | 4 +-- rio-backend/src/crosswords/mod.rs | 4 +-- rio-backend/src/performer/handler.rs | 4 +-- rio-proc-macros/src/lib.rs | 6 ++--- rio-window/src/event.rs | 2 +- rust-toolchain.toml | 2 +- sugarloaf/examples/multi_text.rs | 2 ++ .../src/components/filters/builtin/mod.rs | 4 +-- sugarloaf/src/components/filters/mod.rs | 1 - .../components/rich_text/positioning_tests.rs | 2 ++ sugarloaf/src/font/loader/mod.rs | 2 +- sugarloaf/src/font/text_run_cache.rs | 2 ++ sugarloaf/src/font_introspector/attributes.rs | 10 ++++---- .../src/font_introspector/internal/parse.rs | 2 +- sugarloaf/src/font_introspector/shape/aat.rs | 3 +-- .../font_introspector/text/cluster/info.rs | 2 +- sugarloaf/src/font_introspector/text/lang.rs | 14 +++++------ sugarloaf/src/layout/content.rs | 2 ++ teletypewriter/src/unix/macos.rs | 4 +-- teletypewriter/src/unix/mod.rs | 6 ++--- 44 files changed, 129 insertions(+), 138 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 830dd865..f6d6e19b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 4 [[package]] name = "ab_glyph" -version = "0.2.29" +version = "0.2.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3672c180e71eeaaac3a541fbbc5f5ad4def8b747c595ad30d674e43049f7b0" +checksum = "1e0f4f6fbdc5ee39f2ede9f5f3ec79477271a6d6a2baff22310d51736bda6cea" dependencies = [ "ab_glyph_rasterizer", "owned_ttf_parser", @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "ab_glyph_rasterizer" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" +checksum = "b2187590a23ab1e3df8681afdf0987c48504d80291f002fcdb651f0ef5e25169" [[package]] name = "adler2" @@ -517,7 +517,7 @@ checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "copa" -version = "0.2.20" +version = "0.3.0" dependencies = [ "arrayvec", "criterion", @@ -543,7 +543,7 @@ dependencies = [ [[package]] name = "corcovado" -version = "0.2.20" +version = "0.3.0" dependencies = [ "bytes", "cfg-if 0.1.10", @@ -2754,7 +2754,7 @@ checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" [[package]] name = "rio-backend" -version = "0.2.20" +version = "0.3.0" dependencies = [ "base64", "bitflags 2.9.1", @@ -2787,7 +2787,7 @@ dependencies = [ [[package]] name = "rio-proc-macros" -version = "0.2.20" +version = "0.3.0" dependencies = [ "proc-macro2", "quote", @@ -2795,7 +2795,7 @@ dependencies = [ [[package]] name = "rio-window" -version = "0.2.20" +version = "0.3.0" dependencies = [ "ahash", "atomic-waker", @@ -2847,7 +2847,7 @@ dependencies = [ [[package]] name = "rioterm" -version = "0.2.20" +version = "0.3.0" dependencies = [ "ahash", "bitflags 2.9.1", @@ -3300,7 +3300,7 @@ dependencies = [ [[package]] name = "sugarloaf" -version = "0.2.20" +version = "0.3.0" dependencies = [ "approx", "bytemuck", @@ -3382,7 +3382,7 @@ dependencies = [ [[package]] name = "teletypewriter" -version = "0.2.20" +version = "0.3.0" dependencies = [ "corcovado", "dirs", diff --git a/Cargo.toml b/Cargo.toml index 90c5f41b..1d981870 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,13 +12,13 @@ members = [ resolver = "2" [workspace.package] -version = "0.2.20" +version = "0.3.0" authors = ["Raphael Amorim "] edition = "2021" license = "MIT" keywords = ["graphics", "terminal", "application"] # Minimal stable rust version (MSRV) -rust-version = "1.87.0" +rust-version = "1.88.0" repository = "https://github.com/raphamorim/rio" homepage = "https://raphamorim.io/rio" documentation = "https://github.com/raphamorim/rio#readme" @@ -28,15 +28,15 @@ readme = "README.md" # Note: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#multiple-locations # Sugarloaf example uses path when used locally, but uses # version from crates.io when published. -teletypewriter = { path = "teletypewriter", version = "0.2.20" } -rio-backend = { path = "rio-backend", version = "0.2.20" } -rio-window = { path = "rio-window", version = "0.2.20", default-features = false } -sugarloaf = { path = "sugarloaf", version = "0.2.20" } +teletypewriter = { path = "teletypewriter", version = "0.3.0" } +rio-backend = { path = "rio-backend", version = "0.3.0" } +rio-window = { path = "rio-window", version = "0.3.0", default-features = false } +sugarloaf = { path = "sugarloaf", version = "0.3.0" } # Own dependencies -copa = { path = "copa", default-features = true, version = "0.2.20" } -rio-proc-macros = { path = "rio-proc-macros", version = "0.2.20" } -corcovado = { path = "corcovado", version = "0.2.20" } +copa = { path = "copa", default-features = true, version = "0.3.0" } +rio-proc-macros = { path = "rio-proc-macros", version = "0.3.0" } +corcovado = { path = "corcovado", version = "0.3.0" } raw-window-handle = { version = "0.6.2", features = ["std"] } parking_lot = { version = "0.12.4", features = [ "nightly", diff --git a/copa/benches/parser_benchmark.rs b/copa/benches/parser_benchmark.rs index 6ce9a08c..2eb66348 100644 --- a/copa/benches/parser_benchmark.rs +++ b/copa/benches/parser_benchmark.rs @@ -299,11 +299,8 @@ fn bench_real_world_scenarios(c: &mut Criterion) { let mut data = Vec::new(); for i in 0..100 { data.extend_from_slice( - format!( - "drwxr-xr-x 2 user group 4096 Jan 1 12:00 πŸ“folder_{}\n", - i - ) - .as_bytes(), + format!("drwxr-xr-x 2 user group 4096 Jan 1 12:00 πŸ“folder_{i}\n") + .as_bytes(), ); data.extend_from_slice( format!( @@ -329,12 +326,12 @@ fn bench_real_world_scenarios(c: &mut Criterion) { let mut data = Vec::new(); for i in 0..50 { data.extend_from_slice( - format!("\x1b[33mcommit abc123{}\x1b[0m\n", i).as_bytes(), + format!("\x1b[33mcommit abc123{i}\x1b[0m\n").as_bytes(), ); data.extend_from_slice("Author: Developer πŸ‘¨β€πŸ’» \n".as_bytes()); data.extend_from_slice("Date: Mon Jan 1 12:00:00 2024 +0000\n\n".as_bytes()); data.extend_from_slice( - format!(" πŸš€ Add feature {} with δΈ­ζ–‡ support\n\n", i).as_bytes(), + format!(" πŸš€ Add feature {i} with δΈ­ζ–‡ support\n\n").as_bytes(), ); } data @@ -353,11 +350,11 @@ fn bench_real_world_scenarios(c: &mut Criterion) { let mut data = Vec::new(); for i in 0..200 { data.extend_from_slice( - format!("// This is a comment with UTF-8: πŸ¦€ Rust code line {}\n", i) + format!("// This is a comment with UTF-8: πŸ¦€ Rust code line {i}\n") .as_bytes(), ); data.extend_from_slice( - format!("fn function_{}() -> Result<(), Error> {{\n", i).as_bytes(), + format!("fn function_{i}() -> Result<(), Error> {{\n").as_bytes(), ); data.extend_from_slice(" println!(\"Hello, δΈ–η•Œ! 🌍\");\n".as_bytes()); data.extend_from_slice(b" Ok(())\n}\n\n"); diff --git a/copa/examples/advanced_benchmark.rs b/copa/examples/advanced_benchmark.rs index 3c12eb8c..45734f4b 100644 --- a/copa/examples/advanced_benchmark.rs +++ b/copa/examples/advanced_benchmark.rs @@ -129,11 +129,8 @@ impl BenchmarkSuite { let mut ls_output = Vec::new(); for i in 0..100 { ls_output.extend_from_slice( - format!( - "drwxr-xr-x 2 user group 4096 Jan 1 12:00 πŸ“folder_{}\n", - i - ) - .as_bytes(), + format!("drwxr-xr-x 2 user group 4096 Jan 1 12:00 πŸ“folder_{i}\n") + .as_bytes(), ); ls_output.extend_from_slice( format!( @@ -149,8 +146,7 @@ impl BenchmarkSuite { let mut git_log = Vec::new(); for i in 0..50 { git_log.extend_from_slice(format!( - "\x1b[33mcommit abc123{}\x1b[0m\nAuthor: Dev πŸ‘¨β€πŸ’» \nDate: Mon Jan 1 12:00:00 2024\n\n πŸš€ Feature {} with δΈ­ζ–‡ support\n\n", - i, i + "\x1b[33mcommit abc123{i}\x1b[0m\nAuthor: Dev πŸ‘¨β€πŸ’» \nDate: Mon Jan 1 12:00:00 2024\n\n πŸš€ Feature {i} with δΈ­ζ–‡ support\n\n" ).as_bytes()); } self.add_test("Git Log", &git_log, 1000); @@ -159,8 +155,7 @@ impl BenchmarkSuite { let mut source_code = Vec::new(); for i in 0..100 { source_code.extend_from_slice(format!( - "// Comment with UTF-8: πŸ¦€ Rust line {}\nfn function_{}() -> Result<(), Error> {{\n println!(\"Hello, δΈ–η•Œ! 🌍\");\n Ok(())\n}}\n\n", - i, i + "// Comment with UTF-8: πŸ¦€ Rust line {i}\nfn function_{i}() -> Result<(), Error> {{\n println!(\"Hello, δΈ–η•Œ! 🌍\");\n Ok(())\n}}\n\n" ).as_bytes()); } self.add_test("Source Code", &source_code, 1000); @@ -240,9 +235,9 @@ impl BenchmarkSuite { println!(); println!("Summary Statistics:"); - println!(" Average throughput: {:.2} MB/s", avg_throughput); - println!(" Maximum throughput: {:.2} MB/s", max_throughput); - println!(" Minimum throughput: {:.2} MB/s", min_throughput); + println!(" Average throughput: {avg_throughput:.2} MB/s"); + println!(" Maximum throughput: {max_throughput:.2} MB/s"); + println!(" Minimum throughput: {min_throughput:.2} MB/s"); println!(" Total test cases: {}", self.results.len()); // Category analysis @@ -369,7 +364,7 @@ fn print_system_info() { println!(); let implementation = detect_implementation(); - println!("Implementation: {}", implementation); + println!("Implementation: {implementation}"); println!( "Rust version: {}", std::env::var("RUSTC_VERSION").unwrap_or_else(|_| "unknown".to_string()) @@ -422,10 +417,10 @@ fn main() { let filename = format!("copa_benchmark_{}.json", detect_implementation()); if let Err(e) = std::fs::write(&filename, json_output) { - eprintln!("Warning: Could not write results to {}: {}", filename, e); + eprintln!("Warning: Could not write results to {filename}: {e}"); } else { println!(); - println!("Results exported to: {}", filename); + println!("Results exported to: {filename}"); } println!(); diff --git a/copa/examples/benchmark_comparison.rs b/copa/examples/benchmark_comparison.rs index 6ede376c..8286f656 100644 --- a/copa/examples/benchmark_comparison.rs +++ b/copa/examples/benchmark_comparison.rs @@ -99,8 +99,7 @@ fn generate_test_data() -> Vec<(&'static str, Vec, usize)> { let mut data = Vec::new(); for i in 0..50 { data.extend_from_slice(format!( - "\x1b[33mcommit abc123{}\x1b[0m\nAuthor: Dev πŸ‘¨β€πŸ’» \nDate: Mon Jan 1 12:00:00 2024\n\n πŸš€ Feature {} with δΈ­ζ–‡ support\n\n", - i, i + "\x1b[33mcommit abc123{i}\x1b[0m\nAuthor: Dev πŸ‘¨β€πŸ’» \nDate: Mon Jan 1 12:00:00 2024\n\n πŸš€ Feature {i} with δΈ­ζ–‡ support\n\n" ).as_bytes()); } data @@ -109,8 +108,7 @@ fn generate_test_data() -> Vec<(&'static str, Vec, usize)> { let mut data = Vec::new(); for i in 0..100 { data.extend_from_slice(format!( - "// Comment with UTF-8: πŸ¦€ Rust line {}\nfn function_{}() -> Result<(), Error> {{\n println!(\"Hello, δΈ–η•Œ! 🌍\");\n Ok(())\n}}\n\n", - i, i + "// Comment with UTF-8: πŸ¦€ Rust line {i}\nfn function_{i}() -> Result<(), Error> {{\n println!(\"Hello, δΈ–η•Œ! 🌍\");\n Ok(())\n}}\n\n" ).as_bytes()); } data @@ -159,7 +157,7 @@ fn print_system_info() { Err(_) => "std::str (standard library)", }; - println!("Implementation: {}", implementation); + println!("Implementation: {implementation}"); println!( "Rust version: {}", std::env::var("RUSTC_VERSION").unwrap_or_else(|_| "unknown".to_string()) @@ -241,9 +239,9 @@ fn main() { println!(); println!("Summary Statistics:"); - println!(" Average throughput: {:.2} MB/s", avg_throughput); - println!(" Maximum throughput: {:.2} MB/s", max_throughput); - println!(" Minimum throughput: {:.2} MB/s", min_throughput); + println!(" Average throughput: {avg_throughput:.2} MB/s"); + println!(" Maximum throughput: {max_throughput:.2} MB/s"); + println!(" Minimum throughput: {min_throughput:.2} MB/s"); println!(" Total test cases: {}", results.len()); println!(); @@ -272,13 +270,13 @@ fn main() { if !utf8_tests.is_empty() { let utf8_avg: f64 = utf8_tests.iter().map(|r| r.throughput_mbps).sum::() / utf8_tests.len() as f64; - println!(" UTF-8 heavy workloads: {:.2} MB/s average", utf8_avg); + println!(" UTF-8 heavy workloads: {utf8_avg:.2} MB/s average"); } if !ascii_tests.is_empty() { let ascii_avg: f64 = ascii_tests.iter().map(|r| r.throughput_mbps).sum::() / ascii_tests.len() as f64; - println!(" ASCII workloads: {:.2} MB/s average", ascii_avg); + println!(" ASCII workloads: {ascii_avg:.2} MB/s average"); } if !real_world_tests.is_empty() { @@ -287,7 +285,7 @@ fn main() { .map(|r| r.throughput_mbps) .sum::() / real_world_tests.len() as f64; - println!(" Real-world scenarios: {:.2} MB/s average", real_world_avg); + println!(" Real-world scenarios: {real_world_avg:.2} MB/s average"); } println!(); diff --git a/copa/examples/parselog.rs b/copa/examples/parselog.rs index 892efadd..2d2f70e9 100644 --- a/copa/examples/parselog.rs +++ b/copa/examples/parselog.rs @@ -8,22 +8,21 @@ struct Log; impl Perform for Log { fn print(&mut self, c: char) { - println!("[print] {:?}", c); + println!("[print] {c:?}"); } fn execute(&mut self, byte: u8) { - println!("[execute] {:02x}", byte); + println!("[execute] {byte:02x}"); } fn hook(&mut self, params: &Params, intermediates: &[u8], ignore: bool, c: char) { println!( - "[hook] params={:?}, intermediates={:?}, ignore={:?}, char={:?}", - params, intermediates, ignore, c + "[hook] params={params:?}, intermediates={intermediates:?}, ignore={ignore:?}, char={c:?}" ); } fn put(&mut self, byte: u8) { - println!("[put] {:02x}", byte); + println!("[put] {byte:02x}"); } fn unhook(&mut self) { @@ -31,10 +30,7 @@ impl Perform for Log { } fn osc_dispatch(&mut self, params: &[&[u8]], bell_terminated: bool) { - println!( - "[osc_dispatch] params={:?} bell_terminated={}", - params, bell_terminated - ); + println!("[osc_dispatch] params={params:?} bell_terminated={bell_terminated}"); } fn csi_dispatch( @@ -45,15 +41,13 @@ impl Perform for Log { c: char, ) { println!( - "[csi_dispatch] params={:#?}, intermediates={:?}, ignore={:?}, char={:?}", - params, intermediates, ignore, c + "[csi_dispatch] params={params:#?}, intermediates={intermediates:?}, ignore={ignore:?}, char={c:?}" ); } fn esc_dispatch(&mut self, intermediates: &[u8], ignore: bool, byte: u8) { println!( - "[esc_dispatch] intermediates={:?}, ignore={:?}, byte={:02x}", - intermediates, ignore, byte + "[esc_dispatch] intermediates={intermediates:?}, ignore={ignore:?}, byte={byte:02x}" ); } } @@ -74,7 +68,7 @@ fn main() { statemachine.advance(&mut performer, &buf); } Err(err) => { - println!("err: {}", err); + println!("err: {err}"); break; } } diff --git a/corcovado/src/channel.rs b/corcovado/src/channel.rs index 2924047e..78d405a9 100644 --- a/corcovado/src/channel.rs +++ b/corcovado/src/channel.rs @@ -397,7 +397,7 @@ impl fmt::Display for TrySendError { #[inline] fn format_send_error(e: &SendError, f: &mut fmt::Formatter) -> fmt::Result { match *e { - SendError::Io(ref io_err) => write!(f, "{}", io_err), + SendError::Io(ref io_err) => write!(f, "{io_err}"), SendError::Disconnected(..) => write!(f, "Disconnected"), } } @@ -405,7 +405,7 @@ fn format_send_error(e: &SendError, f: &mut fmt::Formatter) -> fmt::Result #[inline] fn format_try_send_error(e: &TrySendError, f: &mut fmt::Formatter) -> fmt::Result { match *e { - TrySendError::Io(ref io_err) => write!(f, "{}", io_err), + TrySendError::Io(ref io_err) => write!(f, "{io_err}"), TrySendError::Full(..) => write!(f, "Full"), TrySendError::Disconnected(..) => write!(f, "Disconnected"), } diff --git a/corcovado/src/event_imp.rs b/corcovado/src/event_imp.rs index 96cbe8ef..97f4aa71 100644 --- a/corcovado/src/event_imp.rs +++ b/corcovado/src/event_imp.rs @@ -570,7 +570,7 @@ impl fmt::Debug for PollOpt { if one { write!(fmt, " | ")? } - write!(fmt, "{}", msg)?; + write!(fmt, "{msg}")?; one = true } @@ -1037,7 +1037,7 @@ impl fmt::Debug for Ready { if one { write!(fmt, " | ")? } - write!(fmt, "{}", msg)?; + write!(fmt, "{msg}")?; one = true } diff --git a/corcovado/src/sys/unix/ready.rs b/corcovado/src/sys/unix/ready.rs index a3b1a161..344dd2c2 100644 --- a/corcovado/src/sys/unix/ready.rs +++ b/corcovado/src/sys/unix/ready.rs @@ -512,7 +512,7 @@ impl fmt::Debug for UnixReady { if one { write!(fmt, " | ")? } - write!(fmt, "{}", msg)?; + write!(fmt, "{msg}")?; one = true } diff --git a/frontends/rioterm/src/application.rs b/frontends/rioterm/src/application.rs index 91261019..0fca0f44 100644 --- a/frontends/rioterm/src/application.rs +++ b/frontends/rioterm/src/application.rs @@ -1335,10 +1335,8 @@ impl ApplicationHandler for Application<'_> { // SAFETY: The clipboard must be dropped before the event loop, so use the nop clipboard // as a safe placeholder. - std::mem::swap( - &mut self.router.clipboard, - &mut std::rc::Rc::new(std::cell::RefCell::new(Clipboard::new_nop())), - ); + self.router.clipboard = + std::rc::Rc::new(std::cell::RefCell::new(Clipboard::new_nop())); std::process::exit(0); } diff --git a/frontends/rioterm/src/context/mod.rs b/frontends/rioterm/src/context/mod.rs index 8c3170fd..85550dbe 100644 --- a/frontends/rioterm/src/context/mod.rs +++ b/frontends/rioterm/src/context/mod.rs @@ -656,7 +656,7 @@ impl ContextManager { self.event_proxy .send_event(RioEvent::Title(content.to_owned()), self.window_id); - id.push_str(&format!("{}{};", i, content)); + id.push_str(&format!("{i}{content};")); if self.config.should_update_title_extra { self.titles.set_key_val( diff --git a/frontends/rioterm/src/context/title.rs b/frontends/rioterm/src/context/title.rs index ab5e6bbf..1e02e5f3 100644 --- a/frontends/rioterm/src/context/title.rs +++ b/frontends/rioterm/src/context/title.rs @@ -24,7 +24,7 @@ impl ContextManagerTitles { content: String, extra: Option, ) -> ContextManagerTitles { - let key = format!("{}{};", idx, content); + let key = format!("{idx}{content};"); let mut map = FxHashMap::default(); map.insert(idx, ContextTitle { content, extra }); ContextManagerTitles { diff --git a/frontends/rioterm/src/renderer/navigation.rs b/frontends/rioterm/src/renderer/navigation.rs index acfa1421..d8bd2fe8 100644 --- a/frontends/rioterm/src/renderer/navigation.rs +++ b/frontends/rioterm/src/renderer/navigation.rs @@ -241,9 +241,9 @@ impl ScreenNavigation { } let text = if is_current { - format!("β–² {}", name) + format!("β–² {name}") } else { - format!("{}.{}", i + 1, name) + format!("{}.{name}", i + 1) }; let tab = sugarloaf.create_temp_rich_text(); diff --git a/frontends/rioterm/src/router/routes/dialog.rs b/frontends/rioterm/src/router/routes/dialog.rs index 9441a1e9..bdfe2540 100644 --- a/frontends/rioterm/src/router/routes/dialog.rs +++ b/frontends/rioterm/src/router/routes/dialog.rs @@ -69,7 +69,7 @@ pub fn screen( confirm_line .clear() .add_text( - &format!(" {} ", confirm_content), + &format!(" {confirm_content} "), FragmentStyle { color: [0., 0., 0., 1.], background_color: Some(yellow), @@ -88,7 +88,7 @@ pub fn screen( quit_line .clear() .add_text( - &format!(" {} ", quit_content), + &format!(" {quit_content} "), FragmentStyle { color: [0., 0., 0., 1.], background_color: Some(red), diff --git a/frontends/rioterm/src/router/routes/welcome.rs b/frontends/rioterm/src/router/routes/welcome.rs index 35e1dc16..3115f472 100644 --- a/frontends/rioterm/src/router/routes/welcome.rs +++ b/frontends/rioterm/src/router/routes/welcome.rs @@ -95,7 +95,7 @@ pub fn screen(sugarloaf: &mut Sugarloaf, context_dimension: &ContextDimension) { .add_text("To open settings menu use", FragmentStyle::default()) .new_line() .add_text( - &format!(" {} ", shortcut), + &format!(" {shortcut} "), FragmentStyle { background_color: Some(yellow), color: [0., 0., 0., 1.], diff --git a/frontends/rioterm/src/screen/mod.rs b/frontends/rioterm/src/screen/mod.rs index 115576a5..d0ddaefa 100644 --- a/frontends/rioterm/src/screen/mod.rs +++ b/frontends/rioterm/src/screen/mod.rs @@ -1948,7 +1948,7 @@ impl Screen<'_> { if self.get_mode().contains(Mode::FOCUS_IN_OUT) { let chr = if is_focused { "I" } else { "O" }; - let msg = format!("\x1b[{}", chr); + let msg = format!("\x1b[{chr}"); self.ctx_mut() .current_mut() .messenger diff --git a/rio-backend/examples/advance_until_terminated_benchmark.rs b/rio-backend/examples/advance_until_terminated_benchmark.rs index 5ff0d577..a3775f36 100644 --- a/rio-backend/examples/advance_until_terminated_benchmark.rs +++ b/rio-backend/examples/advance_until_terminated_benchmark.rs @@ -2,6 +2,8 @@ //! //! Run with: cargo run --release --example advance_until_terminated_benchmark +#![allow(clippy::uninlined_format_args)] + use copa::{Parser, Perform}; use rio_backend::batched_parser::BatchedParser; use std::time::Instant; diff --git a/rio-backend/examples/batch_utf8_benchmark.rs b/rio-backend/examples/batch_utf8_benchmark.rs index c355b640..02022d45 100644 --- a/rio-backend/examples/batch_utf8_benchmark.rs +++ b/rio-backend/examples/batch_utf8_benchmark.rs @@ -2,6 +2,8 @@ //! //! Run with: cargo run --release --example batch_utf8_benchmark +#![allow(clippy::uninlined_format_args)] + use rio_backend::{batch_utf8, simd_utf8}; use std::time::Instant; diff --git a/rio-backend/examples/enhanced_batched_parser_test.rs b/rio-backend/examples/enhanced_batched_parser_test.rs index 33190b28..4ae63905 100644 --- a/rio-backend/examples/enhanced_batched_parser_test.rs +++ b/rio-backend/examples/enhanced_batched_parser_test.rs @@ -2,6 +2,8 @@ //! //! Run with: cargo run --release --example enhanced_batched_parser_test +#![allow(clippy::uninlined_format_args)] + use copa::Perform; use rio_backend::batched_parser::BatchedParser; diff --git a/rio-backend/examples/parser_comparison_benchmark.rs b/rio-backend/examples/parser_comparison_benchmark.rs index 3828a321..fb1f9ea4 100644 --- a/rio-backend/examples/parser_comparison_benchmark.rs +++ b/rio-backend/examples/parser_comparison_benchmark.rs @@ -2,6 +2,8 @@ //! //! Run with: cargo run --release --example parser_comparison_benchmark +#![allow(clippy::uninlined_format_args)] + use copa::{Parser, Perform}; use rio_backend::batched_parser::BatchedParser; use std::time::Instant; diff --git a/rio-backend/examples/rio_usage_benchmark.rs b/rio-backend/examples/rio_usage_benchmark.rs index bf0ed1d0..262312f4 100644 --- a/rio-backend/examples/rio_usage_benchmark.rs +++ b/rio-backend/examples/rio_usage_benchmark.rs @@ -2,6 +2,8 @@ //! //! Run with: cargo run --release --example rio_usage_benchmark +#![allow(clippy::uninlined_format_args)] + use copa::{Parser, Perform}; use rio_backend::batched_parser::BatchedParser; use std::time::Instant; diff --git a/rio-backend/examples/simd_performance_test.rs b/rio-backend/examples/simd_performance_test.rs index 41b2a463..ccec9b1d 100644 --- a/rio-backend/examples/simd_performance_test.rs +++ b/rio-backend/examples/simd_performance_test.rs @@ -1,7 +1,10 @@ +#![allow(clippy::uninlined_format_args)] + use std::time::Instant; fn main() { println!("Rio Terminal - SIMD UTF-8 Performance Test"); + println!("=========================================="); // Test cases representing common terminal content diff --git a/rio-backend/examples/utf8_benchmark.rs b/rio-backend/examples/utf8_benchmark.rs index 1f8ea58e..1a1ad963 100644 --- a/rio-backend/examples/utf8_benchmark.rs +++ b/rio-backend/examples/utf8_benchmark.rs @@ -2,6 +2,8 @@ //! //! Run with: cargo run --release --example utf8_benchmark +#![allow(clippy::uninlined_format_args)] + use std::time::Instant; fn main() { diff --git a/rio-backend/src/ansi/sixel.rs b/rio-backend/src/ansi/sixel.rs index 05dd5e25..983571ef 100644 --- a/rio-backend/src/ansi/sixel.rs +++ b/rio-backend/src/ansi/sixel.rs @@ -71,11 +71,7 @@ impl fmt::Display for Error { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Error::TooBigImage { width, height } => { - write!( - fmt, - "The image dimensions are too big ({}, {})", - width, height - ) + write!(fmt, "The image dimensions are too big ({width}, {height})") } Error::InvalidColorComponent { @@ -84,8 +80,7 @@ impl fmt::Display for Error { } => { write!( fmt, - "Invalid color component {} for register {}", - component_value, register + "Invalid color component {component_value} for register {register}" ) } @@ -95,8 +90,7 @@ impl fmt::Display for Error { } => { write!( fmt, - "Invalid color coordinate system {} for register {}", - coordinate_system, register + "Invalid color coordinate system {coordinate_system} for register {register}" ) } @@ -719,11 +713,7 @@ mod tests { // Reimplement abs_diff to be compatible with rustc before 1.60. fn abs_diff(x: u8, y: u8) -> u8 { - if x > y { - x - y - } else { - y - x - } + x.abs_diff(y) } macro_rules! assert_color { diff --git a/rio-backend/src/config/mod.rs b/rio-backend/src/config/mod.rs index 95d387c6..64127707 100644 --- a/rio-backend/src/config/mod.rs +++ b/rio-backend/src/config/mod.rs @@ -324,7 +324,7 @@ impl Config { Ok(decoded) } - Err(err_message) => Err(format!("error parsing: {:?}", err_message)), + Err(err_message) => Err(format!("error parsing: {err_message:?}")), } } else { Err(String::from("filepath does not exist")) @@ -336,7 +336,7 @@ impl Config { let content = std::fs::read_to_string(path).unwrap(); match toml::from_str::(&content) { Ok(decoded) => Ok(decoded), - Err(err_message) => Err(format!("error parsing: {:?}", err_message)), + Err(err_message) => Err(format!("error parsing: {err_message:?}")), } } else { Err(String::from("filepath does not exist")) diff --git a/rio-backend/src/crosswords/mod.rs b/rio-backend/src/crosswords/mod.rs index 5a4ce4ce..6edbd251 100644 --- a/rio-backend/src/crosswords/mod.rs +++ b/rio-backend/src/crosswords/mod.rs @@ -2739,9 +2739,9 @@ impl Handler for Crosswords { fn generate_response(pi: u16, ps: u16, pv: &[usize]) -> String { use std::fmt::Write; - let mut text = format!("\x1b[?{};{}", pi, ps); + let mut text = format!("\x1b[?{pi};{ps}"); for item in pv { - let _ = write!(&mut text, ";{}", item); + let _ = write!(&mut text, ";{item}"); } text.push('S'); text diff --git a/rio-backend/src/performer/handler.rs b/rio-backend/src/performer/handler.rs index 3de221e1..bce09c88 100644 --- a/rio-backend/src/performer/handler.rs +++ b/rio-backend/src/performer/handler.rs @@ -1330,7 +1330,7 @@ fn process_xtgettcap_request(buffer: &[u8]) -> String { // Encode both name and value in hex let hex_name = encode_hex_string(&capability_name); let hex_value = encode_hex_string(&value); - format!("\x1bP1+r{}={}\x1b\\", hex_name, hex_value) + format!("\x1bP1+r{hex_name}={hex_value}\x1b\\") } else { // Invalid capability name - return error response "\x1bP0+r\x1b\\".to_string() @@ -1355,7 +1355,7 @@ fn decode_hex_string(hex_bytes: &[u8]) -> Result { /// Encode string as hex (2 hex digits per character). fn encode_hex_string(s: &str) -> String { - s.bytes().map(|b| format!("{:02X}", b)).collect() + s.bytes().map(|b| format!("{b:02X}")).collect() } /// Get termcap/terminfo capability value for Rio terminal. diff --git a/rio-proc-macros/src/lib.rs b/rio-proc-macros/src/lib.rs index e53c164e..500a1f48 100644 --- a/rio-proc-macros/src/lib.rs +++ b/rio-proc-macros/src/lib.rs @@ -145,7 +145,7 @@ fn optional_punct(iter: &mut Peekable, c: char) -> bool fn expect_punct(iter: &mut impl Iterator, c: char) { match iter.next() { Some(Punct(ref punct)) if punct.as_char() == c => (), - token => panic!("Expected punctuation '{}', but got {:?}", c, token), + token => panic!("Expected punctuation '{c}', but got {token:?}"), } } @@ -165,7 +165,7 @@ fn next_usize(iter: &mut impl Iterator) -> usize { literal.parse::().unwrap() } } - token => panic!("Expected literal, but got {:?}", token), + token => panic!("Expected literal, but got {token:?}"), } } @@ -177,6 +177,6 @@ fn next_usize(iter: &mut impl Iterator) -> usize { fn next_group(iter: &mut impl Iterator) -> TokenStream { match iter.next() { Some(Group(group)) => group.stream(), - token => panic!("Expected group, but got {:?}", token), + token => panic!("Expected group, but got {token:?}"), } } diff --git a/rio-window/src/event.rs b/rio-window/src/event.rs index e70c5d15..288b0c3c 100644 --- a/rio-window/src/event.rs +++ b/rio-window/src/event.rs @@ -1231,7 +1231,7 @@ mod tests { #[test] fn ensure_attrs_do_not_panic() { foreach_event!(|event: event::Event<()>| { - let _ = format!("{:?}", event); + let _ = format!("{event:?}"); }); let _ = event::StartCause::Init.clone(); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index ea8b9888..1671f607 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.87" +channel = "1.88" profile = "minimal" components = [ "rustfmt", "clippy" ] diff --git a/sugarloaf/examples/multi_text.rs b/sugarloaf/examples/multi_text.rs index ff805cda..67d5f1c6 100644 --- a/sugarloaf/examples/multi_text.rs +++ b/sugarloaf/examples/multi_text.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + use raw_window_handle::{HasDisplayHandle, HasWindowHandle}; use rio_window::application::ApplicationHandler; use rio_window::event_loop::ControlFlow; diff --git a/sugarloaf/src/components/filters/builtin/mod.rs b/sugarloaf/src/components/filters/builtin/mod.rs index b937f033..509e1946 100644 --- a/sugarloaf/src/components/filters/builtin/mod.rs +++ b/sugarloaf/src/components/filters/builtin/mod.rs @@ -22,10 +22,10 @@ impl fmt::Display for LoadError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { LoadError::ParseError(details) => { - write!(f, "Parse failed: {}", details) + write!(f, "Parse failed: {details}") } LoadError::IoError(details) => { - write!(f, "File failed: {}", details) + write!(f, "File failed: {details}") } } } diff --git a/sugarloaf/src/components/filters/mod.rs b/sugarloaf/src/components/filters/mod.rs index 71220492..ed125c5e 100644 --- a/sugarloaf/src/components/filters/mod.rs +++ b/sugarloaf/src/components/filters/mod.rs @@ -63,7 +63,6 @@ impl FiltersBrush { } }, Err(e) => { - println!("{:?}", e); tracing::error!("Failed to build shader preset from builtin filter {}: {}", configured_filter, e) }, } diff --git a/sugarloaf/src/components/rich_text/positioning_tests.rs b/sugarloaf/src/components/rich_text/positioning_tests.rs index 5efc2a76..af91b046 100644 --- a/sugarloaf/src/components/rich_text/positioning_tests.rs +++ b/sugarloaf/src/components/rich_text/positioning_tests.rs @@ -3,6 +3,8 @@ // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. // + +#![allow(clippy::uninlined_format_args)] // Positioning tests for cached vs non-cached text rendering use crate::components::rich_text::text_run_manager::{CacheResult, TextRunManager}; diff --git a/sugarloaf/src/font/loader/mod.rs b/sugarloaf/src/font/loader/mod.rs index 9a909160..981869fc 100644 --- a/sugarloaf/src/font/loader/mod.rs +++ b/sugarloaf/src/font/loader/mod.rs @@ -68,7 +68,7 @@ impl core::fmt::Display for LoadError { match self { LoadError::MalformedFont => write!(f, "malformed font"), LoadError::UnnamedFont => write!(f, "font doesn't have a family name"), - LoadError::IoError(ref e) => write!(f, "{}", e), + LoadError::IoError(ref e) => write!(f, "{e}"), } } } diff --git a/sugarloaf/src/font/text_run_cache.rs b/sugarloaf/src/font/text_run_cache.rs index 7fb2a431..015d15e2 100644 --- a/sugarloaf/src/font/text_run_cache.rs +++ b/sugarloaf/src/font/text_run_cache.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + use rustc_hash::FxHasher; use std::hash::{Hash, Hasher}; use std::sync::Arc; diff --git a/sugarloaf/src/font_introspector/attributes.rs b/sugarloaf/src/font_introspector/attributes.rs index 8ad9ed16..23f53c5f 100644 --- a/sugarloaf/src/font_introspector/attributes.rs +++ b/sugarloaf/src/font_introspector/attributes.rs @@ -233,15 +233,15 @@ impl fmt::Display for Attributes { return write!(f, "regular"); } if stretch != Stretch::NORMAL { - write!(f, "{}", stretch)?; + write!(f, "{stretch}")?; space = " "; } if style != Style::Normal { - write!(f, "{}{}", space, style)?; + write!(f, "{space}{style}")?; space = " "; } if weight != Weight::NORMAL { - write!(f, "{}{}", space, weight)?; + write!(f, "{space}{weight}")?; } Ok(()) } @@ -429,7 +429,7 @@ impl fmt::Display for Style { if degrees == 14. { "oblique" } else { - return write!(f, "oblique({}deg)", degrees); + return write!(f, "oblique({degrees}deg)"); } } } @@ -486,7 +486,7 @@ impl fmt::Display for Weight { if s.is_empty() { write!(f, "{}", self.0) } else { - write!(f, "{}", s) + write!(f, "{s}") } } } diff --git a/sugarloaf/src/font_introspector/internal/parse.rs b/sugarloaf/src/font_introspector/internal/parse.rs index 2bf227ce..e880aa01 100644 --- a/sugarloaf/src/font_introspector/internal/parse.rs +++ b/sugarloaf/src/font_introspector/internal/parse.rs @@ -296,7 +296,7 @@ where if i > 0 { write!(f, ", ")?; } - write!(f, "{:?}", value)?; + write!(f, "{value:?}")?; } write!(f, "]") } diff --git a/sugarloaf/src/font_introspector/shape/aat.rs b/sugarloaf/src/font_introspector/shape/aat.rs index 6a1c6805..826fb377 100644 --- a/sugarloaf/src/font_introspector/shape/aat.rs +++ b/sugarloaf/src/font_introspector/shape/aat.rs @@ -379,8 +379,7 @@ pub fn apply_kern(data: &[u8], kern: u32, buffer: &mut Buffer) -> Option<()> { } else if let Some(base) = find_base(buffer, buffer.is_rtl, i) { - let diff = - if base >= i { base - i } else { i - base }; + let diff = base.abs_diff(i); if diff < 255 { let pos = &mut buffer.positions[i]; if pos.base == 0 { diff --git a/sugarloaf/src/font_introspector/text/cluster/info.rs b/sugarloaf/src/font_introspector/text/cluster/info.rs index ee9936dc..2ea480b0 100644 --- a/sugarloaf/src/font_introspector/text/cluster/info.rs +++ b/sugarloaf/src/font_introspector/text/cluster/info.rs @@ -170,7 +170,7 @@ impl fmt::Debug for ClusterInfo { Boundary::Word => "w", _ => " ", }; - write!(f, "{}{}{}", e, s, b) + write!(f, "{e}{s}{b}") } } diff --git a/sugarloaf/src/font_introspector/text/lang.rs b/sugarloaf/src/font_introspector/text/lang.rs index 0c353040..1996f879 100644 --- a/sugarloaf/src/font_introspector/text/lang.rs +++ b/sugarloaf/src/font_introspector/text/lang.rs @@ -207,13 +207,13 @@ impl fmt::Display for Language { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.language())?; if let Some(script) = self.script() { - write!(f, "-{}", script)?; + write!(f, "-{script}")?; } if let Some(region) = self.region() { - write!(f, "-{}", region)?; + write!(f, "-{region}")?; } if let Some(name) = self.name() { - write!(f, " ({})", name)?; + write!(f, " ({name})")?; } Ok(()) } @@ -223,19 +223,19 @@ impl fmt::Debug for Language { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.language())?; if let Some(script) = self.script() { - write!(f, "-{}", script)?; + write!(f, "-{script}")?; } if let Some(region) = self.region() { - write!(f, "-{}", region)?; + write!(f, "-{region}")?; } if let Some(tag) = self.tag { let tag = tag.to_be_bytes(); if let Ok(s) = core::str::from_utf8(&tag) { - write!(f, " ({})", s)?; + write!(f, " ({s})")?; } } if let Some(name) = self.name() { - write!(f, " \"{}\"", name)?; + write!(f, " \"{name}\"")?; } Ok(()) } diff --git a/sugarloaf/src/layout/content.rs b/sugarloaf/src/layout/content.rs index 31031aa9..f5f53c46 100644 --- a/sugarloaf/src/layout/content.rs +++ b/sugarloaf/src/layout/content.rs @@ -3,6 +3,8 @@ // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. +#![allow(clippy::uninlined_format_args)] + use crate::components::rich_text::RichTextBrush; use crate::font::FontLibrary; use crate::font_introspector::shape::cluster::OwnedGlyphCluster; diff --git a/teletypewriter/src/unix/macos.rs b/teletypewriter/src/unix/macos.rs index d41b4a1b..b6a3407b 100644 --- a/teletypewriter/src/unix/macos.rs +++ b/teletypewriter/src/unix/macos.rs @@ -34,10 +34,10 @@ impl Display for Error { match self { Error::InvalidSize => write!(f, "Invalid proc_pidinfo return size"), Error::Io(err) => { - write!(f, "Error getting current working directory: {}", err) + write!(f, "Error getting current working directory: {err}") } Error::IntoString(err) => { - write!(f, "Error when parsing current working directory: {}", err) + write!(f, "Error when parsing current working directory: {err}") } } } diff --git a/teletypewriter/src/unix/mod.rs b/teletypewriter/src/unix/mod.rs index d935d9d7..0a649686 100644 --- a/teletypewriter/src/unix/mod.rs +++ b/teletypewriter/src/unix/mod.rs @@ -617,8 +617,7 @@ pub fn create_pty_with_fork(shell: &str, columns: u16, rows: u16) -> Result { default_shell_command(shell_program); Err(Error::other(format!( - "forkpty has reach unreachable with {}", - shell_program + "forkpty has reach unreachable with {shell_program}" ))) } id if id > 0 => { @@ -648,8 +647,7 @@ pub fn create_pty_with_fork(shell: &str, columns: u16, rows: u16) -> Result Err(Error::other(format!( - "forkpty failed using {}", - shell_program + "forkpty failed using {shell_program}" ))), } } -- 2.51.2