diff options
Diffstat (limited to 'cli')
30 files changed, 52 insertions, 59 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 0c3caf0a1..e322aa1e7 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 e347d2e1c..c756c2c2e 100644 --- a/cli/bench/main.rs +++ b/cli/bench/main.rs @@ -343,7 +343,7 @@ fn run_max_mem_benchmark(deno_exe: &Path) -> Result<HashMap<String, i64>> { 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 3bdf2dfb3..73d0208f6 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 5a2f11e3c..81379ac94 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 843f5e0cf..dbebc75c0 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 eb6aa3f0f..f70ccc715 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 5eb42d3b0..b223c71a2 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 937136ce3..9ccbb2c1f 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 63e3fe6dd..ed3d459e1 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -772,7 +772,7 @@ async fn test_command( test_flags: TestFlags, ) -> Result<i32, AnyError> { 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 893020321..dc367f5e7 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 b052f89cd..2ca597bd7 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<PathBuf, AnyError> { 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 e6af92fe8..066c136ee 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 efcea9d99..1a1590a2f 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<NpmPackageReq> { 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 11fa6512c..b160697d1 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 751e093f5..487a8a6aa 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 0cb875078..0d2d81cc0 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 38d44b51f..f123f71a3 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 3383028d6..192fff620 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 f2cee910b..959d46fb4 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 b3a3f441f..efd57b96d 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 58f7e11fa..27a1bb620 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 1868d76b3..c055d8a9c 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 08a695e1d..63b795f76 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 aca8939ee..87ddd8baa 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 832577aa2..9474411b7 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<FileContents, AnyError> { - 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 259eb43b0..494c2f476 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 dca140445..09257efff 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<Vec<_>> = block .get(1) diff --git a/cli/tools/vendor/build.rs b/cli/tools/vendor/build.rs index f0a490a75..dadd84e22 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 05fee531a..3fd381b21 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<bool, AnyError> { - 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 c81ff9335..766bf09e3 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -80,7 +80,7 @@ pub static COMPILER_SNAPSHOT: Lazy<Box<[u8]>> = Lazy::new( ); pub fn compiler_snapshot() -> Snapshot { - Snapshot::Static(&*COMPILER_SNAPSHOT) + Snapshot::Static(&COMPILER_SNAPSHOT) } macro_rules! inc { |