clippy: Fix single_match warnings (#31876)

This commit is contained in:
Oluwatobi Sofela 2024-03-26 15:01:10 +01:00 committed by GitHub
parent d16f259e1d
commit b71de92569
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 115 additions and 133 deletions

View file

@ -354,11 +354,10 @@ impl AudioNodeMethods for AudioNode {
return Ok(());
}
match self.upcast::<EventTarget>().type_id() {
EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelSplitterNode) => {
if let EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelSplitterNode) =
self.upcast::<EventTarget>().type_id()
{
return Err(Error::InvalidState);
},
_ => (),
};
self.channel_interpretation.set(value);

View file

@ -741,13 +741,10 @@ fn parse_time_component(value: &str) -> Option<(u32, u32, f64)> {
if second_iterator.next()?.len() != 2 {
return None;
}
match second_iterator.next() {
Some(second_last) => {
if let Some(second_last) = second_iterator.next() {
if second_last.len() > 3 {
return None;
}
},
None => {},
}
second.parse::<f64>().ok()?

View file

@ -74,17 +74,14 @@ impl<'a> ProcessDataURL for &'a HTMLObjectElement {
// Makes the local `data` member match the status of the `data` attribute and starts
/// prefetching the image. This method must be called after `data` is changed.
fn process_data_url(&self) {
let elem = self.upcast::<Element>();
let element = self.upcast::<Element>();
// TODO: support other values
match (
elem.get_attribute(&ns!(), &local_name!("type")),
elem.get_attribute(&ns!(), &local_name!("data")),
if let (None, Some(_uri)) = (
element.get_attribute(&ns!(), &local_name!("type")),
element.get_attribute(&ns!(), &local_name!("data")),
) {
(None, Some(_uri)) => {
// TODO(gw): Prefetch the image here.
},
_ => {},
}
}
}

View file

@ -2981,8 +2981,7 @@ impl NodeMethods for Node {
// same owner element.
if let Some(node2) = node2 {
if Some(node2) == node1 {
match (attr1, attr2) {
(Some(a1), Some(a2)) => {
if let (Some(a1), Some(a2)) = (attr1, attr2) {
let attrs = node2.downcast::<Element>().unwrap().attrs();
// go through the attrs in order to see if self
// or other is first; spec is clear that we
@ -3006,8 +3005,6 @@ impl NodeMethods for Node {
// both attrs have node2 as their owner element, so
// we can't have left the loop without seeing them
unreachable!();
},
(_, _) => {},
}
}
}

View file

@ -200,8 +200,7 @@ impl RTCDataChannel {
}
pub fn on_state_change(&self, state: DataChannelState) {
match state {
DataChannelState::Closing => {
if let DataChannelState::Closing = state {
let event = Event::new(
&self.global(),
atom!("closing"),
@ -209,8 +208,6 @@ impl RTCDataChannel {
EventCancelable::NotCancelable,
);
event.upcast::<Event>().fire(self.upcast());
},
_ => {},
};
self.ready_state.set(state.into());
}

View file

@ -724,8 +724,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
.pipeline_id(Some(self.global().pipeline_id()));
// step 4 (second half)
match content_type {
Some(content_type) => {
if let Some(content_type) = content_type {
let encoding = match data {
Some(DocumentOrXMLHttpRequestBodyInit::String(_)) |
Some(DocumentOrXMLHttpRequestBodyInit::Document(_)) =>
@ -781,8 +780,6 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
}
}
}
},
_ => (),
}
self.fetch_time.set(time::now().to_timespec().sec);

View file

@ -2778,11 +2778,11 @@ impl ScriptThread {
Some(idx) => {
// https://html.spec.whatwg.org/multipage/#process-a-navigate-response
// 2. If response's status is 204 or 205, then abort these steps.
match metadata {
Some(Metadata {
if let Some(Metadata {
status: Some((204..=205, _)),
..
}) => {
}) = metadata
{
// If we have an existing window that is being navigated:
if let Some(window) = self.documents.borrow().find_window(*id) {
let window_proxy = window.window_proxy();
@ -2801,8 +2801,6 @@ impl ScriptThread {
.send((*id, ScriptMsg::AbortLoadUrl))
.unwrap();
return None;
},
_ => (),
};
let load = self.incomplete_loads.borrow_mut().remove(idx);