From f08bb72d82b2ca9c6cd14ad3b984d3cb0b648118 Mon Sep 17 00:00:00 2001 From: six-shot Date: Wed, 27 Mar 2024 10:55:30 +0000 Subject: [PATCH 1/7] constants have by default a static lifetime --- components/script/dom/bluetoothuuid.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/script/dom/bluetoothuuid.rs b/components/script/dom/bluetoothuuid.rs index 21ca00776d53..dc97edcbf4b3 100644 --- a/components/script/dom/bluetoothuuid.rs +++ b/components/script/dom/bluetoothuuid.rs @@ -523,7 +523,7 @@ const BLUETOOTH_ASSIGNED_CHARCTERISTICS: &[(&str, u32)] = &[ ]; //https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx -const BLUETOOTH_ASSIGNED_DESCRIPTORS: &'static [(&'static str, u32)] = &[ +const BLUETOOTH_ASSIGNED_DESCRIPTORS: &'static [(&str, u32)] = &[ ( "org.bluetooth.descriptor.gatt.characteristic_extended_properties", 0x2900_u32, @@ -568,10 +568,10 @@ const CHARACTERISTIC_PREFIX: &str = "org.bluetooth.characteristic"; const DESCRIPTOR_PREFIX: &str = "org.bluetooth.descriptor"; const VALID_UUID_REGEX: &str = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"; // https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/bluetooth/BluetoothUUID.cpp?l=314 -const UUID_ERROR_MESSAGE: &'static str = "It must be a valid UUID alias (e.g. 0x1234), \ +const UUID_ERROR_MESSAGE: &str = "It must be a valid UUID alias (e.g. 0x1234), \ UUID (lowercase hex characters e.g. '00001234-0000-1000-8000-00805f9b34fb'),\nor recognized standard name from"; // https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/bluetooth/BluetoothUUID.cpp?l=321 -const SERVICES_ERROR_MESSAGE: &'static str = +const SERVICES_ERROR_MESSAGE: &str = "https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx\ \ne.g. 'alert_notification'."; // https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/bluetooth/BluetoothUUID.cpp?l=327 From 0c5e881a39d2352209ee0b3259e943311790b8ca Mon Sep 17 00:00:00 2001 From: six-shot Date: Wed, 27 Mar 2024 10:56:53 +0000 Subject: [PATCH 2/7] constants have by default a static lifetime --- components/script/dom/bluetoothuuid.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/script/dom/bluetoothuuid.rs b/components/script/dom/bluetoothuuid.rs index dc97edcbf4b3..9783fa763fde 100644 --- a/components/script/dom/bluetoothuuid.rs +++ b/components/script/dom/bluetoothuuid.rs @@ -575,11 +575,11 @@ const SERVICES_ERROR_MESSAGE: &str = "https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx\ \ne.g. 'alert_notification'."; // https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/bluetooth/BluetoothUUID.cpp?l=327 -const CHARACTERISTIC_ERROR_MESSAGE: &'static str = +const CHARACTERISTIC_ERROR_MESSAGE: &str = "https://developer.bluetooth.org/gatt/characteristics/Pages/\ CharacteristicsHome.aspx\ne.g. 'aerobic_heart_rate_lower_limit'."; // https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/bluetooth/BluetoothUUID.cpp?l=333 -const DESCRIPTOR_ERROR_MESSAGE: &'static str = +const DESCRIPTOR_ERROR_MESSAGE: &str = "https://developer.bluetooth.org/gatt/descriptors/Pages/\ DescriptorsHomePage.aspx\ne.g. 'gatt.characteristic_presentation_format'."; From 1c66ee618b89ca3cf331c8e9a86b055e3b0196b8 Mon Sep 17 00:00:00 2001 From: six-shot Date: Wed, 27 Mar 2024 11:01:36 +0000 Subject: [PATCH 3/7] unneeded unit expression --- components/script/dom/htmlformelement.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 86888da9d951..4d1179e64bd1 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -1125,7 +1125,7 @@ impl HTMLFormElement { }, HTMLElementTypeId::HTMLObjectElement => { // Unimplemented - () + }, HTMLElementTypeId::HTMLSelectElement => { let select = child.downcast::().unwrap(); From 3f39bd7073f8ea8b7393b975e5b7e512e3760e38 Mon Sep 17 00:00:00 2001 From: six-shot Date: Wed, 27 Mar 2024 11:06:30 +0000 Subject: [PATCH 4/7] unneeded unit expression --- components/script/dom/htmlinputelement.rs | 6 +++--- components/script/dom/node.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 76d4ea670afc..6c10109a5f08 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -83,8 +83,8 @@ use crate::textinput::KeyReaction::{ use crate::textinput::Lines::Single; use crate::textinput::{Direction, SelectionDirection, TextInput, UTF16CodeUnits, UTF8Bytes}; -const DEFAULT_SUBMIT_VALUE: &'static str = "Submit"; -const DEFAULT_RESET_VALUE: &'static str = "Reset"; +const DEFAULT_SUBMIT_VALUE: &str = "Submit"; +const DEFAULT_RESET_VALUE: &str = "Reset"; const PASSWORD_REPLACEMENT_CHAR: char = '●'; #[derive(Clone, Copy, JSTraceable, PartialEq)] @@ -2850,7 +2850,7 @@ impl Activatable for HTMLInputElement { // https://html.spec.whatwg.org/multipage/#radio-button-state-(type=radio):activation-behavior // Check if document owner is fully active if !self.upcast::().is_connected() { - return (); + return; } let target = self.upcast::(); target.fire_bubbling_event(atom!("input")); diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index bbeb7fe14896..526219babf17 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1870,7 +1870,7 @@ impl Node { // Step 1. match parent.type_id() { NodeTypeId::Document(_) | NodeTypeId::DocumentFragment(_) | NodeTypeId::Element(..) => { - () + }, _ => return Err(Error::HierarchyRequest), } @@ -2637,7 +2637,7 @@ impl NodeMethods for Node { // Step 1. match self.type_id() { NodeTypeId::Document(_) | NodeTypeId::DocumentFragment(_) | NodeTypeId::Element(..) => { - () + }, _ => return Err(Error::HierarchyRequest), } From 4fe9f98bdc57a64810316314440141c1954d7a77 Mon Sep 17 00:00:00 2001 From: six-shot Date: Wed, 27 Mar 2024 11:09:05 +0000 Subject: [PATCH 5/7] Box of default value --- components/script/dom/bindings/buffer_source.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/script/dom/bindings/buffer_source.rs b/components/script/dom/bindings/buffer_source.rs index 0549ed9041d3..5dc6cc43dabb 100644 --- a/components/script/dom/bindings/buffer_source.rs +++ b/components/script/dom/bindings/buffer_source.rs @@ -124,7 +124,7 @@ where { pub fn default() -> HeapBufferSource { HeapBufferSource { - buffer_source: BufferSource::Default(Box::new(Heap::default())), + buffer_source: BufferSource::Default(Box::default()), phantom: PhantomData, } } From 9c752fc222950209663746e98a4b3044d38ff1ae Mon Sep 17 00:00:00 2001 From: six-shot Date: Wed, 27 Mar 2024 11:18:33 +0000 Subject: [PATCH 6/7] casting raw pointers --- components/script/dom/bindings/callback.rs | 2 +- components/script/dom/bindings/conversions.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs index 99afe456aff9..d64dc053e797 100644 --- a/components/script/dom/bindings/callback.rs +++ b/components/script/dom/bindings/callback.rs @@ -127,7 +127,7 @@ pub trait CallbackContainer { /// /// ["callback context"]: https://heycam.github.io/webidl/#dfn-callback-context fn incumbent(&self) -> Option<&GlobalScope> { - self.callback_holder().incumbent.as_ref().map(Dom::deref) + self.callback_holder().incumbent.as_deref() } } diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index c33cbad479c2..15087fe5a0f1 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -282,7 +282,7 @@ impl FromJSValConvertible for USVString { let mut length = 0; let chars = JS_GetTwoByteStringCharsAndLength(cx, ptr::null(), jsstr, &mut length); assert!(!chars.is_null()); - let char_vec = slice::from_raw_parts(chars as *const u16, length); + let char_vec = slice::from_raw_parts(chars, length); Ok(ConversionResult::Success(USVString( String::from_utf16_lossy(char_vec), ))) @@ -395,7 +395,7 @@ pub unsafe fn get_dom_class(obj: *mut JSObject) -> Result<&'static DOMClass, ()> if is_dom_class(&*clasp) { trace!("plain old dom object"); let domjsclass: *const DOMJSClass = clasp as *const DOMJSClass; - return Ok(&(&*domjsclass).dom_class); + return Ok(&(*domjsclass).dom_class); } if is_dom_proxy(obj) { trace!("proxy dom object"); From bbad6aef925e86a35e6e7d541bbf2aac0d27cd17 Mon Sep 17 00:00:00 2001 From: six-shot Date: Wed, 27 Mar 2024 11:23:51 +0000 Subject: [PATCH 7/7] casting raw pointers --- components/script/dom/bluetoothuuid.rs | 3 +-- components/script/dom/htmlformelement.rs | 1 - components/script/dom/node.rs | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/components/script/dom/bluetoothuuid.rs b/components/script/dom/bluetoothuuid.rs index 9783fa763fde..c233b69144e2 100644 --- a/components/script/dom/bluetoothuuid.rs +++ b/components/script/dom/bluetoothuuid.rs @@ -579,8 +579,7 @@ const CHARACTERISTIC_ERROR_MESSAGE: &str = "https://developer.bluetooth.org/gatt/characteristics/Pages/\ CharacteristicsHome.aspx\ne.g. 'aerobic_heart_rate_lower_limit'."; // https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/bluetooth/BluetoothUUID.cpp?l=333 -const DESCRIPTOR_ERROR_MESSAGE: &str = - "https://developer.bluetooth.org/gatt/descriptors/Pages/\ +const DESCRIPTOR_ERROR_MESSAGE: &str = "https://developer.bluetooth.org/gatt/descriptors/Pages/\ DescriptorsHomePage.aspx\ne.g. 'gatt.characteristic_presentation_format'."; #[allow(non_snake_case)] diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 4d1179e64bd1..01b349e70711 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -1125,7 +1125,6 @@ impl HTMLFormElement { }, HTMLElementTypeId::HTMLObjectElement => { // Unimplemented - }, HTMLElementTypeId::HTMLSelectElement => { let select = child.downcast::().unwrap(); diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 526219babf17..bfae1cf0c6f1 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1870,7 +1870,6 @@ impl Node { // Step 1. match parent.type_id() { NodeTypeId::Document(_) | NodeTypeId::DocumentFragment(_) | NodeTypeId::Element(..) => { - }, _ => return Err(Error::HierarchyRequest), } @@ -2637,7 +2636,6 @@ impl NodeMethods for Node { // Step 1. match self.type_id() { NodeTypeId::Document(_) | NodeTypeId::DocumentFragment(_) | NodeTypeId::Element(..) => { - }, _ => return Err(Error::HierarchyRequest), }