From bb07e230d1270da2a7c35c5dc277ea6129a2214a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 9 Mar 2023 15:18:00 -0400 Subject: [PATCH] chore: update Rust to 1.68.0 (#18102) --- cli/args/mod.rs | 9 ++------- cli/napi/js_native_api.rs | 6 +++--- cli/node/mod.rs | 1 - cli/tools/test.rs | 1 - runtime/ops/os/mod.rs | 2 +- runtime/permissions/mod.rs | 11 ++++------- rust-toolchain.toml | 2 +- test_util/src/lib.rs | 7 ++----- 8 files changed, 13 insertions(+), 26 deletions(-) diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 5f151d9698..71cc4e2182 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -261,19 +261,14 @@ impl TestOptions { } } -#[derive(Clone, Debug)] +#[derive(Clone, Default, Debug)] pub enum LintReporterKind { + #[default] Pretty, Json, Compact, } -impl Default for LintReporterKind { - fn default() -> Self { - LintReporterKind::Pretty - } -} - #[derive(Clone, Debug, Default)] pub struct LintOptions { pub rules: LintRulesConfig, diff --git a/cli/napi/js_native_api.rs b/cli/napi/js_native_api.rs index e79307714d..ce598cc98d 100644 --- a/cli/napi/js_native_api.rs +++ b/cli/napi/js_native_api.rs @@ -2408,14 +2408,14 @@ fn napi_set_element( fn napi_set_instance_data( env: *mut Env, data: *mut c_void, - finalize_cb: napi_finalize, + finalize_cb: Option, finalize_hint: *mut c_void, ) -> Result { let env = &mut *(env as *mut Env); let shared = env.shared_mut(); shared.instance_data = data; - shared.data_finalize = if !(finalize_cb as *const c_void).is_null() { - Some(finalize_cb) + shared.data_finalize = if finalize_cb.is_some() { + finalize_cb } else { None }; diff --git a/cli/node/mod.rs b/cli/node/mod.rs index e45694fd69..8a2f988e1a 100644 --- a/cli/node/mod.rs +++ b/cli/node/mod.rs @@ -388,7 +388,6 @@ fn resolve_bin_entry_value<'a>( .as_object() .map(|o| { o.keys() - .into_iter() .map(|k| format!(" * npm:{pkg_nv}/{k}")) .collect::>() }) diff --git a/cli/tools/test.rs b/cli/tools/test.rs index 9ca806fb0b..1feb83ca31 100644 --- a/cli/tools/test.rs +++ b/cli/tools/test.rs @@ -672,7 +672,6 @@ fn abbreviate_test_error(js_error: &JsError) -> JsError { false } }) - .into_iter() .collect::>(); frames.reverse(); js_error.frames = frames; diff --git a/runtime/ops/os/mod.rs b/runtime/ops/os/mod.rs index 83ad8164fe..b2c67db5cd 100644 --- a/runtime/ops/os/mod.rs +++ b/runtime/ops/os/mod.rs @@ -326,7 +326,7 @@ fn rss() -> usize { } for n in chars { idx += 1; - if ('0'..='9').contains(&n) { + if n.is_ascii_digit() { out *= 10; out += n as usize - '0' as usize; } else { diff --git a/runtime/permissions/mod.rs b/runtime/permissions/mod.rs index a954387e5f..20978f3b20 100644 --- a/runtime/permissions/mod.rs +++ b/runtime/permissions/mod.rs @@ -38,9 +38,12 @@ static DEBUG_LOG_ENABLED: Lazy = Lazy::new(|| log::log_enabled!(log::Level::Debug)); /// Tri-state value for storing permission state -#[derive(Eq, PartialEq, Debug, Clone, Copy, Deserialize, PartialOrd)] +#[derive( + Eq, PartialEq, Default, Debug, Clone, Copy, Deserialize, PartialOrd, +)] pub enum PermissionState { Granted = 0, + #[default] Prompt = 1, Denied = 2, } @@ -140,12 +143,6 @@ impl fmt::Display for PermissionState { } } -impl Default for PermissionState { - fn default() -> Self { - PermissionState::Prompt - } -} - #[derive(Clone, Debug, Eq, PartialEq)] pub struct UnitPermission { pub name: &'static str, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b42ddcf07f..b2cf8c5f28 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.67.0" +channel = "1.68.0" components = ["rustfmt", "clippy"] diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index 2a22afb4b9..3fdc4db93a 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -344,16 +344,13 @@ async fn run_ws_close_server(addr: &SocketAddr) { } } +#[derive(Default)] enum SupportedHttpVersions { + #[default] All, Http1Only, Http2Only, } -impl Default for SupportedHttpVersions { - fn default() -> SupportedHttpVersions { - SupportedHttpVersions::All - } -} async fn get_tls_config( cert: &str,