diff options
| author | Elisha Hollander <just4now666666@gmail.com> | 2024-04-17 20:40:48 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-17 20:40:48 +0300 |
| commit | da35c19311801965501cd6c417bb29a71571e925 (patch) | |
| tree | 1e305a05b700aed367991847ac2c5a0de09f4452 | |
| parent | dd615004eaf17cb1a989ff355ef8052bbc98f740 (diff) | |
| download | rust-da35c19311801965501cd6c417bb29a71571e925.tar.gz rust-da35c19311801965501cd6c417bb29a71571e925.zip | |
use a function to generate the regex
mainly for testing
| -rw-r--r-- | src/tools/tidy/src/style.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index 7a35ff91beb..f2902bbc634 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -107,6 +107,16 @@ const ROOT_PROBLEMATIC_CONSTS: &[u32] = &[ 173390526, ]; +fn generate_problematic_regex( + consts: &[u32], + letter_digit: &FxHashMap<char, char>, +) -> RegexSet { + RegexSet::new( + generate_problems(consts, letter_digit) + .flat_map(|v| vec![v.to_string(), format!("{:x}", v), format!("{:X}", v)]) + ).unwrap() +} + const INTERNAL_COMPILER_DOCS_LINE: &str = "#### This error code is internal to the compiler and will not be emitted with normal Rust code."; /// Parser states for `line_is_url`. @@ -303,16 +313,10 @@ 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( + let problematic_regex = generate_problematic_regex( 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))) - .collect(); - let problematic_regex = RegexSet::new(problematic_consts_strings.as_slice()).unwrap(); + ); walk(path, skip, &mut |entry, contents| { let file = entry.path(); |
