From b4593532f70bc694967ef1ed663a0379f5428203 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Mon, 8 Sep 2025 20:33:26 +0100 Subject: [PATCH 1/2] Remove mac dependency Signed-off-by: Nico Burns --- Cargo.toml | 1 - tendril/Cargo.toml | 1 - tendril/src/fmt.rs | 4 +++- tendril/src/futf.rs | 14 ++++---------- tendril/src/lib.rs | 2 -- tendril/src/tendril.rs | 2 +- 6 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 390a6ec9..9cbb142c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,6 @@ html5ever = { version = "0.35.0", path = "html5ever" } encoding = "0.2" encoding_rs = "0.8.12" log = "0.4" -mac = "0.1" new_debug_unreachable = "1.0.2" phf = "0.13" phf_codegen = "0.13" diff --git a/tendril/Cargo.toml b/tendril/Cargo.toml index 14dae0d1..a56840a7 100644 --- a/tendril/Cargo.toml +++ b/tendril/Cargo.toml @@ -16,7 +16,6 @@ edition = "2015" [dependencies] encoding = { workspace = true, optional = true} encoding_rs = { workspace = true, optional = true} -mac = { workspace = true } new_debug_unreachable = { workspace = true } utf-8 = { workspace = true } diff --git a/tendril/src/fmt.rs b/tendril/src/fmt.rs index 2ff04bbc..e04aa8bd 100644 --- a/tendril/src/fmt.rs +++ b/tendril/src/fmt.rs @@ -386,7 +386,9 @@ unsafe impl Format for WTF8 { let mut i = 0; let mut prev_lead = false; while i < buf.len() { - let codept = unwrap_or_return!(futf::classify(buf, i), false); + let Some(codept) = futf::classify(buf, i) else { + return false; + }; if !wtf8_meaningful(codept.meaning) { return false; } diff --git a/tendril/src/futf.rs b/tendril/src/futf.rs index 5fac52d5..fbcbab68 100644 --- a/tendril/src/futf.rs +++ b/tendril/src/futf.rs @@ -140,12 +140,6 @@ unsafe fn unsafe_slice<'a>(buf: &'a [u8], start: usize, new_len: usize) -> &'a [ slice::from_raw_parts(buf.as_ptr().offset(start as isize), new_len) } -macro_rules! otry { - ($x:expr) => { - unwrap_or_return!($x, None) - }; -} - /// Describes the UTF-8 codepoint containing the byte at index `idx` within /// `buf`. /// @@ -159,7 +153,7 @@ pub fn classify<'a>(buf: &'a [u8], idx: usize) -> Option> { unsafe { let x = *buf.get_unchecked(idx); - match otry!(Byte::classify(x)) { + match Byte::classify(x)? { Byte::Ascii => Some(Codepoint { bytes: unsafe_slice(buf, idx, 1), rewind: 0, @@ -172,7 +166,7 @@ pub fn classify<'a>(buf: &'a [u8], idx: usize) -> Option> { if !all_cont(unsafe_slice(bytes, 1, n - 1)) { return None; } - let meaning = otry!(decode(bytes)); + let meaning = decode(bytes)?; Some(Codepoint { bytes: bytes, rewind: 0, @@ -201,7 +195,7 @@ pub fn classify<'a>(buf: &'a [u8], idx: usize) -> Option> { start -= 1; checked += 1; - match otry!(Byte::classify(*buf.get_unchecked(start))) { + match Byte::classify(*buf.get_unchecked(start))? { Byte::Cont => (), Byte::Start(n) => { let avail = buf.len() - start; @@ -212,7 +206,7 @@ pub fn classify<'a>(buf: &'a [u8], idx: usize) -> Option> { return None; } } - let meaning = otry!(decode(bytes)); + let meaning = decode(bytes)?; return Some(Codepoint { bytes: bytes, rewind: idx - start, diff --git a/tendril/src/lib.rs b/tendril/src/lib.rs index 2d9f8d10..b3436a13 100644 --- a/tendril/src/lib.rs +++ b/tendril/src/lib.rs @@ -39,8 +39,6 @@ extern crate debug_unreachable; pub extern crate encoding; #[cfg(feature = "encoding_rs")] pub extern crate encoding_rs; -#[macro_use] -extern crate mac; extern crate utf8; pub use fmt::Format; diff --git a/tendril/src/tendril.rs b/tendril/src/tendril.rs index d5fbd7d2..5087125a 100644 --- a/tendril/src/tendril.rs +++ b/tendril/src/tendril.rs @@ -1331,7 +1331,7 @@ where let (class, first_mismatch); { let mut chars = unsafe { F::char_indices(self.as_byte_slice()) }; - let (_, first) = unwrap_or_return!(chars.next(), None); + let (_, first) = chars.next()?; class = classify(first); first_mismatch = chars.find(|&(_, ch)| &classify(ch) != &class); } From be33a93b7a92310e518945436c969fb832aa6a3f Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Tue, 9 Sep 2025 09:48:11 +0100 Subject: [PATCH 2/2] Remove unused syn, quote and proc_macro2 deps Signed-off-by: Nico Burns --- Cargo.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9cbb142c..b44fd6d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,9 +32,6 @@ log = "0.4" new_debug_unreachable = "1.0.2" phf = "0.13" phf_codegen = "0.13" -proc-macro2 = "1" -quote = "1" -syn = { version = "2", features = ["full"] } string_cache = "0.9.0" string_cache_codegen = "0.6.1" utf-8 = "0.7"