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