diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/ffi/dlfcn.rs | 2 | ||||
-rw-r--r-- | ext/ffi/static.rs | 3 | ||||
-rw-r--r-- | ext/http/http_next.rs | 10 | ||||
-rw-r--r-- | ext/http/response_body.rs | 4 | ||||
-rw-r--r-- | ext/kv/remote.rs | 12 | ||||
-rw-r--r-- | ext/kv/sqlite.rs | 27 | ||||
-rw-r--r-- | ext/node/global.rs | 11 | ||||
-rw-r--r-- | ext/node/ops/crypto/x509.rs | 46 | ||||
-rw-r--r-- | ext/node/resolution.rs | 24 | ||||
-rw-r--r-- | ext/web/stream_resource.rs | 3 | ||||
-rw-r--r-- | ext/websocket/lib.rs | 3 |
11 files changed, 81 insertions, 64 deletions
diff --git a/ext/ffi/dlfcn.rs b/ext/ffi/dlfcn.rs index ced64bec5..a10bbbe29 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::<Vec<_>>(); let arguments = [path.as_ptr()]; diff --git a/ext/ffi/static.rs b/ext/ffi/static.rs index ae095d5fc..8a6c147d0 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::Value> = - 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 4d5c63776..e8517c901 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::<HttpJoinHandle>(rid) else { - return SlabId::MAX; + let Ok(join_handle) = state.resource_table.get::<HttpJoinHandle>(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 f88f13f88..5c946a4d3 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 448a87b0d..21286fd47 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 f67154cb4..ea46aae32 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<bool, AnyError> { 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<u8> = 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<u8> = 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 52c1b6bb9..fd2f5a7cb 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 402c58b72..bef5fd2c8 100644 --- a/ext/node/ops/crypto/x509.rs +++ b/ext/node/ops/crypto/x509.rs @@ -230,31 +230,27 @@ fn x509name_to_string( ) -> Result<String, x509_parser::error::X509Error> { // 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 4272b8c86..7a88356d8 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<Option<PackageJson>, 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<Option<PackageJson>, 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 0c483eccc..8a454da73 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::<ReadableStreamResource>(rid) else { + let Ok(resource) = state.resource_table.get::<ReadableStreamResource>(rid) + else { return std::ptr::null(); }; resource.data.tx as _ diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs index bdca1433b..4b05131d9 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::<ServerWebSocket>(rid) else { + .get::<ServerWebSocket>(rid) + else { // op_ws_get_error will correctly handle a bad resource return MessageKind::Error as u16; }; |