|
19 | 19 |
|
20 | 20 | use crate::walk::{filter_dirs, walk};
|
21 | 21 | use regex::{Regex, RegexSet};
|
22 |
| -use std::collections::HashMap; |
23 | 22 | use std::{ffi::OsStr, path::Path};
|
24 | 23 |
|
25 | 24 | /// Error code markdown is restricted to 80 columns because they can be
|
@@ -66,39 +65,8 @@ const ANNOTATIONS_TO_IGNORE: &[&str] = &[
|
66 | 65 | "//@ normalize-stderr-test",
|
67 | 66 | ];
|
68 | 67 |
|
69 |
| -fn generate_problems<'a>( |
70 |
| - consts: &'a [u32], |
71 |
| - letter_digit: &'a HashMap<char, char>, |
72 |
| -) -> impl Iterator<Item = u32> + 'a { |
73 |
| - consts.into_iter().flat_map(move |const_value| { |
74 |
| - let mut problem = format!("{:X}", const_value); |
75 |
| - for (key, value) in letter_digit { |
76 |
| - problem = problem.replace(&value.to_string(), &key.to_string()); |
77 |
| - } |
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(); |
83 |
| - (0..1 << indexes.len()).map(move |i| { |
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 } |
90 |
| - } else { |
91 |
| - c |
92 |
| - } |
93 |
| - }) |
94 |
| - .collect::<String>(); |
95 |
| - u32::from_str_radix(&result, 0x10).unwrap() |
96 |
| - }) |
97 |
| - }) |
98 |
| -} |
99 |
| - |
100 | 68 | // Intentionally written in decimal rather than hex
|
101 |
| -const ROOT_PROBLEMATIC_CONSTS: &[u32] = &[ |
| 69 | +const PROBLEMATIC_CONSTS: &[u32] = &[ |
102 | 70 | 184594741, 2880289470, 2881141438, 2965027518, 2976579765, 3203381950, 3405691582, 3405697037,
|
103 | 71 | 3735927486, 3735932941, 4027431614, 4276992702, 195934910, 252707358, 762133, 179681982,
|
104 | 72 | 173390526,
|
@@ -300,14 +268,16 @@ pub fn check(path: &Path, bad: &mut bool) {
|
300 | 268 | // We only check CSS files in rustdoc.
|
301 | 269 | path.extension().map_or(false, |e| e == "css") && !is_in(path, "src", "librustdoc")
|
302 | 270 | }
|
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>>(); |
308 |
| - let problematic_consts_strings: Vec<String> = (problematic_consts.iter().map(u32::to_string)) |
309 |
| - .chain(problematic_consts.iter().map(|v| format!("{:x}", v))) |
310 |
| - .chain(problematic_consts.iter().map(|v| format!("{:X}", v))) |
| 271 | + let problematic_consts_strings: Vec<String> = (PROBLEMATIC_CONSTS.iter().map(u32::to_string)) |
| 272 | + .chain(PROBLEMATIC_CONSTS.iter().map(|v| { |
| 273 | + format!("{:x}", v) |
| 274 | + .replace("a", "[aA4]") |
| 275 | + .replace("b", "[bB8]") |
| 276 | + .replace("c", "[cC]") |
| 277 | + .replace("d", "[dD]") |
| 278 | + .replace("e", "[eE3]") |
| 279 | + .replace("f", "[fF]") |
| 280 | + })) |
311 | 281 | .collect();
|
312 | 282 | let problematic_regex = RegexSet::new(problematic_consts_strings.as_slice()).unwrap();
|
313 | 283 |
|
|
0 commit comments