aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEkta Siwach <137225906+ektuu@users.noreply.github.com>2024-03-27 02:55:42 +0530
committerGitHub <noreply@github.com>2024-03-26 21:25:42 +0000
commit92b557867c199472ce42a2f5b99676c485ed2ae1 (patch)
treeee8858794b4d7dfe025e1e61c5cf84a0207b63f5
parent8dece05980a4ec46b06505e511f8b158d4c0fe3b (diff)
downloadservo-92b557867c199472ce42a2f5b99676c485ed2ae1.tar.gz
servo-92b557867c199472ce42a2f5b99676c485ed2ae1.zip
clippy: fixed some warnings in components/script (#31888)
-rw-r--r--components/script/devtools.rs2
-rw-r--r--components/script/document_loader.rs7
-rw-r--r--components/script/dom/abstractrange.rs2
-rw-r--r--components/script/dom/customelementregistry.rs28
-rw-r--r--components/script/dom/event.rs2
-rw-r--r--components/script/dom/eventsource.rs2
-rw-r--r--components/script/dom/fakexrinputcontroller.rs6
-rw-r--r--components/script/dom/file.rs6
-rw-r--r--components/script/dom/formdata.rs10
-rwxr-xr-xcomponents/script/dom/htmltextareaelement.rs10
-rw-r--r--components/script/dom/htmltitleelement.rs4
11 files changed, 39 insertions, 40 deletions
diff --git a/components/script/devtools.rs b/components/script/devtools.rs
index bd15db39712..d83e9fecdc6 100644
--- a/components/script/devtools.rs
+++ b/components/script/devtools.rs
@@ -123,7 +123,7 @@ pub fn handle_get_children(
reply: IpcSender<Option<Vec<NodeInfo>>>,
) {
match find_node_by_unique_id(documents, pipeline, &node_id) {
- None => return reply.send(None).unwrap(),
+ None => reply.send(None).unwrap(),
Some(parent) => {
let children = parent.children().map(|child| child.summarize()).collect();
diff --git a/components/script/document_loader.rs b/components/script/document_loader.rs
index 122b732cd65..2d369697303 100644
--- a/components/script/document_loader.rs
+++ b/components/script/document_loader.rs
@@ -164,10 +164,9 @@ impl DocumentLoader {
}
pub fn is_only_blocked_by_iframes(&self) -> bool {
- self.blocking_loads.iter().all(|load| match *load {
- LoadType::Subframe(_) => true,
- _ => false,
- })
+ self.blocking_loads
+ .iter()
+ .all(|load| matches!(*load, LoadType::Subframe(_)))
}
pub fn inhibit_events(&mut self) {
diff --git a/components/script/dom/abstractrange.rs b/components/script/dom/abstractrange.rs
index a39b67b1807..f4f86566f41 100644
--- a/components/script/dom/abstractrange.rs
+++ b/components/script/dom/abstractrange.rs
@@ -142,7 +142,7 @@ impl PartialEq for BoundaryPoint {
/// <https://dom.spec.whatwg.org/#concept-range-bp-position>
pub fn bp_position(a_node: &Node, a_offset: u32, b_node: &Node, b_offset: u32) -> Option<Ordering> {
- if a_node as *const Node == b_node as *const Node {
+ if std::ptr::eq(a_node, b_node) {
// Step 1.
return Some(a_offset.cmp(&b_offset));
}
diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs
index fb530fdc6b1..d47efab3b2f 100644
--- a/components/script/dom/customelementregistry.rs
+++ b/components/script/dom/customelementregistry.rs
@@ -1035,7 +1035,7 @@ pub fn is_valid_custom_element_name(name: &str) -> bool {
// PotentialCustomElementName ::= [a-z] (PCENChar)* '-' (PCENChar)*
let mut chars = name.chars();
- if !chars.next().map_or(false, |c| c >= 'a' && c <= 'z') {
+ if !chars.next().map_or(false, |c| ('a'..='z').contains(&c)) {
return false;
}
@@ -1078,19 +1078,19 @@ fn is_potential_custom_element_char(c: char) -> bool {
c == '.' ||
c == '_' ||
c == '\u{B7}' ||
- (c >= '0' && c <= '9') ||
- (c >= 'a' && c <= 'z') ||
- (c >= '\u{C0}' && c <= '\u{D6}') ||
- (c >= '\u{D8}' && c <= '\u{F6}') ||
- (c >= '\u{F8}' && c <= '\u{37D}') ||
- (c >= '\u{37F}' && c <= '\u{1FFF}') ||
- (c >= '\u{200C}' && c <= '\u{200D}') ||
- (c >= '\u{203F}' && c <= '\u{2040}') ||
- (c >= '\u{2070}' && c <= '\u{2FEF}') ||
- (c >= '\u{3001}' && c <= '\u{D7FF}') ||
- (c >= '\u{F900}' && c <= '\u{FDCF}') ||
- (c >= '\u{FDF0}' && c <= '\u{FFFD}') ||
- (c >= '\u{10000}' && c <= '\u{EFFFF}')
+ ('0'..='9').contains(&c) ||
+ ('a'..='z').contains(&c) ||
+ ('\u{C0}'..='\u{D6}').contains(&c) ||
+ ('\u{D8}'..='\u{F6}').contains(&c) ||
+ ('\u{F8}'..='\u{37D}').contains(&c) ||
+ ('\u{37F}'..='\u{1FFF}').contains(&c) ||
+ ('\u{200C}'..='\u{200D}').contains(&c) ||
+ ('\u{203F}'..='\u{2040}').contains(&c) ||
+ ('\u{2070}'..='\u{2FEF}').contains(&c) ||
+ ('\u{3001}'..='\u{D7FF}').contains(&c) ||
+ ('\u{F900}'..='\u{FDCF}').contains(&c) ||
+ ('\u{FDF0}'..='\u{FFFD}').contains(&c) ||
+ ('\u{10000}'..='\u{EFFFF}').contains(&c)
}
fn is_extendable_element_interface(element: &str) -> bool {
diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs
index 24c74241e9c..44eca46b0f7 100644
--- a/components/script/dom/event.rs
+++ b/components/script/dom/event.rs
@@ -741,7 +741,7 @@ fn inner_invoke(
// Step 2.12
if let Some(window) = global.downcast::<Window>() {
- window.set_current_event(current_event.as_ref().map(|e| &**e));
+ window.set_current_event(current_event.as_deref());
}
// Step 2.13: short-circuit instead of going to next listener
diff --git a/components/script/dom/eventsource.rs b/components/script/dom/eventsource.rs
index 29186846d2a..11e523eb47d 100644
--- a/components/script/dom/eventsource.rs
+++ b/components/script/dom/eventsource.rs
@@ -414,7 +414,7 @@ impl FetchResponseListener for EventSourceContext {
}
fn process_response_eof(&mut self, _response: Result<ResourceFetchTiming, NetworkError>) {
- if let Some(_) = self.incomplete_utf8.take() {
+ if self.incomplete_utf8.take().is_some() {
self.parse("\u{FFFD}".chars());
}
self.reestablish_the_connection();
diff --git a/components/script/dom/fakexrinputcontroller.rs b/components/script/dom/fakexrinputcontroller.rs
index 0de0493d1f9..66be60f744d 100644
--- a/components/script/dom/fakexrinputcontroller.rs
+++ b/components/script/dom/fakexrinputcontroller.rs
@@ -117,7 +117,7 @@ impl FakeXRInputControllerMethods for FakeXRInputController {
XRHandedness::Left => Handedness::Left,
XRHandedness::Right => Handedness::Right,
};
- let _ = self.send_message(MockInputMsg::SetHandedness(h));
+ self.send_message(MockInputMsg::SetHandedness(h));
}
/// <https://immersive-web.github.io/webxr-test-api/#dom-fakexrinputcontroller-settargetraymode>
@@ -127,12 +127,12 @@ impl FakeXRInputControllerMethods for FakeXRInputController {
XRTargetRayMode::Tracked_pointer => TargetRayMode::TrackedPointer,
XRTargetRayMode::Screen => TargetRayMode::Screen,
};
- let _ = self.send_message(MockInputMsg::SetTargetRayMode(t));
+ self.send_message(MockInputMsg::SetTargetRayMode(t));
}
/// <https://immersive-web.github.io/webxr-test-api/#dom-fakexrinputcontroller-setprofiles>
fn SetProfiles(&self, profiles: Vec<DOMString>) {
let t = profiles.into_iter().map(String::from).collect();
- let _ = self.send_message(MockInputMsg::SetProfiles(t));
+ self.send_message(MockInputMsg::SetProfiles(t));
}
}
diff --git a/components/script/dom/file.rs b/components/script/dom/file.rs
index e4c8e0dea75..1ba6ade0a6a 100644
--- a/components/script/dom/file.rs
+++ b/components/script/dom/file.rs
@@ -105,13 +105,13 @@ impl File {
Err(_) => return Err(Error::InvalidCharacter),
};
- let ref blobPropertyBag = filePropertyBag.parent;
+ let blobPropertyBag = &filePropertyBag.parent;
let modified = filePropertyBag.lastModified;
// NOTE: Following behaviour might be removed in future,
// see https://github.com/w3c/FileAPI/issues/41
- let replaced_filename = DOMString::from_string(filename.replace("/", ":"));
- let type_string = normalize_type_string(&blobPropertyBag.type_.to_string());
+ let replaced_filename = DOMString::from_string(filename.replace('/', ":"));
+ let type_string = normalize_type_string(blobPropertyBag.type_.as_ref());
Ok(File::new_with_proto(
global,
proto,
diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs
index c23d540b0c8..f8b657b782b 100644
--- a/components/script/dom/formdata.rs
+++ b/components/script/dom/formdata.rs
@@ -110,7 +110,7 @@ impl FormDataMethods for FormData {
fn Delete(&self, name: USVString) {
self.data
.borrow_mut()
- .retain(|(datum_name, _)| datum_name.0 != LocalName::from(name.0.clone()));
+ .retain(|(datum_name, _)| datum_name.0 != name.0);
}
// https://xhr.spec.whatwg.org/#dom-formdata-get
@@ -118,7 +118,7 @@ impl FormDataMethods for FormData {
self.data
.borrow()
.iter()
- .filter(|(datum_name, _)| datum_name.0 == LocalName::from(name.0.clone()))
+ .filter(|(datum_name, _)| datum_name.0 == name.0)
.next()
.map(|(_, datum)| match &datum.value {
FormDatumValue::String(ref s) => {
@@ -134,7 +134,7 @@ impl FormDataMethods for FormData {
.borrow()
.iter()
.filter_map(|(datum_name, datum)| {
- if datum_name.0 != LocalName::from(name.0.clone()) {
+ if datum_name.0 != name.0 {
return None;
}
@@ -153,7 +153,7 @@ impl FormDataMethods for FormData {
self.data
.borrow()
.iter()
- .any(|(datum_name, _0)| datum_name.0 == LocalName::from(name.0.clone()))
+ .any(|(datum_name, _0)| datum_name.0 == name.0)
}
// https://xhr.spec.whatwg.org/#dom-formdata-set
@@ -211,7 +211,7 @@ impl FormData {
},
};
- let bytes = blob.get_bytes().unwrap_or(vec![]);
+ let bytes = blob.get_bytes().unwrap_or_default();
File::new(
&self.global(),
diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs
index e92b95f5cff..01332823ae4 100755
--- a/components/script/dom/htmltextareaelement.rs
+++ b/components/script/dom/htmltextareaelement.rs
@@ -100,7 +100,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutDom<'_, HTMLTextAreaElement> {
// placeholder is single line, but that's an unimportant detail.
self.placeholder()
.replace("\r\n", "\n")
- .replace("\r", "\n")
+ .replace('\r', "\n")
.into()
} else {
text.into()
@@ -545,7 +545,7 @@ impl VirtualMethods for HTMLTextAreaElement {
}
fn bind_to_tree(&self, context: &BindContext) {
- if let Some(ref s) = self.super_type() {
+ if let Some(s) = self.super_type() {
s.bind_to_tree(context);
}
@@ -599,7 +599,7 @@ impl VirtualMethods for HTMLTextAreaElement {
maybe_doc: Option<&Document>,
clone_children: CloneChildrenFlag,
) {
- if let Some(ref s) = self.super_type() {
+ if let Some(s) = self.super_type() {
s.cloning_steps(copy, maybe_doc, clone_children);
}
let el = copy.downcast::<HTMLTextAreaElement>().unwrap();
@@ -613,7 +613,7 @@ impl VirtualMethods for HTMLTextAreaElement {
}
fn children_changed(&self, mutation: &ChildrenMutation) {
- if let Some(ref s) = self.super_type() {
+ if let Some(s) = self.super_type() {
s.children_changed(mutation);
}
if !self.value_dirty.get() {
@@ -702,7 +702,7 @@ impl FormControl for HTMLTextAreaElement {
self.form_owner.set(form);
}
- fn to_element<'a>(&'a self) -> &'a Element {
+ fn to_element(&self) -> &Element {
self.upcast::<Element>()
}
}
diff --git a/components/script/dom/htmltitleelement.rs b/components/script/dom/htmltitleelement.rs
index 2c308c6c77a..abc16d0d037 100644
--- a/components/script/dom/htmltitleelement.rs
+++ b/components/script/dom/htmltitleelement.rs
@@ -67,7 +67,7 @@ impl VirtualMethods for HTMLTitleElement {
}
fn children_changed(&self, mutation: &ChildrenMutation) {
- if let Some(ref s) = self.super_type() {
+ if let Some(s) = self.super_type() {
s.children_changed(mutation);
}
let node = self.upcast::<Node>();
@@ -77,7 +77,7 @@ impl VirtualMethods for HTMLTitleElement {
}
fn bind_to_tree(&self, context: &BindContext) {
- if let Some(ref s) = self.super_type() {
+ if let Some(s) = self.super_type() {
s.bind_to_tree(context);
}
let node = self.upcast::<Node>();