]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-29740.rs
Merge commit '0eff589afc83e21a03a168497bbab6b4dfbb4ef6' into clippyup
[rust.git] / src / test / ui / issues / issue-29740.rs
1 // check-pass
2 #![allow(dead_code)]
3 // Regression test for #29740. Inefficient MIR matching algorithms
4 // generated way too much code for this sort of case, leading to OOM.
5 #![allow(non_snake_case)]
6
7 pub mod KeyboardEventConstants {
8     pub const DOM_KEY_LOCATION_STANDARD: u32 = 0;
9     pub const DOM_KEY_LOCATION_LEFT: u32 = 1;
10     pub const DOM_KEY_LOCATION_RIGHT: u32 = 2;
11     pub const DOM_KEY_LOCATION_NUMPAD: u32 = 3;
12 } // mod KeyboardEventConstants
13
14 pub enum Key {
15     Space,
16     Apostrophe,
17     Comma,
18     Minus,
19     Period,
20     Slash,
21     Num0,
22     Num1,
23     Num2,
24     Num3,
25     Num4,
26     Num5,
27     Num6,
28     Num7,
29     Num8,
30     Num9,
31     Semicolon,
32     Equal,
33     A,
34     B,
35     C,
36     D,
37     E,
38     F,
39     G,
40     H,
41     I,
42     J,
43     K,
44     L,
45     M,
46     N,
47     O,
48     P,
49     Q,
50     R,
51     S,
52     T,
53     U,
54     V,
55     W,
56     X,
57     Y,
58     Z,
59     LeftBracket,
60     Backslash,
61     RightBracket,
62     GraveAccent,
63     World1,
64     World2,
65
66     Escape,
67     Enter,
68     Tab,
69     Backspace,
70     Insert,
71     Delete,
72     Right,
73     Left,
74     Down,
75     Up,
76     PageUp,
77     PageDown,
78     Home,
79     End,
80     CapsLock,
81     ScrollLock,
82     NumLock,
83     PrintScreen,
84     Pause,
85     F1,
86     F2,
87     F3,
88     F4,
89     F5,
90     F6,
91     F7,
92     F8,
93     F9,
94     F10,
95     F11,
96     F12,
97     F13,
98     F14,
99     F15,
100     F16,
101     F17,
102     F18,
103     F19,
104     F20,
105     F21,
106     F22,
107     F23,
108     F24,
109     F25,
110     Kp0,
111     Kp1,
112     Kp2,
113     Kp3,
114     Kp4,
115     Kp5,
116     Kp6,
117     Kp7,
118     Kp8,
119     Kp9,
120     KpDecimal,
121     KpDivide,
122     KpMultiply,
123     KpSubtract,
124     KpAdd,
125     KpEnter,
126     KpEqual,
127     LeftShift,
128     LeftControl,
129     LeftAlt,
130     LeftSuper,
131     RightShift,
132     RightControl,
133     RightAlt,
134     RightSuper,
135     Menu,
136 }
137
138 fn key_from_string(key_string: &str, location: u32) -> Option<Key> {
139     match key_string {
140         " " => Some(Key::Space),
141         "\"" => Some(Key::Apostrophe),
142         "'" => Some(Key::Apostrophe),
143         "<" => Some(Key::Comma),
144         "," => Some(Key::Comma),
145         "_" => Some(Key::Minus),
146         "-" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Minus),
147         ">" => Some(Key::Period),
148         "." if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Period),
149         "?" => Some(Key::Slash),
150         "/" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Slash),
151         "~" => Some(Key::GraveAccent),
152         "`" => Some(Key::GraveAccent),
153         ")" => Some(Key::Num0),
154         "0" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num0),
155         "!" => Some(Key::Num1),
156         "1" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num1),
157         "@" => Some(Key::Num2),
158         "2" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num2),
159         "#" => Some(Key::Num3),
160         "3" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num3),
161         "$" => Some(Key::Num4),
162         "4" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num4),
163         "%" => Some(Key::Num5),
164         "5" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num5),
165         "^" => Some(Key::Num6),
166         "6" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num6),
167         "&" => Some(Key::Num7),
168         "7" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num7),
169         "*" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num8),
170         "8" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num8),
171         "(" => Some(Key::Num9),
172         "9" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num9),
173         ":" => Some(Key::Semicolon),
174         ";" => Some(Key::Semicolon),
175         "+" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Equal),
176         "=" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Equal),
177         "A" => Some(Key::A),
178         "a" => Some(Key::A),
179         "B" => Some(Key::B),
180         "b" => Some(Key::B),
181         "C" => Some(Key::C),
182         "c" => Some(Key::C),
183         "D" => Some(Key::D),
184         "d" => Some(Key::D),
185         "E" => Some(Key::E),
186         "e" => Some(Key::E),
187         "F" => Some(Key::F),
188         "f" => Some(Key::F),
189         "G" => Some(Key::G),
190         "g" => Some(Key::G),
191         "H" => Some(Key::H),
192         "h" => Some(Key::H),
193         "I" => Some(Key::I),
194         "i" => Some(Key::I),
195         "J" => Some(Key::J),
196         "j" => Some(Key::J),
197         "K" => Some(Key::K),
198         "k" => Some(Key::K),
199         "L" => Some(Key::L),
200         "l" => Some(Key::L),
201         "M" => Some(Key::M),
202         "m" => Some(Key::M),
203         "N" => Some(Key::N),
204         "n" => Some(Key::N),
205         "O" => Some(Key::O),
206         "o" => Some(Key::O),
207         "P" => Some(Key::P),
208         "p" => Some(Key::P),
209         "Q" => Some(Key::Q),
210         "q" => Some(Key::Q),
211         "R" => Some(Key::R),
212         "r" => Some(Key::R),
213         "S" => Some(Key::S),
214         "s" => Some(Key::S),
215         "T" => Some(Key::T),
216         "t" => Some(Key::T),
217         "U" => Some(Key::U),
218         "u" => Some(Key::U),
219         "V" => Some(Key::V),
220         "v" => Some(Key::V),
221         "W" => Some(Key::W),
222         "w" => Some(Key::W),
223         "X" => Some(Key::X),
224         "x" => Some(Key::X),
225         "Y" => Some(Key::Y),
226         "y" => Some(Key::Y),
227         "Z" => Some(Key::Z),
228         "z" => Some(Key::Z),
229         "{" => Some(Key::LeftBracket),
230         "[" => Some(Key::LeftBracket),
231         "|" => Some(Key::Backslash),
232         "\\" => Some(Key::Backslash),
233         "}" => Some(Key::RightBracket),
234         "]" => Some(Key::RightBracket),
235         "Escape" => Some(Key::Escape),
236         "Enter" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD
237                 => Some(Key::Enter),
238         "Tab" => Some(Key::Tab),
239         "Backspace" => Some(Key::Backspace),
240         "Insert" => Some(Key::Insert),
241         "Delete" => Some(Key::Delete),
242         "ArrowRight" => Some(Key::Right),
243         "ArrowLeft" => Some(Key::Left),
244         "ArrowDown" => Some(Key::Down),
245         "ArrowUp" => Some(Key::Up),
246         "PageUp" => Some(Key::PageUp),
247         "PageDown" => Some(Key::PageDown),
248         "Home" => Some(Key::Home),
249         "End" => Some(Key::End),
250         "CapsLock" => Some(Key::CapsLock),
251         "ScrollLock" => Some(Key::ScrollLock),
252         "NumLock" => Some(Key::NumLock),
253         "PrintScreen" => Some(Key::PrintScreen),
254         "Pause" => Some(Key::Pause),
255         "F1" => Some(Key::F1),
256         "F2" => Some(Key::F2),
257         "F3" => Some(Key::F3),
258         "F4" => Some(Key::F4),
259         "F5" => Some(Key::F5),
260         "F6" => Some(Key::F6),
261         "F7" => Some(Key::F7),
262         "F8" => Some(Key::F8),
263         "F9" => Some(Key::F9),
264         "F10" => Some(Key::F10),
265         "F11" => Some(Key::F11),
266         "F12" => Some(Key::F12),
267         "F13" => Some(Key::F13),
268         "F14" => Some(Key::F14),
269         "F15" => Some(Key::F15),
270         "F16" => Some(Key::F16),
271         "F17" => Some(Key::F17),
272         "F18" => Some(Key::F18),
273         "F19" => Some(Key::F19),
274         "F20" => Some(Key::F20),
275         "F21" => Some(Key::F21),
276         "F22" => Some(Key::F22),
277         "F23" => Some(Key::F23),
278         "F24" => Some(Key::F24),
279         "F25" => Some(Key::F25),
280         "0" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp0),
281         "1" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp1),
282         "2" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp2),
283         "3" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp3),
284         "4" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp4),
285         "5" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp5),
286         "6" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp6),
287         "7" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp7),
288         "8" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp8),
289         "9" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp9),
290         "." if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpDecimal),
291         "/" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpDivide),
292         "*" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpMultiply),
293         "-" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpSubtract),
294         "+" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpAdd),
295         "Enter" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD
296                 => Some(Key::KpEnter),
297         "=" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpEqual),
298         "Shift" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT
299                 => Some(Key::LeftShift),
300         "Control" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT
301                 => Some(Key::LeftControl),
302         "Alt" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT => Some(Key::LeftAlt),
303         "Super" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT
304                 => Some(Key::LeftSuper),
305         "Shift" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT
306                 => Some(Key::RightShift),
307         "Control" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT
308                 => Some(Key::RightControl),
309         "Alt" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT => Some(Key::RightAlt),
310         "Super" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT
311                 => Some(Key::RightSuper),
312         "ContextMenu" => Some(Key::Menu),
313         _ => None
314     }
315 }
316
317 fn main() { }