clippy: Fix collapsible_else_if warnings (#31853)

This commit is contained in:
Oluwatobi Sofela 2024-03-26 10:15:04 +01:00 committed by GitHub
parent d814d05539
commit f8a2eaea47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 37 additions and 52 deletions

View file

@ -579,8 +579,7 @@ impl EventTarget {
Some(CommonEventHandler::ErrorEventHandler(unsafe { Some(CommonEventHandler::ErrorEventHandler(unsafe {
OnErrorEventHandlerNonNull::new(cx, funobj) OnErrorEventHandlerNonNull::new(cx, funobj)
})) }))
} else { } else if ty == &atom!("beforeunload") {
if ty == &atom!("beforeunload") {
Some(CommonEventHandler::BeforeUnloadEventHandler(unsafe { Some(CommonEventHandler::BeforeUnloadEventHandler(unsafe {
OnBeforeUnloadEventHandlerNonNull::new(cx, funobj) OnBeforeUnloadEventHandlerNonNull::new(cx, funobj)
})) }))
@ -590,7 +589,6 @@ impl EventTarget {
})) }))
} }
} }
}
#[allow(unsafe_code)] #[allow(unsafe_code)]
pub fn set_event_handler_common<T: CallbackContainer>(&self, ty: &str, listener: Option<Rc<T>>) pub fn set_event_handler_common<T: CallbackContainer>(&self, ty: &str, listener: Option<Rc<T>>)

View file

@ -210,12 +210,10 @@ impl GPUDevice {
} }
} }
self.try_remove_scope(s_id); self.try_remove_scope(s_id);
} else { } else if let Err((err, _)) = result {
if let Err((err, _)) = result {
self.fire_uncaptured_error(err); self.fire_uncaptured_error(err);
} }
} }
}
fn handle_error(&self, scope: ErrorScopeId, error: GPUError) { fn handle_error(&self, scope: ErrorScopeId, error: GPUError) {
let mut context = self.scope_context.borrow_mut(); let mut context = self.scope_context.borrow_mut();

View file

@ -578,8 +578,8 @@ impl HTMLFormElementMethods for HTMLFormElement {
} else { } else {
a.source.cmp(&b.source) a.source.cmp(&b.source)
} }
} else { } else if a
if a.element .element
.upcast::<Node>() .upcast::<Node>()
.CompareDocumentPosition(b.element.upcast::<Node>()) & .CompareDocumentPosition(b.element.upcast::<Node>()) &
NodeConstants::DOCUMENT_POSITION_FOLLOWING == NodeConstants::DOCUMENT_POSITION_FOLLOWING ==
@ -589,7 +589,6 @@ impl HTMLFormElementMethods for HTMLFormElement {
} else { } else {
std::cmp::Ordering::Greater std::cmp::Ordering::Greater
} }
}
}); });
// Step 6 // Step 6

View file

@ -2868,14 +2868,12 @@ fn filter_from_accept(s: &DOMString) -> Vec<FilterPattern> {
for p in split_commas(s) { for p in split_commas(s) {
if let Some('.') = p.chars().nth(0) { if let Some('.') = p.chars().nth(0) {
filter.push(FilterPattern(p[1..].to_string())); filter.push(FilterPattern(p[1..].to_string()));
} else { } else if let Some(exts) = mime_guess::get_mime_extensions_str(p) {
if let Some(exts) = mime_guess::get_mime_extensions_str(p) {
for ext in exts { for ext in exts {
filter.push(FilterPattern(ext.to_string())); filter.push(FilterPattern(ext.to_string()));
} }
} }
} }
}
filter filter
} }

View file

@ -167,14 +167,12 @@ impl HTMLSelectElement {
if let Some(last_selected) = last_selected { if let Some(last_selected) = last_selected {
last_selected.set_selectedness(true); last_selected.set_selectedness(true);
} else { } else if self.display_size() == 1 {
if self.display_size() == 1 {
if let Some(first_enabled) = first_enabled { if let Some(first_enabled) = first_enabled {
first_enabled.set_selectedness(true); first_enabled.set_selectedness(true);
} }
} }
} }
}
pub fn push_form_data(&self, data_set: &mut Vec<FormDatum>) { pub fn push_form_data(&self, data_set: &mut Vec<FormDatum>) {
if self.Name().is_empty() { if self.Name().is_empty() {

View file

@ -92,13 +92,11 @@ impl StylePropertyMapReadOnlyMethods for StylePropertyMapReadOnly {
} else { } else {
Ordering::Greater Ordering::Greater
} }
} else { } else if let Ok(_) = custom_properties::parse_name(key2) {
if let Ok(_) = custom_properties::parse_name(key2) {
Ordering::Less Ordering::Less
} else { } else {
key1.cmp(key2) key1.cmp(key2)
} }
}
}); });
result result
} }

View file

@ -82,14 +82,12 @@ impl<'dom, LayoutDataType: LayoutDataTrait> fmt::Debug for ServoLayoutNode<'dom,
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(el) = self.as_element() { if let Some(el) = self.as_element() {
el.fmt(f) el.fmt(f)
} else { } else if self.is_text_node() {
if self.is_text_node() {
write!(f, "<text node> ({:#x})", self.opaque().0) write!(f, "<text node> ({:#x})", self.opaque().0)
} else { } else {
write!(f, "<non-text node> ({:#x})", self.opaque().0) write!(f, "<non-text node> ({:#x})", self.opaque().0)
} }
} }
}
} }
impl<'dom, LayoutDataType: LayoutDataTrait> ServoLayoutNode<'dom, LayoutDataType> { impl<'dom, LayoutDataType: LayoutDataTrait> ServoLayoutNode<'dom, LayoutDataType> {

View file

@ -627,8 +627,7 @@ impl<T: ClipboardProvider> TextInput<T> {
if self.selection_origin.is_none() { if self.selection_origin.is_none() {
self.selection_origin = Some(self.edit_point); self.selection_origin = Some(self.edit_point);
} }
} else { } else if self.has_selection() {
if self.has_selection() {
self.edit_point = match adjust { self.edit_point = match adjust {
Direction::Backward => self.selection_start(), Direction::Backward => self.selection_start(),
Direction::Forward => self.selection_end(), Direction::Forward => self.selection_end(),
@ -636,7 +635,6 @@ impl<T: ClipboardProvider> TextInput<T> {
self.clear_selection(); self.clear_selection();
return true; return true;
} }
}
false false
} }