diff --git a/c-api/Cargo.lock b/c-api/Cargo.lock index 25f79330..739cd374 100644 --- a/c-api/Cargo.lock +++ b/c-api/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "allocator-api2" @@ -40,9 +40,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "cssparser" -version = "0.27.2" +version = "0.29.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "754b69d351cdc2d8ee09ae203db831e005560fc6030da058f86ad60c92a9cb0a" +checksum = "f93d03419cb5950ccfd3daf3ff1c7a36ace64609a1a8746d493df1ca0afde0fa" dependencies = [ "cssparser-macros", "dtoa-short", @@ -147,21 +147,9 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.8" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "libc" @@ -184,8 +172,6 @@ dependencies = [ "cssparser", "encoding_rs", "hashbrown", - "lazy_static", - "lazycell", "memchr", "mime", "selectors", @@ -381,22 +367,20 @@ dependencies = [ [[package]] name = "selectors" -version = "0.22.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df320f1889ac4ba6bc0cdc9c9af7af4bd64bb927bccdf32d81140dc1f9be12fe" +checksum = "0c37578180969d00692904465fb7f6b3d50b9a2b952b87c23d0e2e5cb5013416" dependencies = [ "bitflags 1.3.2", "cssparser", "derive_more", "fxhash", "log", - "matches", "phf", "phf_codegen", "precomputed-hash", "servo_arc", "smallvec", - "thin-slice", ] [[package]] @@ -407,9 +391,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "servo_arc" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d98238b800e0d1576d8b6e3de32827c2d74bee68bb97748dcf5071fb53965432" +checksum = "d52aa42f8fdf0fed91e5ce7f23d8138441002fa31dca008acf47e6fd4721f741" dependencies = [ "nodrop", "stable_deref_trait", @@ -455,26 +439,20 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "thin-slice" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" - [[package]] name = "thiserror" -version = "1.0.68" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" +checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.68" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" +checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" dependencies = [ "proc-macro2", "quote", diff --git a/c-api/src/lib.rs b/c-api/src/lib.rs index 04523d7d..7d77a08c 100644 --- a/c-api/src/lib.rs +++ b/c-api/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::missing_safety_doc)] + pub use crate::streaming::CStreamingHandler; use libc::{c_char, c_int, c_void, size_t}; use lol_html::html_content::*; diff --git a/c-api/src/rewriter_builder.rs b/c-api/src/rewriter_builder.rs index e219087c..04cb3ceb 100644 --- a/c-api/src/rewriter_builder.rs +++ b/c-api/src/rewriter_builder.rs @@ -58,6 +58,7 @@ pub struct ExternDocumentContentHandlers { } impl ExternDocumentContentHandlers { + #[must_use] pub fn as_safe_document_content_handlers(&self) -> DocumentContentHandlers { let mut handlers = DocumentContentHandlers::default(); @@ -77,6 +78,7 @@ pub struct ExternElementContentHandlers { } impl ExternElementContentHandlers { + #[must_use] pub fn as_safe_element_content_handlers(&self) -> ElementContentHandlers { let mut handlers = ElementContentHandlers::default(); @@ -100,6 +102,7 @@ pub struct HtmlRewriterBuilder { } impl HtmlRewriterBuilder { + #[must_use] pub fn get_safe_handlers(&self) -> SafeContentHandlers { SafeContentHandlers { document: self diff --git a/c-api/src/streaming.rs b/c-api/src/streaming.rs index 426edffd..f827c96e 100644 --- a/c-api/src/streaming.rs +++ b/c-api/src/streaming.rs @@ -59,6 +59,7 @@ pub unsafe extern "C" fn lol_html_streaming_sink_write_utf8_chunk( } /// Safety: the user data and the callbacks must be safe to use from a different thread (e.g. can't rely on thread-local storage). +/// /// It doesn't have to be `Sync`, it will be used only by one thread at a time. /// /// Handler functions copy this struct. It can (and should) be created on the stack. diff --git a/c-api/src/string.rs b/c-api/src/string.rs index fc707056..1794d037 100644 --- a/c-api/src/string.rs +++ b/c-api/src/string.rs @@ -35,7 +35,7 @@ impl Str { impl Drop for Str { fn drop(&mut self) { - if self.data == ptr::null() { + if self.data.is_null() { return; } let bytes = unsafe { slice::from_raw_parts_mut(self.data.cast_mut(), self.len) }; diff --git a/js-api/src/html_rewriter.rs b/js-api/src/html_rewriter.rs index 129e1753..c8f4c8a8 100644 --- a/js-api/src/html_rewriter.rs +++ b/js-api/src/html_rewriter.rs @@ -49,12 +49,12 @@ pub struct HTMLRewriter(RewriterState); #[wasm_bindgen] impl HTMLRewriter { #[wasm_bindgen(constructor)] - pub fn new(encoding: String, output_sink: &JsFunction) -> JsResult { + pub fn new(encoding: String, output_sink: &JsFunction) -> JsResult { let encoding = Encoding::for_label(encoding.as_bytes()) .and_then(AsciiCompatibleEncoding::new) .ok_or_else(|| JsError::new("Invalid encoding"))?; - Ok(HTMLRewriter(RewriterState::Before { + Ok(Self(RewriterState::Before { output_sink: JsOutputSink::new(output_sink), settings: Settings { encoding,