Skip to content

Commit da35c19

Browse files
authored
use a function to generate the regex
mainly for testing
1 parent dd61500 commit da35c19

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/tools/tidy/src/style.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ const ROOT_PROBLEMATIC_CONSTS: &[u32] = &[
107107
173390526,
108108
];
109109

110+
fn generate_problematic_regex(
111+
consts: &[u32],
112+
letter_digit: &FxHashMap<char, char>,
113+
) -> RegexSet {
114+
RegexSet::new(
115+
generate_problems(consts, letter_digit)
116+
.flat_map(|v| vec![v.to_string(), format!("{:x}", v), format!("{:X}", v)])
117+
).unwrap()
118+
}
119+
110120
const INTERNAL_COMPILER_DOCS_LINE: &str = "#### This error code is internal to the compiler and will not be emitted with normal Rust code.";
111121

112122
/// Parser states for `line_is_url`.
@@ -303,16 +313,10 @@ pub fn check(path: &Path, bad: &mut bool) {
303313
// We only check CSS files in rustdoc.
304314
path.extension().map_or(false, |e| e == "css") && !is_in(path, "src", "librustdoc")
305315
}
306-
let problematic_consts = generate_problems(
316+
let problematic_regex = generate_problematic_regex(
307317
ROOT_PROBLEMATIC_CONSTS,
308318
&[('A', '4'), ('B', '8'), ('E', '3')].iter().cloned().collect(),
309-
)
310-
.collect::<Vec<u32>>();
311-
let problematic_consts_strings: Vec<String> = (problematic_consts.iter().map(u32::to_string))
312-
.chain(problematic_consts.iter().map(|v| format!("{:x}", v)))
313-
.chain(problematic_consts.iter().map(|v| format!("{:X}", v)))
314-
.collect();
315-
let problematic_regex = RegexSet::new(problematic_consts_strings.as_slice()).unwrap();
319+
);
316320

317321
walk(path, skip, &mut |entry, contents| {
318322
let file = entry.path();

0 commit comments

Comments
 (0)