about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-07-14 13:25:06 -0400
committerMichael Goulet <michael@errs.io>2024-07-16 00:02:36 -0400
commit71eb49c318c3e7c25a6306414298d78accd164df (patch)
tree428be5ea4c5c5dc14cb2abd7c8d4d14bd23a9702
parentcae4a84146c88cf917fa102c97ad9427591f6040 (diff)
downloadrust-71eb49c318c3e7c25a6306414298d78accd164df.tar.gz
rust-71eb49c318c3e7c25a6306414298d78accd164df.zip
fmt
-rw-r--r--compiler/rustc_span/src/analyze_source_file.rs91
1 files changed, 49 insertions, 42 deletions
diff --git a/compiler/rustc_span/src/analyze_source_file.rs b/compiler/rustc_span/src/analyze_source_file.rs
index 7da7dc610ec..80c5c3bf1b5 100644
--- a/compiler/rustc_span/src/analyze_source_file.rs
+++ b/compiler/rustc_span/src/analyze_source_file.rs
@@ -35,25 +35,25 @@ pub fn analyze_source_file(
 
 cfg_match! {
     cfg(any(target_arch = "x86", target_arch = "x86_64")) => {
-        fn analyze_source_file_dispatch(src: &str,
-                                    lines: &mut Vec<RelativeBytePos>,
-                                    multi_byte_chars: &mut Vec<MultiByteChar>,
-                                    non_narrow_chars: &mut Vec<NonNarrowChar>) {
+        fn analyze_source_file_dispatch(
+            src: &str,
+            lines: &mut Vec<RelativeBytePos>,
+            multi_byte_chars: &mut Vec<MultiByteChar>,
+            non_narrow_chars: &mut Vec<NonNarrowChar>,
+        ) {
             if is_x86_feature_detected!("sse2") {
                 unsafe {
-                    analyze_source_file_sse2(src,
-                                         lines,
-                                         multi_byte_chars,
-                                         non_narrow_chars);
+                    analyze_source_file_sse2(src, lines, multi_byte_chars, non_narrow_chars);
                 }
             } else {
-                analyze_source_file_generic(src,
-                                        src.len(),
-                                        RelativeBytePos::from_u32(0),
-                                        lines,
-                                        multi_byte_chars,
-                                        non_narrow_chars);
-
+                analyze_source_file_generic(
+                    src,
+                    src.len(),
+                    RelativeBytePos::from_u32(0),
+                    lines,
+                    multi_byte_chars,
+                    non_narrow_chars,
+                );
             }
         }
 
@@ -62,10 +62,12 @@ cfg_match! {
         /// function falls back to the generic implementation. Otherwise it uses
         /// SSE2 intrinsics to quickly find all newlines.
         #[target_feature(enable = "sse2")]
-        unsafe fn analyze_source_file_sse2(src: &str,
-                                       lines: &mut Vec<RelativeBytePos>,
-                                       multi_byte_chars: &mut Vec<MultiByteChar>,
-                                       non_narrow_chars: &mut Vec<NonNarrowChar>) {
+        unsafe fn analyze_source_file_sse2(
+            src: &str,
+            lines: &mut Vec<RelativeBytePos>,
+            multi_byte_chars: &mut Vec<MultiByteChar>,
+            non_narrow_chars: &mut Vec<NonNarrowChar>,
+        ) {
             #[cfg(target_arch = "x86")]
             use std::arch::x86::*;
             #[cfg(target_arch = "x86_64")]
@@ -83,7 +85,7 @@ cfg_match! {
             // handled it.
             let mut intra_chunk_offset = 0;
 
-            for chunk_index in 0 .. chunk_count {
+            for chunk_index in 0..chunk_count {
                 let ptr = src_bytes.as_ptr() as *const __m128i;
                 // We don't know if the pointer is aligned to 16 bytes, so we
                 // use `loadu`, which supports unaligned loading.
@@ -126,7 +128,7 @@ cfg_match! {
 
                                 if index >= CHUNK_SIZE as u32 {
                                     // We have arrived at the end of the chunk.
-                                    break
+                                    break;
                                 }
 
                                 lines.push(RelativeBytePos(index) + output_offset);
@@ -137,14 +139,14 @@ cfg_match! {
 
                             // We are done for this chunk. All control characters were
                             // newlines and we took care of those.
-                            continue
+                            continue;
                         } else {
                             // Some of the control characters are not newlines,
                             // fall through to the slow path below.
                         }
                     } else {
                         // No control characters, nothing to record for this chunk
-                        continue
+                        continue;
                     }
                 }
 
@@ -152,43 +154,48 @@ cfg_match! {
                 // There are control chars in here, fallback to generic decoding.
                 let scan_start = chunk_index * CHUNK_SIZE + intra_chunk_offset;
                 intra_chunk_offset = analyze_source_file_generic(
-                    &src[scan_start .. ],
+                    &src[scan_start..],
                     CHUNK_SIZE - intra_chunk_offset,
                     RelativeBytePos::from_usize(scan_start),
                     lines,
                     multi_byte_chars,
-                    non_narrow_chars
+                    non_narrow_chars,
                 );
             }
 
             // There might still be a tail left to analyze
             let tail_start = chunk_count * CHUNK_SIZE + intra_chunk_offset;
             if tail_start < src.len() {
-                analyze_source_file_generic(&src[tail_start ..],
-                                        src.len() - tail_start,
-                                        RelativeBytePos::from_usize(tail_start),
-                                        lines,
-                                        multi_byte_chars,
-                                        non_narrow_chars);
+                analyze_source_file_generic(
+                    &src[tail_start..],
+                    src.len() - tail_start,
+                    RelativeBytePos::from_usize(tail_start),
+                    lines,
+                    multi_byte_chars,
+                    non_narrow_chars,
+                );
             }
         }
     }
     _ => {
         // The target (or compiler version) does not support SSE2 ...
-        fn analyze_source_file_dispatch(src: &str,
-                                    lines: &mut Vec<RelativeBytePos>,
-                                    multi_byte_chars: &mut Vec<MultiByteChar>,
-                                    non_narrow_chars: &mut Vec<NonNarrowChar>) {
-            analyze_source_file_generic(src,
-                                    src.len(),
-                                    RelativeBytePos::from_u32(0),
-                                    lines,
-                                    multi_byte_chars,
-                                    non_narrow_chars);
+        fn analyze_source_file_dispatch(
+            src: &str,
+            lines: &mut Vec<RelativeBytePos>,
+            multi_byte_chars: &mut Vec<MultiByteChar>,
+            non_narrow_chars: &mut Vec<NonNarrowChar>,
+        ) {
+            analyze_source_file_generic(
+                src,
+                src.len(),
+                RelativeBytePos::from_u32(0),
+                lines,
+                multi_byte_chars,
+                non_narrow_chars,
+            );
         }
     }
 }
-
 // `scan_len` determines the number of bytes in `src` to scan. Note that the
 // function can read past `scan_len` if a multi-byte character start within the
 // range but extends past it. The overflow is returned by the function.