Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Nov 30, 2024
1 parent c48aef5 commit e58176c
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use criterion::*;
use criterion::{criterion_group, criterion_main};
use glob::glob;
use lazy_static::lazy_static;
use std::fmt::{self, Debug};
Expand Down
8 changes: 4 additions & 4 deletions src/rewritable_units/text_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<'output_handler> StreamingHandlerSink<'output_handler> {
}
}

impl<'output_handler> StreamingHandlerSinkInner<'output_handler> {
impl StreamingHandlerSinkInner<'_> {
#[inline]
pub(crate) fn write_str(&mut self, content: &str, content_type: ContentType) {
match content_type {
Expand Down Expand Up @@ -175,7 +175,7 @@ impl TextEncoder {

/// This is more efficient than `Bytes::from_str`, because it can output non-UTF-8/non-ASCII encodings
/// without heap allocations.
/// It also avoids methods that have UB: https://github.com/hsivonen/encoding_rs/issues/79
/// It also avoids methods that have UB: <https://github.com/hsivonen/encoding_rs/issues/79>
#[inline(never)]
fn encode(&mut self, mut content: &str, output_handler: &mut dyn FnMut(&[u8])) {
loop {
Expand Down Expand Up @@ -243,7 +243,7 @@ struct IncompleteUtf8Resync {
}

impl IncompleteUtf8Resync {
pub fn new() -> Self {
pub const fn new() -> Self {
Self {
char_bytes: [0; 4],
char_len: 0,
Expand Down Expand Up @@ -440,7 +440,7 @@ fn invalid_utf8_fragments() {
assert!(
!std::str::from_utf8(ch).unwrap().contains('<'),
"{ch:x?} of {bad:x?}"
)
);
};
let mut t = StreamingHandlerSink::new(UTF_8, &mut handler);
for chunk in bad.chunks(len) {
Expand Down
2 changes: 1 addition & 1 deletion src/rewritable_units/tokens/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl Serialize for &Attribute<'_> {
#[inline]
fn into_bytes(self, output_handler: &mut dyn FnMut(&[u8])) -> Result<(), RewritingError> {
if let Some(raw) = self.raw.as_ref() {
output_handler(raw)
output_handler(raw);
} else {
output_handler(&self.name);
output_handler(b"=\"");
Expand Down
2 changes: 1 addition & 1 deletion src/rewritable_units/tokens/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ mod tests {
#[test]
fn sanitizer_bypass2() {
let out = rewrite_comment(b"<?xml >s<img src=x onerror=alert(1)> ?>", UTF_8, |c| {
c.set_text("pie is a lie!").unwrap()
c.set_text("pie is a lie!").unwrap();
});
assert_eq!("<!--pie is a lie!-->s<img src=x onerror=alert(1)> ?>", out);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rewriter/handlers_dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub(crate) struct ContentHandlersDispatcher<'h, H: HandlerTypes> {
matched_elements_with_removed_content: usize,
}

impl<'h, H: HandlerTypes> Default for ContentHandlersDispatcher<'h, H> {
impl<H: HandlerTypes> Default for ContentHandlersDispatcher<'_, H> {
fn default() -> Self {
ContentHandlersDispatcher {
doctype_handlers: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion src/rewriter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl<'h, O: OutputSink, H: HandlerTypes> HtmlRewriter<'h, O, H> {
// NOTE: this opaque Debug implementation is required to make
// `.unwrap()` and `.expect()` methods available on Result
// returned by the `HtmlRewriterBuilder.build()` method.
impl<'h, O: OutputSink, H: HandlerTypes> Debug for HtmlRewriter<'h, O, H> {
impl<O: OutputSink, H: HandlerTypes> Debug for HtmlRewriter<'_, O, H> {
#[cold]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "HtmlRewriter")
Expand Down
4 changes: 2 additions & 2 deletions src/rewriter/rewrite_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<'h, H: HandlerTypes> HtmlRewriteController<'h, H> {
}
}

impl<'h, H: HandlerTypes> HtmlRewriteController<'h, H> {
impl<H: HandlerTypes> HtmlRewriteController<'_, H> {
#[inline]
fn respond_to_aux_info_request(
aux_info_req: AuxStartTagInfoRequest<ElementDescriptor, SelectorHandlersLocator>,
Expand All @@ -65,7 +65,7 @@ impl<'h, H: HandlerTypes> HtmlRewriteController<'h, H> {
}
}

impl<'h, H: HandlerTypes> TransformController for HtmlRewriteController<'h, H> {
impl<H: HandlerTypes> TransformController for HtmlRewriteController<'_, H> {
#[inline]
fn initial_capture_flags(&self) -> TokenCaptureFlags {
self.get_capture_flags()
Expand Down
5 changes: 2 additions & 3 deletions src/rewriter/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ pub struct ElementContentHandlers<'h, H: HandlerTypes = LocalHandlerTypes> {
pub text: Option<H::TextHandler<'h>>,
}

impl<'h, H: HandlerTypes> Default for ElementContentHandlers<'h, H> {
impl<H: HandlerTypes> Default for ElementContentHandlers<'_, H> {
fn default() -> Self {
ElementContentHandlers {
element: None,
Expand Down Expand Up @@ -319,7 +319,7 @@ pub struct DocumentContentHandlers<'h, H: HandlerTypes = LocalHandlerTypes> {
pub end: Option<H::EndHandler<'h>>,
}

impl<'h, H: HandlerTypes> Default for DocumentContentHandlers<'h, H> {
impl<H: HandlerTypes> Default for DocumentContentHandlers<'_, H> {
fn default() -> Self {
DocumentContentHandlers {
doctype: None,
Expand Down Expand Up @@ -525,7 +525,6 @@ macro_rules! comments {
/// ..RewriteStrSettings::default()
/// };
/// ```
#[macro_export(local_inner_macros)]
macro_rules! streaming {
($closure:expr) => {{
Expand Down
2 changes: 1 addition & 1 deletion tests/harness/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<'de> Deserialize<'de> for Input {
{
struct StringVisitor;

impl<'de> Visitor<'de> for StringVisitor {
impl Visitor<'_> for StringVisitor {
type Value = Input;

fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct TokenSinkProxy<'a, Sink> {
pub tokens: &'a mut Vec<TestToken>,
}

impl<'a, Sink> TokenSinkProxy<'a, Sink> {
impl<Sink> TokenSinkProxy<'_, Sink> {
fn push_text_token(&mut self, s: &str) {
if let Some(&mut TestToken::Text(ref mut last)) = self.tokens.last_mut() {
*last += s;
Expand Down

0 comments on commit e58176c

Please sign in to comment.