diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bcdc810efc..fe25f66456 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,7 +79,7 @@ jobs: - name: Install Rust uses: hecrj/setup-rust-action@v1 with: - rust-version: 1.53.0 + rust-version: 1.54.0 - name: Install clippy and rustfmt if: matrix.kind == 'lint' @@ -253,7 +253,7 @@ jobs: ~/.cargo/registry/index ~/.cargo/registry/cache ~/.cargo/git/db - key: e-cargo-home-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }} + key: f-cargo-home-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }} # In main branch, always creates fresh cache - name: Cache build output (main) @@ -268,7 +268,7 @@ jobs: !./target/*/*.zip !./target/*/*.tar.gz key: | - d-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ github.sha }} + f-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ github.sha }} # Restore cache from the latest 'main' branch build. - name: Cache build output (PR) @@ -284,7 +284,7 @@ jobs: !./target/*/*.tar.gz key: never_saved restore-keys: | - d-cargo-target-${{ matrix.os }}-${{ matrix.profile }}- + f-cargo-target-${{ matrix.os }}-${{ matrix.profile }}- # Don't save cache after building PRs or branches other than 'main'. - name: Skip save cache (PR) diff --git a/cli/bench/main.rs b/cli/bench/main.rs index c7a6a714e1..e6d7353971 100644 --- a/cli/bench/main.rs +++ b/cli/bench/main.rs @@ -234,11 +234,11 @@ fn get_binary_sizes(target_dir: &Path) -> Result> { ); // add up size for everything in target/release/deps/libswc* - let swc_size = rlib_size(&target_dir, "libswc"); + let swc_size = rlib_size(target_dir, "libswc"); println!("swc {} bytes", swc_size); sizes.insert("swc_rlib".to_string(), swc_size); - let rusty_v8_size = rlib_size(&target_dir, "librusty_v8"); + let rusty_v8_size = rlib_size(target_dir, "librusty_v8"); println!("rusty_v8 {} bytes", rusty_v8_size); sizes.insert("rusty_v8_rlib".to_string(), rusty_v8_size); diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs index 9d1faa6b18..f2c78d5c4b 100644 --- a/cli/diagnostics.rs +++ b/cli/diagnostics.rs @@ -189,7 +189,7 @@ impl DiagnosticMessageChain { pub fn format_message(&self, level: usize) -> String { let mut s = String::new(); - s.push_str(&std::iter::repeat(" ").take(level * 2).collect::()); + s.push_str(&" ".repeat(level * 2)); s.push_str(&self.message_text); if let Some(next) = &self.next { s.push('\n'); diff --git a/cli/disk_cache.rs b/cli/disk_cache.rs index d24acc3ab2..6a5fd6ec8f 100644 --- a/cli/disk_cache.rs +++ b/cli/disk_cache.rs @@ -139,7 +139,7 @@ impl DiskCache { pub fn set(&self, filename: &Path, data: &[u8]) -> std::io::Result<()> { let path = self.location.join(filename); match path.parent() { - Some(ref parent) => self.ensure_dir_exists(parent), + Some(parent) => self.ensure_dir_exists(parent), None => Ok(()), }?; fs_util::atomic_write_file(&path, data, crate::http_cache::CACHE_PERM) diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index 61cf1dae68..a7bd503ae2 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -469,7 +469,7 @@ impl FileFetcher { Ok((_, headers)) => headers.get("etag").cloned(), _ => None, }; - let maybe_auth_token = self.auth_tokens.get(&specifier); + let maybe_auth_token = self.auth_tokens.get(specifier); let specifier = specifier.clone(); let mut permissions = permissions.clone(); let client = self.http_client.clone(); diff --git a/cli/fmt_errors.rs b/cli/fmt_errors.rs index 9431dab079..2078c8b32f 100644 --- a/cli/fmt_errors.rs +++ b/cli/fmt_errors.rs @@ -67,7 +67,7 @@ fn format_frame(frame: &JsStackFrame) -> String { formatted_method += &format!("{}.", type_name); } } - formatted_method += &function_name; + formatted_method += function_name; if let Some(method_name) = &frame.method_name { if !function_name.ends_with(method_name) { formatted_method += &format!(" [as {}]", method_name); @@ -78,7 +78,7 @@ fn format_frame(frame: &JsStackFrame) -> String { formatted_method += &format!("{}.", type_name); } if let Some(method_name) = &frame.method_name { - formatted_method += &method_name + formatted_method += method_name } else { formatted_method += ""; } diff --git a/cli/http_cache.rs b/cli/http_cache.rs index 37da009835..115eb10a43 100644 --- a/cli/http_cache.rs +++ b/cli/http_cache.rs @@ -93,7 +93,7 @@ impl Metadata { #[cfg(test)] pub fn read(cache_filename: &Path) -> Result { - let metadata_filename = Metadata::filename(&cache_filename); + let metadata_filename = Metadata::filename(cache_filename); let metadata = fs::read_to_string(metadata_filename)?; let metadata: Metadata = serde_json::from_str(&metadata)?; Ok(metadata) diff --git a/cli/import_map.rs b/cli/import_map.rs index 0c7a6f76c4..17ac3727eb 100644 --- a/cli/import_map.rs +++ b/cli/import_map.rs @@ -268,7 +268,7 @@ impl ImportMap { } // Sort in longest and alphabetical order. - normalized_map.sort_by(|k1, _v1, k2, _v2| match k1.cmp(&k2) { + normalized_map.sort_by(|k1, _v1, k2, _v2| match k1.cmp(k2) { Ordering::Greater => Ordering::Less, Ordering::Less => Ordering::Greater, // JSON guarantees that there can't be duplicate keys @@ -324,7 +324,7 @@ impl ImportMap { } // Sort in longest and alphabetical order. - normalized_map.sort_by(|k1, _v1, k2, _v2| match k1.cmp(&k2) { + normalized_map.sort_by(|k1, _v1, k2, _v2| match k1.cmp(k2) { Ordering::Greater => Ordering::Less, Ordering::Less => Ordering::Greater, // JSON guarantees that there can't be duplicate keys @@ -691,7 +691,7 @@ mod tests { ImportMap::from_json(&test.import_map_base_url, &test.import_map) .unwrap(); let maybe_resolved = import_map - .resolve(&given_specifier, &base_url) + .resolve(given_specifier, base_url) .ok() .map(|url| url.to_string()); assert_eq!(expected_specifier, &maybe_resolved, "{}", test.name); diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs index 3d25145c10..aae67f87a0 100644 --- a/cli/lsp/analysis.rs +++ b/cli/lsp/analysis.rs @@ -291,7 +291,7 @@ pub fn parse_module( ast::parse_with_source_map( &specifier.to_string(), source, - &media_type, + media_type, source_map, ) } @@ -309,7 +309,7 @@ pub fn analyze_dependencies( // Parse leading comments for supported triple slash references. for comment in parsed_module.get_leading_comments().iter() { - if let Some((ts_reference, span)) = parse_ts_reference(&comment) { + if let Some((ts_reference, span)) = parse_ts_reference(comment) { let loc = parsed_module.source_map.lookup_char_pos(span.lo); match ts_reference { TypeScriptReference::Path(import) => { @@ -364,7 +364,7 @@ pub fn analyze_dependencies( let maybe_resolved_type_dependency = // Check for `@deno-types` pragmas that affect the import if let Some(comment) = desc.leading_comments.last() { - parse_deno_types(&comment).as_ref().map(|(deno_types, span)| { + parse_deno_types(comment).as_ref().map(|(deno_types, span)| { ( resolve_import(deno_types, specifier, maybe_import_map), deno_types.clone(), diff --git a/cli/lsp/code_lens.rs b/cli/lsp/code_lens.rs index 3ad644af35..1f8d2481b1 100644 --- a/cli/lsp/code_lens.rs +++ b/cli/lsp/code_lens.rs @@ -102,7 +102,7 @@ impl DenoTestCollector { key_value_prop.value.as_ref() { let name = lit_str.value.to_string(); - self.add_code_lens(name, &span); + self.add_code_lens(name, span); } } } @@ -112,7 +112,7 @@ impl DenoTestCollector { } ast::Expr::Lit(ast::Lit::Str(lit_str)) => { let name = lit_str.value.to_string(); - self.add_code_lens(name, &span); + self.add_code_lens(name, span); } _ => (), } @@ -415,7 +415,7 @@ async fn collect_tsc( ) -> Result, AnyError> { let workspace_settings = language_server.config.get_workspace_settings(); let line_index = language_server - .get_line_index_sync(&specifier) + .get_line_index_sync(specifier) .ok_or_else(|| anyhow!("Missing line index."))?; let navigation_tree = language_server.get_navigation_tree(specifier).await?; let code_lenses = Rc::new(RefCell::new(Vec::new())); @@ -435,7 +435,7 @@ async fn collect_tsc( | tsc::ScriptElementKind::MemberGetAccessorElement | tsc::ScriptElementKind::MemberSetAccessorElement => { if ABSTRACT_MODIFIER.is_match(&i.kind_modifiers) { - code_lenses.push(i.to_code_lens(&line_index, &specifier, &source)); + code_lenses.push(i.to_code_lens(&line_index, specifier, &source)); } } _ => (), @@ -447,31 +447,31 @@ async fn collect_tsc( let source = CodeLensSource::References; if let Some(parent) = &mp { if parent.kind == tsc::ScriptElementKind::EnumElement { - code_lenses.push(i.to_code_lens(&line_index, &specifier, &source)); + code_lenses.push(i.to_code_lens(&line_index, specifier, &source)); } } match i.kind { tsc::ScriptElementKind::FunctionElement => { if workspace_settings.code_lens.references_all_functions { - code_lenses.push(i.to_code_lens(&line_index, &specifier, &source)); + code_lenses.push(i.to_code_lens(&line_index, specifier, &source)); } } tsc::ScriptElementKind::ConstElement | tsc::ScriptElementKind::LetElement | tsc::ScriptElementKind::VariableElement => { if EXPORT_MODIFIER.is_match(&i.kind_modifiers) { - code_lenses.push(i.to_code_lens(&line_index, &specifier, &source)); + code_lenses.push(i.to_code_lens(&line_index, specifier, &source)); } } tsc::ScriptElementKind::ClassElement => { if i.text != "" { - code_lenses.push(i.to_code_lens(&line_index, &specifier, &source)); + code_lenses.push(i.to_code_lens(&line_index, specifier, &source)); } } tsc::ScriptElementKind::InterfaceElement | tsc::ScriptElementKind::TypeElement | tsc::ScriptElementKind::EnumElement => { - code_lenses.push(i.to_code_lens(&line_index, &specifier, &source)); + code_lenses.push(i.to_code_lens(&line_index, specifier, &source)); } tsc::ScriptElementKind::LocalFunctionElement | tsc::ScriptElementKind::MemberGetAccessorElement @@ -486,7 +486,7 @@ async fn collect_tsc( | tsc::ScriptElementKind::TypeElement => { code_lenses.push(i.to_code_lens( &line_index, - &specifier, + specifier, &source, )); } diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs index a7051ddf1b..11a4e8364b 100644 --- a/cli/lsp/diagnostics.rs +++ b/cli/lsp/diagnostics.rs @@ -260,13 +260,13 @@ fn to_lsp_related_information( if let (Some(source), Some(start), Some(end)) = (&ri.source, &ri.start, &ri.end) { - let uri = lsp::Url::parse(&source).unwrap(); + let uri = lsp::Url::parse(source).unwrap(); Some(lsp::DiagnosticRelatedInformation { location: lsp::Location { uri, range: to_lsp_range(start, end), }, - message: get_diagnostic_message(&ri), + message: get_diagnostic_message(ri), }) } else { None @@ -421,8 +421,8 @@ fn diagnose_dependency( }) } analysis::ResolvedDependency::Resolved(specifier) => { - if !(documents.contains_key(&specifier) - || sources.contains_key(&specifier)) + if !(documents.contains_key(specifier) + || sources.contains_key(specifier)) { let (code, message) = match specifier.scheme() { "file" => (Some(lsp::NumberOrString::String("no-local".to_string())), format!("Unable to load a local module: \"{}\".\n Please check the file path.", specifier)), @@ -439,8 +439,8 @@ fn diagnose_dependency( data: Some(json!({ "specifier": specifier })), ..Default::default() }); - } else if sources.contains_key(&specifier) { - if let Some(message) = sources.get_maybe_warning(&specifier) { + } else if sources.contains_key(specifier) { + if let Some(message) = sources.get_maybe_warning(specifier) { diagnostics.push(lsp::Diagnostic { range, severity: Some(lsp::DiagnosticSeverity::Warning), diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs index 911e30389d..c2b207e14d 100644 --- a/cli/lsp/documents.rs +++ b/cli/lsp/documents.rs @@ -119,13 +119,13 @@ impl DocumentData { let mut line_index = if let Some(line_index) = &self.line_index { line_index.clone() } else { - LineIndex::new(&content) + LineIndex::new(content) }; let mut index_valid = IndexValid::All; for change in content_changes { if let Some(range) = change.range { if !index_valid.covers(range.start.line) { - line_index = LineIndex::new(&content); + line_index = LineIndex::new(content); } index_valid = IndexValid::UpTo(range.start.line); let range = line_index.get_text_range(range)?; @@ -139,7 +139,7 @@ impl DocumentData { self.line_index = if index_valid == IndexValid::All { Some(line_index) } else { - Some(LineIndex::new(&content)) + Some(LineIndex::new(content)) }; self.maybe_navigation_tree = None; Ok(()) diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index ab17d03fbc..68ce9c58c3 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -620,7 +620,7 @@ impl Inner { Ok(maybe_asset.clone()) } else { let maybe_asset = - tsc::get_asset(&specifier, &self.ts_server, self.snapshot()?).await?; + tsc::get_asset(specifier, &self.ts_server, self.snapshot()?).await?; self.assets.insert(specifier.clone(), maybe_asset.clone()); Ok(maybe_asset) } diff --git a/cli/lsp/registries.rs b/cli/lsp/registries.rs index d044927bcc..6a1dc1a4bc 100644 --- a/cli/lsp/registries.rs +++ b/cli/lsp/registries.rs @@ -104,7 +104,7 @@ fn get_completor_type( if let StringOrNumber::String(name) = &k.name { let value = match_result .get(name) - .map(|s| s.to_string(Some(&k))) + .map(|s| s.to_string(Some(k))) .unwrap_or_default(); len += value.chars().count(); if offset <= len { @@ -183,14 +183,13 @@ fn validate_config(config: &RegistryConfigurationJson) -> Result<(), AnyError> { .collect() }); - let variable_names: Vec = registry - .variables - .iter() - .map(|var| var.key.to_owned()) - .collect(); - for key_name in &key_names { - if !variable_names.contains(key_name) { + if !registry + .variables + .iter() + .map(|var| var.key.to_owned()) + .any(|x| x == *key_name) + { return Err(anyhow!("Invalid registry configuration. Registry with schema \"{}\" is missing variable declaration for key \"{}\".", registry.schema, key_name)); } } diff --git a/cli/lsp/sources.rs b/cli/lsp/sources.rs index 033a1e9d53..8be1420d47 100644 --- a/cli/lsp/sources.rs +++ b/cli/lsp/sources.rs @@ -361,7 +361,7 @@ impl Inner { &mut self, specifier: &ModuleSpecifier, ) -> Option { - let metadata = self.get_metadata(&specifier)?; + let metadata = self.get_metadata(specifier)?; metadata.maybe_warning } @@ -399,7 +399,7 @@ impl Inner { map_content_type(specifier, maybe_content_type); let source = get_source_from_bytes(bytes, maybe_charset).ok()?; let maybe_types = headers.get("x-typescript-types").map(|s| { - analysis::resolve_import(s, &specifier, &self.maybe_import_map) + analysis::resolve_import(s, specifier, &self.maybe_import_map) }); let maybe_warning = headers.get("x-deno-warning").cloned(); (source, media_type, maybe_types, maybe_warning) @@ -432,10 +432,10 @@ impl Inner { fn get_path(&mut self, specifier: &ModuleSpecifier) -> Option { if specifier.scheme() == "file" { specifier.to_file_path().ok() - } else if let Some(path) = self.remotes.get(&specifier) { + } else if let Some(path) = self.remotes.get(specifier) { Some(path.clone()) } else { - let path = self.http_cache.get_cache_filename(&specifier)?; + let path = self.http_cache.get_cache_filename(specifier)?; if path.is_file() { self.remotes.insert(specifier.clone(), path.clone()); Some(path) diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 3f52beb6b9..c3f82fea8f 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -1293,7 +1293,7 @@ impl CallHierarchyOutgoingCall { from_ranges: self .from_spans .iter() - .map(|span| span.to_range(&line_index)) + .map(|span| span.to_range(line_index)) .collect(), }) } diff --git a/cli/main.rs b/cli/main.rs index 52f2c55af8..77366ec126 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -1088,7 +1088,7 @@ async fn test_command( output.insert(specifier); get_dependencies( - &graph, + graph, graph.get_specifier(specifier)?, output, )?; @@ -1099,7 +1099,7 @@ async fn test_command( output.insert(specifier); get_dependencies( - &graph, + graph, graph.get_specifier(specifier)?, output, )?; diff --git a/cli/module_graph.rs b/cli/module_graph.rs index ee359b4bca..1a82bce0e3 100644 --- a/cli/module_graph.rs +++ b/cli/module_graph.rs @@ -348,7 +348,7 @@ impl Module { // parse out any triple slash references for comment in parsed_module.get_leading_comments().iter() { - if let Some((ts_reference, _)) = parse_ts_reference(&comment) { + if let Some((ts_reference, _)) = parse_ts_reference(comment) { let location = parsed_module.get_location(&comment.span); match ts_reference { TypeScriptReference::Path(import) => { @@ -421,7 +421,7 @@ impl Module { // Parse out any `@deno-types` pragmas and modify dependency let maybe_type = if !desc.leading_comments.is_empty() { let comment = desc.leading_comments.last().unwrap(); - if let Some((deno_types, _)) = parse_deno_types(&comment).as_ref() { + if let Some((deno_types, _)) = parse_deno_types(comment).as_ref() { Some(self.resolve_import(deno_types, Some(location.clone()))?) } else { None @@ -923,7 +923,7 @@ impl Graph { // to ESM, which we don't really want unless someone has enabled the // check_js option. if !check_js - && graph.get_media_type(&specifier) == Some(MediaType::JavaScript) + && graph.get_media_type(specifier) == Some(MediaType::JavaScript) { debug!("skipping emit for {}", specifier); continue; @@ -1931,7 +1931,7 @@ impl GraphBuilder { maybe_referrer: &Option, is_dynamic: bool, ) { - if !self.graph.modules.contains_key(&specifier) { + if !self.graph.modules.contains_key(specifier) { self .graph .modules @@ -2231,21 +2231,21 @@ pub mod tests { #[test] fn test_get_version() { let doc_a = "console.log(42);"; - let version_a = get_version(&doc_a, "1.2.3", b""); + let version_a = get_version(doc_a, "1.2.3", b""); let doc_b = "console.log(42);"; - let version_b = get_version(&doc_b, "1.2.3", b""); + let version_b = get_version(doc_b, "1.2.3", b""); assert_eq!(version_a, version_b); - let version_c = get_version(&doc_a, "1.2.3", b"options"); + let version_c = get_version(doc_a, "1.2.3", b"options"); assert_ne!(version_a, version_c); - let version_d = get_version(&doc_b, "1.2.3", b"options"); + let version_d = get_version(doc_b, "1.2.3", b"options"); assert_eq!(version_c, version_d); - let version_e = get_version(&doc_a, "1.2.4", b""); + let version_e = get_version(doc_a, "1.2.4", b""); assert_ne!(version_a, version_e); - let version_f = get_version(&doc_b, "1.2.4", b""); + let version_f = get_version(doc_b, "1.2.4", b""); assert_eq!(version_e, version_f); } diff --git a/cli/program_state.rs b/cli/program_state.rs index 6775b22766..b8fb5e33b2 100644 --- a/cli/program_state.rs +++ b/cli/program_state.rs @@ -115,9 +115,10 @@ impl ProgramState { None => None, Some(import_map_url) => { let import_map_specifier = - deno_core::resolve_url_or_path(&import_map_url).context( - format!("Bad URL (\"{}\") for import map.", import_map_url), - )?; + deno_core::resolve_url_or_path(import_map_url).context(format!( + "Bad URL (\"{}\") for import map.", + import_map_url + ))?; let file = file_fetcher .fetch(&import_map_specifier, &mut Permissions::allow_all()) .await @@ -369,11 +370,11 @@ impl ProgramState { let emit_path = self .dir .gen_cache - .get_cache_filename_with_extension(&url, "js")?; + .get_cache_filename_with_extension(url, "js")?; let emit_map_path = self .dir .gen_cache - .get_cache_filename_with_extension(&url, "js.map")?; + .get_cache_filename_with_extension(url, "js.map")?; if let Ok(code) = self.dir.gen_cache.get(&emit_path) { let maybe_map = if let Ok(map) = self.dir.gen_cache.get(&emit_map_path) { Some(map) diff --git a/cli/specifier_handler.rs b/cli/specifier_handler.rs index cec1049a32..ae47e977a7 100644 --- a/cli/specifier_handler.rs +++ b/cli/specifier_handler.rs @@ -327,7 +327,7 @@ impl SpecifierHandler for FetchHandler { let mut maybe_map_path = None; let map_path = - disk_cache.get_cache_filename_with_extension(&url, "js.map"); + disk_cache.get_cache_filename_with_extension(url, "js.map"); let maybe_map = if let Some(map_path) = map_path { if let Ok(map) = disk_cache.get(&map_path) { maybe_map_path = Some(disk_cache.location.join(map_path)); @@ -340,7 +340,7 @@ impl SpecifierHandler for FetchHandler { }; let mut maybe_emit = None; let mut maybe_emit_path = None; - let emit_path = disk_cache.get_cache_filename_with_extension(&url, "js"); + let emit_path = disk_cache.get_cache_filename_with_extension(url, "js"); if let Some(emit_path) = emit_path { if let Ok(code) = disk_cache.get(&emit_path) { maybe_emit = diff --git a/cli/standalone.rs b/cli/standalone.rs index 65ca58ec39..9a693d9613 100644 --- a/cli/standalone.rs +++ b/cli/standalone.rs @@ -142,7 +142,7 @@ impl ModuleLoader for EmbeddedModuleLoader { _referrer: &str, _is_main: bool, ) -> Result { - if let Ok(module_specifier) = resolve_url(&specifier) { + if let Ok(module_specifier) = resolve_url(specifier) { if get_source_from_data_url(&module_specifier).is_ok() || specifier == SPECIFIER { diff --git a/cli/tools/coverage.rs b/cli/tools/coverage.rs index b7772f3107..bb1e9417d6 100644 --- a/cli/tools/coverage.rs +++ b/cli/tools/coverage.rs @@ -709,7 +709,7 @@ pub async fn cover_files( reporter.visit_coverage( &script_coverage, - &script_source, + script_source, maybe_source_map, maybe_cached_source, ); diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index ac9af0292d..a02b86b179 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -99,7 +99,7 @@ fn format_markdown( ) -> Result { let md_config = get_markdown_config(); dprint_plugin_markdown::format_text( - &file_text, + file_text, &md_config, move |tag, text, line_width| { let tag = tag.to_lowercase(); @@ -125,7 +125,7 @@ fn format_markdown( if matches!(extension, "json" | "jsonc") { let mut json_config = get_json_config(); json_config.line_width = line_width; - dprint_plugin_json::format_text(&text, &json_config) + dprint_plugin_json::format_text(text, &json_config) } else { let fake_filename = PathBuf::from(format!("deno_fmt_stdin.{}", extension)); @@ -133,7 +133,7 @@ fn format_markdown( codeblock_config.line_width = line_width; dprint_plugin_typescript::format_text( &fake_filename, - &text, + text, &codeblock_config, ) } @@ -150,7 +150,7 @@ fn format_markdown( /// See https://git.io/Jt4ht for configuration. fn format_json(file_text: &str) -> Result { let json_config = get_json_config(); - dprint_plugin_json::format_text(&file_text, &json_config) + dprint_plugin_json::format_text(file_text, &json_config) .map_err(|e| e.to_string()) } @@ -162,11 +162,11 @@ pub fn format_file( ) -> Result { let ext = get_extension(file_path).unwrap_or_else(String::new); if ext == "md" { - format_markdown(&file_text, config) + format_markdown(file_text, config) } else if matches!(ext.as_str(), "json" | "jsonc") { - format_json(&file_text) + format_json(file_text) } else { - dprint_plugin_typescript::format_text(&file_path, &file_text, &config) + dprint_plugin_typescript::format_text(file_path, file_text, &config) .map_err(|e| e.to_string()) } } diff --git a/cli/tools/lint.rs b/cli/tools/lint.rs index 0b0479a04d..967eec2ada 100644 --- a/cli/tools/lint.rs +++ b/cli/tools/lint.rs @@ -81,7 +81,7 @@ pub async fn lint_files( sort_diagnostics(&mut file_diagnostics); for d in file_diagnostics.iter() { has_error.store(true, Ordering::Relaxed); - reporter.visit_diagnostic(&d, source.split('\n').collect()); + reporter.visit_diagnostic(d, source.split('\n').collect()); } } Err(err) => { diff --git a/cli/tools/repl.rs b/cli/tools/repl.rs index b86e8ccd80..5b0d788413 100644 --- a/cli/tools/repl.rs +++ b/cli/tools/repl.rs @@ -555,7 +555,7 @@ impl ReplSession { if evaluate_response.get("exceptionDetails").is_some() && wrapped_line != line { - self.evaluate_ts_expression(&line).await? + self.evaluate_ts_expression(line).await? } else { evaluate_response }; @@ -632,7 +632,7 @@ impl ReplSession { expression: &str, ) -> Result { let parsed_module = - crate::ast::parse("repl.ts", &expression, &crate::MediaType::TypeScript)?; + crate::ast::parse("repl.ts", expression, &crate::MediaType::TypeScript)?; let transpiled_src = parsed_module .transpile(&crate::ast::EmitOptions { diff --git a/cli/tools/test_runner.rs b/cli/tools/test_runner.rs index a9610015e5..656db50f43 100644 --- a/cli/tools/test_runner.rs +++ b/cli/tools/test_runner.rs @@ -355,7 +355,7 @@ fn extract_files_from_regex_blocks( lines_regex: &Regex, ) -> Result, AnyError> { let files = blocks_regex - .captures_iter(&source) + .captures_iter(source) .filter_map(|block| { let maybe_attributes = block .get(1) @@ -390,7 +390,7 @@ fn extract_files_from_regex_blocks( // TODO(caspervonb) generate an inline source map let mut file_source = String::new(); - for line in lines_regex.captures_iter(&text) { + for line in lines_regex.captures_iter(text) { let text = line.get(1).unwrap(); file_source.push_str(&format!("{}\n", text.as_str())); } @@ -424,7 +424,7 @@ fn extract_files_from_source_comments( source: &str, media_type: &MediaType, ) -> Result, AnyError> { - let parsed_module = ast::parse(&specifier.as_str(), &source, &media_type)?; + let parsed_module = ast::parse(specifier.as_str(), source, media_type)?; let mut comments = parsed_module.get_comments(); comments .sort_by_key(|comment| parsed_module.get_location(&comment.span).line); @@ -447,7 +447,7 @@ fn extract_files_from_source_comments( extract_files_from_regex_blocks( &location, &comment.text, - &media_type, + media_type, &blocks_regex, &lines_regex, ) @@ -474,8 +474,8 @@ fn extract_files_from_fenced_blocks( extract_files_from_regex_blocks( &location, - &source, - &media_type, + source, + media_type, &blocks_regex, &lines_regex, ) diff --git a/cli/tsc.rs b/cli/tsc.rs index 1b923aa3b0..b355c12faa 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -510,9 +510,9 @@ pub fn exec(request: Request) -> Result { .map(|(s, mt)| match s.scheme() { "data" | "blob" => { let specifier_str = if s.scheme() == "data" { - hash_data_url(&s, &mt) + hash_data_url(s, mt) } else { - hash_blob_url(&s, &mt) + hash_blob_url(s, mt) }; data_url_map.insert(specifier_str.clone(), s.clone()); specifier_str @@ -640,7 +640,7 @@ mod tests { ..Default::default() })); let mut builder = GraphBuilder::new(handler.clone(), None, None); - builder.add(&specifier, false).await?; + builder.add(specifier, false).await?; let graph = Arc::new(Mutex::new(builder.get_graph())); let config = TsConfig::new(json!({ "allowJs": true, diff --git a/core/bindings.rs b/core/bindings.rs index 9ece232769..af8560c6ad 100644 --- a/core/bindings.rs +++ b/core/bindings.rs @@ -690,7 +690,7 @@ fn decode( // - https://encoding.spec.whatwg.org/#dom-textdecoder-decode // - https://github.com/denoland/deno/issues/6649 // - https://github.com/v8/v8/blob/d68fb4733e39525f9ff0a9222107c02c28096e2a/include/v8.h#L3277-L3278 - match v8::String::new_from_utf8(scope, &buf, v8::NewStringType::Normal) { + match v8::String::new_from_utf8(scope, buf, v8::NewStringType::Normal) { Some(text) => rv.set(text.into()), None => { let msg = v8::String::new(scope, "string too long").unwrap(); diff --git a/core/internal.d.ts b/core/internal.d.ts index 6697f47155..593136722e 100644 --- a/core/internal.d.ts +++ b/core/internal.d.ts @@ -48,21 +48,16 @@ declare namespace __bootstrap { */ declare namespace primordials { type UncurryThis unknown> = - ( - self: ThisParameterType, - ...args: Parameters - ) => ReturnType; + (self: ThisParameterType, ...args: Parameters) => ReturnType; type UncurryThisStaticApply< T extends (this: unknown, ...args: unknown[]) => unknown, > = (self: ThisParameterType, args: Parameters) => ReturnType; type StaticApply unknown> = - ( - args: Parameters, - ) => ReturnType; + (args: Parameters) => ReturnType; - export function uncurryThis< - T extends (...args: unknown[]) => unknown, - >(fn: T): (self: ThisType, ...args: Parameters) => ReturnType; + export function uncurryThis unknown>( + fn: T, + ): (self: ThisType, ...args: Parameters) => ReturnType; export function makeSafe( unsafe: NewableFunction, safe: T, diff --git a/core/module_specifier.rs b/core/module_specifier.rs index 4de8750736..831a0f2ac5 100644 --- a/core/module_specifier.rs +++ b/core/module_specifier.rs @@ -96,7 +96,7 @@ pub fn resolve_import( } else { Url::parse(base).map_err(InvalidBaseUrl)? }; - base.join(&specifier).map_err(InvalidUrl)? + base.join(specifier).map_err(InvalidUrl)? } // If parsing the specifier as a URL failed for a different reason than diff --git a/extensions/crypto/lib.rs b/extensions/crypto/lib.rs index d390afdab4..09f237fa60 100644 --- a/extensions/crypto/lib.rs +++ b/extensions/crypto/lib.rs @@ -362,7 +362,7 @@ pub async fn op_crypto_sign_key( }; let rng = RingRand::SystemRandom::new(); - let signature = key_pair.sign(&rng, &data)?; + let signature = key_pair.sign(&rng, data)?; // Signature data as buffer. signature.as_ref().to_vec() @@ -372,7 +372,7 @@ pub async fn op_crypto_sign_key( let key = HmacKey::new(hash, &*args.key.data); - let signature = ring::hmac::sign(&key, &data); + let signature = ring::hmac::sign(&key, data); signature.as_ref().to_vec() } _ => return Err(type_error("Unsupported algorithm".to_string())), diff --git a/extensions/net/ops.rs b/extensions/net/ops.rs index a02bbf91a7..a0fc2179e0 100644 --- a/extensions/net/ops.rs +++ b/extensions/net/ops.rs @@ -260,7 +260,7 @@ where let address_path = Path::new(&args.path); { let mut s = state.borrow_mut(); - s.borrow_mut::().check_write(&address_path)?; + s.borrow_mut::().check_write(address_path)?; } let resource = state .borrow() @@ -338,8 +338,8 @@ where super::check_unstable2(&state, "Deno.connect"); { let mut state_ = state.borrow_mut(); - state_.borrow_mut::().check_read(&address_path)?; - state_.borrow_mut::().check_write(&address_path)?; + state_.borrow_mut::().check_read(address_path)?; + state_.borrow_mut::().check_write(address_path)?; } let path = args.path; let unix_stream = net_unix::UnixStream::connect(Path::new(&path)).await?; @@ -512,13 +512,13 @@ where super::check_unstable(state, "Deno.listenDatagram"); } let permissions = state.borrow_mut::(); - permissions.check_read(&address_path)?; - permissions.check_write(&address_path)?; + permissions.check_read(address_path)?; + permissions.check_write(address_path)?; } let (rid, local_addr) = if transport == "unix" { - net_unix::listen_unix(state, &address_path)? + net_unix::listen_unix(state, address_path)? } else { - net_unix::listen_unix_packet(state, &address_path)? + net_unix::listen_unix_packet(state, address_path)? }; debug!( "New listener {} {}", diff --git a/extensions/web/blob.rs b/extensions/web/blob.rs index bd5284317b..0f27553c75 100644 --- a/extensions/web/blob.rs +++ b/extensions/web/blob.rs @@ -36,7 +36,7 @@ impl BlobStore { id: &Uuid, ) -> Option>> { let parts = self.parts.lock(); - let part = parts.get(&id); + let part = parts.get(id); part.cloned() } @@ -45,7 +45,7 @@ impl BlobStore { id: &Uuid, ) -> Option>> { let mut parts = self.parts.lock(); - parts.remove(&id) + parts.remove(id) } pub fn get_object_url( @@ -78,7 +78,7 @@ impl BlobStore { pub fn remove_object_url(&self, url: &Url) { let mut blob_store = self.object_urls.lock(); - blob_store.remove(&url); + blob_store.remove(url); } } diff --git a/runtime/colors.rs b/runtime/colors.rs index 6d020bb6d9..417a6e76e6 100644 --- a/runtime/colors.rs +++ b/runtime/colors.rs @@ -48,67 +48,67 @@ fn style(s: &str, colorspec: ColorSpec) -> impl fmt::Display { pub fn red_bold(s: &str) -> impl fmt::Display { let mut style_spec = ColorSpec::new(); style_spec.set_fg(Some(Red)).set_bold(true); - style(&s, style_spec) + style(s, style_spec) } pub fn green_bold(s: &str) -> impl fmt::Display { let mut style_spec = ColorSpec::new(); style_spec.set_fg(Some(Green)).set_bold(true); - style(&s, style_spec) + style(s, style_spec) } pub fn italic_bold(s: &str) -> impl fmt::Display { let mut style_spec = ColorSpec::new(); style_spec.set_bold(true).set_italic(true); - style(&s, style_spec) + style(s, style_spec) } pub fn white_on_red(s: &str) -> impl fmt::Display { let mut style_spec = ColorSpec::new(); style_spec.set_bg(Some(Red)).set_fg(Some(White)); - style(&s, style_spec) + style(s, style_spec) } pub fn black_on_green(s: &str) -> impl fmt::Display { let mut style_spec = ColorSpec::new(); style_spec.set_bg(Some(Green)).set_fg(Some(Black)); - style(&s, style_spec) + style(s, style_spec) } pub fn yellow(s: &str) -> impl fmt::Display { let mut style_spec = ColorSpec::new(); style_spec.set_fg(Some(Yellow)); - style(&s, style_spec) + style(s, style_spec) } pub fn cyan(s: &str) -> impl fmt::Display { let mut style_spec = ColorSpec::new(); style_spec.set_fg(Some(Cyan)); - style(&s, style_spec) + style(s, style_spec) } pub fn red(s: &str) -> impl fmt::Display { let mut style_spec = ColorSpec::new(); style_spec.set_fg(Some(Red)); - style(&s, style_spec) + style(s, style_spec) } pub fn green(s: &str) -> impl fmt::Display { let mut style_spec = ColorSpec::new(); style_spec.set_fg(Some(Green)); - style(&s, style_spec) + style(s, style_spec) } pub fn bold(s: &str) -> impl fmt::Display { let mut style_spec = ColorSpec::new(); style_spec.set_bold(true); - style(&s, style_spec) + style(s, style_spec) } pub fn gray(s: &str) -> impl fmt::Display { let mut style_spec = ColorSpec::new(); style_spec.set_fg(Some(Ansi256(8))); - style(&s, style_spec) + style(s, style_spec) } pub fn italic_bold_gray(s: &str) -> impl fmt::Display { @@ -117,11 +117,11 @@ pub fn italic_bold_gray(s: &str) -> impl fmt::Display { .set_fg(Some(Ansi256(8))) .set_bold(true) .set_italic(true); - style(&s, style_spec) + style(s, style_spec) } pub fn intense_blue(s: &str) -> impl fmt::Display { let mut style_spec = ColorSpec::new(); style_spec.set_fg(Some(Blue)).set_intense(true); - style(&s, style_spec) + style(s, style_spec) } diff --git a/runtime/ops/fs.rs b/runtime/ops/fs.rs index cd93d05176..c7f4295ba0 100644 --- a/runtime/ops/fs.rs +++ b/runtime/ops/fs.rs @@ -1366,7 +1366,7 @@ fn make_temp( let prefix_ = prefix.unwrap_or(""); let suffix_ = suffix.unwrap_or(""); let mut buf: PathBuf = match dir { - Some(ref p) => p.to_path_buf(), + Some(p) => p.to_path_buf(), None => temp_dir(), } .join("_"); diff --git a/runtime/permissions.rs b/runtime/permissions.rs index 0d89fb62e1..5215743e34 100644 --- a/runtime/permissions.rs +++ b/runtime/permissions.rs @@ -712,7 +712,7 @@ impl UnaryPermission { pub fn request(&mut self, cmd: Option<&str>) -> PermissionState { if let Some(cmd) = cmd { - let state = self.query(Some(&cmd)); + let state = self.query(Some(cmd)); if state == PermissionState::Prompt { if permission_prompt(&format!("run access to \"{}\"", cmd)) { self.granted_list.retain(|cmd_| cmd_.0 != cmd); @@ -819,7 +819,7 @@ impl Permissions { name: "read", description: "read the file system", global_state: global_state_from_option(state), - granted_list: resolve_read_allowlist(&state), + granted_list: resolve_read_allowlist(state), denied_list: Default::default(), prompt, } @@ -833,7 +833,7 @@ impl Permissions { name: "write", description: "write to the file system", global_state: global_state_from_option(state), - granted_list: resolve_write_allowlist(&state), + granted_list: resolve_write_allowlist(state), denied_list: Default::default(), prompt, } @@ -1469,15 +1469,15 @@ mod tests { #[rustfmt::skip] { assert_eq!(perms1.read.query(None), PermissionState::Granted); - assert_eq!(perms1.read.query(Some(&Path::new("/foo"))), PermissionState::Granted); + assert_eq!(perms1.read.query(Some(Path::new("/foo"))), PermissionState::Granted); assert_eq!(perms2.read.query(None), PermissionState::Prompt); - assert_eq!(perms2.read.query(Some(&Path::new("/foo"))), PermissionState::Granted); - assert_eq!(perms2.read.query(Some(&Path::new("/foo/bar"))), PermissionState::Granted); + assert_eq!(perms2.read.query(Some(Path::new("/foo"))), PermissionState::Granted); + assert_eq!(perms2.read.query(Some(Path::new("/foo/bar"))), PermissionState::Granted); assert_eq!(perms1.write.query(None), PermissionState::Granted); - assert_eq!(perms1.write.query(Some(&Path::new("/foo"))), PermissionState::Granted); + assert_eq!(perms1.write.query(Some(Path::new("/foo"))), PermissionState::Granted); assert_eq!(perms2.write.query(None), PermissionState::Prompt); - assert_eq!(perms2.write.query(Some(&Path::new("/foo"))), PermissionState::Granted); - assert_eq!(perms2.write.query(Some(&Path::new("/foo/bar"))), PermissionState::Granted); + assert_eq!(perms2.write.query(Some(Path::new("/foo"))), PermissionState::Granted); + assert_eq!(perms2.write.query(Some(Path::new("/foo/bar"))), PermissionState::Granted); assert_eq!(perms1.net.query::<&str>(None), PermissionState::Granted); assert_eq!(perms1.net.query(Some(&("127.0.0.1", None))), PermissionState::Granted); assert_eq!(perms2.net.query::<&str>(None), PermissionState::Prompt); @@ -1504,13 +1504,13 @@ mod tests { { let _guard = PERMISSION_PROMPT_GUARD.lock(); set_prompt_result(true); - assert_eq!(perms.read.request(Some(&Path::new("/foo"))), PermissionState::Granted); + assert_eq!(perms.read.request(Some(Path::new("/foo"))), PermissionState::Granted); assert_eq!(perms.read.query(None), PermissionState::Prompt); set_prompt_result(false); - assert_eq!(perms.read.request(Some(&Path::new("/foo/bar"))), PermissionState::Granted); + assert_eq!(perms.read.request(Some(Path::new("/foo/bar"))), PermissionState::Granted); set_prompt_result(false); - assert_eq!(perms.write.request(Some(&Path::new("/foo"))), PermissionState::Denied); - assert_eq!(perms.write.query(Some(&Path::new("/foo/bar"))), PermissionState::Prompt); + assert_eq!(perms.write.request(Some(Path::new("/foo"))), PermissionState::Denied); + assert_eq!(perms.write.query(Some(Path::new("/foo/bar"))), PermissionState::Prompt); set_prompt_result(true); assert_eq!(perms.write.request(None), PermissionState::Denied); set_prompt_result(true); @@ -1572,12 +1572,12 @@ mod tests { }; #[rustfmt::skip] { - assert_eq!(perms.read.revoke(Some(&Path::new("/foo/bar"))), PermissionState::Granted); - assert_eq!(perms.read.revoke(Some(&Path::new("/foo"))), PermissionState::Prompt); - assert_eq!(perms.read.query(Some(&Path::new("/foo/bar"))), PermissionState::Prompt); - assert_eq!(perms.write.revoke(Some(&Path::new("/foo/bar"))), PermissionState::Granted); + assert_eq!(perms.read.revoke(Some(Path::new("/foo/bar"))), PermissionState::Granted); + assert_eq!(perms.read.revoke(Some(Path::new("/foo"))), PermissionState::Prompt); + assert_eq!(perms.read.query(Some(Path::new("/foo/bar"))), PermissionState::Prompt); + assert_eq!(perms.write.revoke(Some(Path::new("/foo/bar"))), PermissionState::Granted); assert_eq!(perms.write.revoke(None), PermissionState::Prompt); - assert_eq!(perms.write.query(Some(&Path::new("/foo/bar"))), PermissionState::Prompt); + assert_eq!(perms.write.query(Some(Path::new("/foo/bar"))), PermissionState::Prompt); assert_eq!(perms.net.revoke(Some(&("127.0.0.1", Some(8000)))), PermissionState::Granted); assert_eq!(perms.net.revoke(Some(&("127.0.0.1", None))), PermissionState::Prompt); assert_eq!(perms.env.revoke(Some(&"HOME".to_string())), PermissionState::Prompt); @@ -1602,16 +1602,16 @@ mod tests { let _guard = PERMISSION_PROMPT_GUARD.lock(); set_prompt_result(true); - assert!(perms.read.check(&Path::new("/foo")).is_ok()); + assert!(perms.read.check(Path::new("/foo")).is_ok()); set_prompt_result(false); - assert!(perms.read.check(&Path::new("/foo")).is_ok()); - assert!(perms.read.check(&Path::new("/bar")).is_err()); + assert!(perms.read.check(Path::new("/foo")).is_ok()); + assert!(perms.read.check(Path::new("/bar")).is_err()); set_prompt_result(true); - assert!(perms.write.check(&Path::new("/foo")).is_ok()); + assert!(perms.write.check(Path::new("/foo")).is_ok()); set_prompt_result(false); - assert!(perms.write.check(&Path::new("/foo")).is_ok()); - assert!(perms.write.check(&Path::new("/bar")).is_err()); + assert!(perms.write.check(Path::new("/foo")).is_ok()); + assert!(perms.write.check(Path::new("/bar")).is_err()); set_prompt_result(true); assert!(perms.net.check(&("127.0.0.1", Some(8000))).is_ok()); @@ -1655,20 +1655,20 @@ mod tests { let _guard = PERMISSION_PROMPT_GUARD.lock(); set_prompt_result(false); - assert!(perms.read.check(&Path::new("/foo")).is_err()); + assert!(perms.read.check(Path::new("/foo")).is_err()); set_prompt_result(true); - assert!(perms.read.check(&Path::new("/foo")).is_err()); - assert!(perms.read.check(&Path::new("/bar")).is_ok()); + assert!(perms.read.check(Path::new("/foo")).is_err()); + assert!(perms.read.check(Path::new("/bar")).is_ok()); set_prompt_result(false); - assert!(perms.read.check(&Path::new("/bar")).is_ok()); + assert!(perms.read.check(Path::new("/bar")).is_ok()); set_prompt_result(false); - assert!(perms.write.check(&Path::new("/foo")).is_err()); + assert!(perms.write.check(Path::new("/foo")).is_err()); set_prompt_result(true); - assert!(perms.write.check(&Path::new("/foo")).is_err()); - assert!(perms.write.check(&Path::new("/bar")).is_ok()); + assert!(perms.write.check(Path::new("/foo")).is_err()); + assert!(perms.write.check(Path::new("/bar")).is_ok()); set_prompt_result(false); - assert!(perms.write.check(&Path::new("/bar")).is_ok()); + assert!(perms.write.check(Path::new("/bar")).is_ok()); set_prompt_result(false); assert!(perms.net.check(&("127.0.0.1", Some(8000))).is_err());