|
20 | 20 | usecrate::walk::{filter_dirs, walk}; |
21 | 21 | use regex::{Regex,RegexSet}; |
22 | 22 | use std::{ffi::OsStr, path::Path}; |
| 23 | +use std::collections::HashMap; |
23 | 24 |
|
24 | 25 | /// Error code markdown is restricted to 80 columns because they can be |
25 | 26 | /// displayed on the console with --example. |
@@ -65,137 +66,40 @@ const ANNOTATIONS_TO_IGNORE: &[&str] = &[ |
65 | 66 | "//@ normalize-stderr-test", |
66 | 67 | ]; |
67 | 68 |
|
68 | | -// Intentionally written in decimal rather than hex |
69 | | -constPROBLEMATIC_CONSTS:&[u32] = &[ |
70 | | -184594917,134263269,184582629,134250981,184594741,134263093,184582453,134250805, |
71 | | -2880289470,1269676734,2829957822,1219345086,2873998014,1263385278,2823666366,1213053630, |
72 | | -2880277182,1269664446,2829945534,1219332798,2873985726,1263372990,2823654078,1213041342, |
73 | | -2880287934,1269675198,2829956286,1219343550,2873996478,1263383742,2823664830,1213052094, |
74 | | -2880275646,1269662910,2829943998,1219331262,2873984190,1263371454,2823652542,1213039806, |
75 | | -2880289422,1269676686,2829957774,1219345038,2873997966,1263385230,2823666318,1213053582, |
76 | | -2880277134,1269664398,2829945486,1219332750,2873985678,1263372942,2823654030,1213041294, |
77 | | -2880287886,1269675150,2829956238,1219343502,2873996430,1263383694,2823664782,1213052046, |
78 | | -2880275598,1269662862,2829943950,1219331214,2873984142,1263371406,2823652494,1213039758, |
79 | | -2880289459,1269676723,2829957811,1219345075,2873998003,1263385267,2823666355,1213053619, |
80 | | -2880277171,1269664435,2829945523,1219332787,2873985715,1263372979,2823654067,1213041331, |
81 | | -2880287923,1269675187,2829956275,1219343539,2873996467,1263383731,2823664819,1213052083, |
82 | | -2880275635,1269662899,2829943987,1219331251,2873984179,1263371443,2823652531,1213039795, |
83 | | -2880289411,1269676675,2829957763,1219345027,2873997955,1263385219,2823666307,1213053571, |
84 | | -2880277123,1269664387,2829945475,1219332739,2873985667,1263372931,2823654019,1213041283, |
85 | | -2880287875,1269675139,2829956227,1219343491,2873996419,1263383683,2823664771,1213052035, |
86 | | -2880275587,1269662851,2829943939,1219331203,2873984131,1263371395,2823652483,1213039747, |
87 | | -2881141438,1270528702,2830809790,1220197054,2877995710,1267382974,2827664062,1217051326, |
88 | | -2880748222,1270135486,2830416574,1219803838,2877602494,1266989758,2827270846,1216658110, |
89 | | -2881129150,1270516414,2830797502,1220184766,2877983422,1267370686,2827651774,1217039038, |
90 | | -2880735934,1270123198,2830404286,1219791550,2877590206,1266977470,2827258558,1216645822, |
91 | | -2881139902,1270527166,2830808254,1220195518,2877994174,1267381438,2827662526,1217049790, |
92 | | -2880746686,1270133950,2830415038,1219802302,2877600958,1266988222,2827269310,1216656574, |
93 | | -2881127614,1270514878,2830795966,1220183230,2877981886,1267369150,2827650238,1217037502, |
94 | | -2880734398,1270121662,2830402750,1219790014,2877588670,1266975934,2827257022,1216644286, |
95 | | -2881141390,1270528654,2830809742,1220197006,2877995662,1267382926,2827664014,1217051278, |
96 | | -2880748174,1270135438,2830416526,1219803790,2877602446,1266989710,2827270798,1216658062, |
97 | | -2881129102,1270516366,2830797454,1220184718,2877983374,1267370638,2827651726,1217038990, |
98 | | -2880735886,1270123150,2830404238,1219791502,2877590158,1266977422,2827258510,1216645774, |
99 | | -2881139854,1270527118,2830808206,1220195470,2877994126,1267381390,2827662478,1217049742, |
100 | | -2880746638,1270133902,2830414990,1219802254,2877600910,1266988174,2827269262,1216656526, |
101 | | -2881127566,1270514830,2830795918,1220183182,2877981838,1267369102,2827650190,1217037454, |
102 | | -2880734350,1270121614,2830402702,1219789966,2877588622,1266975886,2827256974,1216644238, |
103 | | -2881141427,1270528691,2830809779,1220197043,2877995699,1267382963,2827664051,1217051315, |
104 | | -2880748211,1270135475,2830416563,1219803827,2877602483,1266989747,2827270835,1216658099, |
105 | | -2881129139,1270516403,2830797491,1220184755,2877983411,1267370675,2827651763,1217039027, |
106 | | -2880735923,1270123187,2830404275,1219791539,2877590195,1266977459,2827258547,1216645811, |
107 | | -2881139891,1270527155,2830808243,1220195507,2877994163,1267381427,2827662515,1217049779, |
108 | | -2880746675,1270133939,2830415027,1219802291,2877600947,1266988211,2827269299,1216656563, |
109 | | -2881127603,1270514867,2830795955,1220183219,2877981875,1267369139,2827650227,1217037491, |
110 | | -2880734387,1270121651,2830402739,1219790003,2877588659,1266975923,2827257011,1216644275, |
111 | | -2881141379,1270528643,2830809731,1220196995,2877995651,1267382915,2827664003,1217051267, |
112 | | -2880748163,1270135427,2830416515,1219803779,2877602435,1266989699,2827270787,1216658051, |
113 | | -2881129091,1270516355,2830797443,1220184707,2877983363,1267370627,2827651715,1217038979, |
114 | | -2880735875,1270123139,2830404227,1219791491,2877590147,1266977411,2827258499,1216645763, |
115 | | -2881139843,1270527107,2830808195,1220195459,2877994115,1267381379,2827662467,1217049731, |
116 | | -2880746627,1270133891,2830414979,1219802243,2877600899,1266988163,2827269251,1216656515, |
117 | | -2881127555,1270514819,2830795907,1220183171,2877981827,1267369091,2827650179,1217037443, |
118 | | -2880734339,1270121603,2830402691,1219789955,2877588611,1266975875,2827256963,1216644227, |
119 | | -2965027518,2159721150,2961881790,2156575422,2964634302,2159327934,2961488574,2156182206, |
120 | | -2965015230,2159708862,2961869502,2156563134,2964622014,2159315646,2961476286,2156169918, |
121 | | -2965025982,2159719614,2961880254,2156573886,2964632766,2159326398,2961487038,2156180670, |
122 | | -2965013694,2159707326,2961867966,2156561598,2964620478,2159314110,2961474750,2156168382, |
123 | | -2965027470,2159721102,2961881742,2156575374,2964634254,2159327886,2961488526,2156182158, |
124 | | -2965015182,2159708814,2961869454,2156563086,2964621966,2159315598,2961476238,2156169870, |
125 | | -2965025934,2159719566,2961880206,2156573838,2964632718,2159326350,2961486990,2156180622, |
126 | | -2965013646,2159707278,2961867918,2156561550,2964620430,2159314062,2961474702,2156168334, |
127 | | -2965027507,2159721139,2961881779,2156575411,2964634291,2159327923,2961488563,2156182195, |
128 | | -2965015219,2159708851,2961869491,2156563123,2964622003,2159315635,2961476275,2156169907, |
129 | | -2965025971,2159719603,2961880243,2156573875,2964632755,2159326387,2961487027,2156180659, |
130 | | -2965013683,2159707315,2961867955,2156561587,2964620467,2159314099,2961474739,2156168371, |
131 | | -2965027459,2159721091,2961881731,2156575363,2964634243,2159327875,2961488515,2156182147, |
132 | | -2965015171,2159708803,2961869443,2156563075,2964621955,2159315587,2961476227,2156169859, |
133 | | -2965025923,2159719555,2961880195,2156573827,2964632707,2159326339,2961486979,2156180611, |
134 | | -2965013635,2159707267,2961867907,2156561539,2964620419,2159314051,2961474691,2156168323, |
135 | | -2976579765,2171273397,2976383157,2171076789,2976579717,2171273349,2976383109,2171076741, |
136 | | -3203381950,2398075582,3018832574,2213526206,3191847614,2386541246,3007298238,2201991870, |
137 | | -3203369662,2398063294,3018820286,2213513918,3191835326,2386528958,3007285950,2201979582, |
138 | | -3203380414,2398074046,3018831038,2213524670,3191846078,2386539710,3007296702,2201990334, |
139 | | -3203368126,2398061758,3018818750,2213512382,3191833790,2386527422,3007284414,2201978046, |
140 | | -3203381902,2398075534,3018832526,2213526158,3191847566,2386541198,3007298190,2201991822, |
141 | | -3203369614,2398063246,3018820238,2213513870,3191835278,2386528910,3007285902,2201979534, |
142 | | -3203380366,2398073998,3018830990,2213524622,3191846030,2386539662,3007296654,2201990286, |
143 | | -3203368078,2398061710,3018818702,2213512334,3191833742,2386527374,3007284366,2201977998, |
144 | | -3203381939,2398075571,3018832563,2213526195,3191847603,2386541235,3007298227,2201991859, |
145 | | -3203369651,2398063283,3018820275,2213513907,3191835315,2386528947,3007285939,2201979571, |
146 | | -3203380403,2398074035,3018831027,2213524659,3191846067,2386539699,3007296691,2201990323, |
147 | | -3203368115,2398061747,3018818739,2213512371,3191833779,2386527411,3007284403,2201978035, |
148 | | -3203381891,2398075523,3018832515,2213526147,3191847555,2386541187,3007298179,2201991811, |
149 | | -3203369603,2398063235,3018820227,2213513859,3191835267,2386528899,3007285891,2201979523, |
150 | | -3203380355,2398073987,3018830979,2213524611,3191846019,2386539651,3007296643,2201990275, |
151 | | -3203368067,2398061699,3018818691,2213512323,3191833731,2386527363,3007284355,2201977987, |
152 | | -3405691582,3305028286,3404970686,3304307390,3405679294,3305015998,3404958398,3304295102, |
153 | | -3405690046,3305026750,3404969150,3304305854,3405677758,3305014462,3404956862,3304293566, |
154 | | -3405691534,3305028238,3404970638,3304307342,3405679246,3305015950,3404958350,3304295054, |
155 | | -3405689998,3305026702,3404969102,3304305806,3405677710,3305014414,3404956814,3304293518, |
156 | | -3405691571,3305028275,3404970675,3304307379,3405679283,3305015987,3404958387,3304295091, |
157 | | -3405690035,3305026739,3404969139,3304305843,3405677747,3305014451,3404956851,3304293555, |
158 | | -3405691523,3305028227,3404970627,3304307331,3405679235,3305015939,3404958339,3304295043, |
159 | | -3405689987,3305026691,3404969091,3304305795,3405677699,3305014403,3404956803,3304293507, |
160 | | -3405697037,3305033741,3404976141,3304312845,3735927486,3551378110,3729636030,3545086654, |
161 | | -3735915198,3551365822,3729623742,3545074366,3735925950,3551376574,3729634494,3545085118, |
162 | | -3735913662,3551364286,3729622206,3545072830,3735927438,3551378062,3729635982,3545086606, |
163 | | -3735915150,3551365774,3729623694,3545074318,3735925902,3551376526,3729634446,3545085070, |
164 | | -3735913614,3551364238,3729622158,3545072782,3735927475,3551378099,3729636019,3545086643, |
165 | | -3735915187,3551365811,3729623731,3545074355,3735925939,3551376563,3729634483,3545085107, |
166 | | -3735913651,3551364275,3729622195,3545072819,3735927427,3551378051,3729635971,3545086595, |
167 | | -3735915139,3551365763,3729623683,3545074307,3735925891,3551376515,3729634435,3545085059, |
168 | | -3735913603,3551364227,3729622147,3545072771,3735932941,3551383565,3729641485,3545092109, |
169 | | -4027431614,4027419326,4027430078,4027417790,4027431566,4027419278,4027430030,4027417742, |
170 | | -4027431603,4027419315,4027430067,4027417779,4027431555,4027419267,4027430019,4027417731, |
171 | | -4276992702,4092443326,4265458366,4080908990,4276980414,4092431038,4265446078,4080896702, |
172 | | -4276991166,4092441790,4265456830,4080907454,4276978878,4092429502,4265444542,4080895166, |
173 | | -4276992654,4092443278,4265458318,4080908942,4276980366,4092430990,4265446030,4080896654, |
174 | | -4276991118,4092441742,4265456782,4080907406,4276978830,4092429454,4265444494,4080895118, |
175 | | -4276992691,4092443315,4265458355,4080908979,4276980403,4092431027,4265446067,4080896691, |
176 | | -4276991155,4092441779,4265456819,4080907443,4276978867,4092429491,4265444531,4080895155, |
177 | | -4276992643,4092443267,4265458307,4080908931,4276980355,4092430979,4265446019,4080896643, |
178 | | -4276991107,4092441731,4265456771,4080907395,4276978819,4092429443,4265444483,4080895107, |
179 | | -195934910,145603262,189643454,139311806,195922622,145590974,189631166,139299518, |
180 | | -195933374,145601726,189641918,139310270,195921086,145589438,189629630,139297982, |
181 | | -195934862,145603214,189643406,139311758,195922574,145590926,189631118,139299470, |
182 | | -195933326,145601678,189641870,139310222,195921038,145589390,189629582,139297934, |
183 | | -195934899,145603251,189643443,139311795,195922611,145590963,189631155,139299507, |
184 | | -195933363,145601715,189641907,139310259,195921075,145589427,189629619,139297971, |
185 | | -195934851,145603203,189643395,139311747,195922563,145590915,189631107,139299459, |
186 | | -195933315,145601667,189641859,139310211,195921027,145589379,189629571,139297923, |
187 | | -252707358,252707347,762133,565525,737557,540949,179681982,79018686,176536254,75872958, |
188 | | -179669694,79006398,176523966,75860670,179680446,79017150,176534718,75871422,179668158, |
189 | | -79004862,176522430,75859134,179681934,79018638,176536206,75872910,179669646,79006350, |
190 | | -176523918,75860622,179680398,79017102,176534670,75871374,179668110,79004814,176522382, |
191 | | -75859086,179681971,79018675,176536243,75872947,179669683,79006387,176523955,75860659, |
192 | | -179680435,79017139,176534707,75871411,179668147,79004851,176522419,75859123,179681923, |
193 | | -79018627,176536195,75872899,179669635,79006339,176523907,75860611,179680387,79017091, |
194 | | -176534659,75871363,179668099,79004803,176522371,75859075,173390526,72727230,173378238, |
195 | | -72714942,173388990,72725694,173376702,72713406,173390478,72727182,173378190,72714894, |
196 | | -173388942,72725646,173376654,72713358,173390515,72727219,173378227,72714931,173388979, |
197 | | -72725683,173376691,72713395,173390467,72727171,173378179,72714883,173388931,72725635, |
198 | | -173376643,72713347, |
| 69 | +fngenerate_problems<'a>(consts:&'a[u32],letter_digit:&'aHashMap<char,char>) -> implIterator<Item = u32> + 'a{ |
| 70 | + consts.into_iter().flat_map(move |const_value| { |
| 71 | +letmut problem = format!("{:X}", const_value); |
| 72 | +for(key, value)in letter_digit { |
| 73 | + problem = problem.replace(&value.to_string(),&key.to_string()); |
| 74 | +} |
| 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(); |
| 83 | +(0..1 << indexes.len()).map(move |i| { |
| 84 | +let result = problem.chars().enumerate().map(|(index, c)| { |
| 85 | +ifletSome(pos) = indexes.iter().position(|&x| x == index){ |
| 86 | +if(i >> pos)&1 == 1{ |
| 87 | + letter_digit[&c] |
| 88 | +}else{ |
| 89 | + c |
| 90 | +} |
| 91 | +}else{ |
| 92 | + c |
| 93 | +} |
| 94 | +}).collect::<String>(); |
| 95 | + u32::from_str_radix(&result,0x10).unwrap() |
| 96 | +}) |
| 97 | +}) |
| 98 | +} |
| 99 | + |
| 100 | +constROOT_PROBLEMATIC_CONSTS:&[u32] = &[ |
| 101 | +184594741,2880289470,2881141438,2965027518,2976579765,3203381950,3405691582,340569703, |
| 102 | +3735927486,3735932941,4027431614,4276992702,195934910,252707358,762133,179681982,173390526, |
199 | 103 | ]; |
200 | 104 |
|
201 | 105 | constINTERNAL_COMPILER_DOCS_LINE:&str = "#### This error code is internal to the compiler and will not be emitted with normal Rust code."; |
@@ -394,10 +298,10 @@ pub fn check(path: &Path, bad: &mut bool) { |
394 | 298 | // We only check CSS files in rustdoc. |
395 | 299 | path.extension().map_or(false, |e| e == "css") && !is_in(path,"src","librustdoc") |
396 | 300 | } |
397 | | - |
398 | | -let problematic_consts_strings:Vec<String> = (PROBLEMATIC_CONSTS.iter().map(u32::to_string)) |
399 | | -.chain(PROBLEMATIC_CONSTS.iter().map(|v| format!("{:x}", v))) |
400 | | -.chain(PROBLEMATIC_CONSTS.iter().map(|v| format!("{:X}", v))) |
| 301 | +let problematic_consts = generate_problems(ROOT_PROBLEMATIC_CONSTS,&[('A','4'),('B','8'),('E','3')].iter().cloned().collect()).collect::<Vec<u32>>(); |
| 302 | +let problematic_consts_strings:Vec<String> = (problematic_consts.iter().map(u32::to_string)) |
| 303 | +.chain(problematic_consts.iter().map(|v| format!("{:x}", v))) |
| 304 | +.chain(problematic_consts.iter().map(|v| format!("{:X}", v))) |
401 | 305 | .collect(); |
402 | 306 | let problematic_regex = RegexSet::new(problematic_consts_strings.as_slice()).unwrap(); |
403 | 307 |
|
@@ -686,4 +590,4 @@ pub fn check(path: &Path, bad: &mut bool) { |
686 | 590 | let _unused = skip_line_length; |
687 | 591 | let _unused = skip_file_length; |
688 | 592 | }) |
689 | | -} |
| 593 | +} |
0 commit comments