diff --git a/components/selectors/attr.rs b/components/selectors/attr.rs index 96abbe1c132..51173cee50e 100644 --- a/components/selectors/attr.rs +++ b/components/selectors/attr.rs @@ -134,7 +134,7 @@ impl AttrSelectorOperator { } /// The definition of whitespace per CSS Selectors Level 3 ยง 4. -pub static SELECTOR_WHITESPACE: &'static [char] = &[' ', '\t', '\n', '\r', '\x0C']; +pub static SELECTOR_WHITESPACE: &[char] = &[' ', '\t', '\n', '\r', '\x0C']; #[derive(Clone, Copy, Debug, Eq, PartialEq, ToShmem)] pub enum ParsedCaseSensitivity { diff --git a/components/selectors/build.rs b/components/selectors/build.rs index 264c2da6b4b..c5c3803991e 100644 --- a/components/selectors/build.rs +++ b/components/selectors/build.rs @@ -27,7 +27,7 @@ fn main() { } /// -static ASCII_CASE_INSENSITIVE_HTML_ATTRIBUTES: &'static str = r#" +static ASCII_CASE_INSENSITIVE_HTML_ATTRIBUTES: &str = r#" accept accept-charset align diff --git a/components/selectors/context.rs b/components/selectors/context.rs index efbcbdf9230..9146b133e38 100644 --- a/components/selectors/context.rs +++ b/components/selectors/context.rs @@ -286,6 +286,6 @@ where /// against. #[inline] pub fn shadow_host(&self) -> Option { - self.current_host.clone() + self.current_host } } diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs index d3dbdf6c6ac..634ed90d62f 100644 --- a/components/selectors/matching.rs +++ b/components/selectors/matching.rs @@ -334,10 +334,7 @@ where let result = matches_complex_selector_internal(iter, element, context, flags_setter, Rightmost::Yes); - match result { - SelectorMatchingResult::Matched => true, - _ => false, - } + matches!(result, SelectorMatchingResult::Matched) } #[inline] @@ -915,9 +912,11 @@ where element, is_of_type, is_from_end, - cache.as_mut().map(|s| &mut **s), + cache.as_deref_mut(), ); - cache.as_mut().map(|c| c.insert(element.opaque(), i)); + if let Some(c) = cache.as_mut() { + c.insert(element.opaque(), i) + } i }; debug_assert_eq!( diff --git a/components/selectors/nth_index_cache.rs b/components/selectors/nth_index_cache.rs index 8d1d479274f..979c3100175 100644 --- a/components/selectors/nth_index_cache.rs +++ b/components/selectors/nth_index_cache.rs @@ -37,7 +37,7 @@ pub struct NthIndexCacheInner(FxHashMap); impl NthIndexCacheInner { /// Does a lookup for a given element in the cache. pub fn lookup(&mut self, el: OpaqueElement) -> Option { - self.0.get(&el).map(|x| *x) + self.0.get(&el).copied() } /// Inserts an entry into the cache. diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs index 4492369037a..955a428429b 100644 --- a/components/selectors/parser.rs +++ b/components/selectors/parser.rs @@ -493,10 +493,8 @@ where // :where and :is OR their selectors, so we can't put any hash // in the filter if there's more than one selector, as that'd // exclude elements that may match one of the other selectors. - if list.len() == 1 { - if !collect_ancestor_hashes(list[0].iter(), quirks_mode, hashes, len) { - return false; - } + if list.len() == 1 && !collect_ancestor_hashes(list[0].iter(), quirks_mode, hashes, len) { + return false; } continue; }, @@ -2777,8 +2775,8 @@ pub mod tests { assert!(list.is_ok()); } - const MATHML: &'static str = "http://www.w3.org/1998/Math/MathML"; - const SVG: &'static str = "http://www.w3.org/2000/svg"; + const MATHML: &str = "http://www.w3.org/1998/Math/MathML"; + const SVG: &str = "http://www.w3.org/2000/svg"; #[test] fn test_parsing() {