diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index d79bb4368e..e486eda886 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -476,7 +476,8 @@ impl FileFetcher { let Ok(cache_key) = self.http_cache.cache_item_key(specifier) else { return false; }; - let Ok(Some(metadata)) = self.http_cache.read_metadata(&cache_key) else { + let Ok(Some(metadata)) = self.http_cache.read_metadata(&cache_key) + else { return false; }; let cache_semantics = CacheSemantics::new( diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index c29817919a..c7c6a40e3d 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -1872,7 +1872,7 @@ impl Inner { } _ => false, }, - "deno-lint" => matches!(&d.code, Some(_)), + "deno-lint" => d.code.is_some(), "deno" => diagnostics::DenoDiagnostic::is_fixable(d), _ => false, }, diff --git a/cli/napi/js_native_api.rs b/cli/napi/js_native_api.rs index cb31d8c639..7c9b3d4c7c 100644 --- a/cli/napi/js_native_api.rs +++ b/cli/napi/js_native_api.rs @@ -308,10 +308,9 @@ fn napi_coerce_to_number( check_env!(env); let env = unsafe { &mut *env }; let value = napi_value_unchecked(value); - let Some(coerced) = value - .to_number(&mut env.scope()) else { - return napi_number_expected; - }; + let Some(coerced) = value.to_number(&mut env.scope()) else { + return napi_number_expected; + }; let value: v8::Local = coerced.into(); *result = value.into(); napi_ok @@ -1352,10 +1351,9 @@ fn napi_call_function( #[napi_sym::napi_sym] fn napi_close_escapable_handle_scope( - env: *mut Env, + _env: *mut Env, _scope: napi_escapable_handle_scope, ) -> napi_status { - let mut _env = &mut *(env as *mut Env); // TODO: do this properly napi_ok } @@ -1365,7 +1363,7 @@ fn napi_close_handle_scope( env: *mut Env, scope: napi_handle_scope, ) -> napi_status { - let env = &mut *(env as *mut Env); + let env = &mut *env; if env.open_handle_scopes == 0 { return napi_handle_scope_mismatch; } @@ -1497,7 +1495,7 @@ fn napi_define_class( env_ptr, *result, static_descriptors.len(), - static_descriptors.as_ptr() as *const napi_property_descriptor, + static_descriptors.as_ptr(), )); } @@ -1519,7 +1517,8 @@ fn napi_define_properties( let scope = &mut env.scope(); - let Ok(object) = v8::Local::::try_from(napi_value_unchecked(obj)) else { + let Ok(object) = v8::Local::::try_from(napi_value_unchecked(obj)) + else { return napi_object_expected; }; @@ -1614,11 +1613,9 @@ fn napi_delete_property( check_arg!(env, result); let scope = &mut env.scope(); - let Some(object) = object - .map(|o| o.to_object(scope)) - .flatten() else { - return napi_invalid_arg; - }; + let Some(object) = object.map(|o| o.to_object(scope)).flatten() else { + return napi_invalid_arg; + }; let Some(deleted) = object.delete(scope, key.unwrap_unchecked()) else { return napi_generic_failure; @@ -1630,8 +1627,7 @@ fn napi_delete_property( // TODO: properly implement ref counting stuff #[napi_sym::napi_sym] -fn napi_delete_reference(env: *mut Env, _nref: napi_ref) -> napi_status { - let mut _env = &mut *(env as *mut Env); +fn napi_delete_reference(_env: *mut Env, _nref: napi_ref) -> napi_status { napi_ok } @@ -1869,7 +1865,7 @@ fn napi_get_instance_data( env: *mut Env, result: *mut *mut c_void, ) -> napi_status { - let env = &mut *(env as *mut Env); + let env = &mut *env; let shared = env.shared(); *result = shared.instance_data; napi_ok @@ -2118,11 +2114,9 @@ fn napi_has_own_property( check_arg!(env, result); let scope = &mut env.scope(); - let Some(object) = object - .map(|o| o.to_object(scope)) - .flatten() else { - return napi_invalid_arg; - }; + let Some(object) = object.map(|o| o.to_object(scope)).flatten() else { + return napi_invalid_arg; + }; if key.is_none() { return napi_invalid_arg; @@ -2131,7 +2125,7 @@ fn napi_has_own_property( return napi_name_expected; }; - let Some(has_own) = object.has_own_property(scope, key) else { + let Some(has_own) = object.has_own_property(scope, key) else { return napi_generic_failure; }; @@ -2153,11 +2147,9 @@ fn napi_has_property( check_arg!(env, result); let scope = &mut env.scope(); - let Some(object) = object - .map(|o| o.to_object(scope)) - .flatten() else { - return napi_invalid_arg; - }; + let Some(object) = object.map(|o| o.to_object(scope)).flatten() else { + return napi_invalid_arg; + }; let Some(has) = object.has(scope, key.unwrap_unchecked()) else { return napi_generic_failure; @@ -2180,10 +2172,9 @@ fn napi_instanceof( let value = napi_value_unchecked(value); let constructor = napi_value_unchecked(constructor); - let Some(ctor) = constructor - .to_object(&mut env.scope()) else { - return napi_object_expected; - }; + let Some(ctor) = constructor.to_object(&mut env.scope()) else { + return napi_object_expected; + }; if !ctor.is_function() { return napi_function_expected; } @@ -2294,8 +2285,7 @@ fn napi_is_error( } #[napi_sym::napi_sym] -fn napi_is_exception_pending(env: *mut Env, result: *mut bool) -> napi_status { - let mut _env = &mut *(env as *mut Env); +fn napi_is_exception_pending(_env: *mut Env, result: *mut bool) -> napi_status { // TODO *result = false; napi_ok @@ -2389,7 +2379,7 @@ fn napi_open_handle_scope( env: *mut Env, _result: *mut napi_handle_scope, ) -> napi_status { - let env = &mut *(env as *mut Env); + let env = &mut *env; // *result = &mut env.scope() as *mut _ as napi_handle_scope; env.open_handle_scopes += 1; @@ -2525,7 +2515,7 @@ fn napi_set_instance_data( finalize_cb: Option, finalize_hint: *mut c_void, ) -> napi_status { - let env = &mut *(env as *mut Env); + let env = &mut *env; let shared = env.shared_mut(); shared.instance_data = data; shared.data_finalize = if finalize_cb.is_some() { @@ -2567,11 +2557,9 @@ fn napi_set_property( check_arg_option!(env, value); let scope = &mut env.scope(); - let Some(object) = object - .map(|o| o.to_object(scope)) - .flatten() else { - return napi_invalid_arg - }; + let Some(object) = object.map(|o| o.to_object(scope)).flatten() else { + return napi_invalid_arg; + }; if object .set(scope, key.unwrap_unchecked(), value.unwrap_unchecked()) @@ -2759,10 +2747,9 @@ fn napi_unwrap( let shared = &*(env.shared as *const EnvShared); let napi_wrap = v8::Local::new(&mut env.scope(), &shared.napi_wrap); let ext = obj.get_private(&mut env.scope(), napi_wrap).unwrap(); - let Some(ext) = v8::Local::::try_from(ext) - .ok() else { - return napi_invalid_arg; - }; + let Some(ext) = v8::Local::::try_from(ext).ok() else { + return napi_invalid_arg; + }; *result = ext.value(); napi_ok } diff --git a/cli/npm/resolvers/global.rs b/cli/npm/resolvers/global.rs index 1181403b2e..e1144f6102 100644 --- a/cli/npm/resolvers/global.rs +++ b/cli/npm/resolvers/global.rs @@ -100,9 +100,10 @@ impl NpmPackageFsResolver for GlobalNpmPackageResolver { ) -> Result { let Some(referrer_pkg_id) = self .cache - .resolve_package_folder_id_from_specifier(referrer, &self.registry_url) else { - bail!("could not find npm package for '{}'", referrer); - }; + .resolve_package_folder_id_from_specifier(referrer, &self.registry_url) + else { + bail!("could not find npm package for '{}'", referrer); + }; let pkg = if mode.is_types() && !name.starts_with("@types/") { // attempt to resolve the types package first, then fallback to the regular package match self.resolve_types_package(name, &referrer_pkg_id) { @@ -123,10 +124,10 @@ impl NpmPackageFsResolver for GlobalNpmPackageResolver { &self, specifier: &ModuleSpecifier, ) -> Result, AnyError> { - let Some(pkg_folder_id) = self.cache.resolve_package_folder_id_from_specifier( - specifier, - &self.registry_url, - ) else { + let Some(pkg_folder_id) = self + .cache + .resolve_package_folder_id_from_specifier(specifier, &self.registry_url) + else { return Ok(None); }; Ok(Some( diff --git a/cli/npm/resolvers/local.rs b/cli/npm/resolvers/local.rs index 74b7973090..f8d7c2848b 100644 --- a/cli/npm/resolvers/local.rs +++ b/cli/npm/resolvers/local.rs @@ -110,7 +110,9 @@ impl LocalNpmPackageResolver { &self, specifier: &ModuleSpecifier, ) -> Result, AnyError> { - let Some(relative_url) = self.root_node_modules_url.make_relative(specifier) else { + let Some(relative_url) = + self.root_node_modules_url.make_relative(specifier) + else { return Ok(None); }; if relative_url.starts_with("../") { @@ -230,7 +232,9 @@ impl NpmPackageFsResolver for LocalNpmPackageResolver { &self, specifier: &ModuleSpecifier, ) -> Result, AnyError> { - let Some(folder_path) = self.resolve_package_folder_from_specifier(specifier)? else { + let Some(folder_path) = + self.resolve_package_folder_from_specifier(specifier)? + else { return Ok(None); }; let folder_name = folder_path.parent().unwrap().to_string_lossy(); diff --git a/cli/npm/resolvers/mod.rs b/cli/npm/resolvers/mod.rs index 58a70dff07..9f714256d0 100644 --- a/cli/npm/resolvers/mod.rs +++ b/cli/npm/resolvers/mod.rs @@ -135,9 +135,10 @@ impl CliNpmResolver { ) -> Result, AnyError> { let Some(path) = self .fs_resolver - .resolve_package_folder_from_specifier(specifier)? else { - return Ok(None); - }; + .resolve_package_folder_from_specifier(specifier)? + else { + return Ok(None); + }; log::debug!( "Resolved package folder of {} to {}", specifier, @@ -153,9 +154,10 @@ impl CliNpmResolver { ) -> Result, AnyError> { let Some(cache_folder_id) = self .fs_resolver - .resolve_package_cache_folder_id_from_specifier(specifier)? else { - return Ok(None); - }; + .resolve_package_cache_folder_id_from_specifier(specifier)? + else { + return Ok(None); + }; Ok(Some( self .resolution diff --git a/cli/standalone/mod.rs b/cli/standalone/mod.rs index f6c489487d..d7547f847a 100644 --- a/cli/standalone/mod.rs +++ b/cli/standalone/mod.rs @@ -183,10 +183,12 @@ impl ModuleLoader for EmbeddedModuleLoader { }; } - let Some(module) = self.shared.eszip.get_module(original_specifier.as_str()) else { + let Some(module) = + self.shared.eszip.get_module(original_specifier.as_str()) + else { return Box::pin(deno_core::futures::future::ready(Err(type_error( format!("Module not found: {}", original_specifier), - )))) + )))); }; let original_specifier = original_specifier.clone(); let found_specifier = diff --git a/cli/tests/integration/fmt_tests.rs b/cli/tests/integration/fmt_tests.rs index ef0ad3f3e2..dd9e503570 100644 --- a/cli/tests/integration/fmt_tests.rs +++ b/cli/tests/integration/fmt_tests.rs @@ -266,15 +266,15 @@ fn fmt_with_glob_config() { let output = cmd_output.combined_output(); if cfg!(windows) { - assert_contains!(output, r#"glob\nested\fizz\fizz.ts"#); - assert_contains!(output, r#"glob\pages\[id].ts"#); - assert_contains!(output, r#"glob\nested\fizz\bar.ts"#); - assert_contains!(output, r#"glob\nested\foo\foo.ts"#); - assert_contains!(output, r#"glob\data\test1.js"#); - assert_contains!(output, r#"glob\nested\foo\bar.ts"#); - assert_contains!(output, r#"glob\nested\foo\fizz.ts"#); - assert_contains!(output, r#"glob\nested\fizz\foo.ts"#); - assert_contains!(output, r#"glob\data\test1.ts"#); + assert_contains!(output, r"glob\nested\fizz\fizz.ts"); + assert_contains!(output, r"glob\pages\[id].ts"); + assert_contains!(output, r"glob\nested\fizz\bar.ts"); + assert_contains!(output, r"glob\nested\foo\foo.ts"); + assert_contains!(output, r"glob\data\test1.js"); + assert_contains!(output, r"glob\nested\foo\bar.ts"); + assert_contains!(output, r"glob\nested\foo\fizz.ts"); + assert_contains!(output, r"glob\nested\fizz\foo.ts"); + assert_contains!(output, r"glob\data\test1.ts"); } else { assert_contains!(output, "glob/nested/fizz/fizz.ts"); assert_contains!(output, "glob/pages/[id].ts"); @@ -303,15 +303,15 @@ fn fmt_with_glob_config_and_flags() { let output = cmd_output.combined_output(); if cfg!(windows) { - assert_contains!(output, r#"glob\nested\fizz\fizz.ts"#); - assert_contains!(output, r#"glob\pages\[id].ts"#); - assert_contains!(output, r#"glob\nested\fizz\bazz.ts"#); - assert_contains!(output, r#"glob\nested\foo\foo.ts"#); - assert_contains!(output, r#"glob\data\test1.js"#); - assert_contains!(output, r#"glob\nested\foo\bazz.ts"#); - assert_contains!(output, r#"glob\nested\foo\fizz.ts"#); - assert_contains!(output, r#"glob\nested\fizz\foo.ts"#); - assert_contains!(output, r#"glob\data\test1.ts"#); + assert_contains!(output, r"glob\nested\fizz\fizz.ts"); + assert_contains!(output, r"glob\pages\[id].ts"); + assert_contains!(output, r"glob\nested\fizz\bazz.ts"); + assert_contains!(output, r"glob\nested\foo\foo.ts"); + assert_contains!(output, r"glob\data\test1.js"); + assert_contains!(output, r"glob\nested\foo\bazz.ts"); + assert_contains!(output, r"glob\nested\foo\fizz.ts"); + assert_contains!(output, r"glob\nested\fizz\foo.ts"); + assert_contains!(output, r"glob\data\test1.ts"); } else { assert_contains!(output, "glob/nested/fizz/fizz.ts"); assert_contains!(output, "glob/pages/[id].ts"); @@ -333,8 +333,8 @@ fn fmt_with_glob_config_and_flags() { let output = cmd_output.combined_output(); if cfg!(windows) { - assert_contains!(output, r#"glob\data\test1.js"#); - assert_contains!(output, r#"glob\data\test1.ts"#); + assert_contains!(output, r"glob\data\test1.js"); + assert_contains!(output, r"glob\data\test1.ts"); } else { assert_contains!(output, "glob/data/test1.js"); assert_contains!(output, "glob/data/test1.ts"); diff --git a/cli/tests/integration/lint_tests.rs b/cli/tests/integration/lint_tests.rs index 6fef3c000e..d4bf175fc6 100644 --- a/cli/tests/integration/lint_tests.rs +++ b/cli/tests/integration/lint_tests.rs @@ -131,15 +131,15 @@ fn lint_with_glob_config() { let output = cmd_output.combined_output(); if cfg!(windows) { - assert_contains!(output, r#"glob\nested\fizz\fizz.ts:1:10"#); - assert_contains!(output, r#"glob\pages\[id].ts:1:10"#); - assert_contains!(output, r#"glob\nested\fizz\bar.ts:1:10"#); - assert_contains!(output, r#"glob\nested\foo\foo.ts:1:10"#); - assert_contains!(output, r#"glob\data\test1.js:1:10"#); - assert_contains!(output, r#"glob\nested\foo\bar.ts:1:10"#); - assert_contains!(output, r#"glob\nested\foo\fizz.ts:1:10"#); - assert_contains!(output, r#"glob\nested\fizz\foo.ts:1:10"#); - assert_contains!(output, r#"glob\data\test1.ts:1:10"#); + assert_contains!(output, r"glob\nested\fizz\fizz.ts:1:10"); + assert_contains!(output, r"glob\pages\[id].ts:1:10"); + assert_contains!(output, r"glob\nested\fizz\bar.ts:1:10"); + assert_contains!(output, r"glob\nested\foo\foo.ts:1:10"); + assert_contains!(output, r"glob\data\test1.js:1:10"); + assert_contains!(output, r"glob\nested\foo\bar.ts:1:10"); + assert_contains!(output, r"glob\nested\foo\fizz.ts:1:10"); + assert_contains!(output, r"glob\nested\fizz\foo.ts:1:10"); + assert_contains!(output, r"glob\data\test1.ts:1:10"); } else { assert_contains!(output, "glob/nested/fizz/fizz.ts:1:10"); assert_contains!(output, "glob/pages/[id].ts:1:10"); @@ -168,15 +168,15 @@ fn lint_with_glob_config_and_flags() { let output = cmd_output.combined_output(); if cfg!(windows) { - assert_contains!(output, r#"glob\nested\fizz\fizz.ts:1:10"#); - assert_contains!(output, r#"glob\pages\[id].ts:1:10"#); - assert_contains!(output, r#"glob\nested\fizz\bazz.ts:1:10"#); - assert_contains!(output, r#"glob\nested\foo\foo.ts:1:10"#); - assert_contains!(output, r#"glob\data\test1.js:1:10"#); - assert_contains!(output, r#"glob\nested\foo\bazz.ts:1:10"#); - assert_contains!(output, r#"glob\nested\foo\fizz.ts:1:10"#); - assert_contains!(output, r#"glob\nested\fizz\foo.ts:1:10"#); - assert_contains!(output, r#"glob\data\test1.ts:1:10"#); + assert_contains!(output, r"glob\nested\fizz\fizz.ts:1:10"); + assert_contains!(output, r"glob\pages\[id].ts:1:10"); + assert_contains!(output, r"glob\nested\fizz\bazz.ts:1:10"); + assert_contains!(output, r"glob\nested\foo\foo.ts:1:10"); + assert_contains!(output, r"glob\data\test1.js:1:10"); + assert_contains!(output, r"glob\nested\foo\bazz.ts:1:10"); + assert_contains!(output, r"glob\nested\foo\fizz.ts:1:10"); + assert_contains!(output, r"glob\nested\fizz\foo.ts:1:10"); + assert_contains!(output, r"glob\data\test1.ts:1:10"); } else { assert_contains!(output, "glob/nested/fizz/fizz.ts:1:10"); assert_contains!(output, "glob/pages/[id].ts:1:10"); @@ -200,8 +200,8 @@ fn lint_with_glob_config_and_flags() { let output = cmd_output.combined_output(); if cfg!(windows) { - assert_contains!(output, r#"glob\data\test1.js:1:10"#); - assert_contains!(output, r#"glob\data\test1.ts:1:10"#); + assert_contains!(output, r"glob\data\test1.js:1:10"); + assert_contains!(output, r"glob\data\test1.ts:1:10"); } else { assert_contains!(output, "glob/data/test1.js:1:10"); assert_contains!(output, "glob/data/test1.ts:1:10"); diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index d127ed31c6..665fa62758 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -3685,7 +3685,7 @@ fn lsp_find_references() { "uri": "file:///a/mod.ts", "languageId": "typescript", "version": 1, - "text": r#"export const a = 1;\nconst b = 2;"# + "text": r"export const a = 1;\nconst b = 2;" } })); client.did_open(json!({ diff --git a/cli/tests/integration/repl_tests.rs b/cli/tests/integration/repl_tests.rs index 9f37679ef1..5335cf964b 100644 --- a/cli/tests/integration/repl_tests.rs +++ b/cli/tests/integration/repl_tests.rs @@ -242,7 +242,7 @@ fn pty_internal_repl() { fn pty_emoji() { // windows was having issues displaying this util::with_pty(&["repl"], |mut console| { - console.write_line(r#"console.log('\u{1F995}');"#); + console.write_line(r"console.log('\u{1F995}');"); console.expect("🦕"); }); } diff --git a/cli/tools/coverage/merge.rs b/cli/tools/coverage/merge.rs index 21ef29de9b..0a436acfb8 100644 --- a/cli/tools/coverage/merge.rs +++ b/cli/tools/coverage/merge.rs @@ -229,7 +229,7 @@ impl<'a> Iterator for StartEventQueue<'a> { let mut result = self.queue.next().unwrap(); if pending_offset == queue_offset { let pending_trees = self.pending.take().unwrap().trees; - result.trees.extend(pending_trees.into_iter()) + result.trees.extend(pending_trees) } Some(result) } @@ -338,7 +338,7 @@ fn merge_range_tree_children<'a>( let child_forests: Vec>> = flat_children .into_iter() - .zip(wrapped_children.into_iter()) + .zip(wrapped_children) .map(|(flat, wrapped)| merge_children_lists(flat, wrapped)) .collect(); diff --git a/cli/util/v8.rs b/cli/util/v8.rs index 93a2ef83f7..af310608a9 100644 --- a/cli/util/v8.rs +++ b/cli/util/v8.rs @@ -16,7 +16,7 @@ pub fn construct_v8_flags( ) -> Vec { std::iter::once("UNUSED_BUT_NECESSARY_ARG0".to_owned()) .chain(default_v8_flags.iter().cloned()) - .chain(env_v8_flags.into_iter()) + .chain(env_v8_flags) .chain(v8_flags.iter().cloned()) .collect::>() } diff --git a/cli/worker.rs b/cli/worker.rs index 1d9252e65c..ef321ff883 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -507,11 +507,13 @@ impl CliMainWorkerFactory { return Ok(None); } - let Some(resolution) = self.shared.node_resolver.resolve_npm_req_reference( - package_ref, - NodeResolutionMode::Execution, - permissions, - )? else { + let Some(resolution) = + self.shared.node_resolver.resolve_npm_req_reference( + package_ref, + NodeResolutionMode::Execution, + permissions, + )? + else { return Ok(None); }; match &resolution { diff --git a/ext/ffi/dlfcn.rs b/ext/ffi/dlfcn.rs index ced64bec53..a10bbbe293 100644 --- a/ext/ffi/dlfcn.rs +++ b/ext/ffi/dlfcn.rs @@ -377,7 +377,7 @@ pub(crate) fn format_error(e: dlopen::Error, path: String) -> String { let path = OsStr::new(&path) .encode_wide() - .chain(Some(0).into_iter()) + .chain(Some(0)) .collect::>(); let arguments = [path.as_ptr()]; diff --git a/ext/ffi/static.rs b/ext/ffi/static.rs index ae095d5fc3..8a6c147d05 100644 --- a/ext/ffi/static.rs +++ b/ext/ffi/static.rs @@ -10,7 +10,6 @@ use deno_core::op; use deno_core::serde_v8; use deno_core::v8; use deno_core::ResourceId; -use std::ffi::c_void; use std::ptr; #[op(v8)] @@ -147,7 +146,7 @@ pub fn op_ffi_get_static<'scope>( } NativeType::Pointer | NativeType::Function | NativeType::Buffer => { let external: v8::Local = - v8::External::new(scope, data_ptr as *mut c_void).into(); + v8::External::new(scope, data_ptr).into(); external.into() } NativeType::Struct(_) => { diff --git a/ext/http/http_next.rs b/ext/http/http_next.rs index 4d5c637767..e8517c9019 100644 --- a/ext/http/http_next.rs +++ b/ext/http/http_next.rs @@ -962,14 +962,14 @@ where #[smi] pub fn op_http_try_wait(state: &mut OpState, #[smi] rid: ResourceId) -> SlabId { // The resource needs to exist. - let Ok(join_handle) = state - .resource_table - .get::(rid) else { - return SlabId::MAX; + let Ok(join_handle) = state.resource_table.get::(rid) else { + return SlabId::MAX; }; // If join handle is somehow locked, just abort. - let Some(mut handle) = RcRef::map(&join_handle, |this| &this.2).try_borrow_mut() else { + let Some(mut handle) = + RcRef::map(&join_handle, |this| &this.2).try_borrow_mut() + else { return SlabId::MAX; }; diff --git a/ext/http/response_body.rs b/ext/http/response_body.rs index f88f13f889..5c946a4d3c 100644 --- a/ext/http/response_body.rs +++ b/ext/http/response_body.rs @@ -290,7 +290,9 @@ impl Body for ResponseBytes { unreachable!() } ResponseBytesInner::Bytes(..) => { - let ResponseBytesInner::Bytes(data) = self.complete(true) else { unreachable!(); }; + let ResponseBytesInner::Bytes(data) = self.complete(true) else { + unreachable!(); + }; return std::task::Poll::Ready(Some(Ok(Frame::data(data)))); } ResponseBytesInner::UncompressedStream(stm) => { diff --git a/ext/kv/remote.rs b/ext/kv/remote.rs index 47528d15fb..74792a9988 100644 --- a/ext/kv/remote.rs +++ b/ext/kv/remote.rs @@ -494,9 +494,15 @@ async fn call_remote< // `unwrap()` never fails because `tx` is owned by the task held by `refresher`. metadata_rx.changed().await.unwrap(); }; - let Some(sc_endpoint) = metadata.endpoints.iter().find(|x| x.consistency == "strong") else { - return Err(type_error("No strong consistency endpoint is available for this database")); - }; + let Some(sc_endpoint) = metadata + .endpoints + .iter() + .find(|x| x.consistency == "strong") + else { + return Err(type_error( + "No strong consistency endpoint is available for this database", + )); + }; let full_url = format!("{}/{}", sc_endpoint.url, method); { diff --git a/ext/kv/sqlite.rs b/ext/kv/sqlite.rs index f67154cb4d..ea46aae32f 100644 --- a/ext/kv/sqlite.rs +++ b/ext/kv/sqlite.rs @@ -355,7 +355,7 @@ impl SqliteDb { spawn_blocking(move || { let mut db = db.try_lock().ok(); let Some(db) = db.as_mut().and_then(|x| x.as_mut()) else { - return Err(type_error(ERROR_USING_CLOSED_DATABASE)) + return Err(type_error(ERROR_USING_CLOSED_DATABASE)); }; let result = match db.transaction() { Ok(tx) => f(tx), @@ -626,16 +626,17 @@ impl SqliteQueue { tx: &rusqlite::Transaction<'_>, ) -> Result { let Some((_, id, data, backoff_schedule, keys_if_undelivered)) = tx - .prepare_cached(STATEMENT_QUEUE_GET_RUNNING_BY_ID)? - .query_row([id], |row| { - let deadline: u64 = row.get(0)?; - let id: String = row.get(1)?; - let data: Vec = row.get(2)?; - let backoff_schedule: String = row.get(3)?; - let keys_if_undelivered: String = row.get(4)?; - Ok((deadline, id, data, backoff_schedule, keys_if_undelivered)) - }) - .optional()? else { + .prepare_cached(STATEMENT_QUEUE_GET_RUNNING_BY_ID)? + .query_row([id], |row| { + let deadline: u64 = row.get(0)?; + let id: String = row.get(1)?; + let data: Vec = row.get(2)?; + let backoff_schedule: String = row.get(3)?; + let keys_if_undelivered: String = row.get(4)?; + Ok((deadline, id, data, backoff_schedule, keys_if_undelivered)) + }) + .optional()? + else { return Ok(false); }; @@ -926,7 +927,9 @@ fn mutate_le64( mutate: impl FnOnce(u64, u64) -> u64, ) -> Result<(), AnyError> { let Value::U64(operand) = *operand else { - return Err(type_error(format!("Failed to perform '{op_name}' mutation on a non-U64 operand"))); + return Err(type_error(format!( + "Failed to perform '{op_name}' mutation on a non-U64 operand" + ))); }; let old_value = tx diff --git a/ext/node/global.rs b/ext/node/global.rs index 52c1b6bb91..fd2f5a7cb3 100644 --- a/ext/node/global.rs +++ b/ext/node/global.rs @@ -264,7 +264,9 @@ fn is_managed_key( } fn current_mode(scope: &mut v8::HandleScope) -> Mode { - let Some(v8_string) = v8::StackTrace::current_script_name_or_source_url(scope) else { + let Some(v8_string) = + v8::StackTrace::current_script_name_or_source_url(scope) + else { return Mode::Deno; }; let op_state = deno_core::JsRuntime::op_state_from(scope); @@ -375,7 +377,8 @@ pub fn query<'s>( return; }; - let Some(attributes) = inner.get_property_attributes(scope, key.into()) else { + let Some(attributes) = inner.get_property_attributes(scope, key.into()) + else { return; }; @@ -429,7 +432,9 @@ pub fn enumerator<'s>( }; let inner = v8::Local::new(scope, inner); - let Some(array) = inner.get_property_names(scope, GetPropertyNamesArgs::default()) else { + let Some(array) = + inner.get_property_names(scope, GetPropertyNamesArgs::default()) + else { return; }; diff --git a/ext/node/ops/crypto/x509.rs b/ext/node/ops/crypto/x509.rs index 402c58b720..bef5fd2c80 100644 --- a/ext/node/ops/crypto/x509.rs +++ b/ext/node/ops/crypto/x509.rs @@ -230,31 +230,27 @@ fn x509name_to_string( ) -> Result { // Lifted from https://github.com/rusticata/x509-parser/blob/4d618c2ed6b1fc102df16797545895f7c67ee0fe/src/x509.rs#L543-L566 // since it's a private function (Copyright 2017 Pierre Chifflier) - name.iter_rdn().fold(Ok(String::new()), |acc, rdn| { - acc.and_then(|mut _vec| { - rdn - .iter() - .fold(Ok(String::new()), |acc2, attr| { - acc2.and_then(|mut _vec2| { - let val_str = - attribute_value_to_string(attr.attr_value(), attr.attr_type())?; - // look ABBREV, and if not found, use shortname - let abbrev = match oid2abbrev(attr.attr_type(), oid_registry) { - Ok(s) => String::from(s), - _ => format!("{:?}", attr.attr_type()), - }; - let rdn = format!("{}={}", abbrev, val_str); - match _vec2.len() { - 0 => Ok(rdn), - _ => Ok(_vec2 + " + " + rdn.as_str()), - } - }) - }) - .map(|v| match _vec.len() { - 0 => v, - _ => _vec + "\n" + v.as_str(), - }) - }) + name.iter_rdn().try_fold(String::new(), |acc, rdn| { + rdn + .iter() + .try_fold(String::new(), |acc2, attr| { + let val_str = + attribute_value_to_string(attr.attr_value(), attr.attr_type())?; + // look ABBREV, and if not found, use shortname + let abbrev = match oid2abbrev(attr.attr_type(), oid_registry) { + Ok(s) => String::from(s), + _ => format!("{:?}", attr.attr_type()), + }; + let rdn = format!("{}={}", abbrev, val_str); + match acc2.len() { + 0 => Ok(rdn), + _ => Ok(acc2 + " + " + rdn.as_str()), + } + }) + .map(|v| match acc.len() { + 0 => v, + _ => acc + "\n" + v.as_str(), + }) }) } diff --git a/ext/node/resolution.rs b/ext/node/resolution.rs index 4272b8c866..7a88356d88 100644 --- a/ext/node/resolution.rs +++ b/ext/node/resolution.rs @@ -1053,9 +1053,10 @@ impl NodeResolver { // ResolveSelf let Some(package_config) = - self.get_package_scope_config(referrer, permissions)? else { - return Ok(None); - }; + self.get_package_scope_config(referrer, permissions)? + else { + return Ok(None); + }; if package_config.exists && package_config.name.as_ref() == Some(&package_name) { @@ -1132,9 +1133,10 @@ impl NodeResolver { ) -> Result, AnyError> { let Some(root_folder) = self .npm_resolver - .resolve_package_folder_from_path(&referrer.to_file_path().unwrap())? else { - return Ok(None); - }; + .resolve_package_folder_from_path(&referrer.to_file_path().unwrap())? + else { + return Ok(None); + }; let package_json_path = root_folder.join("package.json"); self .load_package_json(permissions, package_json_path) @@ -1146,7 +1148,8 @@ impl NodeResolver { url: &ModuleSpecifier, permissions: &dyn NodePermissions, ) -> Result, AnyError> { - let Some(package_json_path) = self.get_closest_package_json_path(url)? else { + let Some(package_json_path) = self.get_closest_package_json_path(url)? + else { return Ok(None); }; self @@ -1169,9 +1172,10 @@ impl NodeResolver { } let Some(root_pkg_folder) = self .npm_resolver - .resolve_package_folder_from_path(current_dir)? else { - return Ok(None); - }; + .resolve_package_folder_from_path(current_dir)? + else { + return Ok(None); + }; while current_dir.starts_with(&root_pkg_folder) { current_dir = current_dir.parent().unwrap(); let package_json_path = current_dir.join("package.json"); diff --git a/ext/web/stream_resource.rs b/ext/web/stream_resource.rs index 0c483ecccc..8a454da73f 100644 --- a/ext/web/stream_resource.rs +++ b/ext/web/stream_resource.rs @@ -183,7 +183,8 @@ pub fn op_readable_stream_resource_get_sink( state: &mut OpState, #[smi] rid: ResourceId, ) -> *const c_void { - let Ok(resource) = state.resource_table.get::(rid) else { + let Ok(resource) = state.resource_table.get::(rid) + else { return std::ptr::null(); }; resource.data.tx as _ diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs index bdca1433b5..4b05131d9f 100644 --- a/ext/websocket/lib.rs +++ b/ext/websocket/lib.rs @@ -581,7 +581,8 @@ pub async fn op_ws_next_event( let Ok(resource) = state .borrow_mut() .resource_table - .get::(rid) else { + .get::(rid) + else { // op_ws_get_error will correctly handle a bad resource return MessageKind::Error as u16; }; diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs index 076c137657..0b9a95c558 100644 --- a/runtime/ops/process.rs +++ b/runtime/ops/process.rs @@ -579,7 +579,7 @@ mod deprecated { #[cfg(unix)] let signal = run_status.signal(); #[cfg(not(unix))] - let signal = None; + let signal = Default::default(); code .or(signal) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 9058c7d87d..be838d8604 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.71.0" +channel = "1.72.0" components = ["rustfmt", "clippy"] diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index 41fb96a1b8..cf66e33667 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -1228,11 +1228,14 @@ async fn main_server( let body = hyper::body::to_bytes(req.into_body()) .await .unwrap_or_default(); - let Ok(body): Result = prost::Message::decode(&body[..]) else { - return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::empty()) - .unwrap()); + let Ok(body): Result = prost::Message::decode(&body[..]) + else { + return Ok( + Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::empty()) + .unwrap(), + ); }; if body.ranges.is_empty() { return Ok( @@ -1280,11 +1283,14 @@ async fn main_server( let body = hyper::body::to_bytes(req.into_body()) .await .unwrap_or_default(); - let Ok(_body): Result = prost::Message::decode(&body[..]) else { - return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::empty()) - .unwrap()); + let Ok(_body): Result = prost::Message::decode(&body[..]) + else { + return Ok( + Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::empty()) + .unwrap(), + ); }; Ok( Response::builder()