Skip to content

Commit 0844431

Browse files
petrochenkovAmanieu
authored andcommitted
sse42: Add unsafe blocks around unsafe function calls
to fix the `unsafe_op_in_unsafe_fn` lint
1 parent 6b8990c commit 0844431

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Diff for: crates/core_arch/src/x86/sse42.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ pub fn _mm_cmpistrm<const IMM8: i32>(a: __m128i, b: __m128i) -> __m128i {
126126
/// multiple lines";
127127
/// let needle = b"\r\n\t\0\0\0\0\0\0\0\0\0\0\0\0\0";
128128
///
129-
/// let a = _mm_loadu_si128(needle.as_ptr() as *const _);
129+
/// let a = unsafe { _mm_loadu_si128(needle.as_ptr() as *const _) };
130130
/// let hop = 16;
131131
/// let mut indexes = Vec::new();
132132
///
133133
/// // Chunk the haystack into 16 byte chunks and find
134134
/// // the first "\r\n\t" in the chunk.
135135
/// for (i, chunk) in haystack.chunks(hop).enumerate() {
136-
/// let b = _mm_loadu_si128(chunk.as_ptr() as *const _);
136+
/// let b = unsafe { _mm_loadu_si128(chunk.as_ptr() as *const _) };
137137
/// let idx = _mm_cmpistri(a, b, _SIDD_CMP_EQUAL_ORDERED);
138138
/// if idx != 16 {
139139
/// indexes.push((idx as usize) + (i * hop));
@@ -164,8 +164,8 @@ pub fn _mm_cmpistrm<const IMM8: i32>(a: __m128i, b: __m128i) -> __m128i {
164164
/// let special_chars = b"!@#$%^&*()[]:;<>";
165165
///
166166
/// // Load the input
167-
/// let a = _mm_loadu_si128(special_chars.as_ptr() as *const _);
168-
/// let b = _mm_loadu_si128(password.as_ptr() as *const _);
167+
/// let a = unsafe { _mm_loadu_si128(special_chars.as_ptr() as *const _) };
168+
/// let b = unsafe { _mm_loadu_si128(password.as_ptr() as *const _) };
169169
///
170170
/// // Use _SIDD_CMP_EQUAL_ANY to find the index of any bytes in b
171171
/// let idx = _mm_cmpistri(a.into(), b.into(), _SIDD_CMP_EQUAL_ANY);
@@ -196,11 +196,11 @@ pub fn _mm_cmpistrm<const IMM8: i32>(a: __m128i, b: __m128i) -> __m128i {
196196
/// # #[target_feature(enable = "sse4.2")]
197197
/// # unsafe fn worker() {
198198
/// # let b = b":;<=>?@[\\]^_`abc";
199-
/// # let b = _mm_loadu_si128(b.as_ptr() as *const _);
199+
/// # let b = unsafe { _mm_loadu_si128(b.as_ptr() as *const _) };
200200
///
201201
/// // Specify the ranges of values to be searched for [A-Za-z0-9].
202202
/// let a = b"AZaz09\0\0\0\0\0\0\0\0\0\0";
203-
/// let a = _mm_loadu_si128(a.as_ptr() as *const _);
203+
/// let a = unsafe { _mm_loadu_si128(a.as_ptr() as *const _) };
204204
///
205205
/// // Use _SIDD_CMP_RANGES to find the index of first byte in ranges.
206206
/// // Which in this case will be the first alpha numeric byte found
@@ -236,8 +236,8 @@ pub fn _mm_cmpistrm<const IMM8: i32>(a: __m128i, b: __m128i) -> __m128i {
236236
/// # '❤'.encode_utf16(&mut some_utf16_words);
237237
/// # '𝕊'.encode_utf16(&mut more_utf16_words);
238238
/// // Load the input
239-
/// let a = _mm_loadu_si128(some_utf16_words.as_ptr() as *const _);
240-
/// let b = _mm_loadu_si128(more_utf16_words.as_ptr() as *const _);
239+
/// let a = unsafe { _mm_loadu_si128(some_utf16_words.as_ptr() as *const _) };
240+
/// let b = unsafe { _mm_loadu_si128(more_utf16_words.as_ptr() as *const _) };
241241
///
242242
/// // Specify _SIDD_UWORD_OPS to compare words instead of bytes, and
243243
/// // use _SIDD_CMP_EQUAL_EACH to compare the two strings.
@@ -404,8 +404,8 @@ pub fn _mm_cmpestrm<const IMM8: i32>(a: __m128i, la: i32, b: __m128i, lb: i32) -
404404
/// // extra bytes we do not want to search for.
405405
/// let needle = b"\r\n\t ignore this ";
406406
///
407-
/// let a = _mm_loadu_si128(needle.as_ptr() as *const _);
408-
/// let b = _mm_loadu_si128(haystack.as_ptr() as *const _);
407+
/// let a = unsafe { _mm_loadu_si128(needle.as_ptr() as *const _) };
408+
/// let b = unsafe { _mm_loadu_si128(haystack.as_ptr() as *const _) };
409409
///
410410
/// // Note: We explicitly specify we only want to search `b` for the
411411
/// // first 3 characters of a.

0 commit comments

Comments
 (0)