From ec2c30e4c91b4585e319b2734940bb8ab785db61 Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Mon, 29 Jul 2024 22:28:04 +0530 Subject: [PATCH] chore: upgrade to rust 1.80 (#24778) (cherry picked from commit 8c2f1f5a55a2a9bb9e04c12236faa341b3fd49b6) --- cli/errors.rs | 15 +-------------- cli/lsp/tsc.rs | 2 ++ cli/npm/managed/resolvers/local.rs | 2 +- cli/tools/test/mod.rs | 2 +- cli/util/file_watcher.rs | 8 ++++---- ext/fetch/proxy.rs | 4 ++-- ext/ffi/Cargo.toml | 3 +++ ext/webgpu/Cargo.toml | 4 ++++ runtime/Cargo.toml | 3 +++ runtime/ops/http.rs | 10 ---------- runtime/web_worker.rs | 2 +- runtime/worker.rs | 2 +- rust-toolchain.toml | 2 +- tests/Cargo.toml | 1 + tests/integration/run_tests.rs | 12 ++++++------ tests/util/server/src/servers/jsr_registry.rs | 2 +- tests/util/server/src/servers/mod.rs | 2 +- tests/util/server/src/servers/npm_registry.rs | 2 +- 18 files changed, 34 insertions(+), 44 deletions(-) diff --git a/cli/errors.rs b/cli/errors.rs index 9fe433f18d..a8fde6e769 100644 --- a/cli/errors.rs +++ b/cli/errors.rs @@ -17,7 +17,6 @@ use deno_graph::ModuleGraphError; use deno_graph::ModuleLoadError; use deno_graph::ResolutionError; use import_map::ImportMapError; -use std::fmt::Write; fn get_import_map_error_class(_: &ImportMapError) -> &'static str { "URIError" @@ -112,17 +111,5 @@ pub fn get_error_class_name(e: &AnyError) -> &'static str { e.downcast_ref::() .map(get_resolution_error_class) }) - .unwrap_or_else(|| { - if cfg!(debug) { - log::warn!( - "Error '{}' contains boxed error of unknown type:{}", - e, - e.chain().fold(String::new(), |mut output, e| { - let _ = write!(output, "\n {e:?}"); - output - }) - ); - } - "Error" - }) + .unwrap_or("Error") } diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 4592edad40..7dfb68f530 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -215,6 +215,8 @@ pub enum SemicolonPreference { Remove, } +// Allow due to false positive https://github.com/rust-lang/rust-clippy/issues/13170 +#[allow(clippy::needless_borrows_for_generic_args)] fn normalize_diagnostic( diagnostic: &mut crate::tsc::Diagnostic, specifier_map: &TscSpecifierMap, diff --git a/cli/npm/managed/resolvers/local.rs b/cli/npm/managed/resolvers/local.rs index b741fd15da..7687e23f88 100644 --- a/cli/npm/managed/resolvers/local.rs +++ b/cli/npm/managed/resolvers/local.rs @@ -1048,7 +1048,7 @@ fn junction_or_symlink_dir( match junction::create(old_path, new_path) { Ok(()) => Ok(()), Err(junction_err) => { - if cfg!(debug) { + if cfg!(debug_assertions) { // When running the tests, junctions should be created, but if not then // surface this error. log::warn!("Error creating junction. {:#}", junction_err); diff --git a/cli/tools/test/mod.rs b/cli/tools/test/mod.rs index 904b9ecb7b..4fbd0423e8 100644 --- a/cli/tools/test/mod.rs +++ b/cli/tools/test/mod.rs @@ -1653,7 +1653,7 @@ fn is_supported_test_ext(path: &Path) -> bool { /// input order. /// /// - Specifiers matching the `is_supported_test_ext` predicate are marked as -/// `TestMode::Documentation`. +/// `TestMode::Documentation`. /// - Specifiers matching the `is_supported_test_path` are marked as `TestMode::Executable`. /// - Specifiers matching both predicates are marked as `TestMode::Both` fn collect_specifiers_with_test_mode( diff --git a/cli/util/file_watcher.rs b/cli/util/file_watcher.rs index 51dde8404f..d92d880bc1 100644 --- a/cli/util/file_watcher.rs +++ b/cli/util/file_watcher.rs @@ -195,8 +195,8 @@ impl WatcherCommunicator { /// Creates a file watcher. /// /// - `operation` is the actual operation we want to run every time the watcher detects file -/// changes. For example, in the case where we would like to bundle, then `operation` would -/// have the logic for it like bundling the code. +/// changes. For example, in the case where we would like to bundle, then `operation` would +/// have the logic for it like bundling the code. pub async fn watch_func( flags: Arc, print_config: PrintConfig, @@ -234,8 +234,8 @@ pub enum WatcherRestartMode { /// Creates a file watcher. /// /// - `operation` is the actual operation we want to run every time the watcher detects file -/// changes. For example, in the case where we would like to bundle, then `operation` would -/// have the logic for it like bundling the code. +/// changes. For example, in the case where we would like to bundle, then `operation` would +/// have the logic for it like bundling the code. pub async fn watch_recv( mut flags: Arc, print_config: PrintConfig, diff --git a/ext/fetch/proxy.rs b/ext/fetch/proxy.rs index bbb40e2f1d..f23df5dd0a 100644 --- a/ext/fetch/proxy.rs +++ b/ext/fetch/proxy.rs @@ -269,10 +269,10 @@ impl NoProxy { /// * If neither environment variable is set, `None` is returned /// * Entries are expected to be comma-separated (whitespace between entries is ignored) /// * IP addresses (both IPv4 and IPv6) are allowed, as are optional subnet masks (by adding /size, - /// for example "`192.168.1.0/24`"). + /// for example "`192.168.1.0/24`"). /// * An entry "`*`" matches all hostnames (this is the only wildcard allowed) /// * Any other entry is considered a domain name (and may contain a leading dot, for example `google.com` - /// and `.google.com` are equivalent) and would match both that domain AND all subdomains. + /// and `.google.com` are equivalent) and would match both that domain AND all subdomains. /// /// For example, if `"NO_PROXY=google.com, 192.168.1.0/24"` was set, all of the following would match /// (and therefore would bypass the proxy): diff --git a/ext/ffi/Cargo.toml b/ext/ffi/Cargo.toml index 5220c4fdba..961c96b01e 100644 --- a/ext/ffi/Cargo.toml +++ b/ext/ffi/Cargo.toml @@ -27,3 +27,6 @@ serde_json = "1.0" [target.'cfg(windows)'.dependencies] winapi = { workspace = true, features = ["errhandlingapi", "minwindef", "ntdef", "winbase", "winnt"] } + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_aarch, values("x86_64", "aarch64"))'] } diff --git a/ext/webgpu/Cargo.toml b/ext/webgpu/Cargo.toml index 47b2a31724..00e265f099 100644 --- a/ext/webgpu/Cargo.toml +++ b/ext/webgpu/Cargo.toml @@ -13,6 +13,10 @@ description = "WebGPU implementation for Deno" [lib] path = "lib.rs" +[features] +angle = [] +vulkan-portability = [] + # We make all dependencies conditional on not being wasm, # so the whole workspace can built as wasm. [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 35b1606365..72ffa3eaeb 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -28,6 +28,9 @@ hmr = ["include_js_files_for_snapshotting"] # assertion that a snapshot is provided. only_snapshotted_js_sources = ["include_js_files_for_snapshotting"] +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tokio_unstable)'] } + [lib] name = "deno_runtime" path = "lib.rs" diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs index ca51b001dc..cde2d5858a 100644 --- a/runtime/ops/http.rs +++ b/runtime/ops/http.rs @@ -8,11 +8,9 @@ use deno_core::error::AnyError; use deno_core::op2; use deno_core::OpState; use deno_core::ResourceId; -use deno_core::ToJsBuffer; use deno_http::http_create_conn_resource; use deno_net::io::TcpStreamResource; use deno_net::ops_tls::TlsStreamResource; -use serde::Serialize; pub const UNSTABLE_FEATURE_NAME: &str = "http"; @@ -74,11 +72,3 @@ fn op_http_start( Err(bad_resource_id()) } - -#[derive(Serialize)] -#[serde(rename_all = "camelCase")] -pub struct HttpUpgradeResult { - conn_rid: ResourceId, - conn_type: &'static str, - read_buf: ToJsBuffer, -} diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index 2611b6f345..ed1e19c9ec 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -514,7 +514,7 @@ impl WebWorker { ops::web_worker::deno_web_worker::init_ops_and_esm(), ]; - #[cfg(hmr)] + #[cfg(feature = "hmr")] assert!( cfg!(not(feature = "only_snapshotted_js_sources")), "'hmr' is incompatible with 'only_snapshotted_js_sources'." diff --git a/runtime/worker.rs b/runtime/worker.rs index bd67c87067..696786b564 100644 --- a/runtime/worker.rs +++ b/runtime/worker.rs @@ -448,7 +448,7 @@ impl MainWorker { ops::web_worker::deno_web_worker::init_ops_and_esm().disable(), ]; - #[cfg(hmr)] + #[cfg(feature = "hmr")] assert!( cfg!(not(feature = "only_snapshotted_js_sources")), "'hmr' is incompatible with 'only_snapshotted_js_sources'." diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 874939176e..85cb9e7bb5 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.79.0" +channel = "1.80.0" components = ["rustfmt", "clippy"] diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 34cffbb406..daef13dc7d 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -14,6 +14,7 @@ path = "lib.rs" [features] run = [] +upgrade = [] [[test]] name = "integration_tests" diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index 7a6ee61cf1..9252de2e7e 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -2621,7 +2621,7 @@ mod permissions { fn with_allow() { for permission in &util::PERMISSION_VARIANTS { let status = util::deno_cmd() - .current_dir(&util::testdata_path()) + .current_dir(util::testdata_path()) .arg("run") .arg("--unstable") .arg(format!("--allow-{permission}")) @@ -2655,7 +2655,7 @@ mod permissions { const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"]; for permission in &PERMISSION_VARIANTS { let status = util::deno_cmd() - .current_dir(&util::testdata_path()) + .current_dir(util::testdata_path()) .arg("run") .arg(format!( "--allow-{0}={1}", @@ -2698,7 +2698,7 @@ mod permissions { const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"]; for permission in &PERMISSION_VARIANTS { let status = util::deno_cmd() - .current_dir(&util::testdata_path()) + .current_dir(util::testdata_path()) .arg("run") .arg(format!( "--allow-{0}={1}", @@ -2746,7 +2746,7 @@ mod permissions { let js_dir = util::root_path().join("js"); for permission in &PERMISSION_VARIANTS { let status = util::deno_cmd() - .current_dir(&util::testdata_path()) + .current_dir(util::testdata_path()) .arg("run") .arg(format!("--allow-{permission}={test_dir},{js_dir}")) .arg("run/complex_permissions_test.ts") @@ -2765,7 +2765,7 @@ mod permissions { const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"]; for permission in &PERMISSION_VARIANTS { let status = util::deno_cmd() - .current_dir(&util::testdata_path()) + .current_dir(util::testdata_path()) .arg("run") .arg(format!("--allow-{permission}=.")) .arg("run/complex_permissions_test.ts") @@ -2784,7 +2784,7 @@ mod permissions { const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"]; for permission in &PERMISSION_VARIANTS { let status = util::deno_cmd() - .current_dir(&util::testdata_path()) + .current_dir(util::testdata_path()) .arg("run") .arg(format!("--allow-{permission}=tls/../")) .arg("run/complex_permissions_test.ts") diff --git a/tests/util/server/src/servers/jsr_registry.rs b/tests/util/server/src/servers/jsr_registry.rs index affd2c30e4..8970750a28 100644 --- a/tests/util/server/src/servers/jsr_registry.rs +++ b/tests/util/server/src/servers/jsr_registry.rs @@ -153,7 +153,7 @@ async fn registry_server_handler( // serve the registry package files let mut file_path = tests_path().join("registry").join("jsr").to_path_buf(); file_path.push( - &req.uri().path()[1..] + req.uri().path()[1..] .replace("%2f", "/") .replace("%2F", "/"), ); diff --git a/tests/util/server/src/servers/mod.rs b/tests/util/server/src/servers/mod.rs index 1b6e2f71df..3e18aafce4 100644 --- a/tests/util/server/src/servers/mod.rs +++ b/tests/util/server/src/servers/mod.rs @@ -1135,7 +1135,7 @@ async fn main_server( _ => { let uri_path = req.uri().path(); let mut file_path = testdata_path().to_path_buf(); - file_path.push(&uri_path[1..].replace("%2f", "/")); + file_path.push(uri_path[1..].replace("%2f", "/")); if let Ok(file) = tokio::fs::read(&file_path).await { let file_resp = custom_headers(uri_path, file); return Ok(file_resp); diff --git a/tests/util/server/src/servers/npm_registry.rs b/tests/util/server/src/servers/npm_registry.rs index f19fa5d923..acbd9cab48 100644 --- a/tests/util/server/src/servers/npm_registry.rs +++ b/tests/util/server/src/servers/npm_registry.rs @@ -150,7 +150,7 @@ async fn handle_req_for_registry( // serve the registry package files let uri_path = req.uri().path(); let mut file_path = root_dir.to_path_buf(); - file_path.push(&uri_path[1..].replace("%2f", "/").replace("%2F", "/")); + file_path.push(uri_path[1..].replace("%2f", "/").replace("%2F", "/")); // serve if the filepath exists if let Ok(file) = tokio::fs::read(&file_path).await {