Skip to content

Commit

Permalink
clippy:Fix clippy problems in components/scripts/binding (servo#31893)
Browse files Browse the repository at this point in the history
* constants have by default a static lifetime

* constants have by default a static lifetime

* unneeded unit expression

* unneeded unit expression

* Box of default value

* casting raw pointers

* casting raw pointers
  • Loading branch information
six-shot authored and ektuu committed Mar 28, 2024
1 parent d871f2d commit d90e4a0
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion components/script/dom/bindings/buffer_source.rs
Expand Up @@ -124,7 +124,7 @@ where
{
pub fn default() -> HeapBufferSource<T> {
HeapBufferSource {
buffer_source: BufferSource::Default(Box::new(Heap::default())),
buffer_source: BufferSource::Default(Box::default()),
phantom: PhantomData,
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/bindings/callback.rs
Expand Up @@ -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()
}
}

Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/bindings/conversions.rs
Expand Up @@ -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),
)))
Expand Down Expand Up @@ -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");
Expand Down
11 changes: 5 additions & 6 deletions components/script/dom/bluetoothuuid.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -568,19 +568,18 @@ 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
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 =
"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)]
Expand Down
1 change: 0 additions & 1 deletion components/script/dom/htmlformelement.rs
Expand Up @@ -1125,7 +1125,6 @@ impl HTMLFormElement {
},
HTMLElementTypeId::HTMLObjectElement => {
// Unimplemented
()
},
HTMLElementTypeId::HTMLSelectElement => {
let select = child.downcast::<HTMLSelectElement>().unwrap();
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/htmlinputelement.rs
Expand Up @@ -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)]
Expand Down Expand Up @@ -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::<Node>().is_connected() {
return ();
return;
}
let target = self.upcast::<EventTarget>();
target.fire_bubbling_event(atom!("input"));
Expand Down
2 changes: 0 additions & 2 deletions components/script/dom/node.rs
Expand Up @@ -1873,7 +1873,6 @@ impl Node {
// Step 1.
match parent.type_id() {
NodeTypeId::Document(_) | NodeTypeId::DocumentFragment(_) | NodeTypeId::Element(..) => {
()
},
_ => return Err(Error::HierarchyRequest),
}
Expand Down Expand Up @@ -2640,7 +2639,6 @@ impl NodeMethods for Node {
// Step 1.
match self.type_id() {
NodeTypeId::Document(_) | NodeTypeId::DocumentFragment(_) | NodeTypeId::Element(..) => {
()
},
_ => return Err(Error::HierarchyRequest),
}
Expand Down

0 comments on commit d90e4a0

Please sign in to comment.