diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9d8be10..1c91417c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,9 @@ on: branches: - main +permissions: + contents: read + env: RUSTFLAGS: -Dwarnings RUST_BACKTRACE: 1 diff --git a/Cargo.toml b/Cargo.toml index b925c49d..94d874dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lol_html" -version = "3.0.3" +version = "3.0.4" authors = ["Ivan Nikulin "] license = "BSD-3-Clause" description = "Streaming HTML rewriter/parser with CSS selector-based API" @@ -11,7 +11,7 @@ keywords = ["html", "css-selectors", "parser", "rewriter", "streaming"] readme = "README.md" include = ["/Cargo.toml", "/LICENSE", "/README.md", "/media", "/src"] edition = "2024" -rust-version = "1.85" +rust-version = "1.95" [lib] # Disable libtest to make sure criterion can parse the command line flags. @@ -29,31 +29,31 @@ harness = false name = "bench" [dependencies] -cssparser = "0.36" -bitflags = "2.11.1" -cfg-if = "1.0.4" -encoding_rs = "0.8.35" -hashbrown = "0.17.0" +cssparser = "0.38" +bitflags = "2.13.2" +cfg-if = "1.0.5" +encoding_rs = "0.8.42" +hashbrown = "0.17.1" # hashbrown uses foldhash without std, which has a performance penalty foldhash = { version = "0.2.0", features = ["std"] } -memchr = "2.8.0" +memchr = "2.8.3" mime = "0.3.17" -selectors = "0.37" +selectors = "0.41" thiserror = "2.0" precomputed-hash = "0.1.1" [dev-dependencies] criterion = "0.8.2" -glob = "0.3.3" -hashbrown = { version = "0.17.0", features = ["serde"] } +glob = "0.3.4" +hashbrown = { version = "0.17.1", features = ["serde"] } html5ever = "0.39" markup5ever_rcdom = "0.39" -serde = "1.0.228" -serde_derive = "1.0.228" -serde_json = "1.0.149" +serde = "1.0.229" +serde_derive = "1.0.229" +serde_json = "1.0.154" static_assertions = "1.1.0" rand = "0.10" -itertools = "0.14" +itertools = "0.15" [lints.rust] keyword_idents = { level = "deny", priority = 1 } diff --git a/c-api/Cargo.lock b/c-api/Cargo.lock index dff66503..ca459baf 100644 --- a/c-api/Cargo.lock +++ b/c-api/Cargo.lock @@ -28,9 +28,9 @@ checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" [[package]] name = "cssparser" -version = "0.36.0" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dae61cf9c0abb83bd659dab65b7e4e38d8236824c85f0f804f173567bda257d2" +checksum = "11119743ad110e8c1bdccd930d7f5c30c99e5fc76a7b63ec9807e84eef0c5f59" dependencies = [ "cssparser-macros", "dtoa-short", @@ -41,12 +41,12 @@ dependencies = [ [[package]] name = "cssparser-macros" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" +checksum = "d045de693cb712d0b22c6a64be5b953f67b3ce00ab5ad3dd5d8b441886ab8e1a" dependencies = [ "quote", - "syn 2.0.119", + "syn 3.0.9", ] [[package]] @@ -148,7 +148,7 @@ checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" [[package]] name = "lol_html" -version = "3.0.3" +version = "3.0.4" dependencies = [ "bitflags", "cfg-if", @@ -199,30 +199,20 @@ checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "phf" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf" +checksum = "010378780309880b08997fae13be7834dba947d36393bd372f2b1556deb2a2f6" dependencies = [ "phf_macros", "phf_shared", "serde", ] -[[package]] -name = "phf_codegen" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49aa7f9d80421bca176ca8dbfebe668cc7a2684708594ec9f3c0db0805d5d6e1" -dependencies = [ - "phf_generator", - "phf_shared", -] - [[package]] name = "phf_generator" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737" +checksum = "aeb62e0959d5a1bebc965f4d15d9e2b7cea002b6b0f5ba8cde6cc26738467100" dependencies = [ "fastrand", "phf_shared", @@ -230,9 +220,9 @@ dependencies = [ [[package]] name = "phf_macros" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef" +checksum = "5fa8d0ca26d424d27630da600c6624696e7dec8bf7b3b492b383c5dc49e5e085" dependencies = [ "phf_generator", "phf_shared", @@ -243,9 +233,9 @@ dependencies = [ [[package]] name = "phf_shared" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266" +checksum = "c6fd9027e2d9319be6349febd1db4e8d02aa544921200c9b777720ac34a3aa89" dependencies = [ "siphasher", ] @@ -303,17 +293,15 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "selectors" -version = "0.37.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfaaa6035167f0e604e42723c7650d59ee269ef220d7bbe0565602c8a0173b9" +checksum = "8322aebea94a6cc288ff884e8a49bdbceef60206c400c6c46d22e62fc4fd91a6" dependencies = [ "bitflags", "cssparser", "derive_more", "log", "new_debug_unreachable", - "phf", - "phf_codegen", "precomputed-hash", "rustc-hash", "servo_arc", @@ -357,9 +345,9 @@ dependencies = [ [[package]] name = "servo_arc" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "170fb83ab34de17dc69aa7c67482b22218ddb85da56546f9bd6b929e32a05930" +checksum = "b4eceb519ec34d8290aaf6e46f435102f2bfa63f22b05a144fb16ab266d3b198" dependencies = [ "stable_deref_trait", ] diff --git a/js-api/Cargo.lock b/js-api/Cargo.lock index f4646645..2f1439b3 100644 --- a/js-api/Cargo.lock +++ b/js-api/Cargo.lock @@ -34,9 +34,9 @@ checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" [[package]] name = "cssparser" -version = "0.36.0" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dae61cf9c0abb83bd659dab65b7e4e38d8236824c85f0f804f173567bda257d2" +checksum = "11119743ad110e8c1bdccd930d7f5c30c99e5fc76a7b63ec9807e84eef0c5f59" dependencies = [ "cssparser-macros", "dtoa-short", @@ -47,12 +47,12 @@ dependencies = [ [[package]] name = "cssparser-macros" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" +checksum = "d045de693cb712d0b22c6a64be5b953f67b3ce00ab5ad3dd5d8b441886ab8e1a" dependencies = [ "quote", - "syn 2.0.119", + "syn 3.0.9", ] [[package]] @@ -196,7 +196,7 @@ dependencies = [ [[package]] name = "lol_html" -version = "3.0.3" +version = "3.0.4" dependencies = [ "bitflags", "cfg-if", @@ -243,30 +243,20 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "phf" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf" +checksum = "010378780309880b08997fae13be7834dba947d36393bd372f2b1556deb2a2f6" dependencies = [ "phf_macros", "phf_shared", "serde", ] -[[package]] -name = "phf_codegen" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49aa7f9d80421bca176ca8dbfebe668cc7a2684708594ec9f3c0db0805d5d6e1" -dependencies = [ - "phf_generator", - "phf_shared", -] - [[package]] name = "phf_generator" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737" +checksum = "aeb62e0959d5a1bebc965f4d15d9e2b7cea002b6b0f5ba8cde6cc26738467100" dependencies = [ "fastrand", "phf_shared", @@ -274,9 +264,9 @@ dependencies = [ [[package]] name = "phf_macros" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef" +checksum = "5fa8d0ca26d424d27630da600c6624696e7dec8bf7b3b492b383c5dc49e5e085" dependencies = [ "phf_generator", "phf_shared", @@ -287,9 +277,9 @@ dependencies = [ [[package]] name = "phf_shared" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266" +checksum = "c6fd9027e2d9319be6349febd1db4e8d02aa544921200c9b777720ac34a3aa89" dependencies = [ "siphasher", ] @@ -353,17 +343,15 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "selectors" -version = "0.37.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfaaa6035167f0e604e42723c7650d59ee269ef220d7bbe0565602c8a0173b9" +checksum = "8322aebea94a6cc288ff884e8a49bdbceef60206c400c6c46d22e62fc4fd91a6" dependencies = [ "bitflags", "cssparser", "derive_more", "log", "new_debug_unreachable", - "phf", - "phf_codegen", "precomputed-hash", "rustc-hash", "servo_arc", @@ -419,9 +407,9 @@ dependencies = [ [[package]] name = "servo_arc" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "170fb83ab34de17dc69aa7c67482b22218ddb85da56546f9bd6b929e32a05930" +checksum = "b4eceb519ec34d8290aaf6e46f435102f2bfa63f22b05a144fb16ab266d3b198" dependencies = [ "stable_deref_trait", ] diff --git a/src/parser/lexer/actions.rs b/src/parser/lexer/actions.rs index b5a661e2..814cef8f 100644 --- a/src/parser/lexer/actions.rs +++ b/src/parser/lexer/actions.rs @@ -336,12 +336,12 @@ impl StateMachineActions for Lexer { #[inline] fn finish_attr(&mut self, _context: &mut ParserContext, _input: &[u8]) -> ActionResult { - if let Some(attr) = self.current_attr.take() { - if let Some(StartTag { attributes, .. }) = self.current_tag_token.as_mut() { - attributes - .push(attr) - .map_err(RewritingError::MemoryLimitExceeded)?; - } + if let Some(attr) = self.current_attr.take() + && let Some(StartTag { attributes, .. }) = self.current_tag_token.as_mut() + { + attributes + .push(attr) + .map_err(RewritingError::MemoryLimitExceeded)?; } Ok(()) } diff --git a/src/rewritable_units/text_encoder.rs b/src/rewritable_units/text_encoder.rs index 620131e1..c3902262 100644 --- a/src/rewritable_units/text_encoder.rs +++ b/src/rewritable_units/text_encoder.rs @@ -146,15 +146,15 @@ impl IncompleteUtf8Resync { if self.char_len > 0 { let mut must_emit_now = false; while let Some((&next_byte, rest)) = content.split_first() { - if is_continuation_byte(next_byte) { - if let Some(buf) = self.char_bytes.get_mut(self.char_len as usize) { - *buf = next_byte; - self.char_len += 1; - content = rest; - continue; - } - // overlong sequences fall here, and will be checked when the char_bytes is flushed + if is_continuation_byte(next_byte) + && let Some(buf) = self.char_bytes.get_mut(self.char_len as usize) + { + *buf = next_byte; + self.char_len += 1; + content = rest; + continue; } + // overlong sequences fall here, and will be checked when the char_bytes is flushed must_emit_now = true; break; } diff --git a/src/rewriter/handlers_dispatcher.rs b/src/rewriter/handlers_dispatcher.rs index 208592d2..317f5e7a 100644 --- a/src/rewriter/handlers_dispatcher.rs +++ b/src/rewriter/handlers_dispatcher.rs @@ -281,17 +281,17 @@ impl<'h, H: HandlerTypes> ContentHandlersDispatcher<'h, H> { self.element_handlers .do_for_each_active_and_deactivate(|h| h(&mut element))?; - if self.next_element_can_have_content { - if let Some(elem_desc) = current_element_data { - if element.should_remove_content() { - elem_desc.remove_content = true; - self.matched_elements_with_removed_content += 1; - } + if self.next_element_can_have_content + && let Some(elem_desc) = current_element_data + { + if element.should_remove_content() { + elem_desc.remove_content = true; + self.matched_elements_with_removed_content += 1; + } - debug_assert!(element.can_have_content()); - if let Some(handler) = element.into_end_tag_handler() { - elem_desc.end_tag_handler_idx = self.end_tag_handlers.push(handler, false); - } + debug_assert!(element.can_have_content()); + if let Some(handler) = element.into_end_tag_handler() { + elem_desc.end_tag_handler_idx = self.end_tag_handlers.push(handler, false); } } diff --git a/src/selectors_vm/error.rs b/src/selectors_vm/error.rs index 64f44b72..9e82cae0 100644 --- a/src/selectors_vm/error.rs +++ b/src/selectors_vm/error.rs @@ -59,34 +59,35 @@ pub enum SelectorError { UnsupportedSyntax, } -impl From> for SelectorError { +impl From for SelectorError { #[cold] - fn from(err: SelectorParseError<'_>) -> Self { + fn from(err: SelectorParseError) -> Self { // NOTE: always use explicit variants in this match, so we // get compile-time error if new error types were added to // the parser. #[deny(clippy::wildcard_enum_match_arm)] match err.kind { ParseErrorKind::Basic(err) => match err { - BasicParseErrorKind::UnexpectedToken(_) => Self::UnexpectedToken, + BasicParseErrorKind::UnexpectedToken => Self::UnexpectedToken, BasicParseErrorKind::EndOfInput => Self::UnexpectedEnd, BasicParseErrorKind::AtRuleBodyInvalid - | BasicParseErrorKind::AtRuleInvalid(_) - | BasicParseErrorKind::QualifiedRuleInvalid => Self::UnsupportedSyntax, + | BasicParseErrorKind::AtRuleInvalid + | BasicParseErrorKind::QualifiedRuleInvalid + | BasicParseErrorKind::TooManyNestedBlocks => Self::UnsupportedSyntax, }, ParseErrorKind::Custom(err) => match err { - SelectorParseErrorKind::NoQualifiedNameInAttributeSelector(_) => { + SelectorParseErrorKind::NoQualifiedNameInAttributeSelector => { Self::MissingAttributeName } SelectorParseErrorKind::EmptySelector => Self::EmptySelector, SelectorParseErrorKind::DanglingCombinator => Self::DanglingCombinator, - SelectorParseErrorKind::UnsupportedPseudoClassOrElement(_) + SelectorParseErrorKind::UnsupportedPseudoClassOrElement | SelectorParseErrorKind::InvalidPseudoElementInsideWhere | SelectorParseErrorKind::NonPseudoElementAfterSlotted | SelectorParseErrorKind::InvalidPseudoElementAfterSlotted - | SelectorParseErrorKind::PseudoElementExpectedColon(_) - | SelectorParseErrorKind::PseudoElementExpectedIdent(_) - | SelectorParseErrorKind::NoIdentForPseudo(_) + | SelectorParseErrorKind::PseudoElementExpectedColon + | SelectorParseErrorKind::PseudoElementExpectedIdent + | SelectorParseErrorKind::NoIdentForPseudo // NOTE: according to the parser code this error occurs only during // the parsing of vendor-specific pseudo-classes. | SelectorParseErrorKind::NonCompoundSelector => { @@ -94,21 +95,19 @@ impl From> for SelectorError { } // NOTE: there are currently no cases in the parser code // that trigger this error. - SelectorParseErrorKind::UnexpectedIdent(_) => { + SelectorParseErrorKind::UnexpectedIdent => { debug_assert!(false); Self::UnsupportedSyntax - }, - SelectorParseErrorKind::ExpectedNamespace(_) => Self::NamespacedSelector, - SelectorParseErrorKind::ExplicitNamespaceUnexpectedToken(_) => { - Self::UnexpectedToken } - SelectorParseErrorKind::UnexpectedTokenInAttributeSelector(_) - | SelectorParseErrorKind::ExpectedBarInAttr(_) - | SelectorParseErrorKind::BadValueInAttr(_) - | SelectorParseErrorKind::InvalidQualNameInAttr(_) => { + SelectorParseErrorKind::ExpectedNamespace => Self::NamespacedSelector, + SelectorParseErrorKind::ExplicitNamespaceUnexpectedToken => Self::UnexpectedToken, + SelectorParseErrorKind::UnexpectedTokenInAttributeSelector + | SelectorParseErrorKind::ExpectedBarInAttr + | SelectorParseErrorKind::BadValueInAttr + | SelectorParseErrorKind::InvalidQualNameInAttr => { Self::UnexpectedTokenInAttribute } - SelectorParseErrorKind::ClassNeedsIdent(_) => Self::InvalidClassName, + SelectorParseErrorKind::ClassNeedsIdent => Self::InvalidClassName, SelectorParseErrorKind::InvalidState => { debug_assert!(false, "invalid state"); Self::UnsupportedSyntax diff --git a/src/selectors_vm/mod.rs b/src/selectors_vm/mod.rs index 64c8ff42..fc1f7ecd 100644 --- a/src/selectors_vm/mod.rs +++ b/src/selectors_vm/mod.rs @@ -408,14 +408,14 @@ where ptr: JumpPtr, ) { // NOTE: find pointed jumps instruction set and execute it with the offset. - if let Some(parent) = self.stack.items().last() { - if let Some(ptr_jumps) = parent.jumps.get(ptr.instr_set_idx) { - self.exec_instr_set_with_attrs(ptr_jumps, attr_matcher, ctx, ptr.offset); + if let Some(parent) = self.stack.items().last() + && let Some(ptr_jumps) = parent.jumps.get(ptr.instr_set_idx) + { + self.exec_instr_set_with_attrs(ptr_jumps, attr_matcher, ctx, ptr.offset); - // NOTE: execute remaining jumps instruction sets as usual. - for jumps in parent.jumps.iter().skip(ptr.instr_set_idx + 1) { - self.exec_instr_set_with_attrs(jumps, attr_matcher, ctx, 0); - } + // NOTE: execute remaining jumps instruction sets as usual. + for jumps in parent.jumps.iter().skip(ptr.instr_set_idx + 1) { + self.exec_instr_set_with_attrs(jumps, attr_matcher, ctx, 0); } } } diff --git a/src/selectors_vm/parser.rs b/src/selectors_vm/parser.rs index 8f829a24..25a0b56e 100644 --- a/src/selectors_vm/parser.rs +++ b/src/selectors_vm/parser.rs @@ -1,6 +1,6 @@ use super::SelectorError; use crate::html::Namespace; -use cssparser::{Parser as CssParser, ParserInput, ToCss}; +use cssparser::{Parser as CssParser, ToCss}; use selectors::parser::{ Combinator, Component, NonTSPseudoClass, Parser, PseudoElement, SelectorImpl, SelectorList, SelectorParseErrorKind, @@ -83,16 +83,12 @@ impl ToCss for PseudoElementStub { } } -impl PseudoElement for PseudoElementStub { - type Impl = SelectorImplDescriptor; -} +impl PseudoElement for PseudoElementStub {} #[derive(PartialEq, Eq, Clone, Debug, Hash)] pub(crate) enum NonTSPseudoClassStub {} impl NonTSPseudoClass for NonTSPseudoClassStub { - type Impl = SelectorImplDescriptor; - fn is_active_or_hover(&self) -> bool { #[allow(clippy::uninhabited_references)] match *self {} @@ -217,8 +213,7 @@ impl SelectorsParser { #[inline] pub fn parse(selector: &str) -> Result, SelectorError> { - let mut input = ParserInput::new(selector); - let mut css_parser = CssParser::new(&mut input); + let mut css_parser = CssParser::new(selector); SelectorList::parse(&Self, &mut css_parser, ParseRelative::No) .map_err(SelectorError::from) @@ -226,9 +221,9 @@ impl SelectorsParser { } } -impl<'i> Parser<'i> for SelectorsParser { +impl Parser<'_> for SelectorsParser { type Impl = SelectorImplDescriptor; - type Error = SelectorParseErrorKind<'i>; + type Error = SelectorParseErrorKind; fn parse_nth_child_of(&self) -> bool { false diff --git a/src/selectors_vm/stack.rs b/src/selectors_vm/stack.rs index 82219e59..3338da34 100644 --- a/src/selectors_vm/stack.rs +++ b/src/selectors_vm/stack.rs @@ -26,12 +26,10 @@ fn is_void_element(local_name: &LocalName<'_>, enable_esi_tags: bool) -> bool { return true; } - if enable_esi_tags { - if let LocalName::Bytes(bytes) = local_name { - // https://www.w3.org/TR/esi-lang/ - if &**bytes == b"esi:include" || &**bytes == b"esi:comment" { - return true; - } + if enable_esi_tags && let LocalName::Bytes(bytes) = local_name { + // https://www.w3.org/TR/esi-lang/ + if &**bytes == b"esi:include" || &**bytes == b"esi:comment" { + return true; } } diff --git a/src/transform_stream/dispatcher.rs b/src/transform_stream/dispatcher.rs index 13484447..105f447d 100644 --- a/src/transform_stream/dispatcher.rs +++ b/src/transform_stream/dispatcher.rs @@ -466,11 +466,11 @@ where self.adjust_capture_flags_for_tag_lexeme(lexeme)?; } - if let TagTokenOutline::EndTag { .. } = lexeme.token_outline() { - if self.delegate.should_stop_removing_element_content() { - self.delegate.emission_enabled = true; - self.delegate.remaining_content_start = lexeme.raw_range().start; - } + if let TagTokenOutline::EndTag { .. } = lexeme.token_outline() + && self.delegate.should_stop_removing_element_content() + { + self.delegate.emission_enabled = true; + self.delegate.remaining_content_start = lexeme.raw_range().start; } self.try_produce_token_from_lexeme(lexeme)?; diff --git a/tests/fixtures/token_capturing.rs b/tests/fixtures/token_capturing.rs index d10959d9..fc6472f8 100644 --- a/tests/fixtures/token_capturing.rs +++ b/tests/fixtures/token_capturing.rs @@ -150,12 +150,12 @@ fn filter_tokens(tokens: &[TestToken], capture_flags: TokenCaptureFlags) -> Vec< fn fold_text_tokens(tokens: Vec) -> Vec { tokens.into_iter().fold(Vec::default(), |mut res, t| { - if let TestToken::Text(ref text) = t { - if let Some(TestToken::Text(last)) = res.last_mut() { - *last += text; + if let TestToken::Text(ref text) = t + && let Some(TestToken::Text(last)) = res.last_mut() + { + *last += text; - return res; - } + return res; } res.push(t); diff --git a/tests/harness/suites/html5lib_tests/decoder.rs b/tests/harness/suites/html5lib_tests/decoder.rs index a5b40231..6567a8d0 100644 --- a/tests/harness/suites/html5lib_tests/decoder.rs +++ b/tests/harness/suites/html5lib_tests/decoder.rs @@ -90,10 +90,11 @@ impl<'a> Decoder<'a> { if let Some(&m) = NAMED_ENTITIES.get(&name_buf[..]) { self.chars.next(); if m.0 != 0 { - if c != ';' && self.entities == Entities::Attribute { - if let Some('A'..='Z' | 'a'..='z' | '0'..='9' | '=') = self.chars.peek() { - continue; - } + if c != ';' + && self.entities == Entities::Attribute + && let Some('A'..='Z' | 'a'..='z' | '0'..='9' | '=') = self.chars.peek() + { + continue; } name_match = (m.0, m.1, name_buf.len()); }