@@ -257,6 +257,8 @@ fn analyze_source_file_dispatch(
257
257
/// SSE2 intrinsics to quickly find all newlines.
258
258
#[ target_feature( enable = "sse2" ) ]
259
259
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
260
+ // This can be removed once 1.87 is stable due to some intrinsics switching to safe.
261
+ #[ allow( unsafe_op_in_unsafe_fn) ]
260
262
unsafe fn analyze_source_file_sse2 (
261
263
src : & str ,
262
264
lines : & mut Vec < TextSize > ,
@@ -287,17 +289,17 @@ unsafe fn analyze_source_file_sse2(
287
289
288
290
// For character in the chunk, see if its byte value is < 0, which
289
291
// indicates that it's part of a UTF-8 char.
290
- let multibyte_test = unsafe { _mm_cmplt_epi8 ( chunk, _mm_set1_epi8 ( 0 ) ) } ;
292
+ let multibyte_test = _mm_cmplt_epi8 ( chunk, _mm_set1_epi8 ( 0 ) ) ;
291
293
// Create a bit mask from the comparison results.
292
- let multibyte_mask = unsafe { _mm_movemask_epi8 ( multibyte_test) } ;
294
+ let multibyte_mask = _mm_movemask_epi8 ( multibyte_test) ;
293
295
294
296
// If the bit mask is all zero, we only have ASCII chars here:
295
297
if multibyte_mask == 0 {
296
298
assert ! ( intra_chunk_offset == 0 ) ;
297
299
298
300
// Check for newlines in the chunk
299
- let newlines_test = unsafe { _mm_cmpeq_epi8 ( chunk, _mm_set1_epi8 ( b'\n' as i8 ) ) } ;
300
- let newlines_mask = unsafe { _mm_movemask_epi8 ( newlines_test) } ;
301
+ let newlines_test = _mm_cmpeq_epi8 ( chunk, _mm_set1_epi8 ( b'\n' as i8 ) ) ;
302
+ let newlines_mask = _mm_movemask_epi8 ( newlines_test) ;
301
303
302
304
if newlines_mask != 0 {
303
305
// All control characters are newlines, record them
@@ -354,15 +356,19 @@ unsafe fn analyze_source_file_sse2(
354
356
// The mask is a 64-bit integer, where each 4-bit corresponds to a u8 in the
355
357
// input vector. The least significant 4 bits correspond to the first byte in
356
358
// the vector.
359
+ // This can be removed once 1.87 is stable due to some intrinsics switching to safe.
360
+ #[ allow( unsafe_op_in_unsafe_fn) ]
357
361
unsafe fn move_mask ( v : std:: arch:: aarch64:: uint8x16_t ) -> u64 {
358
362
use std:: arch:: aarch64:: * ;
359
363
360
- let nibble_mask = unsafe { vshrn_n_u16 ( vreinterpretq_u16_u8 ( v) , 4 ) } ;
361
- unsafe { vget_lane_u64 ( vreinterpret_u64_u8 ( nibble_mask) , 0 ) }
364
+ let nibble_mask = vshrn_n_u16 ( vreinterpretq_u16_u8 ( v) , 4 ) ;
365
+ vget_lane_u64 ( vreinterpret_u64_u8 ( nibble_mask) , 0 )
362
366
}
363
367
364
368
#[ target_feature( enable = "neon" ) ]
365
369
#[ cfg( all( target_arch = "aarch64" , target_endian = "little" ) ) ]
370
+ // This can be removed once 1.87 is stable due to some intrinsics switching to safe.
371
+ #[ allow( unsafe_op_in_unsafe_fn) ]
366
372
unsafe fn analyze_source_file_neon (
367
373
src : & str ,
368
374
lines : & mut Vec < TextSize > ,
@@ -376,7 +382,7 @@ unsafe fn analyze_source_file_neon(
376
382
377
383
let chunk_count = src. len ( ) / CHUNK_SIZE ;
378
384
379
- let newline = unsafe { vdupq_n_s8 ( b'\n' as i8 ) } ;
385
+ let newline = vdupq_n_s8 ( b'\n' as i8 ) ;
380
386
381
387
// This variable keeps track of where we should start decoding a
382
388
// chunk. If a multi-byte character spans across chunk boundaries,
@@ -390,7 +396,7 @@ unsafe fn analyze_source_file_neon(
390
396
391
397
// For character in the chunk, see if its byte value is < 0, which
392
398
// indicates that it's part of a UTF-8 char.
393
- let multibyte_test = unsafe { vcltzq_s8 ( chunk) } ;
399
+ let multibyte_test = vcltzq_s8 ( chunk) ;
394
400
// Create a bit mask from the comparison results.
395
401
let multibyte_mask = unsafe { move_mask ( multibyte_test) } ;
396
402
@@ -399,7 +405,7 @@ unsafe fn analyze_source_file_neon(
399
405
assert ! ( intra_chunk_offset == 0 ) ;
400
406
401
407
// Check for newlines in the chunk
402
- let newlines_test = unsafe { vceqq_s8 ( chunk, newline) } ;
408
+ let newlines_test = vceqq_s8 ( chunk, newline) ;
403
409
let mut newlines_mask = unsafe { move_mask ( newlines_test) } ;
404
410
405
411
// If the bit mask is not all zero, there are newlines in this chunk.
0 commit comments