about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-06-02 13:47:07 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-06-02 13:47:07 +0200
commit320e27dc80ad1ced41b5a69fa6114ef70aa3340d (patch)
treeb9155cc88cdb34427df9b822ff31665188677d11
parent705b613037bdb1224504c02fb8e5f442a4a39ff1 (diff)
parent2b80753330e58c209581f17208bbb87316a54cdf (diff)
downloadrust-320e27dc80ad1ced41b5a69fa6114ef70aa3340d.tar.gz
rust-320e27dc80ad1ced41b5a69fa6114ef70aa3340d.zip
Rollup merge of #34015 - GuillaumeGomez:err-code-tests, r=jonathandturner
Add new error code tests

r? @steveklabnik
-rw-r--r--src/test/compile-fail/E0162.rs18
-rw-r--r--src/test/compile-fail/E0163.rs20
-rw-r--r--src/test/compile-fail/E0164.rs20
-rw-r--r--src/test/compile-fail/E0165.rs18
-rw-r--r--src/test/compile-fail/E0166.rs14
-rw-r--r--src/test/compile-fail/E0172.rs14
-rw-r--r--src/test/compile-fail/E0178.rs21
-rw-r--r--src/test/compile-fail/E0184.rs20
-rw-r--r--src/test/compile-fail/E0185.rs22
-rw-r--r--src/test/compile-fail/E0186.rs22
-rw-r--r--src/test/compile-fail/E0191.rs18
-rw-r--r--src/test/compile-fail/E0192.rs22
-rw-r--r--src/test/compile-fail/E0194.rs17
-rw-r--r--src/test/compile-fail/E0195.rs23
-rw-r--r--src/test/compile-fail/E0197.rs16
-rw-r--r--src/test/compile-fail/E0199.rs18
-rw-r--r--src/test/compile-fail/E0200.rs18
17 files changed, 321 insertions, 0 deletions
diff --git a/src/test/compile-fail/E0162.rs b/src/test/compile-fail/E0162.rs
new file mode 100644
index 00000000000..e13b0af6f79
--- /dev/null
+++ b/src/test/compile-fail/E0162.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.
+
+struct Irrefutable(i32);
+
+fn main() {
+    let irr = Irrefutable(0);
+    if let Irrefutable(x) = irr { //~ ERROR E0162
+        println!("{}", x);
+    }
+}
diff --git a/src/test/compile-fail/E0163.rs b/src/test/compile-fail/E0163.rs
new file mode 100644
index 00000000000..5cb6f4d2803
--- /dev/null
+++ b/src/test/compile-fail/E0163.rs
@@ -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.
+
+enum Foo { B(u32) }
+
+fn bar(foo: Foo) -> u32 {
+    match foo {
+        Foo::B { i } => i, //~ ERROR E0163
+    }
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0164.rs b/src/test/compile-fail/E0164.rs
new file mode 100644
index 00000000000..491b2e9e5b2
--- /dev/null
+++ b/src/test/compile-fail/E0164.rs
@@ -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.
+
+enum Foo { B { i: u32 } }
+
+fn bar(foo: Foo) -> u32 {
+    match foo {
+        Foo::B(i) => i, //~ ERROR E0164
+    }
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0165.rs b/src/test/compile-fail/E0165.rs
new file mode 100644
index 00000000000..cca714bbcc1
--- /dev/null
+++ b/src/test/compile-fail/E0165.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.
+
+struct Irrefutable(i32);
+
+fn main() {
+    let irr = Irrefutable(0);
+    while let Irrefutable(x) = irr { //~ ERROR E0165
+        // ...
+    }
+}
diff --git a/src/test/compile-fail/E0166.rs b/src/test/compile-fail/E0166.rs
new file mode 100644
index 00000000000..9fa41249aa5
--- /dev/null
+++ b/src/test/compile-fail/E0166.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 foo() -> ! { return; } //~ ERROR E0166
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0172.rs b/src/test/compile-fail/E0172.rs
new file mode 100644
index 00000000000..7011bf0e937
--- /dev/null
+++ b/src/test/compile-fail/E0172.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 foo(bar: i32+std::fmt::Display) {} //~ ERROR E0172
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0178.rs b/src/test/compile-fail/E0178.rs
new file mode 100644
index 00000000000..f34f3834e05
--- /dev/null
+++ b/src/test/compile-fail/E0178.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.
+
+trait Foo {}
+
+struct Bar<'a> {
+    w: &'a Foo + Copy, //~ ERROR E0178
+    x: &'a Foo + 'a, //~ ERROR E0178
+    y: &'a mut Foo + 'a, //~ ERROR E0178
+    z: fn() -> Foo + 'a, //~ ERROR E0178
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0184.rs b/src/test/compile-fail/E0184.rs
new file mode 100644
index 00000000000..5d72d00ffe8
--- /dev/null
+++ b/src/test/compile-fail/E0184.rs
@@ -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.
+
+#[derive(Copy)] //~ ERROR E0184
+struct Foo;
+
+impl Drop for Foo {
+    fn drop(&mut self) {
+    }
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0185.rs b/src/test/compile-fail/E0185.rs
new file mode 100644
index 00000000000..0e33687a84d
--- /dev/null
+++ b/src/test/compile-fail/E0185.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.
+
+trait Foo {
+    fn foo();
+}
+
+struct Bar;
+
+impl Foo for Bar {
+    fn foo(&self) {} //~ ERROR E0185
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0186.rs b/src/test/compile-fail/E0186.rs
new file mode 100644
index 00000000000..aa0a38bedcb
--- /dev/null
+++ b/src/test/compile-fail/E0186.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.
+
+trait Foo {
+    fn foo(&self);
+}
+
+struct Bar;
+
+impl Foo for Bar {
+    fn foo() {} //~ ERROR E0186
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0191.rs b/src/test/compile-fail/E0191.rs
new file mode 100644
index 00000000000..489ebb033f8
--- /dev/null
+++ b/src/test/compile-fail/E0191.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.
+
+trait Trait {
+    type Bar;
+}
+
+type Foo = Trait; //~ ERROR E0191
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0192.rs b/src/test/compile-fail/E0192.rs
new file mode 100644
index 00000000000..92f5876ee04
--- /dev/null
+++ b/src/test/compile-fail/E0192.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.
+
+#![feature(optin_builtin_traits)]
+
+trait Trait {
+    type Bar;
+}
+
+struct Foo;
+
+impl !Trait for Foo { } //~ ERROR E0192
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0194.rs b/src/test/compile-fail/E0194.rs
new file mode 100644
index 00000000000..96b3062cacb
--- /dev/null
+++ b/src/test/compile-fail/E0194.rs
@@ -0,0 +1,17 @@
+// 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 Foo<T> {
+    fn do_something(&self) -> T;
+    fn do_something_else<T: Clone>(&self, bar: T); //~ ERROR E0194
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0195.rs b/src/test/compile-fail/E0195.rs
new file mode 100644
index 00000000000..0630dfea5e6
--- /dev/null
+++ b/src/test/compile-fail/E0195.rs
@@ -0,0 +1,23 @@
+// 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 Trait {
+    fn bar<'a,'b:'a>(x: &'a str, y: &'b str);
+}
+
+struct Foo;
+
+impl Trait for Foo {
+    fn bar<'a,'b>(x: &'a str, y: &'b str) { //~ ERROR E0195
+    }
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0197.rs b/src/test/compile-fail/E0197.rs
new file mode 100644
index 00000000000..f25fa9b92b9
--- /dev/null
+++ b/src/test/compile-fail/E0197.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.
+
+struct Foo;
+
+unsafe impl Foo { } //~ ERROR E0197
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0199.rs b/src/test/compile-fail/E0199.rs
new file mode 100644
index 00000000000..8bd3ffdf6f6
--- /dev/null
+++ b/src/test/compile-fail/E0199.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.
+
+#![feature(optin_builtin_traits)]
+
+struct Foo;
+
+unsafe impl !Clone for Foo { } //~ ERROR E0199
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0200.rs b/src/test/compile-fail/E0200.rs
new file mode 100644
index 00000000000..6bfea0e59d7
--- /dev/null
+++ b/src/test/compile-fail/E0200.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.
+
+struct Foo;
+
+unsafe trait Bar { }
+
+impl Bar for Foo { } //~ ERROR E0200
+
+fn main() {
+}