Skip to content

Commit 586d9d6

Browse files
committed
format
1 parent 4ff9f25 commit 586d9d6

File tree

1 file changed

+28
-22
lines changed

1 file changed

+28
-22
lines changed

src/tools/tidy/src/style.rs

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
use crate::walk::{filter_dirs, walk};
2121
use regex::{Regex, RegexSet};
22-
use std::{ffi::OsStr, path::Path};
2322
use std::collections::HashMap;
23+
use std::{ffi::OsStr, path::Path};
2424

2525
/// Error code markdown is restricted to 80 columns because they can be
2626
/// displayed on the console with --example.
@@ -66,40 +66,42 @@ const ANNOTATIONS_TO_IGNORE: &[&str] = &[
6666
"//@ normalize-stderr-test",
6767
];
6868

69-
fn generate_problems<'a>(consts: &'a[u32], letter_digit: &'a HashMap<char, char>) -> impl Iterator<Item = u32> + 'a {
69+
fn generate_problems<'a>(
70+
consts: &'a [u32],
71+
letter_digit: &'a HashMap<char, char>,
72+
) -> impl Iterator<Item = u32> + 'a {
7073
consts.into_iter().flat_map(move |const_value| {
7174
let mut problem = format!("{:X}", const_value);
7275
for (key, value) in letter_digit {
7376
problem = problem.replace(&value.to_string(), &key.to_string());
7477
}
75-
let indexes: Vec<usize> = problem.chars().enumerate().filter_map(|(index, c)| {
76-
if letter_digit.contains_key(&c) {
77-
Some(index)
78-
}
79-
else {
80-
None
81-
}
82-
}).collect();
78+
let indexes: Vec<usize> = problem
79+
.chars()
80+
.enumerate()
81+
.filter_map(|(index, c)| if letter_digit.contains_key(&c) { Some(index) } else { None })
82+
.collect();
8383
(0..1 << indexes.len()).map(move |i| {
84-
let result = problem.chars().enumerate().map(|(index, c)| {
85-
if let Some(pos) = indexes.iter().position(|&x| x == index) {
86-
if (i >> pos) & 1 == 1 {
87-
letter_digit[&c]
84+
let result = problem
85+
.chars()
86+
.enumerate()
87+
.map(|(index, c)| {
88+
if let Some(pos) = indexes.iter().position(|&x| x == index) {
89+
if (i >> pos) & 1 == 1 { letter_digit[&c] } else { c }
8890
} else {
8991
c
9092
}
91-
} else {
92-
c
93-
}
94-
}).collect::<String>();
93+
})
94+
.collect::<String>();
9595
u32::from_str_radix(&result, 0x10).unwrap()
9696
})
9797
})
9898
}
9999

100+
// Intentionally written in decimal rather than hex
100101
const ROOT_PROBLEMATIC_CONSTS: &[u32] = &[
101-
184594741, 2880289470, 2881141438, 2965027518, 2976579765, 3203381950, 3405691582, 3405697037,
102-
3735927486, 3735932941, 4027431614, 4276992702, 195934910, 252707358, 762133, 179681982, 173390526,
102+
184594741, 2880289470, 2881141438, 2965027518, 2976579765, 3203381950, 3405691582, 3405697037,
103+
3735927486, 3735932941, 4027431614, 4276992702, 195934910, 252707358, 762133, 179681982,
104+
173390526,
103105
];
104106

105107
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) {
298300
// We only check CSS files in rustdoc.
299301
path.extension().map_or(false, |e| e == "css") && !is_in(path, "src", "librustdoc")
300302
}
301-
let problematic_consts = generate_problems(ROOT_PROBLEMATIC_CONSTS, &[('A', '4'), ('B', '8'), ('E', '3')].iter().cloned().collect()).collect::<Vec<u32>>();
303+
let problematic_consts = generate_problems(
304+
ROOT_PROBLEMATIC_CONSTS,
305+
&[('A', '4'), ('B', '8'), ('E', '3')].iter().cloned().collect(),
306+
)
307+
.collect::<Vec<u32>>();
302308
let problematic_consts_strings: Vec<String> = (problematic_consts.iter().map(u32::to_string))
303309
.chain(problematic_consts.iter().map(|v| format!("{:x}", v)))
304310
.chain(problematic_consts.iter().map(|v| format!("{:X}", v)))
@@ -590,4 +596,4 @@ pub fn check(path: &Path, bad: &mut bool) {
590596
let _unused = skip_line_length;
591597
let _unused = skip_file_length;
592598
})
593-
}
599+
}

0 commit comments

Comments
 (0)