diff --git a/benches/function.rs b/benches/function.rs index 52d7947f30..8983e8f20e 100644 --- a/benches/function.rs +++ b/benches/function.rs @@ -130,17 +130,16 @@ fn main() { &["undefined_from_scope", "undefined_from_isolate"][..], ), ] { - println!("Running {} ...", group_name); + println!("Running {group_name} ..."); for x in benches { let code = format!( " - function bench() {{ return {}(); }}; - runs = {}; + function bench() {{ return {x}(); }}; + runs = {runs}; start = Date.now(); for (i = 0; i < runs; i++) bench(); Date.now() - start; ", - x, runs ); let r = eval(scope, &code).unwrap(); @@ -150,8 +149,7 @@ fn main() { let ns_per_run = total_ns / (runs as f64); let mops_per_sec = (runs as f64) / (total_ms / 1000.0) / 1e6; println!( - " {:.1} ns per run {:.1} million ops/sec → {}", - ns_per_run, mops_per_sec, x + " {ns_per_run:.1} ns per run {mops_per_sec:.1} million ops/sec → {x}" ); } } diff --git a/build.rs b/build.rs index d916ab6068..777c7e3904 100644 --- a/build.rs +++ b/build.rs @@ -52,7 +52,7 @@ fn main() { "CARGO_ENCODED_RUSTFLAGS", ]; for env in envs { - println!("cargo:rerun-if-env-changed={}", env); + println!("cargo:rerun-if-env-changed={env}"); } // Detect if trybuild tests are being compiled. @@ -133,7 +133,7 @@ fn acquire_lock() -> LockFile { let mut lockfile = LockFile::open(&lockfilepath) .expect("Couldn't open lib download lockfile."); lockfile.lock_with_pid().expect("Couldn't get lock"); - println!("lockfile: {:?}", &lockfilepath); + println!("lockfile: {lockfilepath:?}"); lockfile } @@ -213,12 +213,12 @@ fn build_v8(is_asan: bool) { gn_args.push("line_tables_only=false".into()); } else if let Some(clang_base_path) = find_compatible_system_clang() { println!("clang_base_path (system): {}", clang_base_path.display()); - gn_args.push(format!("clang_base_path={:?}", clang_base_path)); + gn_args.push(format!("clang_base_path={clang_base_path:?}")); gn_args.push("treat_warnings_as_errors=false".to_string()); } else { println!("using Chromium's clang"); let clang_base_path = clang_download(); - gn_args.push(format!("clang_base_path={:?}", clang_base_path)); + gn_args.push(format!("clang_base_path={clang_base_path:?}")); if target_os == "android" && target_arch == "aarch64" { gn_args.push("treat_warnings_as_errors=false".to_string()); @@ -270,8 +270,8 @@ fn build_v8(is_asan: bool) { if target_arch == "x86_64" { maybe_install_sysroot("amd64"); } - gn_args.push(format!(r#"v8_target_cpu="{}""#, arch).to_string()); - gn_args.push(format!(r#"target_cpu="{}""#, arch).to_string()); + gn_args.push(format!(r#"v8_target_cpu="{arch}""#).to_string()); + gn_args.push(format!(r#"target_cpu="{arch}""#).to_string()); gn_args.push(r#"target_os="android""#.to_string()); gn_args.push("treat_warnings_as_errors=false".to_string()); gn_args.push("use_sysroot=true".to_string()); @@ -302,14 +302,11 @@ fn build_v8(is_asan: bool) { static CHROMIUM_URI: &str = "https://chromium.googlesource.com"; maybe_clone_repo( "./third_party/android_platform", - &format!( - "{}/chromium/src/third_party/android_platform.git", - CHROMIUM_URI - ), + &format!("{CHROMIUM_URI}/chromium/src/third_party/android_platform.git",), ); maybe_clone_repo( "./third_party/catapult", - &format!("{}/catapult.git", CHROMIUM_URI), + &format!("{CHROMIUM_URI}/catapult.git"), ); } @@ -351,11 +348,11 @@ fn maybe_clone_repo(dest: &str, repo: &str) { } fn maybe_install_sysroot(arch: &str) { - let sysroot_path = format!("build/linux/debian_sid_{}-sysroot", arch); + let sysroot_path = format!("build/linux/debian_sid_{arch}-sysroot"); if !PathBuf::from(sysroot_path).is_dir() { assert!(Command::new(python()) .arg("./build/linux/sysroot_scripts/install-sysroot.py") - .arg(format!("--arch={}", arch)) + .arg(format!("--arch={arch}")) .status() .unwrap() .success()); @@ -431,10 +428,8 @@ fn static_lib_url() -> String { let profile = prebuilt_profile(); let features = prebuilt_features_suffix(); format!( - "{}/v{}/{}.gz", - base, - version, - static_lib_name(&format!("{}_{}_{}", features, profile, target)), + "{base}/v{version}/{}.gz", + static_lib_name(&format!("{features}_{profile}_{target}")), ) } @@ -511,7 +506,7 @@ fn download_file(url: &str, filename: &Path) { // Try downloading with python first. Python is a V8 build dependency, // so this saves us from adding a Rust HTTP client dependency. - println!("Downloading (using Python) {}", url); + println!("Downloading (using Python) {url}"); let status = Command::new(python()) .arg("./tools/download_file.py") .arg("--url") @@ -554,7 +549,7 @@ fn download_file(url: &str, filename: &Path) { fn download_static_lib_binaries() { let url = static_lib_url(); - println!("static lib URL: {}", url); + println!("static lib URL: {url}"); let dir = static_lib_dir(); std::fs::create_dir_all(&dir).unwrap(); @@ -653,7 +648,7 @@ fn print_link_flags() { // Based on https://github.com/alexcrichton/cc-rs/blob/fba7feded71ee4f63cfe885673ead6d7b4f2f454/src/lib.rs#L2462 if let Ok(stdlib) = env::var("CXXSTDLIB") { if !stdlib.is_empty() { - println!("cargo:rustc-link-lib=dylib={}", stdlib); + println!("cargo:rustc-link-lib=dylib={stdlib}"); } } else { let target = env::var("TARGET").unwrap(); @@ -692,20 +687,20 @@ fn print_link_flags() { fn print_prebuilt_src_binding_path() { if let Ok(binding) = env::var("RUSTY_V8_SRC_BINDING_PATH") { - println!("cargo:rustc-env=RUSTY_V8_SRC_BINDING_PATH={}", binding); + println!("cargo:rustc-env=RUSTY_V8_SRC_BINDING_PATH={binding}"); return; } let target = env::var("TARGET").unwrap(); let profile = prebuilt_profile(); let features = prebuilt_features_suffix(); - let name = format!("src_binding{}_{}_{}.rs", features, profile, target); + let name = format!("src_binding{features}_{profile}_{target}.rs"); let src_binding_path = get_dirs().root.join("gen").join(name.clone()); if let Ok(base) = env::var("RUSTY_V8_MIRROR") { let version = env::var("CARGO_PKG_VERSION").unwrap(); - let url = format!("{}/v{}/{}", base, version, name); + let url = format!("{base}/v{version}/{name}"); download_file(&url, &src_binding_path); } @@ -778,7 +773,7 @@ fn clang_download() -> PathBuf { } fn cc_wrapper(gn_args: &mut Vec, sccache_path: &Path) { - gn_args.push(format!("cc_wrapper={:?}", sccache_path)); + gn_args.push(format!("cc_wrapper={sccache_path:?}")); } struct Dirs { @@ -837,7 +832,7 @@ fn maybe_symlink_root_dir(dirs: &mut Dirs) { let symlink = &*out.join("gn_root"); let target = &*root.canonicalize().unwrap(); - println!("Creating symlink {:?} to {:?}", &symlink, &root); + println!("Creating symlink {symlink:?} to {root:?}"); let mut retries = 0; loop { @@ -845,19 +840,19 @@ fn maybe_symlink_root_dir(dirs: &mut Dirs) { Ok(existing) if existing == target => break, Ok(_) => remove_dir_all(symlink).expect("remove_dir_all failed"), Err(err) => { - println!("symlink.canonicalize failed: {:?}", err); + println!("symlink.canonicalize failed: {err:?}"); // we're having very strange issues on GHA when the cache // is restored, so trying this out temporarily if let Err(err) = remove_dir_all(symlink) { - eprintln!("remove_dir_all failed: {:?}", err); + eprintln!("remove_dir_all failed: {err:?}"); if let Err(err) = remove_file(symlink) { - eprintln!("remove_file failed: {:?}", err); + eprintln!("remove_file failed: {err:?}"); } } match symlink_dir(target, symlink) { Ok(_) => break, Err(err) => { - println!("symlink_dir failed: {:?}", err); + println!("symlink_dir failed: {err:?}"); retries += 1; std::thread::sleep(std::time::Duration::from_millis( 50 * retries, @@ -884,7 +879,7 @@ pub fn is_debug() -> bool { } else if m == "debug" { true } else { - panic!("unhandled PROFILE value {}", m) + panic!("unhandled PROFILE value {m}") } } diff --git a/examples/android/lib.rs b/examples/android/lib.rs index 84ed6fa86e..3a007c277e 100644 --- a/examples/android/lib.rs +++ b/examples/android/lib.rs @@ -103,7 +103,7 @@ fn execute_script( .map(|value| value.to_rust_string_lossy(try_catch)) .unwrap_or_else(|| "no stack trace".into()); - panic!("{}", exception_string); + panic!("{exception_string}"); } } @@ -128,7 +128,7 @@ fn draw( .map(|value| value.to_rust_string_lossy(try_catch)) .unwrap_or_else(|| "no stack trace".into()); - panic!("{}", exception_string); + panic!("{exception_string}"); } }; diff --git a/examples/cppgc-object.rs b/examples/cppgc-object.rs index 4b739d909a..707ee693e9 100644 --- a/examples/cppgc-object.rs +++ b/examples/cppgc-object.rs @@ -122,6 +122,6 @@ fn execute_script( |value| value.to_rust_string_lossy(try_catch), ); - panic!("{}", exception_string); + panic!("{exception_string}"); } } diff --git a/examples/cppgc.rs b/examples/cppgc.rs index 21e55310fa..0ba256e7b0 100644 --- a/examples/cppgc.rs +++ b/examples/cppgc.rs @@ -14,7 +14,7 @@ impl std::fmt::Display for Rope { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.part)?; if let Some(next) = self.next.borrow() { - write!(f, "{}", next)?; + write!(f, "{next}")?; } Ok(()) } @@ -67,7 +67,7 @@ fn main() { ) }; - println!("{}", rope); + println!("{rope}"); // Manually trigger garbage collection. heap.enable_detached_garbage_collections_for_testing(); @@ -80,7 +80,7 @@ fn main() { } // Should still be live here: - println!("{}", rope); + println!("{rope}"); println!("Collect: NoHeapPointers"); unsafe { diff --git a/examples/process.rs b/examples/process.rs index 009c574053..9fbb655e59 100644 --- a/examples/process.rs +++ b/examples/process.rs @@ -13,7 +13,7 @@ fn log_callback( .unwrap() .to_rust_string_lossy(scope); - println!("Logged: {}", message); + println!("Logged: {message}"); } fn main() { @@ -32,7 +32,7 @@ fn main() { let mut scope = v8::HandleScope::new(&mut isolate); let source = std::fs::read_to_string(&file) - .unwrap_or_else(|err| panic!("failed to open {}: {}", file, err)); + .unwrap_or_else(|err| panic!("failed to open {file}: {err}")); let source = v8::String::new(&mut scope, &source).unwrap(); let mut processor = JsHttpRequestProcessor::new(&mut scope, source, options); @@ -223,7 +223,7 @@ where .unwrap() .to_rust_string_lossy(try_catch); - panic!("{}", exception_string); + panic!("{exception_string}"); } } @@ -251,7 +251,7 @@ where .unwrap() .to_rust_string_lossy(try_catch); - panic!("{}", exception_string); + panic!("{exception_string}"); } } @@ -376,7 +376,7 @@ where let key = key.to_string(scope).unwrap().to_rust_string_lossy(scope); let value = value.to_string(scope).unwrap().to_rust_string_lossy(scope); - println!("{}: {}", key, value); + println!("{key}: {value}"); } } } diff --git a/examples/shell.rs b/examples/shell.rs index b1bb41cfcd..6cda6c574e 100644 --- a/examples/shell.rs +++ b/examples/shell.rs @@ -44,7 +44,7 @@ fn run_shell(scope: &mut v8::HandleScope) { execute_string(scope, &buf, "(shell)", true, true); } - Err(error) => println!("error: {}", error), + Err(error) => println!("error: {error}"), } } } @@ -89,7 +89,7 @@ fn run_main( } arg => { if arg.starts_with("--") { - eprintln!("Warning: unknown flag {}.\nTry --help for options", arg); + eprintln!("Warning: unknown flag {arg}.\nTry --help for options"); continue; } @@ -174,7 +174,7 @@ fn report_exceptions(mut try_catch: v8::TryCatch) { let message = if let Some(message) = try_catch.message() { message } else { - eprintln!("{}", exception_string); + eprintln!("{exception_string}"); return; }; @@ -191,7 +191,7 @@ fn report_exceptions(mut try_catch: v8::TryCatch) { ); let line_number = message.get_line_number(&mut try_catch).unwrap_or_default(); - eprintln!("{}:{}: {}", filename, line_number, exception_string); + eprintln!("{filename}:{line_number}: {exception_string}"); // Print line of source code. let source_line = message @@ -202,7 +202,7 @@ fn report_exceptions(mut try_catch: v8::TryCatch) { .to_rust_string_lossy(&mut try_catch) }) .unwrap(); - eprintln!("{}", source_line); + eprintln!("{source_line}"); // Print wavy underline (GetUnderline is deprecated). let start_column = message.get_start_column(); @@ -231,6 +231,6 @@ fn report_exceptions(mut try_catch: v8::TryCatch) { .map(|s| s.to_rust_string_lossy(&mut try_catch)); if let Some(stack_trace) = stack_trace { - eprintln!("{}", stack_trace); + eprintln!("{stack_trace}"); } } diff --git a/src/data.rs b/src/data.rs index a09b402183..b1da55585a 100644 --- a/src/data.rs +++ b/src/data.rs @@ -253,10 +253,10 @@ impl Display for DataError { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { Self::BadType { expected, actual } => { - write!(f, "expected type `{}`, got `{}`", expected, actual) + write!(f, "expected type `{expected}`, got `{actual}`") } Self::NoData { expected } => { - write!(f, "expected `Some({})`, found `None`", expected) + write!(f, "expected `Some({expected})`, found `None`") } } } diff --git a/src/inspector.rs b/src/inspector.rs index 92f764dcbc..638a8b2aff 100644 --- a/src/inspector.rs +++ b/src/inspector.rs @@ -758,8 +758,8 @@ impl StringView<'static> { impl fmt::Display for StringView<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - Self::U16(v) => write!(f, "{}", v), - Self::U8(v) => write!(f, "{}", v), + Self::U16(v) => write!(f, "{v}"), + Self::U8(v) => write!(f, "{v}"), } } } diff --git a/src/support.rs b/src/support.rs index c70d230c4a..e9e69b42e8 100644 --- a/src/support.rs +++ b/src/support.rs @@ -359,13 +359,10 @@ fn assert_shared_ptr_use_count_eq( }; assert!( ok, - "assertion failed: `{}<{}>` reference count does not match expectation\ - \n actual: {}\ - \n expected: {}", - wrapper_type_name, + "assertion failed: `{wrapper_type_name}<{}>` reference count does not match expectation\ + \n actual: {actual}\ + \n expected: {expected}", type_name::(), - actual, - expected ); } diff --git a/src/wasm.rs b/src/wasm.rs index 6b404d4b2a..45edf9a084 100644 --- a/src/wasm.rs +++ b/src/wasm.rs @@ -73,7 +73,7 @@ impl WasmStreaming { pub fn set_url(&mut self, url: &str) { // Although not documented, V8 requires the url to be null terminated. // See https://chromium-review.googlesource.com/c/v8/v8/+/3289148. - let null_terminated_url = format!("{}\0", url); + let null_terminated_url = format!("{url}\0"); unsafe { v8__WasmStreaming__SetUrl( &mut self.0, diff --git a/tests/test_api.rs b/tests/test_api.rs index a24423d615..f0df74575a 100644 --- a/tests/test_api.rs +++ b/tests/test_api.rs @@ -4140,7 +4140,7 @@ fn function_script_origin_and_id() { let mut num_cases = 10; let mut prev_id = None; while num_cases > 0 { - let resource_name = format!("google.com/{}", num_cases); + let resource_name = format!("google.com/{num_cases}"); let mut source = mock_source( scope, resource_name.as_str(), // make sure each source has a different resource name @@ -6675,8 +6675,7 @@ impl v8::inspector::ChannelImpl for ChannelCounter { message: v8::UniquePtr, ) { println!( - "send_response call_id {} message {}", - call_id, + "send_response call_id {call_id} message {}", message.unwrap().string() ); self.count_send_response += 1; @@ -6686,7 +6685,7 @@ impl v8::inspector::ChannelImpl for ChannelCounter { message: v8::UniquePtr, ) { let msg = message.unwrap().string().to_string(); - println!("send_notification message {}", msg); + println!("send_notification message {msg}"); self.count_send_notification += 1; self.notifications.push(msg); } diff --git a/tests/test_concurrent_isolate_creation_and_disposal.rs b/tests/test_concurrent_isolate_creation_and_disposal.rs index 428fa888e5..50d09610ef 100644 --- a/tests/test_concurrent_isolate_creation_and_disposal.rs +++ b/tests/test_concurrent_isolate_creation_and_disposal.rs @@ -12,7 +12,7 @@ fn concurrent_isolate_creation_and_disposal() { v8::V8::initialize(); for round in 0..1000 { - eprintln!("round {}", round); + eprintln!("round {round}"); let threads = repeat_with(|| { thread::spawn(|| { diff --git a/tests/test_cppgc.rs b/tests/test_cppgc.rs index c4a90d56a1..cd3a82209b 100644 --- a/tests/test_cppgc.rs +++ b/tests/test_cppgc.rs @@ -238,6 +238,6 @@ fn execute_script( |value| value.to_rust_string_lossy(scope), ); - panic!("{}", exception_string); + panic!("{exception_string}"); } }