diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34b6e6289c..70424c0b0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -157,15 +157,15 @@ jobs: # to complete. sudo apt-get remove --purge -y man-db - # Install clang-14, lld-14, and debootstrap. - echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" | - sudo dd of=/etc/apt/sources.list.d/llvm-toolchain-focal-14.list + # Install clang-15, lld-15, and debootstrap. + echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main" | + sudo dd of=/etc/apt/sources.list.d/llvm-toolchain-focal-15.list curl https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor | sudo dd of=/etc/apt/trusted.gpg.d/llvm-snapshot.gpg sudo apt-get update sudo apt-get install --no-install-recommends debootstrap \ - clang-14 lld-14 + clang-15 lld-15 # Create ubuntu-16.04 sysroot environment, which is used to avoid # depending on a very recent version of glibc. @@ -190,8 +190,8 @@ jobs: CARGO_PROFILE_RELEASE_LTO=false RUSTFLAGS<<__1 -C linker-plugin-lto=true - -C linker=clang-14 - -C link-arg=-fuse-ld=lld-14 + -C linker=clang-15 + -C link-arg=-fuse-ld=lld-15 -C link-arg=--sysroot=/sysroot -C link-arg=-Wl,--allow-shlib-undefined -C link-arg=-Wl,--thinlto-cache-dir=$(pwd)/target/release/lto-cache @@ -200,15 +200,15 @@ jobs: __1 RUSTDOCFLAGS<<__1 -C linker-plugin-lto=true - -C linker=clang-14 - -C link-arg=-fuse-ld=lld-14 + -C linker=clang-15 + -C link-arg=-fuse-ld=lld-15 -C link-arg=--sysroot=/sysroot -C link-arg=-Wl,--allow-shlib-undefined -C link-arg=-Wl,--thinlto-cache-dir=$(pwd)/target/release/lto-cache -C link-arg=-Wl,--thinlto-cache-policy,cache_size_bytes=700m ${{ env.RUSTFLAGS }} __1 - CC=clang-14 + CC=clang-15 CFLAGS=-flto=thin --sysroot=/sysroot __0 diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 0c3caf0a14..e322aa1e7b 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -637,7 +637,7 @@ fn clap_root(version: &str) -> Command { .help("Set log level") .hide(true) .takes_value(true) - .possible_values(&["debug", "info"]) + .possible_values(["debug", "info"]) .global(true), ) .arg( @@ -811,7 +811,7 @@ fn compile_subcommand<'a>() -> Command<'a> { .long("target") .help("Target OS architecture") .takes_value(true) - .possible_values(&[ + .possible_values([ "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "x86_64-apple-darwin", @@ -848,7 +848,7 @@ fn completions_subcommand<'a>() -> Command<'a> { .disable_help_subcommand(true) .arg( Arg::new("shell") - .possible_values(&["bash", "fish", "powershell", "zsh", "fig"]) + .possible_values(["bash", "fish", "powershell", "zsh", "fig"]) .required(true), ) .about("Generate shell completions") @@ -1049,7 +1049,7 @@ This command has implicit access to all permissions (--allow-all).", .help("Set standard input (stdin) content type") .takes_value(true) .default_value("js") - .possible_values(&["ts", "tsx", "js", "jsx"]), + .possible_values(["ts", "tsx", "js", "jsx"]), ) .arg( Arg::new("print") @@ -1106,7 +1106,7 @@ Ignore formatting a file by adding an ignore comment at the top of the file: .help("Set standard input (stdin) content type") .takes_value(true) .default_value("ts") - .possible_values(&["ts", "tsx", "js", "jsx", "md", "json", "jsonc"]), + .possible_values(["ts", "tsx", "js", "jsx", "md", "json", "jsonc"]), ) .arg( Arg::new("ignore") @@ -1165,7 +1165,7 @@ Ignore formatting a file by adding an ignore comment at the top of the file: Arg::new("options-prose-wrap") .long("options-prose-wrap") .takes_value(true) - .possible_values(&["always", "never", "preserve"]) + .possible_values(["always", "never", "preserve"]) .help("Define how prose should be wrapped. Defaults to always."), ) } diff --git a/cli/bench/main.rs b/cli/bench/main.rs index e347d2e1cd..c756c2c2e4 100644 --- a/cli/bench/main.rs +++ b/cli/bench/main.rs @@ -343,7 +343,7 @@ fn run_max_mem_benchmark(deno_exe: &Path) -> Result> { for (name, args, return_code) in EXEC_TIME_BENCHMARKS { let proc = Command::new("time") - .args(&["-v", deno_exe.to_str().unwrap()]) + .args(["-v", deno_exe.to_str().unwrap()]) .args(args.iter()) .stdout(Stdio::null()) .stderr(Stdio::piped()) @@ -501,7 +501,7 @@ async fn main() -> Result<()> { let mut file = secure_tempfile::NamedTempFile::new()?; let exit_status = Command::new("strace") - .args(&[ + .args([ "-c", "-f", "-o", diff --git a/cli/build.rs b/cli/build.rs index 3bdf2dfb3e..73d0208f67 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -39,7 +39,7 @@ fn create_snapshot( } let snapshot = js_runtime.snapshot(); - let snapshot_slice: &[u8] = &*snapshot; + let snapshot_slice: &[u8] = &snapshot; println!("Snapshot size: {}", snapshot_slice.len()); let compressed_snapshot_with_size = { @@ -64,7 +64,7 @@ fn create_snapshot( compressed_snapshot_with_size.len() ); - std::fs::write(&snapshot_path, compressed_snapshot_with_size).unwrap(); + std::fs::write(snapshot_path, compressed_snapshot_with_size).unwrap(); println!("Snapshot written to: {} ", snapshot_path.display()); } diff --git a/cli/cache/disk_cache.rs b/cli/cache/disk_cache.rs index 5a2f11e3c3..81379ac94a 100644 --- a/cli/cache/disk_cache.rs +++ b/cli/cache/disk_cache.rs @@ -40,7 +40,7 @@ impl DiskCache { if path.is_dir() { return Ok(()); } - fs::create_dir_all(&path).map_err(|e| { + fs::create_dir_all(path).map_err(|e| { io::Error::new(e.kind(), format!( "Could not create TypeScript compiler cache location: {:?}\nCheck the permission of the directory.", path diff --git a/cli/fs_util.rs b/cli/fs_util.rs index 843f5e0cfe..dbebc75c08 100644 --- a/cli/fs_util.rs +++ b/cli/fs_util.rs @@ -333,9 +333,9 @@ pub async fn remove_dir_all_if_exists(path: &Path) -> std::io::Result<()> { /// /// Note: Does not handle symlinks. pub fn copy_dir_recursive(from: &Path, to: &Path) -> Result<(), AnyError> { - std::fs::create_dir_all(&to) + std::fs::create_dir_all(to) .with_context(|| format!("Creating {}", to.display()))?; - let read_dir = std::fs::read_dir(&from) + let read_dir = std::fs::read_dir(from) .with_context(|| format!("Reading {}", from.display()))?; for entry in read_dir { @@ -362,9 +362,9 @@ pub fn copy_dir_recursive(from: &Path, to: &Path) -> Result<(), AnyError> { /// /// Note: Does not handle symlinks. pub fn hard_link_dir_recursive(from: &Path, to: &Path) -> Result<(), AnyError> { - std::fs::create_dir_all(&to) + std::fs::create_dir_all(to) .with_context(|| format!("Creating {}", to.display()))?; - let read_dir = std::fs::read_dir(&from) + let read_dir = std::fs::read_dir(from) .with_context(|| format!("Reading {}", from.display()))?; for entry in read_dir { @@ -451,7 +451,7 @@ pub fn symlink_dir(oldpath: &Path, newpath: &Path) -> Result<(), AnyError> { #[cfg(unix)] { use std::os::unix::fs::symlink; - symlink(&oldpath, &newpath).map_err(err_mapper)?; + symlink(oldpath, newpath).map_err(err_mapper)?; } #[cfg(not(unix))] { diff --git a/cli/http_cache.rs b/cli/http_cache.rs index eb6aa3f0f7..f70ccc715b 100644 --- a/cli/http_cache.rs +++ b/cli/http_cache.rs @@ -123,7 +123,7 @@ impl HttpCache { if path.is_dir() { return Ok(()); } - fs::create_dir_all(&path).map_err(|e| { + fs::create_dir_all(path).map_err(|e| { io::Error::new( e.kind(), format!( diff --git a/cli/lsp/completions.rs b/cli/lsp/completions.rs index 5eb42d3b09..b223c71a2b 100644 --- a/cli/lsp/completions.rs +++ b/cli/lsp/completions.rs @@ -469,7 +469,7 @@ fn get_workspace_completions( specifier_strings .into_iter() .filter_map(|label| { - if label.starts_with(¤t) { + if label.starts_with(current) { let detail = Some( if label.starts_with("http:") || label.starts_with("https:") { "(remote)".to_string() diff --git a/cli/lsp/path_to_regex.rs b/cli/lsp/path_to_regex.rs index 937136ce31..9ccbb2c1fa 100644 --- a/cli/lsp/path_to_regex.rs +++ b/cli/lsp/path_to_regex.rs @@ -877,7 +877,7 @@ mod tests { assert!(result.is_ok(), "Could not parse path: \"{}\"", path); let (re, _) = result.unwrap(); for (fixture, expected) in fixtures { - let result = re.find(*fixture); + let result = re.find(fixture); assert!( result.is_ok(), "Find failure for path \"{}\" and fixture \"{}\"", diff --git a/cli/main.rs b/cli/main.rs index 63e3fe6dd4..ed3d459e13 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -772,7 +772,7 @@ async fn test_command( test_flags: TestFlags, ) -> Result { if let Some(ref coverage_dir) = flags.coverage_dir { - std::fs::create_dir_all(&coverage_dir)?; + std::fs::create_dir_all(coverage_dir)?; env::set_var( "DENO_UNSTABLE_COVERAGE_DIR", PathBuf::from(coverage_dir).canonicalize()?, @@ -994,7 +994,7 @@ pub fn main() { Err(err) => unwrap_or_exit(Err(AnyError::from(err))), }; if !flags.v8_flags.is_empty() { - init_v8_flags(&*flags.v8_flags); + init_v8_flags(&flags.v8_flags); } logger::init(flags.log_level); diff --git a/cli/module_loader.rs b/cli/module_loader.rs index 8930203219..dc367f5e75 100644 --- a/cli/module_loader.rs +++ b/cli/module_loader.rs @@ -140,7 +140,7 @@ impl CliModuleLoader { let file_path = specifier.to_file_path().unwrap(); let code = std::fs::read_to_string(&file_path).with_context(|| { let mut msg = "Unable to load ".to_string(); - msg.push_str(&*file_path.to_string_lossy()); + msg.push_str(&file_path.to_string_lossy()); if let Some(referrer) = &maybe_referrer { msg.push_str(" imported from "); msg.push_str(referrer.as_str()); diff --git a/cli/npm/cache.rs b/cli/npm/cache.rs index b052f89cd2..2ca597bd77 100644 --- a/cli/npm/cache.rs +++ b/cli/npm/cache.rs @@ -78,7 +78,7 @@ pub fn with_folder_sync_lock( match inner(output_folder, action) { Ok(()) => Ok(()), Err(err) => { - if let Err(remove_err) = fs::remove_dir_all(&output_folder) { + if let Err(remove_err) = fs::remove_dir_all(output_folder) { if remove_err.kind() != std::io::ErrorKind::NotFound { bail!( concat!( @@ -156,7 +156,7 @@ impl ReadonlyNpmCache { root_dir: &Path, ) -> Result { if !root_dir.exists() { - std::fs::create_dir_all(&root_dir) + std::fs::create_dir_all(root_dir) .with_context(|| format!("Error creating {}", root_dir.display()))?; } Ok(crate::fs_util::canonicalize_path(root_dir)?) diff --git a/cli/npm/registry.rs b/cli/npm/registry.rs index e6af92fe84..066c136ee5 100644 --- a/cli/npm/registry.rs +++ b/cli/npm/registry.rs @@ -397,7 +397,7 @@ impl RealNpmRegistryApiInner { ) -> Result<(), AnyError> { let file_cache_path = self.get_package_file_cache_path(name); let file_text = serde_json::to_string(&package_info)?; - std::fs::create_dir_all(&file_cache_path.parent().unwrap())?; + std::fs::create_dir_all(file_cache_path.parent().unwrap())?; fs_util::atomic_write_file(&file_cache_path, file_text, CACHE_PERM)?; Ok(()) } diff --git a/cli/npm/resolution/specifier.rs b/cli/npm/resolution/specifier.rs index efcea9d993..1a1590a2f9 100644 --- a/cli/npm/resolution/specifier.rs +++ b/cli/npm/resolution/specifier.rs @@ -245,7 +245,7 @@ pub fn resolve_npm_package_reqs(graph: &ModuleGraph) -> Vec { for specifier in &specifiers { if let Ok(npm_ref) = NpmPackageReference::from_specifier(specifier) { leaf.reqs.insert(npm_ref.req); - } else if !specifier.as_str().starts_with(&parent_specifier.as_str()) { + } else if !specifier.as_str().starts_with(parent_specifier.as_str()) { leaf .dependencies .insert(get_folder_path_specifier(specifier)); diff --git a/cli/npm/resolvers/common.rs b/cli/npm/resolvers/common.rs index 11fa6512ce..b160697d10 100644 --- a/cli/npm/resolvers/common.rs +++ b/cli/npm/resolvers/common.rs @@ -104,7 +104,7 @@ pub fn ensure_registry_read_permission( path: &Path, ) -> Result<(), AnyError> { // allow reading if it's in the node_modules - if path.starts_with(®istry_path) + if path.starts_with(registry_path) && path .components() .all(|c| !matches!(c, std::path::Component::ParentDir)) diff --git a/cli/npm/tarball.rs b/cli/npm/tarball.rs index 751e093f5a..487a8a6aac 100644 --- a/cli/npm/tarball.rs +++ b/cli/npm/tarball.rs @@ -110,8 +110,8 @@ fn extract_tarball(data: &[u8], output_folder: &Path) -> Result<(), AnyError> { absolute_path.parent().unwrap() }; if created_dirs.insert(dir_path.to_path_buf()) { - fs::create_dir_all(&dir_path)?; - let canonicalized_dir = fs::canonicalize(&dir_path)?; + fs::create_dir_all(dir_path)?; + let canonicalized_dir = fs::canonicalize(dir_path)?; if !canonicalized_dir.starts_with(&output_folder) { bail!( "Extracted directory '{}' of npm tarball was not in output directory.", diff --git a/cli/tests/integration/info_tests.rs b/cli/tests/integration/info_tests.rs index 0cb8750783..0d2d81cc08 100644 --- a/cli/tests/integration/info_tests.rs +++ b/cli/tests/integration/info_tests.rs @@ -15,7 +15,7 @@ fn info_with_compiled_source() { .env("DENO_DIR", t.path()) .current_dir(util::testdata_path()) .arg("cache") - .arg(&module_path) + .arg(module_path) .spawn() .unwrap(); let status = deno.wait().unwrap(); @@ -26,7 +26,7 @@ fn info_with_compiled_source() { .env("NO_COLOR", "1") .current_dir(util::testdata_path()) .arg("info") - .arg(&module_path) + .arg(module_path) .output() .unwrap(); diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index 38d44b51f6..f123f71a37 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -6077,7 +6077,7 @@ Deno.test({ } }); "#; - fs::write(&module_path, &contents).unwrap(); + fs::write(&module_path, contents).unwrap(); fs::write(temp_dir.path().join("./deno.jsonc"), r#"{}"#).unwrap(); params.root_uri = Some(root_specifier); diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 3383028d6d..192fff620d 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -1703,8 +1703,7 @@ fn exec_path() { .unwrap(); assert!(output.status.success()); let stdout_str = std::str::from_utf8(&output.stdout).unwrap().trim(); - let actual = - std::fs::canonicalize(&std::path::Path::new(stdout_str)).unwrap(); + let actual = std::fs::canonicalize(std::path::Path::new(stdout_str)).unwrap(); let expected = std::fs::canonicalize(util::deno_exe_path()).unwrap(); assert_eq!(expected, actual); } diff --git a/cli/tests/integration/upgrade_tests.rs b/cli/tests/integration/upgrade_tests.rs index f2cee910b3..959d46fb42 100644 --- a/cli/tests/integration/upgrade_tests.rs +++ b/cli/tests/integration/upgrade_tests.rs @@ -120,7 +120,7 @@ fn upgrade_with_out_in_tmpdir() { .arg("--version") .arg("1.11.5") .arg("--output") - .arg(&new_exe_path.to_str().unwrap()) + .arg(new_exe_path.to_str().unwrap()) .spawn() .unwrap() .wait() diff --git a/cli/tests/integration/vendor_tests.rs b/cli/tests/integration/vendor_tests.rs index b3a3f441fd..efd57b96d9 100644 --- a/cli/tests/integration/vendor_tests.rs +++ b/cli/tests/integration/vendor_tests.rs @@ -262,7 +262,7 @@ fn existing_import_map_no_remote() { let import_map_filename = "imports2.json"; let import_map_text = r#"{ "imports": { "http://localhost:4545/vendor/": "./logger/" } }"#; - t.write(import_map_filename, &import_map_text); + t.write(import_map_filename, import_map_text); t.create_dir_all("logger"); t.write("logger/logger.ts", "export class Logger {}"); diff --git a/cli/tests/integration/watcher_tests.rs b/cli/tests/integration/watcher_tests.rs index 58f7e11fa1..27a1bb6201 100644 --- a/cli/tests/integration/watcher_tests.rs +++ b/cli/tests/integration/watcher_tests.rs @@ -219,7 +219,7 @@ fn lint_all_files_on_each_change_test() { let mut child = util::deno_cmd() .current_dir(util::testdata_path()) .arg("lint") - .arg(&t.path()) + .arg(t.path()) .arg("--watch") .arg("--unstable") .stdout(std::process::Stdio::piped()) @@ -349,7 +349,7 @@ fn fmt_check_all_files_on_each_change_test() { let mut child = util::deno_cmd() .current_dir(&fmt_testdata_path) .arg("fmt") - .arg(&t.path()) + .arg(t.path()) .arg("--watch") .arg("--check") .arg("--unstable") @@ -832,7 +832,7 @@ fn test_watch() { .arg("--watch") .arg("--unstable") .arg("--no-check") - .arg(&t.path()) + .arg(t.path()) .env("NO_COLOR", "1") .stdout(std::process::Stdio::piped()) .stderr(std::process::Stdio::piped()) @@ -973,7 +973,7 @@ fn test_watch_doc() { .arg("--watch") .arg("--doc") .arg("--unstable") - .arg(&t.path()) + .arg(t.path()) .env("NO_COLOR", "1") .stdout(std::process::Stdio::piped()) .stderr(std::process::Stdio::piped()) diff --git a/cli/tools/bench.rs b/cli/tools/bench.rs index 1868d76b3a..c055d8a9c7 100644 --- a/cli/tools/bench.rs +++ b/cli/tools/bench.rs @@ -210,7 +210,7 @@ impl BenchReporter for ConsoleReporter { println!(); } - if None == self.group || group != self.group.as_ref().unwrap() { + if self.group.is_none() || group != self.group.as_ref().unwrap() { self.report_group_summary(); } diff --git a/cli/tools/coverage/merge.rs b/cli/tools/coverage/merge.rs index 08a695e1d6..63b795f765 100644 --- a/cli/tools/coverage/merge.rs +++ b/cli/tools/coverage/merge.rs @@ -126,8 +126,7 @@ pub fn merge_functions( trees.push(tree); } } - let merged = - RangeTree::normalize(&rta, merge_range_trees(&rta, trees).unwrap()); + let merged = RangeTree::normalize(merge_range_trees(&rta, trees).unwrap()); let ranges = merged.to_ranges(); let is_block_coverage: bool = !(ranges.len() == 1 && ranges[0].count == 0); diff --git a/cli/tools/coverage/range_tree.rs b/cli/tools/coverage/range_tree.rs index aca8939ee6..87ddd8baac 100644 --- a/cli/tools/coverage/range_tree.rs +++ b/cli/tools/coverage/range_tree.rs @@ -71,10 +71,7 @@ impl<'rt> RangeTree<'rt> { (rta.alloc(left), rta.alloc(right)) } - pub fn normalize<'a>( - rta: &'a RangeTreeArena<'a>, - tree: &'a mut RangeTree<'a>, - ) -> &'a mut RangeTree<'a> { + pub fn normalize<'a>(tree: &'a mut RangeTree<'a>) -> &'a mut RangeTree<'a> { tree.children = { let mut children: Vec<&'a mut RangeTree<'a>> = Vec::new(); let mut chain: Vec<&'a mut RangeTree<'a>> = Vec::new(); @@ -96,7 +93,7 @@ impl<'rt> RangeTree<'rt> { head.children.push(sub_child); } } - children.push(RangeTree::normalize(rta, head)); + children.push(RangeTree::normalize(head)); } chain.push(child) } @@ -110,7 +107,7 @@ impl<'rt> RangeTree<'rt> { head.children.push(sub_child); } } - children.push(RangeTree::normalize(rta, head)); + children.push(RangeTree::normalize(head)); } if children.len() == 1 diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index 832577aa2e..9474411b7d 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -635,7 +635,7 @@ struct FileContents { } fn read_file_contents(file_path: &Path) -> Result { - let file_bytes = fs::read(&file_path) + let file_bytes = fs::read(file_path) .with_context(|| format!("Error reading {}", file_path.display()))?; let charset = text_encoding::detect_charset(&file_bytes); let file_text = text_encoding::convert_to_utf8(&file_bytes, charset)?; diff --git a/cli/tools/standalone.rs b/cli/tools/standalone.rs index 259eb43b03..494c2f4761 100644 --- a/cli/tools/standalone.rs +++ b/cli/tools/standalone.rs @@ -85,9 +85,9 @@ async fn download_base_binary( std::process::exit(1) }; - std::fs::create_dir_all(&output_directory)?; + std::fs::create_dir_all(output_directory)?; let output_path = output_directory.join(binary_path_suffix); - std::fs::create_dir_all(&output_path.parent().unwrap())?; + std::fs::create_dir_all(output_path.parent().unwrap())?; tokio::fs::write(output_path, binary_content).await?; Ok(()) } diff --git a/cli/tools/test.rs b/cli/tools/test.rs index dca1404458..09257efff2 100644 --- a/cli/tools/test.rs +++ b/cli/tools/test.rs @@ -742,9 +742,7 @@ fn extract_files_from_regex_blocks( let files = blocks_regex .captures_iter(source) .filter_map(|block| { - if block.get(1) == None { - return None; - } + block.get(1)?; let maybe_attributes: Option> = block .get(1) diff --git a/cli/tools/vendor/build.rs b/cli/tools/vendor/build.rs index f0a490a750..dadd84e22e 100644 --- a/cli/tools/vendor/build.rs +++ b/cli/tools/vendor/build.rs @@ -502,7 +502,7 @@ mod test { let output = builder .with_loader(|loader| { loader - .add("/mod.ts", &mod_file_text) + .add("/mod.ts", mod_file_text) .add("https://localhost/mod.ts", "export class Example {}"); }) .build() diff --git a/cli/tools/vendor/mod.rs b/cli/tools/vendor/mod.rs index 05fee531a5..3fd381b213 100644 --- a/cli/tools/vendor/mod.rs +++ b/cli/tools/vendor/mod.rs @@ -113,7 +113,7 @@ fn validate_options( .and_then(|p| fs_util::canonicalize_path(&p).ok()) { // make the output directory in order to canonicalize it for the check below - std::fs::create_dir_all(&output_dir)?; + std::fs::create_dir_all(output_dir)?; let output_dir = fs_util::canonicalize_path(output_dir).with_context(|| { format!("Failed to canonicalize: {}", output_dir.display()) @@ -248,7 +248,7 @@ fn update_config_text( } fn is_dir_empty(dir_path: &Path) -> Result { - match std::fs::read_dir(&dir_path) { + match std::fs::read_dir(dir_path) { Ok(mut dir) => Ok(dir.next().is_none()), Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(true), Err(err) => { diff --git a/cli/tsc.rs b/cli/tsc.rs index c81ff9335b..766bf09e38 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -80,7 +80,7 @@ pub static COMPILER_SNAPSHOT: Lazy> = Lazy::new( ); pub fn compiler_snapshot() -> Snapshot { - Snapshot::Static(&*COMPILER_SNAPSHOT) + Snapshot::Static(&COMPILER_SNAPSHOT) } macro_rules! inc { diff --git a/core/async_cell.rs b/core/async_cell.rs index ea6cac831d..e643af7829 100644 --- a/core/async_cell.rs +++ b/core/async_cell.rs @@ -220,13 +220,13 @@ impl Deref for RcRef { impl Borrow for RcRef { fn borrow(&self) -> &T { - &**self + self } } impl AsRef for RcRef { fn as_ref(&self) -> &T { - &**self + self } } @@ -478,13 +478,13 @@ mod internal { impl Borrow for AsyncBorrowImpl { fn borrow(&self) -> &T { - &**self + self } } impl AsRef for AsyncBorrowImpl { fn as_ref(&self) -> &T { - &**self + self } } @@ -500,13 +500,13 @@ mod internal { impl BorrowMut for AsyncBorrowImpl { fn borrow_mut(&mut self) -> &mut T { - &mut **self + self } } impl AsMut for AsyncBorrowImpl { fn as_mut(&mut self) -> &mut T { - &mut **self + self } } diff --git a/core/error.rs b/core/error.rs index 9ad99c6da2..d71da31641 100644 --- a/core/error.rs +++ b/core/error.rs @@ -242,7 +242,7 @@ impl JsError { serde_v8::from_v8(scope, exception.into()).unwrap_or_default(); // Get the message by formatting error.name and error.message. let name = e.name.clone().unwrap_or_else(|| "Error".to_string()); - let message_prop = e.message.clone().unwrap_or_else(|| "".to_string()); + let message_prop = e.message.clone().unwrap_or_default(); let exception_message = exception_message.unwrap_or_else(|| { if !name.is_empty() && !message_prop.is_empty() { format!("Uncaught {}: {}", name, message_prop) diff --git a/core/examples/http_bench_json_ops.rs b/core/examples/http_bench_json_ops.rs index 6eaa99a38a..af57f31215 100644 --- a/core/examples/http_bench_json_ops.rs +++ b/core/examples/http_bench_json_ops.rs @@ -131,7 +131,7 @@ fn create_js_runtime() -> JsRuntime { fn op_listen(state: &mut OpState) -> Result { log::debug!("listen"); let addr = "127.0.0.1:4570".parse::().unwrap(); - let std_listener = std::net::TcpListener::bind(&addr)?; + let std_listener = std::net::TcpListener::bind(addr)?; std_listener.set_nonblocking(true)?; let listener = TcpListener::try_from(std_listener)?; let rid = state.resource_table.add(listener); diff --git a/core/runtime.rs b/core/runtime.rs index e85b7296af..b1ce148832 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -2888,7 +2888,7 @@ pub mod tests { ..Default::default() }); runtime.execute_script("a.js", "a = 1 + 2").unwrap(); - let snap: &[u8] = &*runtime.snapshot(); + let snap: &[u8] = &runtime.snapshot(); Vec::from(snap).into_boxed_slice() }; @@ -4051,7 +4051,7 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({ will_snapshot: true, ..Default::default() }); - let snap: &[u8] = &*runtime.snapshot(); + let snap: &[u8] = &runtime.snapshot(); Vec::from(snap).into_boxed_slice() }; diff --git a/ext/crypto/lib.rs b/ext/crypto/lib.rs index f09982920d..cea5f08a80 100644 --- a/ext/crypto/lib.rs +++ b/ext/crypto/lib.rs @@ -198,14 +198,14 @@ pub async fn op_crypto_sign_key( let signature = match algorithm { Algorithm::RsassaPkcs1v15 => { - let private_key = RsaPrivateKey::from_pkcs1_der(&*args.key.data)?; + let private_key = RsaPrivateKey::from_pkcs1_der(&args.key.data)?; let (padding, hashed) = match args .hash .ok_or_else(|| type_error("Missing argument hash".to_string()))? { CryptoHash::Sha1 => { let mut hasher = Sha1::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::PKCS1v15Sign { hash: Some(rsa::hash::Hash::SHA1), @@ -215,7 +215,7 @@ pub async fn op_crypto_sign_key( } CryptoHash::Sha256 => { let mut hasher = Sha256::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::PKCS1v15Sign { hash: Some(rsa::hash::Hash::SHA2_256), @@ -225,7 +225,7 @@ pub async fn op_crypto_sign_key( } CryptoHash::Sha384 => { let mut hasher = Sha384::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::PKCS1v15Sign { hash: Some(rsa::hash::Hash::SHA2_384), @@ -235,7 +235,7 @@ pub async fn op_crypto_sign_key( } CryptoHash::Sha512 => { let mut hasher = Sha512::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::PKCS1v15Sign { hash: Some(rsa::hash::Hash::SHA2_512), @@ -248,7 +248,7 @@ pub async fn op_crypto_sign_key( private_key.sign(padding, &hashed)? } Algorithm::RsaPss => { - let private_key = RsaPrivateKey::from_pkcs1_der(&*args.key.data)?; + let private_key = RsaPrivateKey::from_pkcs1_der(&args.key.data)?; let salt_len = args .salt_length @@ -262,7 +262,7 @@ pub async fn op_crypto_sign_key( { CryptoHash::Sha1 => { let mut hasher = Sha1::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::new_pss_with_salt::(rng, salt_len), hasher.finalize()[..].to_vec(), @@ -270,7 +270,7 @@ pub async fn op_crypto_sign_key( } CryptoHash::Sha256 => { let mut hasher = Sha256::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::new_pss_with_salt::(rng, salt_len), hasher.finalize()[..].to_vec(), @@ -278,7 +278,7 @@ pub async fn op_crypto_sign_key( } CryptoHash::Sha384 => { let mut hasher = Sha384::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::new_pss_with_salt::(rng, salt_len), hasher.finalize()[..].to_vec(), @@ -286,7 +286,7 @@ pub async fn op_crypto_sign_key( } CryptoHash::Sha512 => { let mut hasher = Sha512::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::new_pss_with_salt::(rng, salt_len), hasher.finalize()[..].to_vec(), @@ -301,7 +301,7 @@ pub async fn op_crypto_sign_key( let curve: &EcdsaSigningAlgorithm = args.named_curve.ok_or_else(not_supported)?.try_into()?; - let key_pair = EcdsaKeyPair::from_pkcs8(curve, &*args.key.data)?; + let key_pair = EcdsaKeyPair::from_pkcs8(curve, &args.key.data)?; // We only support P256-SHA256 & P384-SHA384. These are recommended signature pairs. // https://briansmith.org/rustdoc/ring/signature/index.html#statics if let Some(hash) = args.hash { @@ -320,7 +320,7 @@ pub async fn op_crypto_sign_key( Algorithm::Hmac => { let hash: HmacAlgorithm = args.hash.ok_or_else(not_supported)?.into(); - let key = HmacKey::new(hash, &*args.key.data); + let key = HmacKey::new(hash, &args.key.data); let signature = ring::hmac::sign(&key, data); signature.as_ref().to_vec() @@ -359,7 +359,7 @@ pub async fn op_crypto_verify_key( { CryptoHash::Sha1 => { let mut hasher = Sha1::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::PKCS1v15Sign { hash: Some(rsa::hash::Hash::SHA1), @@ -369,7 +369,7 @@ pub async fn op_crypto_verify_key( } CryptoHash::Sha256 => { let mut hasher = Sha256::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::PKCS1v15Sign { hash: Some(rsa::hash::Hash::SHA2_256), @@ -379,7 +379,7 @@ pub async fn op_crypto_verify_key( } CryptoHash::Sha384 => { let mut hasher = Sha384::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::PKCS1v15Sign { hash: Some(rsa::hash::Hash::SHA2_384), @@ -389,7 +389,7 @@ pub async fn op_crypto_verify_key( } CryptoHash::Sha512 => { let mut hasher = Sha512::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::PKCS1v15Sign { hash: Some(rsa::hash::Hash::SHA2_512), @@ -399,9 +399,7 @@ pub async fn op_crypto_verify_key( } }; - public_key - .verify(padding, &hashed, &*args.signature) - .is_ok() + public_key.verify(padding, &hashed, &args.signature).is_ok() } Algorithm::RsaPss => { let salt_len = args @@ -417,7 +415,7 @@ pub async fn op_crypto_verify_key( { CryptoHash::Sha1 => { let mut hasher = Sha1::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::new_pss_with_salt::(rng, salt_len), hasher.finalize()[..].to_vec(), @@ -425,7 +423,7 @@ pub async fn op_crypto_verify_key( } CryptoHash::Sha256 => { let mut hasher = Sha256::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::new_pss_with_salt::(rng, salt_len), hasher.finalize()[..].to_vec(), @@ -433,7 +431,7 @@ pub async fn op_crypto_verify_key( } CryptoHash::Sha384 => { let mut hasher = Sha384::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::new_pss_with_salt::(rng, salt_len), hasher.finalize()[..].to_vec(), @@ -441,7 +439,7 @@ pub async fn op_crypto_verify_key( } CryptoHash::Sha512 => { let mut hasher = Sha512::new(); - hasher.update(&data); + hasher.update(data); ( PaddingScheme::new_pss_with_salt::(rng, salt_len), hasher.finalize()[..].to_vec(), @@ -449,14 +447,12 @@ pub async fn op_crypto_verify_key( } }; - public_key - .verify(padding, &hashed, &*args.signature) - .is_ok() + public_key.verify(padding, &hashed, &args.signature).is_ok() } Algorithm::Hmac => { let hash: HmacAlgorithm = args.hash.ok_or_else(not_supported)?.into(); - let key = HmacKey::new(hash, &*args.key.data); - ring::hmac::verify(&key, data, &*args.signature).is_ok() + let key = HmacKey::new(hash, &args.key.data); + ring::hmac::verify(&key, data, &args.signature).is_ok() } Algorithm::Ecdsa => { let signing_alg: &EcdsaSigningAlgorithm = @@ -468,7 +464,7 @@ pub async fn op_crypto_verify_key( let public_key_bytes = match args.key.r#type { KeyType::Private => { - private_key = EcdsaKeyPair::from_pkcs8(signing_alg, &*args.key.data)?; + private_key = EcdsaKeyPair::from_pkcs8(signing_alg, &args.key.data)?; private_key.public_key().as_ref() } @@ -479,7 +475,7 @@ pub async fn op_crypto_verify_key( let public_key = ring::signature::UnparsedPublicKey::new(verify_alg, public_key_bytes); - public_key.verify(data, &*args.signature).is_ok() + public_key.verify(data, &args.signature).is_ok() } _ => return Err(type_error("Unsupported algorithm".to_string())), }; @@ -659,9 +655,9 @@ pub async fn op_crypto_derive_bits( fn read_rsa_public_key(key_data: KeyData) -> Result { let public_key = match key_data.r#type { KeyType::Private => { - RsaPrivateKey::from_pkcs1_der(&*key_data.data)?.to_public_key() + RsaPrivateKey::from_pkcs1_der(&key_data.data)?.to_public_key() } - KeyType::Public => RsaPublicKey::from_pkcs1_der(&*key_data.data)?, + KeyType::Public => RsaPublicKey::from_pkcs1_der(&key_data.data)?, KeyType::Secret => unreachable!("unexpected KeyType::Secret"), }; Ok(public_key) diff --git a/ext/crypto/shared.rs b/ext/crypto/shared.rs index 2e4eabdafa..d2f7d53e82 100644 --- a/ext/crypto/shared.rs +++ b/ext/crypto/shared.rs @@ -89,7 +89,7 @@ impl RawKeyData { match self { RawKeyData::Public(data) => { // public_key is a serialized EncodedPoint - p256::EncodedPoint::from_bytes(&data) + p256::EncodedPoint::from_bytes(data) .map_err(|_| type_error("expected valid public EC key")) } RawKeyData::Private(data) => { @@ -106,7 +106,7 @@ impl RawKeyData { match self { RawKeyData::Public(data) => { // public_key is a serialized EncodedPoint - p384::EncodedPoint::from_bytes(&data) + p384::EncodedPoint::from_bytes(data) .map_err(|_| type_error("expected valid public EC key")) } RawKeyData::Private(data) => { diff --git a/ext/net/ops_unix.rs b/ext/net/ops_unix.rs index bf03f40151..2a67589faf 100644 --- a/ext/net/ops_unix.rs +++ b/ext/net/ops_unix.rs @@ -198,7 +198,7 @@ where let permissions = state.borrow_mut::(); permissions.check_read(address_path, "Deno.listen()")?; permissions.check_write(address_path, "Deno.listen()")?; - let listener = UnixListener::bind(&address_path)?; + let listener = UnixListener::bind(address_path)?; let local_addr = listener.local_addr()?; let pathname = local_addr.as_pathname().map(pathstring).transpose()?; let listener_resource = UnixListenerResource { @@ -220,7 +220,7 @@ where let permissions = state.borrow_mut::(); permissions.check_read(address_path, "Deno.listenDatagram()")?; permissions.check_write(address_path, "Deno.listenDatagram()")?; - let socket = UnixDatagram::bind(&address_path)?; + let socket = UnixDatagram::bind(address_path)?; let local_addr = socket.local_addr()?; let pathname = local_addr.as_pathname().map(pathstring).transpose()?; let datagram_resource = UnixDatagramResource { diff --git a/ops/lib.rs b/ops/lib.rs index d295ec9bd7..4d0c89bd2a 100644 --- a/ops/lib.rs +++ b/ops/lib.rs @@ -47,8 +47,6 @@ struct Op { impl Op { fn new(mut item: ItemFn, attrs: Attributes) -> Self { - add_scope_lifetime(&mut item); - // Preserve the original function. Change the name to `call`. // // impl op_foo { @@ -58,6 +56,8 @@ impl Op { let mut orig = item.clone(); orig.sig.ident = Ident::new("call", Span::call_site()); + add_scope_lifetime(&mut item); + let is_async = item.sig.asyncness.is_some() || is_future(&item.sig.output); let type_params = exclude_lifetime_params(&item.sig.generics.params); let core = deno::import(); diff --git a/runtime/build.rs b/runtime/build.rs index 71301a36b1..3feca3e765 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -36,7 +36,7 @@ mod not_docs { } let snapshot = js_runtime.snapshot(); - let snapshot_slice: &[u8] = &*snapshot; + let snapshot_slice: &[u8] = &snapshot; println!("Snapshot size: {}", snapshot_slice.len()); let compressed_snapshot_with_size = { @@ -63,7 +63,7 @@ mod not_docs { compressed_snapshot_with_size.len() ); - std::fs::write(&snapshot_path, compressed_snapshot_with_size).unwrap(); + std::fs::write(snapshot_path, compressed_snapshot_with_size).unwrap(); println!("Snapshot written to: {} ", snapshot_path.display()); } diff --git a/runtime/errors.rs b/runtime/errors.rs index 0f6df5828c..442f9ee1bb 100644 --- a/runtime/errors.rs +++ b/runtime/errors.rs @@ -165,7 +165,7 @@ pub fn get_error_class_name(e: &AnyError) -> Option<&'static str> { .or_else(|| e.downcast_ref::().map(get_hyper_error_class)) .or_else(|| { e.downcast_ref::>() - .map(|e| get_hyper_error_class(&**e)) + .map(|e| get_hyper_error_class(e)) }) .or_else(|| { e.downcast_ref::().map(|e| { diff --git a/runtime/fmt_errors.rs b/runtime/fmt_errors.rs index e285d07b48..bd8cf4b941 100644 --- a/runtime/fmt_errors.rs +++ b/runtime/fmt_errors.rs @@ -195,7 +195,7 @@ fn find_recursive_cause(js_error: &JsError) -> Option { { return Some(ErrorReference { from: current_error, - to: *seen, + to: seen, }); } else { current_error = cause; diff --git a/runtime/js.rs b/runtime/js.rs index cdd479858e..54a08d9b42 100644 --- a/runtime/js.rs +++ b/runtime/js.rs @@ -30,7 +30,7 @@ pub static CLI_SNAPSHOT: Lazy> = Lazy::new( pub fn deno_isolate_init() -> Snapshot { debug!("Deno isolate init with snapshots."); - Snapshot::Static(&*CLI_SNAPSHOT) + Snapshot::Static(&CLI_SNAPSHOT) } #[cfg(test)] diff --git a/runtime/ops/fs.rs b/runtime/ops/fs.rs index a7e515d7bb..e48e365bef 100644 --- a/runtime/ops/fs.rs +++ b/runtime/ops/fs.rs @@ -271,7 +271,7 @@ async fn op_write_file_async( None => None, }; let (path, open_options) = open_helper( - &mut *state.borrow_mut(), + &mut state.borrow_mut(), &path, mode, Some(&write_open_options(create, append)), @@ -646,7 +646,7 @@ fn raw_chmod(path: &Path, _raw_mode: u32) -> Result<(), AnyError> { { use std::os::unix::fs::PermissionsExt; let permissions = PermissionsExt::from_mode(_raw_mode); - std::fs::set_permissions(&path, permissions).map_err(err_mapper)?; + std::fs::set_permissions(path, permissions).map_err(err_mapper)?; Ok(()) } // TODO Implement chmod for Windows (#4357) diff --git a/runtime/ops/worker_host.rs b/runtime/ops/worker_host.rs index 2f07e48b23..72d466a94e 100644 --- a/runtime/ops/worker_host.rs +++ b/runtime/ops/worker_host.rs @@ -184,7 +184,7 @@ fn op_create_worker( state.put::(worker_id.next().unwrap()); let module_specifier = deno_core::resolve_url(&specifier)?; - let worker_name = args_name.unwrap_or_else(|| "".to_string()); + let worker_name = args_name.unwrap_or_default(); let (handle_sender, handle_receiver) = std::sync::mpsc::sync_channel::< Result, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index cc8f987ef3..c032b57308 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.64.0" +channel = "1.65.0" components = ["rustfmt", "clippy"] diff --git a/serde_v8/de.rs b/serde_v8/de.rs index 554b2c3665..a43a9c1774 100644 --- a/serde_v8/de.rs +++ b/serde_v8/de.rs @@ -434,7 +434,7 @@ impl<'de, 'a, 'b, 's, 'x> de::Deserializer<'de> V: Visitor<'de>, { magic::buffer::ZeroCopyBuf::from_v8(self.scope, self.input) - .and_then(|zb| visitor.visit_bytes(&*zb)) + .and_then(|zb| visitor.visit_bytes(&zb)) } fn deserialize_byte_buf(self, visitor: V) -> Result diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index 5bbccacd89..3b23af7364 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -1088,7 +1088,7 @@ async fn download_npm_registry_file( .into_bytes() }; std::fs::create_dir_all(file_path.parent().unwrap())?; - std::fs::write(&file_path, bytes)?; + std::fs::write(file_path, bytes)?; Ok(()) } @@ -1918,7 +1918,7 @@ impl<'a> CheckOutputIntegrationTest<'a> { command.env_clear(); } command.envs(self.envs.clone()); - command.current_dir(&cwd); + command.current_dir(cwd); command.stdin(Stdio::piped()); let writer_clone = writer.try_clone().unwrap(); command.stderr(writer_clone); @@ -2163,13 +2163,13 @@ pub fn parse_wrk_output(output: &str) -> WrkOutput { let mut latency = None; for line in output.lines() { - if requests == None { + if requests.is_none() { if let Some(cap) = REQUESTS_RX.captures(line) { requests = Some(str::parse::(cap.get(1).unwrap().as_str()).unwrap()); } } - if latency == None { + if latency.is_none() { if let Some(cap) = LATENCY_RX.captures(line) { let time = cap.get(1).unwrap(); let unit = cap.get(2).unwrap();