mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
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 <mrobinson@igalia.com>
This commit is contained in:
parent
92d9081366
commit
e3d6b66d5f
5 changed files with 34 additions and 54 deletions
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
)
|
||||
}
|
||||
|
|
|
@ -345,16 +345,17 @@ impl Element {
|
|||
self.is.borrow().clone()
|
||||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#concept-element-custom-element-state>
|
||||
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 {
|
|||
}
|
||||
|
||||
// <a>, <input>, <select>, and <textrea> are inherently focusable.
|
||||
match node.type_id() {
|
||||
matches!(
|
||||
node.type_id(),
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
HTMLElementTypeId::HTMLAnchorElement,
|
||||
)) |
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
)) | NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
HTMLElementTypeId::HTMLInputElement,
|
||||
)) |
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
)) | NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
HTMLElementTypeId::HTMLSelectElement,
|
||||
)) |
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
)) | NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
HTMLElementTypeId::HTMLTextAreaElement,
|
||||
)) => true,
|
||||
_ => false,
|
||||
}
|
||||
))
|
||||
)
|
||||
}
|
||||
|
||||
pub fn is_actually_disabled(&self) -> bool {
|
||||
|
@ -1493,7 +1491,7 @@ impl Element {
|
|||
.map(|js| DomRoot::from_ref(&**js))
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
|
||||
/// <https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name>
|
||||
pub fn get_attribute_by_name(&self, name: DOMString) -> Option<DomRoot<Attr>> {
|
||||
let name = &self.parsed_name(name);
|
||||
let maybe_attribute = self
|
||||
|
@ -1506,10 +1504,7 @@ impl Element {
|
|||
if *name == local_name!("id") || *name == local_name!("name") {
|
||||
match maybe_attr {
|
||||
None => true,
|
||||
Some(ref attr) => match *attr.value() {
|
||||
AttrValue::Atom(_) => true,
|
||||
_ => false,
|
||||
},
|
||||
Some(ref attr) => matches!(*attr.value(), AttrValue::Atom(_)),
|
||||
}
|
||||
} else {
|
||||
true
|
||||
|
@ -2932,10 +2927,7 @@ impl VirtualMethods for Element {
|
|||
//
|
||||
// Juggle a bit to keep the borrow checker happy
|
||||
// while avoiding the extra clone.
|
||||
let is_declaration = match *attr.value() {
|
||||
AttrValue::Declaration(..) => true,
|
||||
_ => false,
|
||||
};
|
||||
let is_declaration = matches!(*attr.value(), AttrValue::Declaration(..));
|
||||
|
||||
let block = if is_declaration {
|
||||
let mut value = AttrValue::String(String::new());
|
||||
|
|
|
@ -24,10 +24,7 @@ gl_enums! {
|
|||
|
||||
impl TexImageTarget {
|
||||
pub fn is_cubic(&self) -> bool {
|
||||
match *self {
|
||||
TexImageTarget::Texture2D => false,
|
||||
_ => true,
|
||||
}
|
||||
!matches!(*self, TexImageTarget::Texture2D)
|
||||
}
|
||||
|
||||
pub fn dimensions(self) -> u8 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue