Skip to content

Commit 1e16196

Browse files
kornelskiorium
authored andcommitted
Clippy
1 parent bfb0bd5 commit 1e16196

File tree

12 files changed

+34
-25
lines changed

12 files changed

+34
-25
lines changed

src/html/text_type.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ cfg_if! {
5656
}
5757

5858
impl<'s> From<&'s str> for TextType {
59+
#[allow(clippy::fallible_impl_from)]
5960
fn from(text_type: &'s str) -> Self {
6061
match text_type {
6162
"Data state" => Self::Data,

src/parser/lexer/conditions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::*;
1+
use super::{LexemeSink, Lexer, TagTokenOutline};
22
use crate::parser::state_machine::StateMachineConditions;
33

44
impl<S: LexemeSink> StateMachineConditions for Lexer<S> {

src/parser/tag_scanner/conditions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::*;
1+
use super::{TagHintSink, TagScanner};
22
use crate::parser::state_machine::StateMachineConditions;
33

44
impl<S: TagHintSink> StateMachineConditions for TagScanner<S> {

src/parser/tag_scanner/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,11 @@ impl<S: TagHintSink> TagScanner<S> {
134134
fn take_feedback_directive(&mut self) -> FeedbackDirective {
135135
self.pending_text_type_change
136136
.take()
137-
.map(|text_type| {
137+
.map_or(FeedbackDirective::Skip, |text_type| {
138138
FeedbackDirective::ApplyUnhandledFeedback(TreeBuilderFeedback::SwitchTextType(
139139
text_type,
140140
))
141141
})
142-
.unwrap_or(FeedbackDirective::Skip)
143142
}
144143
}
145144

src/rewritable_units/text_encoder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,16 @@ impl Buffer {
142142

143143
fn buffer_for_length(&mut self, content_len: usize) -> &mut [u8] {
144144
let buffer = match self {
145-
Buffer::Heap(buf) => buf.as_mut_slice(),
145+
Self::Heap(buf) => buf.as_mut_slice(),
146146
// Long non-ASCII content could take lots of roundtrips through the encoder
147147
buf if content_len >= Self::CONTENT_WRITE_LENGTH_LONG_ENOUGH_TO_USE_LARGER_BUFFER => {
148-
*buf = Buffer::Heap(vec![0; Self::DEFAULT_HEAP_BUFFER_SIZE]);
148+
*buf = Self::Heap(vec![0; Self::DEFAULT_HEAP_BUFFER_SIZE]);
149149
match buf {
150-
Buffer::Heap(buf) => buf.as_mut(),
150+
Self::Heap(buf) => buf.as_mut(),
151151
_ => unreachable!(),
152152
}
153153
}
154-
Buffer::Stack(buf) => buf.as_mut_slice(),
154+
Self::Stack(buf) => buf.as_mut_slice(),
155155
};
156156
buffer
157157
}

src/rewritable_units/tokens/start_tag.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct StartTag<'i> {
2424
impl<'i> StartTag<'i> {
2525
#[inline]
2626
#[must_use]
27-
pub(super) fn new_token(
27+
pub(super) const fn new_token(
2828
name: Bytes<'i>,
2929
attributes: Attributes<'i>,
3030
ns: Namespace,
@@ -117,6 +117,9 @@ impl<'i> StartTag<'i> {
117117
self.self_closing
118118
}
119119

120+
/// If false, the tag won't be seiralized with `/>`
121+
///
122+
/// This doesn't affect content model
120123
pub(crate) fn set_self_closing_syntax(&mut self, has_slash: bool) {
121124
self.self_closing = has_slash;
122125
}

src/rewriter/handlers_dispatcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl<'h, H: HandlerTypes> ContentHandlersDispatcher<'h, H> {
185185
}
186186

187187
#[inline]
188-
pub fn start_matching(&mut self, match_info: MatchInfo<SelectorHandlersLocator>) {
188+
pub fn start_matching(&mut self, match_info: &MatchInfo<SelectorHandlersLocator>) {
189189
let locator = match_info.payload;
190190

191191
if match_info.with_content {

src/rewriter/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ mod rewrite_controller;
55
pub(crate) mod settings;
66

77
use self::handlers_dispatcher::ContentHandlersDispatcher;
8-
use self::rewrite_controller::*;
8+
use self::rewrite_controller::{ElementDescriptor, HtmlRewriteController};
99
pub use self::settings::*;
1010
use crate::base::SharedEncoding;
1111
use crate::memory::{MemoryLimitExceededError, SharedMemoryLimiter};

src/rewriter/rewrite_controller.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::{HandlerTypes, RewritingError};
33
use crate::html::{LocalName, Namespace};
44
use crate::rewritable_units::{DocumentEnd, Token, TokenCaptureFlags};
55
use crate::selectors_vm::{AuxStartTagInfoRequest, ElementData, SelectorMatchingVm, VmError};
6-
use crate::transform_stream::*;
6+
use crate::transform_stream::{DispatcherError, StartTagHandlingResult, TransformController};
77
use hashbrown::HashSet;
88

99
#[derive(Default)]
@@ -48,7 +48,7 @@ impl<H: HandlerTypes> HtmlRewriteController<'_, H> {
4848
Err(DispatcherError::InfoRequest(Box::new(
4949
move |this, aux_info| {
5050
if let Some(ref mut vm) = this.selector_matching_vm {
51-
let mut match_handler = |m| this.handlers_dispatcher.start_matching(m);
51+
let mut match_handler = |m| this.handlers_dispatcher.start_matching(&m);
5252

5353
aux_info_req(vm, aux_info, &mut match_handler)
5454
.map_err(RewritingError::MemoryLimitExceeded)?;
@@ -78,7 +78,7 @@ impl<H: HandlerTypes> TransformController for HtmlRewriteController<'_, H> {
7878
) -> StartTagHandlingResult<Self> {
7979
match self.selector_matching_vm {
8080
Some(ref mut vm) => {
81-
let mut match_handler = |m| self.handlers_dispatcher.start_matching(m);
81+
let mut match_handler = |m| self.handlers_dispatcher.start_matching(&m);
8282

8383
match vm.exec_for_start_tag(local_name, ns, &mut match_handler) {
8484
Ok(()) => Ok(self.get_capture_flags()),

src/selectors_vm/ast.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ impl From<&Component<SelectorImplDescriptor>> for Condition {
128128
Self::OnTagName(OnTagNameExpr::ExplicitAny)
129129
}
130130
Component::ExplicitNoNamespace => Self::OnTagName(OnTagNameExpr::Unmatchable),
131-
Component::ID(id) => Self::OnAttributes(OnAttributesExpr::Id(id.0.to_owned())),
132-
Component::Class(c) => Self::OnAttributes(OnAttributesExpr::Class(c.0.to_owned())),
131+
Component::ID(id) => Self::OnAttributes(OnAttributesExpr::Id(id.0.clone())),
132+
Component::Class(c) => Self::OnAttributes(OnAttributesExpr::Class(c.0.clone())),
133133
Component::AttributeInNoNamespaceExists { local_name, .. } => {
134-
Self::OnAttributes(OnAttributesExpr::AttributeExists(local_name.0.to_owned()))
134+
Self::OnAttributes(OnAttributesExpr::AttributeExists(local_name.0.clone()))
135135
}
136136
&Component::AttributeInNoNamespace {
137137
ref local_name,
@@ -145,8 +145,8 @@ impl From<&Component<SelectorImplDescriptor>> for Condition {
145145
} else {
146146
Self::OnAttributes(OnAttributesExpr::AttributeComparisonExpr(
147147
AttributeComparisonExpr::new(
148-
local_name.0.to_owned(),
149-
value.0.to_owned(),
148+
local_name.0.clone(),
149+
value.0.clone(),
150150
case_sensitivity,
151151
operator,
152152
),

0 commit comments

Comments
 (0)