]> git.lizzy.rs Git - rust.git/commitdiff
Add new error code tests
authorggomez <guillaume1.gomez@gmail.com>
Tue, 17 May 2016 13:01:31 +0000 (15:01 +0200)
committerggomez <guillaume1.gomez@gmail.com>
Wed, 18 May 2016 10:05:59 +0000 (12:05 +0200)
src/test/compile-fail/E0027.rs [new file with mode: 0644]
src/test/compile-fail/E0029.rs [new file with mode: 0644]
src/test/compile-fail/E0030.rs [new file with mode: 0644]
src/test/compile-fail/E0033.rs [new file with mode: 0644]
src/test/compile-fail/E0034.rs [new file with mode: 0644]
src/test/compile-fail/E0035.rs [new file with mode: 0644]

diff --git a/src/test/compile-fail/E0027.rs b/src/test/compile-fail/E0027.rs
new file mode 100644 (file)
index 0000000..b2f2044
--- /dev/null
@@ -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.
+
+struct Dog {
+    name: String,
+    age: u32,
+}
+
+fn main() {
+    let d = Dog { name: "Rusty".to_string(), age: 8 };
+
+    match d {
+        Dog { age: x } => {} //~ ERROR E0027
+    }
+}
diff --git a/src/test/compile-fail/E0029.rs b/src/test/compile-fail/E0029.rs
new file mode 100644 (file)
index 0000000..9cbdec9
--- /dev/null
@@ -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 s = "hoho";
+
+    match s {
+        "hello" ... "world" => {} //~ ERROR E0029
+        _ => {}
+    }
+}
diff --git a/src/test/compile-fail/E0030.rs b/src/test/compile-fail/E0030.rs
new file mode 100644 (file)
index 0000000..7f26f6c
--- /dev/null
@@ -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 5u32 {
+        1000 ... 5 => {} //~ ERROR E0030
+    }
+}
diff --git a/src/test/compile-fail/E0033.rs b/src/test/compile-fail/E0033.rs
new file mode 100644 (file)
index 0000000..9466000
--- /dev/null
@@ -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.
+
+trait SomeTrait {
+    fn foo();
+}
+
+fn main() {
+    let trait_obj: &SomeTrait = SomeTrait; //~ ERROR E0425
+                                           //~^ ERROR E0038
+    let &invalid = trait_obj; //~ ERROR E0033
+}
diff --git a/src/test/compile-fail/E0034.rs b/src/test/compile-fail/E0034.rs
new file mode 100644 (file)
index 0000000..669bece
--- /dev/null
@@ -0,0 +1,26 @@
+// 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 Test;
+
+trait Trait1 {
+    fn foo();
+}
+
+trait Trait2 {
+    fn foo();
+}
+
+impl Trait1 for Test { fn foo() {} }
+impl Trait2 for Test { fn foo() {} }
+
+fn main() {
+    Test::foo() //~ ERROR E0034
+}
diff --git a/src/test/compile-fail/E0035.rs b/src/test/compile-fail/E0035.rs
new file mode 100644 (file)
index 0000000..43f46e3
--- /dev/null
@@ -0,0 +1,20 @@
+// 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 Test;
+
+impl Test {
+    fn method(&self) {}
+}
+
+fn main() {
+    let x = Test;
+    x.method::<i32>(); //~ ERROR E0035
+}