diff --git a/pulldown-cmark-escape/Cargo.toml b/pulldown-cmark-escape/Cargo.toml index bc09d934..31f61947 100644 --- a/pulldown-cmark-escape/Cargo.toml +++ b/pulldown-cmark-escape/Cargo.toml @@ -13,3 +13,6 @@ categories = ["text-processing"] edition = "2021" rust-version = "1.70" # Update README.md and azure-pipelines.yml if this changes. readme = "../README.md" + +[features] +simd = [] diff --git a/pulldown-cmark-escape/src/lib.rs b/pulldown-cmark-escape/src/lib.rs index cc14a2f1..7ee03ae2 100644 --- a/pulldown-cmark-escape/src/lib.rs +++ b/pulldown-cmark-escape/src/lib.rs @@ -271,7 +271,6 @@ fn escape_html_scalar( mod simd { use super::StrWrite; use std::arch::x86_64::*; - use std::io; use std::mem::size_of; const VECTOR_SIZE: usize = size_of::<__m128i>(); @@ -280,7 +279,7 @@ mod simd { mut w: W, s: &str, table: &'static [u8; 256], - ) -> io::Result<()> { + ) -> Result<(), W::Error> { // The SIMD accelerated code uses the PSHUFB instruction, which is part // of the SSSE3 instruction set. Further, we can only use this code if // the buffer is at least one VECTOR_SIZE in length to prevent reading @@ -361,13 +360,13 @@ mod simd { /// Make sure to only call this when `bytes.len() >= 16`, undefined behaviour may /// occur otherwise. #[target_feature(enable = "ssse3")] - unsafe fn foreach_special_simd( + unsafe fn foreach_special_simd( bytes: &[u8], mut offset: usize, mut callback: F, - ) -> io::Result<()> + ) -> Result<(), E> where - F: FnMut(usize) -> io::Result<()>, + F: FnMut(usize) -> Result<(), E>, { // The strategy here is to walk the byte buffer in chunks of VECTOR_SIZE (16) // bytes at a time starting at the given offset. For each chunk, we compute a @@ -410,7 +409,7 @@ mod simd { unsafe { super::foreach_special_simd("&aXaaaa.a'aa9a<>aab&".as_bytes(), 0, |ix| { #[allow(clippy::unit_arg)] - Ok(vec.push(ix)) + Ok::<_, std::fmt::Error>(vec.push(ix)) }) .unwrap(); } @@ -427,7 +426,7 @@ mod simd { unsafe { super::foreach_special_simd(&vek, 0, |_| { match_count += 1; - Ok(()) + Ok::<_, std::fmt::Error>(()) }) .unwrap(); } diff --git a/pulldown-cmark/Cargo.toml b/pulldown-cmark/Cargo.toml index 99f8d936..0289891d 100644 --- a/pulldown-cmark/Cargo.toml +++ b/pulldown-cmark/Cargo.toml @@ -81,5 +81,5 @@ bincode = "1.3.1" [features] default = ["getopts", "html"] gen-tests = [] -simd = [] +simd = ["pulldown-cmark-escape?/simd"] html = ["pulldown-cmark-escape"]