about summary refs log tree commit diff
path: root/src/test/debuginfo
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2015-02-05 18:26:58 +0100
committerMichael Woerister <michaelwoerister@posteo>2015-02-06 21:24:06 +0100
commit93edb7c17bd4d2d56b0f1f510de5f820cf61bb5f (patch)
tree6655dfd67da9912eb5c9b28e74d17534830e5f1c /src/test/debuginfo
parent0eec22640c1f1b6d9360f5a05961f19465ca9e14 (diff)
downloadrust-93edb7c17bd4d2d56b0f1f510de5f820cf61bb5f.tar.gz
rust-93edb7c17bd4d2d56b0f1f510de5f820cf61bb5f.zip
debuginfo: Fix problem with debug locations of constants in match patterns.
Diffstat (limited to 'src/test/debuginfo')
-rw-r--r--src/test/debuginfo/constant-in-match-pattern.rs92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/test/debuginfo/constant-in-match-pattern.rs b/src/test/debuginfo/constant-in-match-pattern.rs
new file mode 100644
index 00000000000..487c69a85d6
--- /dev/null
+++ b/src/test/debuginfo/constant-in-match-pattern.rs
@@ -0,0 +1,92 @@
+// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-android: FIXME(#10381)
+// min-lldb-version: 310
+
+// compile-flags:-g
+
+#![allow(unused_variables)]
+#![allow(dead_code)]
+#![omit_gdb_pretty_printer_section]
+
+// This test makes sure that the compiler doesn't crash when trying to assign
+// debug locations to 'constant' patterns in match expressions.
+
+const CONSTANT: u64 = 3;
+
+struct Struct {
+    a: isize,
+    b: usize,
+}
+const STRUCT: Struct = Struct { a: 1, b: 2 };
+
+struct TupleStruct(u32);
+const TUPLE_STRUCT: TupleStruct = TupleStruct(4);
+
+enum Enum {
+    Variant1(char),
+    Variant2 { a: u8 },
+    Variant3
+}
+const VARIANT1: Enum = Enum::Variant1('v');
+const VARIANT2: Enum = Enum::Variant2 { a: 2 };
+const VARIANT3: Enum = Enum::Variant3;
+
+const STRING: &'static str = "String";
+
+fn main() {
+
+    match 1 {
+        CONSTANT => {}
+        _ => {}
+    };
+
+    // if let 3 = CONSTANT {}
+
+    match (Struct { a: 2, b: 2 }) {
+        STRUCT => {}
+        _ => {}
+    };
+
+    // if let STRUCT = STRUCT {}
+
+    match TupleStruct(3) {
+        TUPLE_STRUCT => {}
+        _ => {}
+    };
+
+    // if let TupleStruct(4) = TUPLE_STRUCT {}
+
+    match VARIANT3 {
+        VARIANT1 => {},
+        VARIANT2 => {},
+        VARIANT3 => {},
+        _ => {}
+    };
+
+    match (VARIANT3, VARIANT2) {
+        (VARIANT1, VARIANT3) => {},
+        (VARIANT2, VARIANT2) => {},
+        (VARIANT3, VARIANT1) => {},
+        _ => {}
+    };
+
+    // if let VARIANT1 = Enum::Variant3 {}
+    // if let VARIANT2 = Enum::Variant3 {}
+    // if let VARIANT3 = Enum::Variant3 {}
+
+    match "abc" {
+        STRING => {},
+        _ => {}
+    }
+
+    if let STRING = "def" {}
+}