mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-02-01 12:15:46 -05:00
chore: cleanup format args
Apply [`uninlined_format_args`](https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args) clippy lint -- makes code a bit more readable.
This commit is contained in:
parent
a5657ae68d
commit
5add1340f9
10 changed files with 43 additions and 48 deletions
|
@ -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}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
41
build.rs
41
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.
|
||||
|
@ -199,7 +199,7 @@ fn build_v8(is_asan: bool) {
|
|||
|
||||
// Fix GN's host_cpu detection when using x86_64 bins on Apple Silicon
|
||||
if cfg!(target_os = "macos") && cfg!(target_arch = "aarch64") {
|
||||
gn_args.push("host_cpu=\"arm64\"".to_string())
|
||||
gn_args.push("host_cpu=\"arm64\"".to_string());
|
||||
}
|
||||
|
||||
if env::var_os("DISABLE_CLANG").is_some() {
|
||||
|
@ -208,12 +208,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());
|
||||
|
@ -265,8 +265,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());
|
||||
|
@ -297,14 +297,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"),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -346,11 +343,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());
|
||||
|
@ -420,7 +417,7 @@ fn static_lib_url() -> String {
|
|||
"{}/v{}/{}.gz",
|
||||
base,
|
||||
version,
|
||||
static_lib_name(&format!("_{}_{}", profile, target)),
|
||||
static_lib_name(&format!("_{profile}_{target}")),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -502,7 +499,7 @@ fn download_file(url: String, filename: PathBuf) {
|
|||
|
||||
// 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")
|
||||
|
@ -545,7 +542,7 @@ fn download_file(url: String, filename: PathBuf) {
|
|||
|
||||
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();
|
||||
|
@ -644,7 +641,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();
|
||||
|
@ -683,19 +680,19 @@ 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 name = format!("src_binding_{}_{}.rs", profile, target);
|
||||
let name = format!("src_binding_{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.clone());
|
||||
}
|
||||
|
||||
|
@ -767,7 +764,7 @@ fn clang_download() -> PathBuf {
|
|||
}
|
||||
|
||||
fn cc_wrapper(gn_args: &mut Vec<String>, sccache_path: &Path) {
|
||||
gn_args.push(format!("cc_wrapper={:?}", sccache_path));
|
||||
gn_args.push(format!("cc_wrapper={sccache_path:?}"));
|
||||
}
|
||||
|
||||
struct Dirs {
|
||||
|
@ -873,7 +870,7 @@ pub fn is_debug() -> bool {
|
|||
} else if m == "debug" {
|
||||
true
|
||||
} else {
|
||||
panic!("unhandled PROFILE value {}", m)
|
||||
panic!("unhandled PROFILE value {m}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<v8::HandleScope>) {
|
|||
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<v8::HandleScope>) {
|
|||
);
|
||||
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<v8::HandleScope>) {
|
|||
.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<v8::HandleScope>) {
|
|||
.map(|s| s.to_rust_string_lossy(&mut try_catch));
|
||||
|
||||
if let Some(stack_trace) = stack_trace {
|
||||
eprintln!("{}", stack_trace);
|
||||
eprintln!("{stack_trace}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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`")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,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,
|
||||
|
|
|
@ -4142,7 +4142,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
|
||||
|
@ -6707,7 +6707,7 @@ impl v8::inspector::ChannelImpl for ChannelCounter {
|
|||
message: v8::UniquePtr<v8::inspector::StringBuffer>,
|
||||
) {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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(|| {
|
||||
|
|
Loading…
Add table
Reference in a new issue