From eb27ea6c5861513568e1de49cb0b94c16d986221 Mon Sep 17 00:00:00 2001 From: linbingquan <695601626@qq.com> Date: Sun, 18 Dec 2022 06:20:15 +0800 Subject: [PATCH] chore: update to Rust 1.66.0 (#17078) --- cli/args/config_file.rs | 2 +- cli/args/mod.rs | 4 ++-- cli/bench/main.rs | 2 +- cli/cache/disk_cache.rs | 2 +- cli/lsp/completions.rs | 6 +++--- cli/lsp/documents.rs | 2 +- cli/lsp/registries.rs | 2 +- cli/lsp/tsc.rs | 2 +- cli/napi/js_native_api.rs | 6 +++--- cli/node/mod.rs | 4 ++-- cli/npm/resolvers/local.rs | 8 ++++---- cli/npm/resolvers/mod.rs | 4 ++-- cli/tests/coverage_tests.rs | 2 +- cli/tests/fmt_tests.rs | 6 +++--- cli/tests/run_tests.rs | 6 +++--- cli/tests/watcher_tests.rs | 24 ++++++++++++------------ cli/tools/coverage/merge.rs | 4 ++-- cli/tools/info.rs | 10 ++++------ cli/tools/installer.rs | 6 +++--- cli/tools/vendor/mod.rs | 2 +- cli/tools/vendor/test.rs | 2 +- cli/tsc/mod.rs | 2 +- cli/util/fs.rs | 4 ++-- cli/util/progress_bar/renderer.rs | 4 +--- core/module_specifier.rs | 2 +- core/runtime.rs | 2 +- ext/cache/sqlite.rs | 2 +- ext/ffi/callback.rs | 7 +++---- ext/ffi/ir.rs | 8 ++++---- ext/ffi/repr.rs | 8 ++------ ext/ffi/turbocall.rs | 2 ++ ext/node/resolution.rs | 2 +- ext/web/timers.rs | 2 +- runtime/fs_util.rs | 2 +- runtime/ops/fs.rs | 9 ++++++++- rust-toolchain.toml | 2 +- serde_v8/de.rs | 4 ++-- 37 files changed, 84 insertions(+), 84 deletions(-) diff --git a/cli/args/config_file.rs b/cli/args/config_file.rs index 904efdff8d..0fa8e4d615 100644 --- a/cli/args/config_file.rs +++ b/cli/args/config_file.rs @@ -593,7 +593,7 @@ impl ConfigFile { pub fn from_specifier(specifier: &ModuleSpecifier) -> Result { let config_path = specifier_to_file_path(specifier)?; - let config_text = match std::fs::read_to_string(&config_path) { + let config_text = match std::fs::read_to_string(config_path) { Ok(text) => text, Err(err) => bail!( "Error reading config file {}: {}", diff --git a/cli/args/mod.rs b/cli/args/mod.rs index f936f9c256..09690412df 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -150,7 +150,7 @@ pub fn get_root_cert_store( } else { PathBuf::from(ca_file) }; - let certfile = std::fs::File::open(&ca_file)?; + let certfile = std::fs::File::open(ca_file)?; let mut reader = BufReader::new(certfile); match rustls_pemfile::certs(&mut reader) { @@ -720,7 +720,7 @@ mod test { let import_map_path = std::env::current_dir().unwrap().join("import-map.json"); let expected_specifier = - ModuleSpecifier::from_file_path(&import_map_path).unwrap(); + ModuleSpecifier::from_file_path(import_map_path).unwrap(); assert!(actual.is_ok()); let actual = actual.unwrap(); assert_eq!(actual, Some(expected_specifier)); diff --git a/cli/bench/main.rs b/cli/bench/main.rs index c756c2c2e4..02df982d85 100644 --- a/cli/bench/main.rs +++ b/cli/bench/main.rs @@ -433,7 +433,7 @@ async fn main() -> Result<()> { let target_dir = test_util::target_dir(); let deno_exe = test_util::deno_exe_path(); - env::set_current_dir(&test_util::root_path())?; + env::set_current_dir(test_util::root_path())?; let mut new_data = BenchResult { created_at: chrono::Utc::now() diff --git a/cli/cache/disk_cache.rs b/cli/cache/disk_cache.rs index 60e353d852..894b96d2a1 100644 --- a/cli/cache/disk_cache.rs +++ b/cli/cache/disk_cache.rs @@ -136,7 +136,7 @@ impl DiskCache { pub fn get(&self, filename: &Path) -> std::io::Result> { let path = self.location.join(filename); - fs::read(&path) + fs::read(path) } pub fn set(&self, filename: &Path, data: &[u8]) -> std::io::Result<()> { diff --git a/cli/lsp/completions.rs b/cli/lsp/completions.rs index 5e0fad0f43..7a93c8baf1 100644 --- a/cli/lsp/completions.rs +++ b/cli/lsp/completions.rs @@ -587,11 +587,11 @@ mod tests { let file_c = dir_a.join("c.ts"); std::fs::write(&file_c, b"").expect("could not create"); let file_d = dir_b.join("d.ts"); - std::fs::write(&file_d, b"").expect("could not create"); + std::fs::write(file_d, b"").expect("could not create"); let file_e = dir_a.join("e.txt"); - std::fs::write(&file_e, b"").expect("could not create"); + std::fs::write(file_e, b"").expect("could not create"); let file_f = dir_a.join("f.mjs"); - std::fs::write(&file_f, b"").expect("could not create"); + std::fs::write(file_f, b"").expect("could not create"); let specifier = ModuleSpecifier::from_file_path(file_c).expect("could not create"); let actual = get_local_completions( diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs index 82e2618b3f..936d225ecc 100644 --- a/cli/lsp/documents.rs +++ b/cli/lsp/documents.rs @@ -1266,7 +1266,7 @@ fn lsp_deno_graph_analyze( use deno_graph::ModuleParser; let analyzer = deno_graph::CapturingModuleAnalyzer::new( - Some(Box::new(LspModuleParser::default())), + Some(Box::::default()), None, ); let parsed_source_result = analyzer.parse_module( diff --git a/cli/lsp/registries.rs b/cli/lsp/registries.rs index 1488077dd4..aeaa4c0128 100644 --- a/cli/lsp/registries.rs +++ b/cli/lsp/registries.rs @@ -955,7 +955,7 @@ impl ModuleRegistry { None } else { Some(lsp::CompletionList { - items: completions.into_iter().map(|(_, i)| i).collect(), + items: completions.into_values().collect(), is_incomplete, }) }; diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 1152c080d2..5d5b8213b3 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -1969,7 +1969,7 @@ impl CompletionEntryDetails { let detail = if original_item.detail.is_some() { original_item.detail.clone() } else if !self.display_parts.is_empty() { - Some(replace_links(&display_parts_to_string( + Some(replace_links(display_parts_to_string( &self.display_parts, language_server, ))) diff --git a/cli/napi/js_native_api.rs b/cli/napi/js_native_api.rs index dedea8f799..256584a138 100644 --- a/cli/napi/js_native_api.rs +++ b/cli/napi/js_native_api.rs @@ -549,7 +549,7 @@ fn napi_create_string_latin1( .unwrap() .as_bytes() } else { - std::slice::from_raw_parts(string, length as usize) + std::slice::from_raw_parts(string, length) }; match v8::String::new_from_one_byte( &mut env.scope(), @@ -626,7 +626,7 @@ fn napi_create_string_utf8( .to_str() .unwrap() } else { - let string = std::slice::from_raw_parts(string, length as usize); + let string = std::slice::from_raw_parts(string, length); std::str::from_utf8(string).unwrap() }; let v8str = v8::String::new(&mut env.scope(), string).unwrap(); @@ -1070,7 +1070,7 @@ fn napi_call_function( .map_err(|_| Error::FunctionExpected)?; let argv: &[v8::Local] = - transmute(std::slice::from_raw_parts(argv, argc as usize)); + transmute(std::slice::from_raw_parts(argv, argc)); let ret = func.call(&mut env.scope(), recv, argv); if !result.is_null() { *result = transmute::>, napi_value>(ret); diff --git a/cli/node/mod.rs b/cli/node/mod.rs index 190f386a76..19bc4ed149 100644 --- a/cli/node/mod.rs +++ b/cli/node/mod.rs @@ -759,7 +759,7 @@ fn finalize_resolution( p_str.to_string() }; - let (is_dir, is_file) = if let Ok(stats) = std::fs::metadata(&p) { + let (is_dir, is_file) = if let Ok(stats) = std::fs::metadata(p) { (stats.is_dir(), stats.is_file()) } else { (false, false) @@ -958,7 +958,7 @@ pub fn translate_cjs_to_esm( npm_resolver, )?; let reexport_specifier = - ModuleSpecifier::from_file_path(&resolved_reexport).unwrap(); + ModuleSpecifier::from_file_path(resolved_reexport).unwrap(); // Second, read the source code from disk let reexport_file = file_fetcher .get_source(&reexport_specifier) diff --git a/cli/npm/resolvers/local.rs b/cli/npm/resolvers/local.rs index 69f275c709..5343dc2b40 100644 --- a/cli/npm/resolvers/local.rs +++ b/cli/npm/resolvers/local.rs @@ -342,7 +342,7 @@ async fn sync_resolution_with_fs( for package in &package_partitions.copy_packages { let package_cache_folder_id = package.get_package_cache_folder_id(); let destination_path = deno_local_registry_dir - .join(&get_package_folder_id_folder_name(&package_cache_folder_id)); + .join(get_package_folder_id_folder_name(&package_cache_folder_id)); let initialized_file = destination_path.join(".initialized"); if !initialized_file.exists() { let sub_node_modules = destination_path.join("node_modules"); @@ -352,7 +352,7 @@ async fn sync_resolution_with_fs( })?; let source_path = join_package_name( &deno_local_registry_dir - .join(&get_package_folder_id_folder_name( + .join(get_package_folder_id_folder_name( &package_cache_folder_id.with_no_count(), )) .join("node_modules"), @@ -372,7 +372,7 @@ async fn sync_resolution_with_fs( // node_modules/.deno//node_modules/ for package in &all_packages { let sub_node_modules = deno_local_registry_dir - .join(&get_package_folder_id_folder_name( + .join(get_package_folder_id_folder_name( &package.get_package_cache_folder_id(), )) .join("node_modules"); @@ -419,7 +419,7 @@ async fn sync_resolution_with_fs( let package = snapshot.package_from_id(&package_id).unwrap(); let local_registry_package_path = join_package_name( &deno_local_registry_dir - .join(&get_package_folder_id_folder_name( + .join(get_package_folder_id_folder_name( &package.get_package_cache_folder_id(), )) .join("node_modules"), diff --git a/cli/npm/resolvers/mod.rs b/cli/npm/resolvers/mod.rs index a9c459d122..0f1ed5d85a 100644 --- a/cli/npm/resolvers/mod.rs +++ b/cli/npm/resolvers/mod.rs @@ -355,7 +355,7 @@ impl RequireNpmResolver for NpmPackageResolver { fn in_npm_package(&self, path: &Path) -> bool { let specifier = - match ModuleSpecifier::from_file_path(&path.to_path_buf().clean()) { + match ModuleSpecifier::from_file_path(path.to_path_buf().clean()) { Ok(p) => p, Err(_) => return false, }; @@ -370,7 +370,7 @@ impl RequireNpmResolver for NpmPackageResolver { } fn path_to_specifier(path: &Path) -> Result { - match ModuleSpecifier::from_file_path(&path.to_path_buf().clean()) { + match ModuleSpecifier::from_file_path(path.to_path_buf().clean()) { Ok(specifier) => Ok(specifier), Err(()) => bail!("Could not convert '{}' to url.", path.display()), } diff --git a/cli/tests/coverage_tests.rs b/cli/tests/coverage_tests.rs index 6515fd6eca..357d54ee6c 100644 --- a/cli/tests/coverage_tests.rs +++ b/cli/tests/coverage_tests.rs @@ -51,7 +51,7 @@ mod coverage { // Write the inital mod.ts file std::fs::copy(mod_before_path, &mod_temp_path).unwrap(); // And the test file - std::fs::copy(mod_test_path, &mod_test_temp_path).unwrap(); + std::fs::copy(mod_test_path, mod_test_temp_path).unwrap(); // Generate coverage let status = util::deno_cmd_with_deno_dir(&deno_dir) diff --git a/cli/tests/fmt_tests.rs b/cli/tests/fmt_tests.rs index 6ace4ce5ba..807306b2cb 100644 --- a/cli/tests/fmt_tests.rs +++ b/cli/tests/fmt_tests.rs @@ -17,21 +17,21 @@ mod fmt { testdata_fmt_dir.join("badly_formatted.mjs"); let badly_formatted_js = t.path().join("badly_formatted.js"); let badly_formatted_js_str = badly_formatted_js.to_str().unwrap(); - std::fs::copy(&badly_formatted_original_js, &badly_formatted_js).unwrap(); + std::fs::copy(badly_formatted_original_js, &badly_formatted_js).unwrap(); let fixed_md = testdata_fmt_dir.join("badly_formatted_fixed.md"); let badly_formatted_original_md = testdata_fmt_dir.join("badly_formatted.md"); let badly_formatted_md = t.path().join("badly_formatted.md"); let badly_formatted_md_str = badly_formatted_md.to_str().unwrap(); - std::fs::copy(&badly_formatted_original_md, &badly_formatted_md).unwrap(); + std::fs::copy(badly_formatted_original_md, &badly_formatted_md).unwrap(); let fixed_json = testdata_fmt_dir.join("badly_formatted_fixed.json"); let badly_formatted_original_json = testdata_fmt_dir.join("badly_formatted.json"); let badly_formatted_json = t.path().join("badly_formatted.json"); let badly_formatted_json_str = badly_formatted_json.to_str().unwrap(); - std::fs::copy(&badly_formatted_original_json, &badly_formatted_json) + std::fs::copy(badly_formatted_original_json, &badly_formatted_json) .unwrap(); // First, check formatting by ignoring the badly formatted file. let status = util::deno_cmd() diff --git a/cli/tests/run_tests.rs b/cli/tests/run_tests.rs index 6cae9d9e3c..6196f641da 100644 --- a/cli/tests/run_tests.rs +++ b/cli/tests/run_tests.rs @@ -2505,7 +2505,7 @@ mod run { .unwrap(); assert!(status.success()); std::fs::write(&mod1_path, "export { foo } from \"./mod2.ts\";").unwrap(); - std::fs::write(&mod2_path, "(").unwrap(); + std::fs::write(mod2_path, "(").unwrap(); let status = deno_cmd .current_dir(util::testdata_path()) .arg("run") @@ -2528,7 +2528,7 @@ mod run { let mut deno_cmd = util::deno_cmd(); // With a fresh `DENO_DIR`, run a module with a dependency and a type error. std::fs::write(&mod1_path, "import './mod2.ts'; Deno.exit('0');").unwrap(); - std::fs::write(&mod2_path, "console.log('Hello, world!');").unwrap(); + std::fs::write(mod2_path, "console.log('Hello, world!');").unwrap(); let status = deno_cmd .current_dir(util::testdata_path()) .arg("run") @@ -2969,7 +2969,7 @@ mod run { assert!(output.status.success()); let prg = util::deno_exe_path(); - let output = Command::new(&prg) + let output = Command::new(prg) .env("DENO_DIR", deno_dir.path()) .env("HTTP_PROXY", "http://nil") .env("NO_COLOR", "1") diff --git a/cli/tests/watcher_tests.rs b/cli/tests/watcher_tests.rs index f9c8e1508a..06af71eb48 100644 --- a/cli/tests/watcher_tests.rs +++ b/cli/tests/watcher_tests.rs @@ -105,7 +105,7 @@ mod watcher { util::testdata_path().join("lint/watch/badly_linted_fixed2.js.out"); let badly_linted = t.path().join("badly_linted.js"); - std::fs::copy(&badly_linted_original, &badly_linted).unwrap(); + std::fs::copy(badly_linted_original, &badly_linted).unwrap(); let mut child = util::deno_cmd() .current_dir(util::testdata_path()) @@ -125,7 +125,7 @@ mod watcher { assert_eq!(output, expected); // Change content of the file again to be badly-linted1 - std::fs::copy(&badly_linted_fixed1, &badly_linted).unwrap(); + std::fs::copy(badly_linted_fixed1, &badly_linted).unwrap(); std::thread::sleep(std::time::Duration::from_secs(1)); output = read_all_lints(&mut stderr_lines); @@ -133,7 +133,7 @@ mod watcher { assert_eq!(output, expected); // Change content of the file again to be badly-linted1 - std::fs::copy(&badly_linted_fixed2, &badly_linted).unwrap(); + std::fs::copy(badly_linted_fixed2, &badly_linted).unwrap(); output = read_all_lints(&mut stderr_lines); let expected = std::fs::read_to_string(badly_linted_fixed2_output).unwrap(); @@ -163,7 +163,7 @@ mod watcher { util::testdata_path().join("lint/watch/badly_linted_fixed2.js.out"); let badly_linted = t.path().join("badly_linted.js"); - std::fs::copy(&badly_linted_original, &badly_linted).unwrap(); + std::fs::copy(badly_linted_original, &badly_linted).unwrap(); let mut child = util::deno_cmd() .current_dir(t.path()) @@ -183,14 +183,14 @@ mod watcher { assert_eq!(output, expected); // Change content of the file again to be badly-linted1 - std::fs::copy(&badly_linted_fixed1, &badly_linted).unwrap(); + std::fs::copy(badly_linted_fixed1, &badly_linted).unwrap(); output = read_all_lints(&mut stderr_lines); let expected = std::fs::read_to_string(badly_linted_fixed1_output).unwrap(); assert_eq!(output, expected); // Change content of the file again to be badly-linted1 - std::fs::copy(&badly_linted_fixed2, &badly_linted).unwrap(); + std::fs::copy(badly_linted_fixed2, &badly_linted).unwrap(); std::thread::sleep(std::time::Duration::from_secs(1)); output = read_all_lints(&mut stderr_lines); @@ -216,8 +216,8 @@ mod watcher { let badly_linted_1 = t.path().join("badly_linted_1.js"); let badly_linted_2 = t.path().join("badly_linted_2.js"); - std::fs::copy(&badly_linted_fixed0, &badly_linted_1).unwrap(); - std::fs::copy(&badly_linted_fixed1, &badly_linted_2).unwrap(); + std::fs::copy(badly_linted_fixed0, badly_linted_1).unwrap(); + std::fs::copy(badly_linted_fixed1, &badly_linted_2).unwrap(); let mut child = util::deno_cmd() .current_dir(util::testdata_path()) @@ -236,7 +236,7 @@ mod watcher { "Checked 2 files" ); - std::fs::copy(&badly_linted_fixed2, &badly_linted_2).unwrap(); + std::fs::copy(badly_linted_fixed2, badly_linted_2).unwrap(); assert_contains!( read_line("Checked", &mut stderr_lines), @@ -356,7 +356,7 @@ mod watcher { let badly_formatted_1 = t.path().join("badly_formatted_1.js"); let badly_formatted_2 = t.path().join("badly_formatted_2.js"); std::fs::copy(&badly_formatted_original, &badly_formatted_1).unwrap(); - std::fs::copy(&badly_formatted_original, &badly_formatted_2).unwrap(); + std::fs::copy(&badly_formatted_original, badly_formatted_2).unwrap(); let mut child = util::deno_cmd() .current_dir(&fmt_testdata_path) @@ -868,7 +868,7 @@ mod watcher { ) .unwrap(); write( - &bar_test, + bar_test, "import bar from './bar.js'; Deno.test('bar', bar);", ) .unwrap(); @@ -1102,7 +1102,7 @@ mod watcher { .unwrap(); let file_to_watch2 = t.path().join("imported.js"); write( - &file_to_watch2, + file_to_watch2, r#" import "./imported2.js"; console.log("I'm dynamically imported and I cause restarts!"); diff --git a/cli/tools/coverage/merge.rs b/cli/tools/coverage/merge.rs index 63b795f765..d995c6ab37 100644 --- a/cli/tools/coverage/merge.rs +++ b/cli/tools/coverage/merge.rs @@ -73,8 +73,8 @@ pub fn merge_scripts( } let functions: Vec = range_to_funcs - .into_iter() - .map(|(_, funcs)| merge_functions(funcs).unwrap()) + .into_values() + .map(|funcs| merge_functions(funcs).unwrap()) .collect(); Some(ScriptCoverage { diff --git a/cli/tools/info.rs b/cli/tools/info.rs index 6ab74360bf..86a18c4e2a 100644 --- a/cli/tools/info.rs +++ b/cli/tools/info.rs @@ -70,7 +70,7 @@ fn print_cache_info( if let Some(location) = &location { origin_dir = - origin_dir.join(&checksum::gen(&[location.to_string().as_bytes()])); + origin_dir.join(checksum::gen(&[location.to_string().as_bytes()])); } let local_storage_dir = origin_dir.join("local_storage"); @@ -526,11 +526,9 @@ impl<'a> GraphDisplayContext<'a> { Specifier(_) => specifier_str, }; let maybe_size = match &package_or_specifier { - Package(package) => self - .npm_info - .package_sizes - .get(&package.id) - .map(|s| *s as u64), + Package(package) => { + self.npm_info.package_sizes.get(&package.id).copied() + } Specifier(_) => module .maybe_source .as_ref() diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index db49ed7a01..07397131c1 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -77,7 +77,7 @@ deno {} "$@" "#, args.join(" "), ); - let mut file = File::create(&shim_data.file_path.with_extension(""))?; + let mut file = File::create(shim_data.file_path.with_extension(""))?; file.write_all(template.as_bytes())?; Ok(()) } @@ -1127,11 +1127,11 @@ mod tests { // create extra files { let file_path = file_path.with_extension("tsconfig.json"); - File::create(&file_path).unwrap(); + File::create(file_path).unwrap(); } { let file_path = file_path.with_extension("lock.json"); - File::create(&file_path).unwrap(); + File::create(file_path).unwrap(); } uninstall("echo_test".to_string(), Some(temp_dir.path().to_path_buf())) diff --git a/cli/tools/vendor/mod.rs b/cli/tools/vendor/mod.rs index 02261e34c0..21e3a44858 100644 --- a/cli/tools/vendor/mod.rs +++ b/cli/tools/vendor/mod.rs @@ -120,7 +120,7 @@ fn validate_options( format!("Failed to canonicalize: {}", output_dir.display()) })?; - if import_map_path.starts_with(&output_dir) { + if import_map_path.starts_with(output_dir) { // canonicalize to make the test for this pass on the CI let cwd = canonicalize_path(&std::env::current_dir()?)?; // We don't allow using the output directory to help generate the diff --git a/cli/tools/vendor/test.rs b/cli/tools/vendor/test.rs index c703357d8f..9cf2bb6036 100644 --- a/cli/tools/vendor/test.rs +++ b/cli/tools/vendor/test.rs @@ -192,7 +192,7 @@ impl VendorTestBuilder { } pub fn new_import_map(&self, base_path: &str) -> ImportMap { - let base = ModuleSpecifier::from_file_path(&make_path(base_path)).unwrap(); + let base = ModuleSpecifier::from_file_path(make_path(base_path)).unwrap(); ImportMap::new(base) } diff --git a/cli/tsc/mod.rs b/cli/tsc/mod.rs index 3751712f08..2b7b3d368d 100644 --- a/cli/tsc/mod.rs +++ b/cli/tsc/mod.rs @@ -858,7 +858,7 @@ mod tests { .replace("://", "_") .replace('/', "-"); let source_path = self.fixtures.join(specifier_text); - let response = fs::read_to_string(&source_path) + let response = fs::read_to_string(source_path) .map(|c| { Some(deno_graph::source::LoadResponse::Module { specifier: specifier.clone(), diff --git a/cli/util/fs.rs b/cli/util/fs.rs index 40dfafdd85..cb8a4d3692 100644 --- a/cli/util/fs.rs +++ b/cli/util/fs.rs @@ -160,7 +160,7 @@ pub fn resolve_from_cwd(path: &Path) -> Result { cwd.join(path) }; - Ok(normalize_path(&resolved_path)) + Ok(normalize_path(resolved_path)) } /// Collects file paths that satisfy the given predicate, by recursively walking `files`. @@ -280,7 +280,7 @@ pub fn collect_specifiers( } else { root_path.join(path) }; - let p = normalize_path(&p); + let p = normalize_path(p); if p.is_dir() { let test_files = file_collector.collect_files(&[p])?; let mut test_files_as_urls = test_files diff --git a/cli/util/progress_bar/renderer.rs b/cli/util/progress_bar/renderer.rs index cb249ce365..75a4cafed8 100644 --- a/cli/util/progress_bar/renderer.rs +++ b/cli/util/progress_bar/renderer.rs @@ -75,9 +75,7 @@ impl ProgressBarRenderer for BarProgressBarRenderer { )); } text.push_str(&elapsed_text); - let max_width = - std::cmp::max(10, std::cmp::min(75, data.terminal_width as i32 - 5)) - as usize; + let max_width = (data.terminal_width as i32 - 5).clamp(10, 75) as usize; let same_line_text_width = elapsed_text.len() + total_text_max_width + bytes_text_max_width + 3; // space, open and close brace let total_bars = if same_line_text_width > max_width { diff --git a/core/module_specifier.rs b/core/module_specifier.rs index 3f329f53ff..4727ff2cb3 100644 --- a/core/module_specifier.rs +++ b/core/module_specifier.rs @@ -141,7 +141,7 @@ pub fn resolve_path( let path = current_dir() .map_err(|_| ModuleResolutionError::InvalidPath(path_str.into()))? .join(path_str); - let path = normalize_path(&path); + let path = normalize_path(path); Url::from_file_path(path.clone()) .map_err(|()| ModuleResolutionError::InvalidPath(path)) } diff --git a/core/runtime.rs b/core/runtime.rs index 3d37b13fa1..a95ca0ca64 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -2116,7 +2116,7 @@ impl JsRuntime { let (promise_id, op_id, mut resp) = item; state.unrefed_ops.remove(&promise_id); state.op_state.borrow().tracker.track_async_completed(op_id); - args.push(v8::Integer::new(scope, promise_id as i32).into()); + args.push(v8::Integer::new(scope, promise_id).into()); args.push(match resp.to_v8(scope) { Ok(v) => v, Err(e) => OpResult::Err(OpError::new(&|_| "TypeError", e.into())) diff --git a/ext/cache/sqlite.rs b/ext/cache/sqlite.rs index caf3867774..f1314516ff 100644 --- a/ext/cache/sqlite.rs +++ b/ext/cache/sqlite.rs @@ -114,7 +114,7 @@ impl Cache for SqliteBackedCache { }, )?; let responses_dir = get_responses_dir(cache_storage_dir, cache_id); - std::fs::create_dir_all(&responses_dir)?; + std::fs::create_dir_all(responses_dir)?; Ok::(cache_id) }) .await? diff --git a/ext/ffi/callback.rs b/ext/ffi/callback.rs index 9b759a30ea..b63bb8eabb 100644 --- a/ext/ffi/callback.rs +++ b/ext/ffi/callback.rs @@ -171,7 +171,7 @@ unsafe fn do_ffi_callback( let func = callback.open(scope); let result = result as *mut c_void; let vals: &[*const c_void] = - std::slice::from_raw_parts(args, info.parameters.len() as usize); + std::slice::from_raw_parts(args, info.parameters.len()); let mut params: Vec> = vec![]; for (native_type, val) in info.parameters.iter().zip(vals) { @@ -307,7 +307,7 @@ unsafe fn do_ffi_callback( // Fallthrough, probably UB. value .int32_value(scope) - .expect("Unable to deserialize result parameter.") as i32 + .expect("Unable to deserialize result parameter.") }; *(result as *mut i32) = value; } @@ -425,8 +425,7 @@ unsafe fn do_ffi_callback( } else { *(result as *mut i64) = value .integer_value(scope) - .expect("Unable to deserialize result parameter.") - as i64; + .expect("Unable to deserialize result parameter."); } } NativeType::U64 => { diff --git a/ext/ffi/ir.rs b/ext/ffi/ir.rs index 67c65b5b5a..ee67171a4c 100644 --- a/ext/ffi/ir.rs +++ b/ext/ffi/ir.rs @@ -250,7 +250,7 @@ pub fn ffi_parse_u32_arg( ) -> Result { let u32_value = v8::Local::::try_from(arg) .map_err(|_| type_error("Invalid FFI u32 type, expected unsigned integer"))? - .value() as u32; + .value(); Ok(NativeValue { u32_value }) } @@ -260,7 +260,7 @@ pub fn ffi_parse_i32_arg( ) -> Result { let i32_value = v8::Local::::try_from(arg) .map_err(|_| type_error("Invalid FFI i32 type, expected integer"))? - .value() as i32; + .value(); Ok(NativeValue { i32_value }) } @@ -297,7 +297,7 @@ pub fn ffi_parse_i64_arg( { value.i64_value().0 } else if let Ok(value) = v8::Local::::try_from(arg) { - value.integer_value(scope).unwrap() as i64 + value.integer_value(scope).unwrap() } else { return Err(type_error("Invalid FFI i64 type, expected integer")); }; @@ -358,7 +358,7 @@ pub fn ffi_parse_f64_arg( ) -> Result { let f64_value = v8::Local::::try_from(arg) .map_err(|_| type_error("Invalid FFI f64 type, expected number"))? - .value() as f64; + .value(); Ok(NativeValue { f64_value }) } diff --git a/ext/ffi/repr.rs b/ext/ffi/repr.rs index 22cf03a6be..20b98154c0 100644 --- a/ext/ffi/repr.rs +++ b/ext/ffi/repr.rs @@ -301,9 +301,7 @@ where } // SAFETY: ptr and offset are user provided. - Ok(unsafe { - ptr::read_unaligned::(ptr.add(offset) as *const u32) as u32 - }) + Ok(unsafe { ptr::read_unaligned::(ptr.add(offset) as *const u32) }) } #[op(fast)] @@ -327,9 +325,7 @@ where } // SAFETY: ptr and offset are user provided. - Ok(unsafe { - ptr::read_unaligned::(ptr.add(offset) as *const i32) as i32 - }) + Ok(unsafe { ptr::read_unaligned::(ptr.add(offset) as *const i32) }) } #[op] diff --git a/ext/ffi/turbocall.rs b/ext/ffi/turbocall.rs index 79ec814b48..bbe29238ac 100644 --- a/ext/ffi/turbocall.rs +++ b/ext/ffi/turbocall.rs @@ -910,6 +910,7 @@ impl Aarch64Apple { aarch64!(self.assmblr; str x0, [x19]); } + #[allow(clippy::unnecessary_cast)] fn save_frame_record(&mut self) { debug_assert!( self.allocated_stack >= 16, @@ -922,6 +923,7 @@ impl Aarch64Apple { ) } + #[allow(clippy::unnecessary_cast)] fn recover_frame_record(&mut self) { // The stack cannot have been deallocated before the frame record is restored debug_assert!( diff --git a/ext/node/resolution.rs b/ext/node/resolution.rs index 10f085070f..cd9496ad4b 100644 --- a/ext/node/resolution.rs +++ b/ext/node/resolution.rs @@ -888,7 +888,7 @@ pub fn legacy_main_resolve( .path .parent() .unwrap() - .join(&format!("{}{}", main, ending)) + .join(format!("{}{}", main, ending)) .clean(); if file_exists(&guess) { // TODO(bartlomieju): emitLegacyIndexDeprecation() diff --git a/ext/web/timers.rs b/ext/web/timers.rs index 5b13107928..6026b7c3bf 100644 --- a/ext/web/timers.rs +++ b/ext/web/timers.rs @@ -51,7 +51,7 @@ where // SAFETY: buffer is at least 8 bytes long. unsafe { std::slice::from_raw_parts_mut(buf.as_mut_ptr() as _, 2) }; buf[0] = seconds as u32; - buf[1] = subsec_nanos as u32; + buf[1] = subsec_nanos; } pub struct TimerHandle(Rc); diff --git a/runtime/fs_util.rs b/runtime/fs_util.rs index 30598e0419..a71e709864 100644 --- a/runtime/fs_util.rs +++ b/runtime/fs_util.rs @@ -28,7 +28,7 @@ pub fn resolve_from_cwd(path: &Path) -> Result { } else { let cwd = current_dir().context("Failed to get current working directory")?; - Ok(normalize_path(&cwd.join(path))) + Ok(normalize_path(cwd.join(path))) } } diff --git a/runtime/ops/fs.rs b/runtime/ops/fs.rs index ec60eed62c..b9f6374482 100644 --- a/runtime/ops/fs.rs +++ b/runtime/ops/fs.rs @@ -525,7 +525,14 @@ fn op_umask(state: &mut OpState, mask: Option) -> Result { let _ = umask(prev); prev }; - Ok(r.bits() as u32) + #[cfg(target_os = "linux")] + { + Ok(r.bits()) + } + #[cfg(target_os = "macos")] + { + Ok(r.bits() as u32) + } } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c032b57308..d1df584a7d 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.65.0" +channel = "1.66.0" components = ["rustfmt", "clippy"] diff --git a/serde_v8/de.rs b/serde_v8/de.rs index a43a9c1774..300b047b71 100644 --- a/serde_v8/de.rs +++ b/serde_v8/de.rs @@ -170,11 +170,11 @@ impl<'de, 'a, 'b, 's, 'x> de::Deserializer<'de> { visitor.visit_f64( if let Ok(x) = v8::Local::::try_from(self.input) { - x.value() as f64 + x.value() } else if let Ok(x) = v8::Local::::try_from(self.input) { bigint_to_f64(x) } else if let Some(x) = self.input.number_value(self.scope) { - x as f64 + x } else if let Some(x) = self.input.to_big_int(self.scope) { bigint_to_f64(x) } else {