]>
Commit | Line | Data |
---|---|---|
85aaf69f SL |
1 | // Copyright 2013-2015 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 | ||
85aaf69f SL |
11 | // min-lldb-version: 310 |
12 | ||
13 | // compile-flags:-g | |
14 | ||
d9579d0f | 15 | #![allow(dead_code, unused_variables)] |
b039eaaf | 16 | #![feature(omit_gdb_pretty_printer_section)] |
85aaf69f SL |
17 | #![omit_gdb_pretty_printer_section] |
18 | ||
19 | // This test makes sure that the compiler doesn't crash when trying to assign | |
20 | // debug locations to 'constant' patterns in match expressions. | |
21 | ||
22 | const CONSTANT: u64 = 3; | |
23 | ||
54a0048b | 24 | #[derive(PartialEq, Eq)] |
85aaf69f SL |
25 | struct Struct { |
26 | a: isize, | |
27 | b: usize, | |
28 | } | |
29 | const STRUCT: Struct = Struct { a: 1, b: 2 }; | |
30 | ||
54a0048b | 31 | #[derive(PartialEq, Eq)] |
85aaf69f SL |
32 | struct TupleStruct(u32); |
33 | const TUPLE_STRUCT: TupleStruct = TupleStruct(4); | |
34 | ||
54a0048b | 35 | #[derive(PartialEq, Eq)] |
85aaf69f SL |
36 | enum Enum { |
37 | Variant1(char), | |
38 | Variant2 { a: u8 }, | |
39 | Variant3 | |
40 | } | |
41 | const VARIANT1: Enum = Enum::Variant1('v'); | |
42 | const VARIANT2: Enum = Enum::Variant2 { a: 2 }; | |
43 | const VARIANT3: Enum = Enum::Variant3; | |
44 | ||
45 | const STRING: &'static str = "String"; | |
46 | ||
47 | fn main() { | |
48 | ||
49 | match 1 { | |
50 | CONSTANT => {} | |
51 | _ => {} | |
52 | }; | |
53 | ||
54 | // if let 3 = CONSTANT {} | |
55 | ||
56 | match (Struct { a: 2, b: 2 }) { | |
57 | STRUCT => {} | |
58 | _ => {} | |
59 | }; | |
60 | ||
61 | // if let STRUCT = STRUCT {} | |
62 | ||
63 | match TupleStruct(3) { | |
64 | TUPLE_STRUCT => {} | |
65 | _ => {} | |
66 | }; | |
67 | ||
68 | // if let TupleStruct(4) = TUPLE_STRUCT {} | |
69 | ||
70 | match VARIANT3 { | |
71 | VARIANT1 => {}, | |
72 | VARIANT2 => {}, | |
73 | VARIANT3 => {}, | |
74 | _ => {} | |
75 | }; | |
76 | ||
77 | match (VARIANT3, VARIANT2) { | |
78 | (VARIANT1, VARIANT3) => {}, | |
79 | (VARIANT2, VARIANT2) => {}, | |
80 | (VARIANT3, VARIANT1) => {}, | |
81 | _ => {} | |
82 | }; | |
83 | ||
84 | // if let VARIANT1 = Enum::Variant3 {} | |
85 | // if let VARIANT2 = Enum::Variant3 {} | |
86 | // if let VARIANT3 = Enum::Variant3 {} | |
87 | ||
88 | match "abc" { | |
89 | STRING => {}, | |
90 | _ => {} | |
91 | } | |
92 | ||
93 | if let STRING = "def" {} | |
94 | } |