aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorRosemary Ajayi <okhuomonajayi54@gmail.com>2024-03-19 08:01:23 +0000
committerGitHub <noreply@github.com>2024-03-19 08:01:23 +0000
commit06a021db552c1d2f8899484f7c1143424c387eef (patch)
treefbe14142bd89c6388635dd4a201146c1d60a3580 /components/script
parent291fbce434f804c2ce51d2b966bab4c472d9ecf3 (diff)
downloadservo-06a021db552c1d2f8899484f7c1143424c387eef.tar.gz
servo-06a021db552c1d2f8899484f7c1143424c387eef.zip
clippy: Fix some warnings in `components/script` (#31735)
* fix clippy problems * fix clippy error * fix clippy error * fix clippy error * fix clippy error * fix clippy error * fix clippy errors
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/bluetooth.rs24
-rw-r--r--components/script/dom/bluetoothadvertisingevent.rs8
-rw-r--r--components/script/dom/bluetoothcharacteristicproperties.rs18
-rw-r--r--components/script/dom/bluetoothdevice.rs4
-rw-r--r--components/script/dom/bluetoothremotegattcharacteristic.rs4
-rw-r--r--components/script/dom/bluetoothremotegattservice.rs6
-rw-r--r--components/script/dom/bluetoothuuid.rs15
-rw-r--r--components/script/dom/canvaspattern.rs4
-rw-r--r--components/script/dom/client.rs2
-rw-r--r--components/script/dom/closeevent.rs6
-rw-r--r--components/script/dom/htmlvideoelement.rs4
-rw-r--r--components/script/dom/mediafragmentparser.rs34
12 files changed, 60 insertions, 69 deletions
diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs
index 7b7aa791b0a..6489e8872e8 100644
--- a/components/script/dom/bluetooth.rs
+++ b/components/script/dom/bluetooth.rs
@@ -44,25 +44,23 @@ use std::rc::Rc;
use std::str::FromStr;
use std::sync::{Arc, Mutex};
-const KEY_CONVERSION_ERROR: &'static str =
+const KEY_CONVERSION_ERROR: &str =
"This `manufacturerData` key can not be parsed as unsigned short:";
-const FILTER_EMPTY_ERROR: &'static str =
+const FILTER_EMPTY_ERROR: &str =
"'filters' member, if present, must be nonempty to find any devices.";
-const FILTER_ERROR: &'static str = "A filter must restrict the devices in some way.";
-const MANUFACTURER_DATA_ERROR: &'static str =
+const FILTER_ERROR: &str = "A filter must restrict the devices in some way.";
+const MANUFACTURER_DATA_ERROR: &str =
"'manufacturerData', if present, must be non-empty to filter devices.";
-const MASK_LENGTH_ERROR: &'static str =
- "`mask`, if present, must have the same length as `dataPrefix`.";
+const MASK_LENGTH_ERROR: &str = "`mask`, if present, must have the same length as `dataPrefix`.";
// 248 is the maximum number of UTF-8 code units in a Bluetooth Device Name.
const MAX_DEVICE_NAME_LENGTH: usize = 248;
-const NAME_PREFIX_ERROR: &'static str = "'namePrefix', if present, must be nonempty.";
-const NAME_TOO_LONG_ERROR: &'static str = "A device name can't be longer than 248 bytes.";
-const SERVICE_DATA_ERROR: &'static str =
- "'serviceData', if present, must be non-empty to filter devices.";
-const SERVICE_ERROR: &'static str = "'services', if present, must contain at least one service.";
-const OPTIONS_ERROR: &'static str = "Fields of 'options' conflict with each other.
+const NAME_PREFIX_ERROR: &str = "'namePrefix', if present, must be nonempty.";
+const NAME_TOO_LONG_ERROR: &str = "A device name can't be longer than 248 bytes.";
+const SERVICE_DATA_ERROR: &str = "'serviceData', if present, must be non-empty to filter devices.";
+const SERVICE_ERROR: &str = "'services', if present, must contain at least one service.";
+const OPTIONS_ERROR: &str = "Fields of 'options' conflict with each other.
Either 'acceptAllDevices' member must be true, or 'filters' member must be set to a value.";
-const BT_DESC_CONVERSION_ERROR: &'static str =
+const BT_DESC_CONVERSION_ERROR: &str =
"Can't convert to an IDL value of type BluetoothPermissionDescriptor";
#[derive(JSTraceable, MallocSizeOf)]
diff --git a/components/script/dom/bluetoothadvertisingevent.rs b/components/script/dom/bluetoothadvertisingevent.rs
index e134153563b..a8697bbde41 100644
--- a/components/script/dom/bluetoothadvertisingevent.rs
+++ b/components/script/dom/bluetoothadvertisingevent.rs
@@ -43,10 +43,10 @@ impl BluetoothAdvertisingEvent {
BluetoothAdvertisingEvent {
event: Event::new_inherited(),
device: Dom::from_ref(device),
- name: name,
- appearance: appearance,
- tx_power: tx_power,
- rssi: rssi,
+ name,
+ appearance,
+ tx_power,
+ rssi,
}
}
diff --git a/components/script/dom/bluetoothcharacteristicproperties.rs b/components/script/dom/bluetoothcharacteristicproperties.rs
index 3f1a765d234..3401d445a89 100644
--- a/components/script/dom/bluetoothcharacteristicproperties.rs
+++ b/components/script/dom/bluetoothcharacteristicproperties.rs
@@ -39,15 +39,15 @@ impl BluetoothCharacteristicProperties {
) -> BluetoothCharacteristicProperties {
BluetoothCharacteristicProperties {
reflector_: Reflector::new(),
- broadcast: broadcast,
- read: read,
- write_without_response: write_without_response,
- write: write,
- notify: notify,
- indicate: indicate,
- authenticated_signed_writes: authenticated_signed_writes,
- reliable_write: reliable_write,
- writable_auxiliaries: writable_auxiliaries,
+ broadcast,
+ read,
+ write_without_response,
+ write,
+ notify,
+ indicate,
+ authenticated_signed_writes,
+ reliable_write,
+ writable_auxiliaries,
}
}
diff --git a/components/script/dom/bluetoothdevice.rs b/components/script/dom/bluetoothdevice.rs
index 0d58c4f2f9d..955b64ffb5c 100644
--- a/components/script/dom/bluetoothdevice.rs
+++ b/components/script/dom/bluetoothdevice.rs
@@ -57,8 +57,8 @@ impl BluetoothDevice {
) -> BluetoothDevice {
BluetoothDevice {
eventtarget: EventTarget::new_inherited(),
- id: id,
- name: name,
+ id,
+ name,
gatt: Default::default(),
context: Dom::from_ref(context),
attribute_instance_map: (
diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs
index 71c54461b8a..639c1dfd63f 100644
--- a/components/script/dom/bluetoothremotegattcharacteristic.rs
+++ b/components/script/dom/bluetoothremotegattcharacteristic.rs
@@ -56,10 +56,10 @@ impl BluetoothRemoteGATTCharacteristic {
BluetoothRemoteGATTCharacteristic {
eventtarget: EventTarget::new_inherited(),
service: Dom::from_ref(service),
- uuid: uuid,
+ uuid,
properties: Dom::from_ref(properties),
value: DomRefCell::new(None),
- instance_id: instance_id,
+ instance_id,
}
}
diff --git a/components/script/dom/bluetoothremotegattservice.rs b/components/script/dom/bluetoothremotegattservice.rs
index 650ba5151d1..1bac5715bdc 100644
--- a/components/script/dom/bluetoothremotegattservice.rs
+++ b/components/script/dom/bluetoothremotegattservice.rs
@@ -40,9 +40,9 @@ impl BluetoothRemoteGATTService {
BluetoothRemoteGATTService {
eventtarget: EventTarget::new_inherited(),
device: Dom::from_ref(device),
- uuid: uuid,
- is_primary: is_primary,
- instance_id: instance_id,
+ uuid,
+ is_primary,
+ instance_id,
}
}
diff --git a/components/script/dom/bluetoothuuid.rs b/components/script/dom/bluetoothuuid.rs
index f37fa166032..6d9909ca2bf 100644
--- a/components/script/dom/bluetoothuuid.rs
+++ b/components/script/dom/bluetoothuuid.rs
@@ -24,7 +24,7 @@ pub struct BluetoothUUID {
}
//https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
-const BLUETOOTH_ASSIGNED_SERVICES: &'static [(&'static str, u32)] = &[
+const BLUETOOTH_ASSIGNED_SERVICES: &[(&str, u32)] = &[
("org.bluetooth.service.alert_notification", 0x1811_u32),
("org.bluetooth.service.automation_io", 0x1815_u32),
("org.bluetooth.service.battery_service", 0x180f_u32),
@@ -75,7 +75,7 @@ const BLUETOOTH_ASSIGNED_SERVICES: &'static [(&'static str, u32)] = &[
];
//https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
-const BLUETOOTH_ASSIGNED_CHARCTERISTICS: &'static [(&'static str, u32)] = &[
+const BLUETOOTH_ASSIGNED_CHARCTERISTICS: &[(&str, u32)] = &[
(
"org.bluetooth.characteristic.aerobic_heart_rate_lower_limit",
0x2a7e_u32,
@@ -562,12 +562,11 @@ const BLUETOOTH_ASSIGNED_DESCRIPTORS: &'static [(&'static str, u32)] = &[
("org.bluetooth.descriptor.time_trigger_setting", 0x290e_u32),
];
-const BASE_UUID: &'static str = "-0000-1000-8000-00805f9b34fb";
-const SERVICE_PREFIX: &'static str = "org.bluetooth.service";
-const CHARACTERISTIC_PREFIX: &'static str = "org.bluetooth.characteristic";
-const DESCRIPTOR_PREFIX: &'static str = "org.bluetooth.descriptor";
-const VALID_UUID_REGEX: &'static str =
- "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
+const BASE_UUID: &str = "-0000-1000-8000-00805f9b34fb";
+const SERVICE_PREFIX: &str = "org.bluetooth.service";
+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), \
UUID (lowercase hex characters e.g. '00001234-0000-1000-8000-00805f9b34fb'),\nor recognized standard name from";
diff --git a/components/script/dom/canvaspattern.rs b/components/script/dom/canvaspattern.rs
index d63bc938d19..a5d0c525799 100644
--- a/components/script/dom/canvaspattern.rs
+++ b/components/script/dom/canvaspattern.rs
@@ -39,11 +39,11 @@ impl CanvasPattern {
CanvasPattern {
reflector_: Reflector::new(),
- surface_data: surface_data,
+ surface_data,
surface_size,
repeat_x: x,
repeat_y: y,
- origin_clean: origin_clean,
+ origin_clean,
}
}
pub fn new(
diff --git a/components/script/dom/client.rs b/components/script/dom/client.rs
index d8e382e750d..610f4671bbd 100644
--- a/components/script/dom/client.rs
+++ b/components/script/dom/client.rs
@@ -32,7 +32,7 @@ impl Client {
Client {
reflector_: Reflector::new(),
active_worker: Default::default(),
- url: url,
+ url,
frame_type: FrameType::None,
id: Uuid::new_v4(),
}
diff --git a/components/script/dom/closeevent.rs b/components/script/dom/closeevent.rs
index 4f136ebe905..4dee3eb84cf 100644
--- a/components/script/dom/closeevent.rs
+++ b/components/script/dom/closeevent.rs
@@ -30,9 +30,9 @@ impl CloseEvent {
pub fn new_inherited(was_clean: bool, code: u16, reason: DOMString) -> CloseEvent {
CloseEvent {
event: Event::new_inherited(),
- was_clean: was_clean,
- code: code,
- reason: reason,
+ was_clean,
+ code,
+ reason,
}
}
diff --git a/components/script/dom/htmlvideoelement.rs b/components/script/dom/htmlvideoelement.rs
index 1adddebd626..01bbc3b6a20 100644
--- a/components/script/dom/htmlvideoelement.rs
+++ b/components/script/dom/htmlvideoelement.rs
@@ -299,13 +299,13 @@ impl ImageCacheListener for HTMLVideoElement {
ImageResponse::Loaded(image, url) => {
debug!("Loaded poster image for video element: {:?}", url);
self.htmlmediaelement.process_poster_image_loaded(image);
- LoadBlocker::terminate(&mut *self.load_blocker.borrow_mut());
+ LoadBlocker::terminate(&mut self.load_blocker.borrow_mut());
},
ImageResponse::MetadataLoaded(..) => {},
// The image cache may have loaded a placeholder for an invalid poster url
ImageResponse::PlaceholderLoaded(..) | ImageResponse::None => {
// A failed load should unblock the document load.
- LoadBlocker::terminate(&mut *self.load_blocker.borrow_mut());
+ LoadBlocker::terminate(&mut self.load_blocker.borrow_mut());
},
}
}
diff --git a/components/script/dom/mediafragmentparser.rs b/components/script/dom/mediafragmentparser.rs
index 796b8a0ba82..c416ab29222 100644
--- a/components/script/dom/mediafragmentparser.rs
+++ b/components/script/dom/mediafragmentparser.rs
@@ -114,8 +114,8 @@ impl MediaFragmentParser {
}
} else {
let mut iterator = fragment.split(',');
- let start = parse_hms(iterator.next().ok_or_else(|| ())?)?;
- let end = parse_hms(iterator.next().ok_or_else(|| ())?)?;
+ let start = parse_hms(iterator.next().ok_or(())?)?;
+ let end = parse_hms(iterator.next().ok_or(())?)?;
if iterator.next().is_some() || start >= end {
return Err(());
@@ -150,8 +150,8 @@ impl MediaFragmentParser {
.flat_map(|s| parse_hms(&s.time().to_string()))
.collect();
- let end = hms.pop().ok_or_else(|| ())?;
- let start = hms.pop().ok_or_else(|| ())?;
+ let end = hms.pop().ok_or(())?;
+ let start = hms.pop().ok_or(())?;
if !hms.is_empty() || start >= end {
return Err(());
@@ -168,10 +168,10 @@ impl MediaFragmentParser {
let mut clipping = SpatialClipping {
region: None,
- x: queue.pop_front().ok_or_else(|| ())?,
- y: queue.pop_front().ok_or_else(|| ())?,
- width: queue.pop_front().ok_or_else(|| ())?,
- height: queue.pop_front().ok_or_else(|| ())?,
+ x: queue.pop_front().ok_or(())?,
+ y: queue.pop_front().ok_or(())?,
+ width: queue.pop_front().ok_or(())?,
+ height: queue.pop_front().ok_or(())?,
};
if !queue.is_empty() {
@@ -209,10 +209,7 @@ impl From<&ServoUrl> for MediaFragmentParser {
// 5.1.1 Processing name-value components.
fn decode_octets(bytes: &[u8]) -> Vec<(Cow<str>, Cow<str>)> {
form_urlencoded::parse(bytes)
- .filter(|(key, _)| match key.as_bytes() {
- b"t" | b"track" | b"id" | b"xywh" => true,
- _ => false,
- })
+ .filter(|(key, _)| matches!(key.as_bytes(), b"t" | b"track" | b"id" | b"xywh"))
.collect()
}
@@ -239,10 +236,7 @@ fn split_url(s: &str) -> (&str, &str) {
}
fn is_byte_number(byte: u8) -> bool {
- match byte {
- 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 => true,
- _ => false,
- }
+ matches!(byte, 48..=57)
}
fn split_prefix(s: &str) -> (Option<&str>, &str) {
@@ -320,13 +314,13 @@ fn parse_hms(s: &str) -> Result<f64, ()> {
},
2 => hms_to_seconds(
0,
- parse_npt_minute(vec.pop_front().ok_or_else(|| ())?)?,
- parse_npt_seconds(vec.pop_front().ok_or_else(|| ())?)?,
+ parse_npt_minute(vec.pop_front().ok_or(())?)?,
+ parse_npt_seconds(vec.pop_front().ok_or(())?)?,
),
3 => hms_to_seconds(
vec.pop_front().ok_or_else(|| ())?.parse().map_err(|_| ())?,
- parse_npt_minute(vec.pop_front().ok_or_else(|| ())?)?,
- parse_npt_seconds(vec.pop_front().ok_or_else(|| ())?)?,
+ parse_npt_minute(vec.pop_front().ok_or(())?)?,
+ parse_npt_seconds(vec.pop_front().ok_or(())?)?,
),
_ => return Err(()),
};