From 3ddb47e902901514285c89f9a3b53581ca750933 Mon Sep 17 00:00:00 2001 From: Rosemary Ajayi Date: Thu, 28 Mar 2024 12:26:39 +0100 Subject: [PATCH] clippy: Fix more clippy warnings in `components/scripts/dom` (#31914) * refrence to a reference * refrence to a reference --- components/script/dom/urlsearchparams.rs | 2 +- components/script/dom/vertexarrayobject.rs | 2 +- components/script/dom/virtualmethods.rs | 14 +++++++------- components/script/dom/windowproxy.rs | 2 +- components/script/dom/worker.rs | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/components/script/dom/urlsearchparams.rs b/components/script/dom/urlsearchparams.rs index 4320b99c3a2..c1584ae94c5 100644 --- a/components/script/dom/urlsearchparams.rs +++ b/components/script/dom/urlsearchparams.rs @@ -131,7 +131,7 @@ impl URLSearchParamsMethods for URLSearchParams { let list = self.list.borrow(); list.iter() .find(|&kv| kv.0 == name.0) - .map(|ref kv| USVString(kv.1.clone())) + .map(|kv| USVString(kv.1.clone())) } // https://url.spec.whatwg.org/#dom-urlsearchparams-getall diff --git a/components/script/dom/vertexarrayobject.rs b/components/script/dom/vertexarrayobject.rs index b205df7358e..08ce5fb9854 100644 --- a/components/script/dom/vertexarrayobject.rs +++ b/components/script/dom/vertexarrayobject.rs @@ -293,7 +293,7 @@ impl Default for VertexAttribData { impl VertexAttribData { pub fn buffer(&self) -> Option<&WebGLBuffer> { - self.buffer.as_ref().map(|b| &**b) + self.buffer.as_deref() } pub fn max_vertices(&self) -> u32 { diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index 33074127860..26cee31d302 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -86,7 +86,7 @@ pub trait VirtualMethods { /// on this element. fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { match self.super_type() { - Some(ref s) => s.parse_plain_attribute(name, value), + Some(s) => s.parse_plain_attribute(name, value), _ => AttrValue::String(value.into()), } } @@ -94,7 +94,7 @@ pub trait VirtualMethods { /// Called when a Node is appended to a tree, where 'tree_connected' indicates /// whether the tree is part of a Document. 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); } } @@ -104,14 +104,14 @@ pub trait VirtualMethods { /// Implements removing steps: /// fn unbind_from_tree(&self, context: &UnbindContext) { - if let Some(ref s) = self.super_type() { + if let Some(s) = self.super_type() { s.unbind_from_tree(context); } } /// Called on the parent when its children are changed. 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); } } @@ -125,7 +125,7 @@ pub trait VirtualMethods { /// fn adopting_steps(&self, old_doc: &Document) { - if let Some(ref s) = self.super_type() { + if let Some(s) = self.super_type() { s.adopting_steps(old_doc); } } @@ -137,7 +137,7 @@ pub trait VirtualMethods { 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); } } @@ -145,7 +145,7 @@ pub trait VirtualMethods { /// Called on an element when it is popped off the stack of open elements /// of a parser. fn pop(&self) { - if let Some(ref s) = self.super_type() { + if let Some(s) = self.super_type() { s.pop(); } } diff --git a/components/script/dom/windowproxy.rs b/components/script/dom/windowproxy.rs index 25bcdfca00e..905368d0263 100644 --- a/components/script/dom/windowproxy.rs +++ b/components/script/dom/windowproxy.rs @@ -831,7 +831,7 @@ fn tokenize_open_features(features: DOMString) -> IndexMap { fn parse_open_feature_boolean(tokenized_features: &IndexMap, name: &str) -> bool { if let Some(value) = tokenized_features.get(name) { // Step 1 & 2 - if value == "" || value == "yes" { + if value.is_empty() || value == "yes" { return true; } // Step 3 & 4 diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 33c5922de85..2ea9b3e497c 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -118,7 +118,7 @@ impl Worker { let (devtools_sender, devtools_receiver) = ipc::channel().unwrap(); let worker_id = WorkerId(Uuid::new_v4()); - if let Some(ref chan) = global.devtools_chan() { + if let Some(chan) = global.devtools_chan() { let pipeline_id = global.pipeline_id(); let title = format!("Worker for {}", worker_url); if let Some(browsing_context) = browsing_context {