mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +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 {
|
fn is_valid_continuation(c: char) -> bool {
|
||||||
is_valid_start(c) ||
|
is_valid_start(c) ||
|
||||||
match c {
|
matches!(c,
|
||||||
'-' |
|
'-' |
|
||||||
'.' |
|
'.' |
|
||||||
'0'..='9' |
|
'0'..='9' |
|
||||||
'\u{B7}' |
|
'\u{B7}' |
|
||||||
'\u{300}'..='\u{36F}' |
|
'\u{300}'..='\u{36F}' |
|
||||||
'\u{203F}'..='\u{2040}' => true,
|
'\u{203F}'..='\u{2040}')
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut iter = name.chars();
|
let mut iter = name.chars();
|
||||||
|
|
|
@ -64,14 +64,14 @@ impl CryptoMethods for Crypto {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_integer_buffer(array_type: Type) -> bool {
|
fn is_integer_buffer(array_type: Type) -> bool {
|
||||||
match array_type {
|
matches!(
|
||||||
|
array_type,
|
||||||
Type::Uint8 |
|
Type::Uint8 |
|
||||||
Type::Uint8Clamped |
|
Type::Uint8Clamped |
|
||||||
Type::Int8 |
|
Type::Int8 |
|
||||||
Type::Uint16 |
|
Type::Uint16 |
|
||||||
Type::Int16 |
|
Type::Int16 |
|
||||||
Type::Uint32 |
|
Type::Uint32 |
|
||||||
Type::Int32 => true,
|
Type::Int32
|
||||||
_ => false,
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -345,16 +345,17 @@ impl Element {
|
||||||
self.is.borrow().clone()
|
self.is.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <https://dom.spec.whatwg.org/#concept-element-custom-element-state>
|
||||||
pub fn set_custom_element_state(&self, state: CustomElementState) {
|
pub fn set_custom_element_state(&self, state: CustomElementState) {
|
||||||
// no need to inflate rare data for uncustomized
|
// no need to inflate rare data for uncustomized
|
||||||
if state != CustomElementState::Uncustomized || self.rare_data().is_some() {
|
if state != CustomElementState::Uncustomized || self.rare_data().is_some() {
|
||||||
self.ensure_rare_data().custom_element_state = state;
|
self.ensure_rare_data().custom_element_state = state;
|
||||||
}
|
}
|
||||||
// https://dom.spec.whatwg.org/#concept-element-defined
|
|
||||||
let in_defined_state = match state {
|
let in_defined_state = matches!(
|
||||||
CustomElementState::Uncustomized | CustomElementState::Custom => true,
|
state,
|
||||||
_ => false,
|
CustomElementState::Uncustomized | CustomElementState::Custom
|
||||||
};
|
);
|
||||||
self.set_state(ElementState::DEFINED, in_defined_state)
|
self.set_state(ElementState::DEFINED, in_defined_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1393,21 +1394,18 @@ impl Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// <a>, <input>, <select>, and <textrea> are inherently focusable.
|
// <a>, <input>, <select>, and <textrea> are inherently focusable.
|
||||||
match node.type_id() {
|
matches!(
|
||||||
|
node.type_id(),
|
||||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||||
HTMLElementTypeId::HTMLAnchorElement,
|
HTMLElementTypeId::HTMLAnchorElement,
|
||||||
)) |
|
)) | NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
|
||||||
HTMLElementTypeId::HTMLInputElement,
|
HTMLElementTypeId::HTMLInputElement,
|
||||||
)) |
|
)) | NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
|
||||||
HTMLElementTypeId::HTMLSelectElement,
|
HTMLElementTypeId::HTMLSelectElement,
|
||||||
)) |
|
)) | NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
|
||||||
HTMLElementTypeId::HTMLTextAreaElement,
|
HTMLElementTypeId::HTMLTextAreaElement,
|
||||||
)) => true,
|
))
|
||||||
_ => false,
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_actually_disabled(&self) -> bool {
|
pub fn is_actually_disabled(&self) -> bool {
|
||||||
|
@ -1493,7 +1491,7 @@ impl Element {
|
||||||
.map(|js| DomRoot::from_ref(&**js))
|
.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>> {
|
pub fn get_attribute_by_name(&self, name: DOMString) -> Option<DomRoot<Attr>> {
|
||||||
let name = &self.parsed_name(name);
|
let name = &self.parsed_name(name);
|
||||||
let maybe_attribute = self
|
let maybe_attribute = self
|
||||||
|
@ -1506,10 +1504,7 @@ impl Element {
|
||||||
if *name == local_name!("id") || *name == local_name!("name") {
|
if *name == local_name!("id") || *name == local_name!("name") {
|
||||||
match maybe_attr {
|
match maybe_attr {
|
||||||
None => true,
|
None => true,
|
||||||
Some(ref attr) => match *attr.value() {
|
Some(ref attr) => matches!(*attr.value(), AttrValue::Atom(_)),
|
||||||
AttrValue::Atom(_) => true,
|
|
||||||
_ => false,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
|
@ -2932,10 +2927,7 @@ impl VirtualMethods for Element {
|
||||||
//
|
//
|
||||||
// Juggle a bit to keep the borrow checker happy
|
// Juggle a bit to keep the borrow checker happy
|
||||||
// while avoiding the extra clone.
|
// while avoiding the extra clone.
|
||||||
let is_declaration = match *attr.value() {
|
let is_declaration = matches!(*attr.value(), AttrValue::Declaration(..));
|
||||||
AttrValue::Declaration(..) => true,
|
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
let block = if is_declaration {
|
let block = if is_declaration {
|
||||||
let mut value = AttrValue::String(String::new());
|
let mut value = AttrValue::String(String::new());
|
||||||
|
|
|
@ -24,10 +24,7 @@ gl_enums! {
|
||||||
|
|
||||||
impl TexImageTarget {
|
impl TexImageTarget {
|
||||||
pub fn is_cubic(&self) -> bool {
|
pub fn is_cubic(&self) -> bool {
|
||||||
match *self {
|
!matches!(*self, TexImageTarget::Texture2D)
|
||||||
TexImageTarget::Texture2D => false,
|
|
||||||
_ => true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dimensions(self) -> u8 {
|
pub fn dimensions(self) -> u8 {
|
||||||
|
|
|
@ -149,10 +149,7 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ServoLayoutElement<'dom, LayoutDataT
|
||||||
fn is_root(&self) -> bool {
|
fn is_root(&self) -> bool {
|
||||||
match self.as_node().parent_node() {
|
match self.as_node().parent_node() {
|
||||||
None => false,
|
None => false,
|
||||||
Some(node) => match node.script_type_id() {
|
Some(node) => matches!(node.script_type_id(), NodeTypeId::Document(_)),
|
||||||
NodeTypeId::Document(_) => true,
|
|
||||||
_ => false,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -587,15 +584,11 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ::selectors::Element
|
||||||
|
|
||||||
NonTSPseudoClass::Lang(ref lang) => self.match_element_lang(None, lang),
|
NonTSPseudoClass::Lang(ref lang) => self.match_element_lang(None, lang),
|
||||||
|
|
||||||
NonTSPseudoClass::ServoNonZeroBorder => {
|
NonTSPseudoClass::ServoNonZeroBorder => !matches!(
|
||||||
match self
|
self.element
|
||||||
.element
|
.get_attr_for_layout(&ns!(), &local_name!("border")),
|
||||||
.get_attr_for_layout(&ns!(), &local_name!("border"))
|
None | Some(&AttrValue::UInt(_, 0))
|
||||||
{
|
),
|
||||||
None | Some(&AttrValue::UInt(_, 0)) => false,
|
|
||||||
_ => true,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
NonTSPseudoClass::ReadOnly => !self
|
NonTSPseudoClass::ReadOnly => !self
|
||||||
.element
|
.element
|
||||||
.get_state_for_layout()
|
.get_state_for_layout()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue