about summary refs log tree commit diff
diff options
context:
space:
mode:
authorElisha Hollander <just4now666666@gmail.com>2023-09-18 08:30:56 +0300
committerdonno2048 <just4now666666@gmail.com>2024-04-16 22:19:55 +0000
commit586d9d6dafc4d3f15c7feefafc02d5b63f4712c8 (patch)
tree4077e330196942c5b3c0940324b1158ed3f4f81a
parent4ff9f25467365bff7863246cc89152e1ca6a9b59 (diff)
downloadrust-586d9d6dafc4d3f15c7feefafc02d5b63f4712c8.tar.gz
rust-586d9d6dafc4d3f15c7feefafc02d5b63f4712c8.zip
format
-rw-r--r--src/tools/tidy/src/style.rs50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs
index a235bbcdebe..5e3aa28ed94 100644
--- a/src/tools/tidy/src/style.rs
+++ b/src/tools/tidy/src/style.rs
@@ -19,8 +19,8 @@
 
 use crate::walk::{filter_dirs, walk};
 use regex::{Regex, RegexSet};
-use std::{ffi::OsStr, path::Path};
 use std::collections::HashMap;
+use std::{ffi::OsStr, path::Path};
 
 /// Error code markdown is restricted to 80 columns because they can be
 /// displayed on the console with --example.
@@ -66,40 +66,42 @@ const ANNOTATIONS_TO_IGNORE: &[&str] = &[
     "//@ normalize-stderr-test",
 ];
 
-fn generate_problems<'a>(consts: &'a[u32], letter_digit: &'a HashMap<char, char>) -> impl Iterator<Item = u32> + 'a {
+fn generate_problems<'a>(
+    consts: &'a [u32],
+    letter_digit: &'a HashMap<char, char>,
+) -> impl Iterator<Item = u32> + 'a {
     consts.into_iter().flat_map(move |const_value| {
         let mut problem = format!("{:X}", const_value);
         for (key, value) in letter_digit {
             problem = problem.replace(&value.to_string(), &key.to_string());
         }
-        let indexes: Vec<usize> = problem.chars().enumerate().filter_map(|(index, c)| {
-            if letter_digit.contains_key(&c) {
-                Some(index)
-            }
-            else {
-                None
-            }
-        }).collect();
+        let indexes: Vec<usize> = problem
+            .chars()
+            .enumerate()
+            .filter_map(|(index, c)| if letter_digit.contains_key(&c) { Some(index) } else { None })
+            .collect();
         (0..1 << indexes.len()).map(move |i| {
-            let result = problem.chars().enumerate().map(|(index, c)| {
-                if let Some(pos) = indexes.iter().position(|&x| x == index) {
-                    if (i >> pos) & 1 == 1 {
-                        letter_digit[&c]
+            let result = problem
+                .chars()
+                .enumerate()
+                .map(|(index, c)| {
+                    if let Some(pos) = indexes.iter().position(|&x| x == index) {
+                        if (i >> pos) & 1 == 1 { letter_digit[&c] } else { c }
                     } else {
                         c
                     }
-                } else {
-                    c
-                }
-            }).collect::<String>();
+                })
+                .collect::<String>();
             u32::from_str_radix(&result, 0x10).unwrap()
         })
     })
 }
 
+// Intentionally written in decimal rather than hex
 const ROOT_PROBLEMATIC_CONSTS: &[u32] = &[
-        184594741, 2880289470, 2881141438, 2965027518, 2976579765, 3203381950, 3405691582, 3405697037,
-        3735927486, 3735932941, 4027431614, 4276992702, 195934910, 252707358, 762133, 179681982, 173390526,
+    184594741, 2880289470, 2881141438, 2965027518, 2976579765, 3203381950, 3405691582, 3405697037,
+    3735927486, 3735932941, 4027431614, 4276992702, 195934910, 252707358, 762133, 179681982,
+    173390526,
 ];
 
 const INTERNAL_COMPILER_DOCS_LINE: &str = "#### This error code is internal to the compiler and will not be emitted with normal Rust code.";
@@ -298,7 +300,11 @@ pub fn check(path: &Path, bad: &mut bool) {
         // We only check CSS files in rustdoc.
         path.extension().map_or(false, |e| e == "css") && !is_in(path, "src", "librustdoc")
     }
-    let problematic_consts = generate_problems(ROOT_PROBLEMATIC_CONSTS, &[('A', '4'), ('B', '8'), ('E', '3')].iter().cloned().collect()).collect::<Vec<u32>>();
+    let problematic_consts = generate_problems(
+        ROOT_PROBLEMATIC_CONSTS,
+        &[('A', '4'), ('B', '8'), ('E', '3')].iter().cloned().collect(),
+    )
+    .collect::<Vec<u32>>();
     let problematic_consts_strings: Vec<String> = (problematic_consts.iter().map(u32::to_string))
         .chain(problematic_consts.iter().map(|v| format!("{:x}", v)))
         .chain(problematic_consts.iter().map(|v| format!("{:X}", v)))
@@ -590,4 +596,4 @@ pub fn check(path: &Path, bad: &mut bool) {
         let _unused = skip_line_length;
         let _unused = skip_file_length;
     })
-        }
+    }