about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorggomez <guillaume1.gomez@gmail.com>2016-05-12 15:17:02 +0200
committerggomez <guillaume1.gomez@gmail.com>2016-05-13 14:43:56 +0200
commit1d6411d863d9f765a5bfca06eb444075dd1ca9ce (patch)
treefaca5b9f5d906971a7b3fbe8342eeebe1ef901ab /src
parent992bb1332ffc68093a6aa555807b9129a1e94977 (diff)
downloadrust-1d6411d863d9f765a5bfca06eb444075dd1ca9ce.tar.gz
rust-1d6411d863d9f765a5bfca06eb444075dd1ca9ce.zip
Add compile-fail tests for error codes
Diffstat (limited to 'src')
-rw-r--r--src/test/compile-fail/E0001.rs18
-rw-r--r--src/test/compile-fail/E0002.rs15
-rw-r--r--src/test/compile-fail/E0004.rs22
-rw-r--r--src/test/compile-fail/E0005.rs14
-rw-r--r--src/test/compile-fail/E0007.rs18
-rw-r--r--src/test/compile-fail/E0008.rs16
-rw-r--r--src/test/compile-fail/E0009.rs18
-rw-r--r--src/test/compile-fail/E0010.rs15
-rw-r--r--src/test/compile-fail/E0017.rs22
-rw-r--r--src/test/compile-fail/E0023.rs22
-rw-r--r--src/test/compile-fail/E0024.rs22
-rw-r--r--src/test/compile-fail/E0025.rs19
-rw-r--r--src/test/compile-fail/E0026.rs21
13 files changed, 242 insertions, 0 deletions
diff --git a/src/test/compile-fail/E0001.rs b/src/test/compile-fail/E0001.rs
new file mode 100644
index 00000000000..906642d8555
--- /dev/null
+++ b/src/test/compile-fail/E0001.rs
@@ -0,0 +1,18 @@
+// Copyright 2016 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.
+
+fn main() {
+    let foo = Some(1);
+    match foo {
+        Some(bar) => {/* ... */}
+        None => {/* ... */}
+        _ => {/* ... */} //~ ERROR E0001
+    }
+}
diff --git a/src/test/compile-fail/E0002.rs b/src/test/compile-fail/E0002.rs
new file mode 100644
index 00000000000..0e94c9595d8
--- /dev/null
+++ b/src/test/compile-fail/E0002.rs
@@ -0,0 +1,15 @@
+// Copyright 2016 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.
+
+fn main() {
+    let x = Some(1);
+
+    match x { } //~ ERROR E0002
+}
diff --git a/src/test/compile-fail/E0004.rs b/src/test/compile-fail/E0004.rs
new file mode 100644
index 00000000000..79e53c7a29f
--- /dev/null
+++ b/src/test/compile-fail/E0004.rs
@@ -0,0 +1,22 @@
+// Copyright 2016 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.
+
+enum Terminator {
+    HastaLaVistaBaby,
+    TalkToMyHand,
+}
+
+fn main() {
+    let x = Terminator::HastaLaVistaBaby;
+
+    match x { //~ ERROR E0004
+        Terminator::TalkToMyHand => {}
+    }
+}
\ No newline at end of file
diff --git a/src/test/compile-fail/E0005.rs b/src/test/compile-fail/E0005.rs
new file mode 100644
index 00000000000..0405bba81b5
--- /dev/null
+++ b/src/test/compile-fail/E0005.rs
@@ -0,0 +1,14 @@
+// Copyright 2016 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.
+
+fn main() {
+    let x = Some(1);
+    let Some(y) = x; //~ ERROR E0005
+}
diff --git a/src/test/compile-fail/E0007.rs b/src/test/compile-fail/E0007.rs
new file mode 100644
index 00000000000..bfc0f1afe3a
--- /dev/null
+++ b/src/test/compile-fail/E0007.rs
@@ -0,0 +1,18 @@
+// Copyright 2016 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.
+
+fn main() {
+    let x = Some("s".to_string());
+    match x {
+        op_string @ Some(s) => {}, //~ ERROR E0007
+                                   //~| ERROR E0303
+        None => {},
+    }
+}
diff --git a/src/test/compile-fail/E0008.rs b/src/test/compile-fail/E0008.rs
new file mode 100644
index 00000000000..97dd0f368bd
--- /dev/null
+++ b/src/test/compile-fail/E0008.rs
@@ -0,0 +1,16 @@
+// Copyright 2016 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.
+
+fn main() {
+    match Some("hi".to_string()) {
+        Some(s) if s.len() == 0 => {}, //~ ERROR E0008
+        _ => {},
+    }
+}
diff --git a/src/test/compile-fail/E0009.rs b/src/test/compile-fail/E0009.rs
new file mode 100644
index 00000000000..51f71ea10c9
--- /dev/null
+++ b/src/test/compile-fail/E0009.rs
@@ -0,0 +1,18 @@
+// Copyright 2016 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.
+
+fn main() {
+    struct X { x: (), }
+    let x = Some((X { x: () }, X { x: () }));
+    match x {
+        Some((y, ref z)) => {}, //~ ERROR E0009
+        None => panic!()
+    }
+}
diff --git a/src/test/compile-fail/E0010.rs b/src/test/compile-fail/E0010.rs
new file mode 100644
index 00000000000..9ae9e795466
--- /dev/null
+++ b/src/test/compile-fail/E0010.rs
@@ -0,0 +1,15 @@
+// Copyright 2016 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.
+
+#![feature(box_syntax)]
+
+const CON : Box<i32> = box 0; //~ ERROR E0010
+
+fn main() {}
diff --git a/src/test/compile-fail/E0017.rs b/src/test/compile-fail/E0017.rs
new file mode 100644
index 00000000000..13f2c23d8c4
--- /dev/null
+++ b/src/test/compile-fail/E0017.rs
@@ -0,0 +1,22 @@
+// Copyright 2016 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.
+
+static X: i32 = 1;
+const C: i32 = 2;
+
+const CR: &'static mut i32 = &mut C; //~ ERROR E0017
+                                     //~| ERROR E0017
+static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
+                                              //~| ERROR E0017
+                                              //~| ERROR E0388
+static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
+                                             //~| ERROR E0017
+
+fn main() {}
diff --git a/src/test/compile-fail/E0023.rs b/src/test/compile-fail/E0023.rs
new file mode 100644
index 00000000000..05f126baf9a
--- /dev/null
+++ b/src/test/compile-fail/E0023.rs
@@ -0,0 +1,22 @@
+// Copyright 2016 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.
+
+enum Fruit {
+    Apple(String, String),
+    Pear(u32),
+}
+
+fn main() {
+    let x = Fruit::Apple(String::new(), String::new());
+    match x {
+        Fruit::Apple(a) => {}, //~ ERROR E0023
+        Fruit::Apple(a, b, c) => {}, //~ ERROR E0023
+    }
+}
diff --git a/src/test/compile-fail/E0024.rs b/src/test/compile-fail/E0024.rs
new file mode 100644
index 00000000000..18f4dcf19d7
--- /dev/null
+++ b/src/test/compile-fail/E0024.rs
@@ -0,0 +1,22 @@
+// Copyright 2016 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.
+
+enum Number {
+    Zero,
+    One(u32)
+}
+
+fn main() {
+    let x = Number::Zero;
+    match x {
+        Number::Zero(inside) => {}, //~ ERROR E0024
+        Number::One(inside) => {},
+    }
+}
diff --git a/src/test/compile-fail/E0025.rs b/src/test/compile-fail/E0025.rs
new file mode 100644
index 00000000000..3f5922cdc02
--- /dev/null
+++ b/src/test/compile-fail/E0025.rs
@@ -0,0 +1,19 @@
+// Copyright 2016 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.
+
+struct Foo {
+    a: u8,
+    b: u8,
+}
+
+fn main() {
+    let x = Foo { a:1, b:2 };
+    let Foo { a: x, a: y, b: 0 } = x; //~ ERROR E0025
+}
diff --git a/src/test/compile-fail/E0026.rs b/src/test/compile-fail/E0026.rs
new file mode 100644
index 00000000000..359c2a822a2
--- /dev/null
+++ b/src/test/compile-fail/E0026.rs
@@ -0,0 +1,21 @@
+// Copyright 2016 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.
+
+struct Thing {
+    x: u32,
+    y: u32
+}
+
+fn main() {
+    let thing = Thing { x: 0, y: 0 };
+    match thing {
+        Thing { x, y, z } => {} //~ ERROR E0026
+    }
+}