aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/flow.rs
diff options
context:
space:
mode:
authoreri <eri@inventati.org>2024-03-11 11:24:36 +0100
committerGitHub <noreply@github.com>2024-03-11 10:24:36 +0000
commita6e25d555beec2c454c03f9ca0f5c4047d538b2d (patch)
tree2bf5504d7b8f3733072d39c6a6858f14694a0ca3 /components/layout/flow.rs
parent7f1ef4c7fe7d68b08894eb0e944448505178f79d (diff)
downloadservo-a6e25d555beec2c454c03f9ca0f5c4047d538b2d.tar.gz
servo-a6e25d555beec2c454c03f9ca0f5c4047d538b2d.zip
clippy: Fix warnings in `components/layout` (#31612)
* clippy: fix warnings in components/layout * fix: formatting
Diffstat (limited to 'components/layout/flow.rs')
-rw-r--r--components/layout/flow.rs67
1 files changed, 22 insertions, 45 deletions
diff --git a/components/layout/flow.rs b/components/layout/flow.rs
index 1f5b7104780..29152507c12 100644
--- a/components/layout/flow.rs
+++ b/components/layout/flow.rs
@@ -250,7 +250,7 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static {
fn collect_stacking_contexts(&mut self, state: &mut StackingContextCollectionState);
/// If this is a float, places it. The default implementation does nothing.
- fn place_float_if_applicable<'a>(&mut self) {}
+ fn place_float_if_applicable(&mut self) {}
/// Assigns block-sizes in-order; or, if this is a float, places the float. The default
/// implementation simply assigns block-sizes if this flow might have floats in. Returns true
@@ -505,6 +505,7 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static {
}
}
+#[allow(clippy::wrong_self_convention)]
pub trait ImmutableFlowUtils {
// Convenience functions
@@ -603,18 +604,18 @@ pub enum FlowClass {
impl FlowClass {
fn is_block_like(self) -> bool {
- match self {
+ matches!(
+ self,
FlowClass::Block |
- FlowClass::ListItem |
- FlowClass::Table |
- FlowClass::TableRowGroup |
- FlowClass::TableRow |
- FlowClass::TableCaption |
- FlowClass::TableCell |
- FlowClass::TableWrapper |
- FlowClass::Flex => true,
- _ => false,
- }
+ FlowClass::ListItem |
+ FlowClass::Table |
+ FlowClass::TableRowGroup |
+ FlowClass::TableRow |
+ FlowClass::TableCaption |
+ FlowClass::TableCell |
+ FlowClass::TableWrapper |
+ FlowClass::Flex
+ )
}
}
@@ -1232,50 +1233,32 @@ impl<'a> ImmutableFlowUtils for &'a dyn Flow {
/// Returns true if this flow is a table row flow.
fn is_table_row(self) -> bool {
- match self.class() {
- FlowClass::TableRow => true,
- _ => false,
- }
+ matches!(self.class(), FlowClass::TableRow)
}
/// Returns true if this flow is a table cell flow.
fn is_table_cell(self) -> bool {
- match self.class() {
- FlowClass::TableCell => true,
- _ => false,
- }
+ matches!(self.class(), FlowClass::TableCell)
}
/// Returns true if this flow is a table colgroup flow.
fn is_table_colgroup(self) -> bool {
- match self.class() {
- FlowClass::TableColGroup => true,
- _ => false,
- }
+ matches!(self.class(), FlowClass::TableColGroup)
}
/// Returns true if this flow is a table flow.
fn is_table(self) -> bool {
- match self.class() {
- FlowClass::Table => true,
- _ => false,
- }
+ matches!(self.class(), FlowClass::Table)
}
/// Returns true if this flow is a table caption flow.
fn is_table_caption(self) -> bool {
- match self.class() {
- FlowClass::TableCaption => true,
- _ => false,
- }
+ matches!(self.class(), FlowClass::TableCaption)
}
/// Returns true if this flow is a table rowgroup flow.
fn is_table_rowgroup(self) -> bool {
- match self.class() {
- FlowClass::TableRowGroup => true,
- _ => false,
- }
+ matches!(self.class(), FlowClass::TableRowGroup)
}
/// Returns the number of children that this flow possesses.
@@ -1285,18 +1268,12 @@ impl<'a> ImmutableFlowUtils for &'a dyn Flow {
/// Returns true if this flow is a block flow.
fn is_block_flow(self) -> bool {
- match self.class() {
- FlowClass::Block => true,
- _ => false,
- }
+ matches!(self.class(), FlowClass::Block)
}
/// Returns true if this flow is an inline flow.
fn is_inline_flow(self) -> bool {
- match self.class() {
- FlowClass::Inline => true,
- _ => false,
- }
+ matches!(self.class(), FlowClass::Inline)
}
/// Dumps the flow tree for debugging.
@@ -1392,7 +1369,7 @@ impl MutableOwnedFlowUtils for FlowRef {
for descendant_link in abs_descendants.descendant_links.iter_mut() {
// TODO(servo#30573) revert to debug_assert!() once underlying bug is fixed
#[cfg(debug_assertions)]
- if !(!descendant_link.has_reached_containing_block) {
+ if descendant_link.has_reached_containing_block {
log::warn!("debug assertion failed! !descendant_link.has_reached_containing_block");
}
let descendant_base = FlowRef::deref_mut(&mut descendant_link.flow).mut_base();