From e3d6b66d5fa0d6b076012d282012264906e55ea6 Mon Sep 17 00:00:00 2001 From: eri Date: Sat, 30 Mar 2024 11:06:26 +0100 Subject: [PATCH 1/3] clippy: Fix `match_like_matches` warnings (#31947) * clippy: Fix `match_like_matches` warnings * Fix link to custom element state in specification. --------- Co-authored-by: Martin Robinson --- components/script/dom/bindings/xmlname.rs | 6 +-- components/script/dom/crypto.rs | 18 ++++----- components/script/dom/element.rs | 40 ++++++++----------- .../script/dom/webgl_validations/types.rs | 5 +-- components/script/layout_dom/element.rs | 19 +++------ 5 files changed, 34 insertions(+), 54 deletions(-) diff --git a/components/script/dom/bindings/xmlname.rs b/components/script/dom/bindings/xmlname.rs index aac839f53fd..a4774e2b0f7 100644 --- a/components/script/dom/bindings/xmlname.rs +++ b/components/script/dom/bindings/xmlname.rs @@ -110,15 +110,13 @@ pub fn xml_name_type(name: &str) -> XMLName { fn is_valid_continuation(c: char) -> bool { is_valid_start(c) || - match c { + matches!(c, '-' | '.' | '0'..='9' | '\u{B7}' | '\u{300}'..='\u{36F}' | - '\u{203F}'..='\u{2040}' => true, - _ => false, - } + '\u{203F}'..='\u{2040}') } let mut iter = name.chars(); diff --git a/components/script/dom/crypto.rs b/components/script/dom/crypto.rs index 844b165865d..e5c441815f0 100644 --- a/components/script/dom/crypto.rs +++ b/components/script/dom/crypto.rs @@ -64,14 +64,14 @@ impl CryptoMethods for Crypto { } fn is_integer_buffer(array_type: Type) -> bool { - match array_type { + matches!( + array_type, Type::Uint8 | - Type::Uint8Clamped | - Type::Int8 | - Type::Uint16 | - Type::Int16 | - Type::Uint32 | - Type::Int32 => true, - _ => false, - } + Type::Uint8Clamped | + Type::Int8 | + Type::Uint16 | + Type::Int16 | + Type::Uint32 | + Type::Int32 + ) } diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index c86cb2e0a9f..f4e9b16d2f1 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -345,16 +345,17 @@ impl Element { self.is.borrow().clone() } + /// pub fn set_custom_element_state(&self, state: CustomElementState) { // no need to inflate rare data for uncustomized if state != CustomElementState::Uncustomized || self.rare_data().is_some() { self.ensure_rare_data().custom_element_state = state; } - // https://dom.spec.whatwg.org/#concept-element-defined - let in_defined_state = match state { - CustomElementState::Uncustomized | CustomElementState::Custom => true, - _ => false, - }; + + let in_defined_state = matches!( + state, + CustomElementState::Uncustomized | CustomElementState::Custom + ); self.set_state(ElementState::DEFINED, in_defined_state) } @@ -1393,21 +1394,18 @@ impl Element { } // , ,