diff options
author | komuhangi <51232461+jahielkomu@users.noreply.github.com> | 2024-04-10 10:50:01 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-10 07:50:01 +0000 |
commit | 89a48205197a059c05f1ec6f07c14d82fb94d16b (patch) | |
tree | 47dcc5005d8199171aaf4fbed5138bdd1961fc21 /components | |
parent | 245269c64942f88bdd26d5962adc5440f2751aa3 (diff) | |
download | servo-89a48205197a059c05f1ec6f07c14d82fb94d16b.tar.gz servo-89a48205197a059c05f1ec6f07c14d82fb94d16b.zip |
Fixed some clippy warnings in components (#32025)
* Fixed some clippy warnings in components
* Updated the simplification of bolean expressions in componets/script/dom/range.rs
Diffstat (limited to 'components')
-rw-r--r-- | components/script/dom/range.rs | 14 | ||||
-rw-r--r-- | components/script/dom/rtcicecandidate.rs | 6 | ||||
-rw-r--r-- | components/script/dom/rtcpeerconnection.rs | 6 | ||||
-rw-r--r-- | components/script/dom/windowproxy.rs | 2 | ||||
-rw-r--r-- | components/script/dom/xmlhttprequest.rs | 3 | ||||
-rw-r--r-- | components/script/script_module.rs | 2 |
6 files changed, 15 insertions, 18 deletions
diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index fa7d14795d3..3f6b274e958 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -1021,11 +1021,11 @@ impl RangeMethods for Range { // Step 4. let ancestor = self.CommonAncestorContainer(); - let mut iter = start_node + let iter = start_node .following_nodes(&ancestor) .filter_map(DomRoot::downcast::<Text>); - while let Some(child) = iter.next() { + for child in iter { if self.contains(child.upcast()) { s.push_str(&child.upcast::<CharacterData>().Data()); } @@ -1189,9 +1189,8 @@ impl WeakRangeVec { let move_start = node_is_start && range.start_offset() == offset; let move_end = node_is_end && range.end_offset() == offset; - let remove_from_node = move_start && move_end || - move_start && !node_is_end || - move_end && !node_is_start; + let remove_from_node = + move_start && (move_end || !node_is_end) || move_end && !node_is_start; let already_in_child = range.start().node() == child || range.end().node() == child; let push_to_child = !already_in_child && (move_start || move_end); @@ -1252,9 +1251,8 @@ impl WeakRangeVec { let move_start = node_is_start && start_offset > offset; let move_end = node_is_end && end_offset > offset; - let remove_from_node = move_start && move_end || - move_start && !node_is_end || - move_end && !node_is_start; + let remove_from_node = + move_start && (move_end || !node_is_end) || move_end && !node_is_start; let already_in_sibling = range.start().node() == sibling || range.end().node() == sibling; diff --git a/components/script/dom/rtcicecandidate.rs b/components/script/dom/rtcicecandidate.rs index de49a539c1a..9bb9efd7fea 100644 --- a/components/script/dom/rtcicecandidate.rs +++ b/components/script/dom/rtcicecandidate.rs @@ -84,9 +84,9 @@ impl RTCIceCandidate { config: &RTCIceCandidateInit, ) -> Fallible<DomRoot<RTCIceCandidate>> { if config.sdpMid.is_none() && config.sdpMLineIndex.is_none() { - return Err(Error::Type(format!( - "one of sdpMid and sdpMLineIndex must be set" - ))); + return Err(Error::Type( + "one of sdpMid and sdpMLineIndex must be set".to_string(), + )); } Ok(RTCIceCandidate::new_with_proto( &window.global(), diff --git a/components/script/dom/rtcpeerconnection.rs b/components/script/dom/rtcpeerconnection.rs index b14badaabf9..72b399b860c 100644 --- a/components/script/dom/rtcpeerconnection.rs +++ b/components/script/dom/rtcpeerconnection.rs @@ -565,9 +565,9 @@ impl RTCPeerConnectionMethods for RTCPeerConnection { // XXXManishearth add support for sdpMid if candidate.sdpMLineIndex.is_none() { - p.reject_error(Error::Type(format!( - "servo only supports sdpMLineIndex right now" - ))); + p.reject_error(Error::Type( + "servo only supports sdpMLineIndex right now".to_string(), + )); return p; } diff --git a/components/script/dom/windowproxy.rs b/components/script/dom/windowproxy.rs index a8c32bb11a9..495de9bc5aa 100644 --- a/components/script/dom/windowproxy.rs +++ b/components/script/dom/windowproxy.rs @@ -291,7 +291,7 @@ impl WindowProxy { .currently_active .get() .and_then(ScriptThread::find_document) - .and_then(|doc| Some(DomRoot::from_ref(doc.window()))) + .map(|doc| DomRoot::from_ref(doc.window())) .unwrap(); let msg = EmbedderMsg::AllowOpeningWebView(chan); window.send_to_embedder(msg); diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index f9ba44d560f..e9966f22774 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -1616,13 +1616,12 @@ impl XMLHttpRequest { /// <https://xhr.spec.whatwg.org/#response-mime-type> fn response_mime_type(&self) -> Option<Mime> { return extract_mime_type(&self.response_headers.borrow()) - .map(|mime_as_bytes| { + .and_then(|mime_as_bytes| { String::from_utf8(mime_as_bytes) .unwrap_or_default() .parse() .ok() }) - .flatten() .or(Some(mime::TEXT_XML)); } diff --git a/components/script/script_module.rs b/components/script/script_module.rs index 0a220e7c8bb..d036eadcda1 100644 --- a/components/script/script_module.rs +++ b/components/script/script_module.rs @@ -1314,7 +1314,7 @@ impl ScriptFetchOptions { } #[allow(unsafe_code)] -unsafe fn module_script_from_reference_private<'a>( +unsafe fn module_script_from_reference_private( reference_private: &RawHandle<JSVal>, ) -> Option<&ModuleScript> { if reference_private.get().is_undefined() { |