about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-08-26 00:14:20 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-08-26 17:28:50 +0200
commit3e1b33dbdde108cadf10a35d36d14911cc3e5aea (patch)
tree1b5ce292c94be9ca466543e359f0bd14a6c21445
parenta9907a1dd14c8fbed0f1b46f2cdddde7c2c15bbe (diff)
downloadrust-3e1b33dbdde108cadf10a35d36d14911cc3e5aea.tar.gz
rust-3e1b33dbdde108cadf10a35d36d14911cc3e5aea.zip
Add new error code tests
-rw-r--r--src/test/compile-fail/E0502.rs18
-rw-r--r--src/test/compile-fail/E0503.rs15
-rw-r--r--src/test/compile-fail/E0504.rs25
-rw-r--r--src/test/compile-fail/E0505.rs21
-rw-r--r--src/test/compile-fail/E0506.rs21
-rw-r--r--src/test/compile-fail/E0507.rs23
-rw-r--r--src/test/compile-fail/E0508.rs16
-rw-r--r--src/test/compile-fail/E0509.rs28
-rw-r--r--src/test/compile-fail/E0511.rs19
-rw-r--r--src/test/compile-fail/E0512.rs15
-rw-r--r--src/test/compile-fail/E0516.rs13
-rw-r--r--src/test/compile-fail/E0517.rs25
-rw-r--r--src/test/compile-fail/E0518.rs19
-rw-r--r--src/test/compile-fail/E0520.rs30
-rw-r--r--src/test/compile-fail/E0522.rs16
-rw-r--r--src/test/compile-fail/E0527.rs20
16 files changed, 324 insertions, 0 deletions
diff --git a/src/test/compile-fail/E0502.rs b/src/test/compile-fail/E0502.rs
new file mode 100644
index 00000000000..fce8513ca64
--- /dev/null
+++ b/src/test/compile-fail/E0502.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 bar(x: &mut i32) {}
+fn foo(a: &mut i32) {
+    let ref y = a;
+    bar(a); //~ ERROR E0502
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0503.rs b/src/test/compile-fail/E0503.rs
new file mode 100644
index 00000000000..810eb8d9b07
--- /dev/null
+++ b/src/test/compile-fail/E0503.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 mut value = 3;
+    let _borrow = &mut value;
+    let _sum = value + 1; //~ ERROR E0503
+}
diff --git a/src/test/compile-fail/E0504.rs b/src/test/compile-fail/E0504.rs
new file mode 100644
index 00000000000..c594f241520
--- /dev/null
+++ b/src/test/compile-fail/E0504.rs
@@ -0,0 +1,25 @@
+// 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 FancyNum {
+    num: u8,
+}
+
+fn main() {
+    let fancy_num = FancyNum { num: 5 };
+    let fancy_ref = &fancy_num;
+
+    let x = move || {
+        println!("child function: {}", fancy_num.num); //~ ERROR E0504
+    };
+
+    x();
+    println!("main function: {}", fancy_ref.num);
+}
diff --git a/src/test/compile-fail/E0505.rs b/src/test/compile-fail/E0505.rs
new file mode 100644
index 00000000000..2d534b8a44a
--- /dev/null
+++ b/src/test/compile-fail/E0505.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 Value {}
+
+fn eat(val: Value) {}
+
+fn main() {
+    let x = Value{};
+    {
+        let _ref_to_val: &Value = &x;
+        eat(x); //~ ERROR E0505
+    }
+}
diff --git a/src/test/compile-fail/E0506.rs b/src/test/compile-fail/E0506.rs
new file mode 100644
index 00000000000..ddaffd4a273
--- /dev/null
+++ b/src/test/compile-fail/E0506.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 FancyNum {
+    num: u8,
+}
+
+fn main() {
+    let mut fancy_num = FancyNum { num: 5 };
+    let fancy_ref = &fancy_num;
+    fancy_num = FancyNum { num: 6 }; //~ ERROR E0506
+
+    println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num);
+}
diff --git a/src/test/compile-fail/E0507.rs b/src/test/compile-fail/E0507.rs
new file mode 100644
index 00000000000..87b1bf51bdb
--- /dev/null
+++ b/src/test/compile-fail/E0507.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.
+
+use std::cell::RefCell;
+
+struct TheDarkKnight;
+
+impl TheDarkKnight {
+    fn nothing_is_true(self) {}
+}
+
+fn main() {
+    let x = RefCell::new(TheDarkKnight);
+
+    x.borrow().nothing_is_true(); //~ ERROR E0507
+}
diff --git a/src/test/compile-fail/E0508.rs b/src/test/compile-fail/E0508.rs
new file mode 100644
index 00000000000..a72c29cc3a5
--- /dev/null
+++ b/src/test/compile-fail/E0508.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 NonCopy;
+
+fn main() {
+    let array = [NonCopy; 1];
+    let _value = array[0]; //~ ERROR E0508
+}
diff --git a/src/test/compile-fail/E0509.rs b/src/test/compile-fail/E0509.rs
new file mode 100644
index 00000000000..b92024cd6e2
--- /dev/null
+++ b/src/test/compile-fail/E0509.rs
@@ -0,0 +1,28 @@
+// 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 FancyNum {
+    num: usize
+}
+
+struct DropStruct {
+    fancy: FancyNum
+}
+
+impl Drop for DropStruct {
+    fn drop(&mut self) {
+    }
+}
+
+fn main() {
+    let drop_struct = DropStruct{fancy: FancyNum{num: 5}};
+    let fancy_field = drop_struct.fancy; //~ ERROR E0509
+    println!("Fancy: {}", fancy_field.num);
+}
diff --git a/src/test/compile-fail/E0511.rs b/src/test/compile-fail/E0511.rs
new file mode 100644
index 00000000000..c5c03f81825
--- /dev/null
+++ b/src/test/compile-fail/E0511.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.
+
+#![feature(platform_intrinsics)]
+
+extern "platform-intrinsic" {
+    fn simd_add<T>(a: T, b: T) -> T;
+}
+
+fn main() {
+    unsafe { simd_add(0, 1); } //~ ERROR E0511
+}
diff --git a/src/test/compile-fail/E0512.rs b/src/test/compile-fail/E0512.rs
new file mode 100644
index 00000000000..25f96271641
--- /dev/null
+++ b/src/test/compile-fail/E0512.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 takes_u8(_: u8) {}
+
+fn main() {
+    unsafe { takes_u8(::std::mem::transmute(0u16)); } //~ ERROR E0512
+}
diff --git a/src/test/compile-fail/E0516.rs b/src/test/compile-fail/E0516.rs
new file mode 100644
index 00000000000..a5f609de849
--- /dev/null
+++ b/src/test/compile-fail/E0516.rs
@@ -0,0 +1,13 @@
+// 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: typeof(92) = 92; //~ ERROR E0516
+}
diff --git a/src/test/compile-fail/E0517.rs b/src/test/compile-fail/E0517.rs
new file mode 100644
index 00000000000..be06e809915
--- /dev/null
+++ b/src/test/compile-fail/E0517.rs
@@ -0,0 +1,25 @@
+// 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.
+
+#[repr(C)] //~ ERROR E0517
+type Foo = u8;
+
+#[repr(packed)] //~ ERROR E0517
+enum Foo2 {Bar, Baz}
+
+#[repr(u8)] //~ ERROR E0517
+struct Foo3 {bar: bool, baz: bool}
+
+#[repr(C)] //~ ERROR E0517
+impl Foo3 {
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0518.rs b/src/test/compile-fail/E0518.rs
new file mode 100644
index 00000000000..8518bb4a6be
--- /dev/null
+++ b/src/test/compile-fail/E0518.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.
+
+#[inline(always)] //~ ERROR E0518
+struct Foo;
+
+#[inline(never)] //~ ERROR E0518
+impl Foo {
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0520.rs b/src/test/compile-fail/E0520.rs
new file mode 100644
index 00000000000..bb52843ee78
--- /dev/null
+++ b/src/test/compile-fail/E0520.rs
@@ -0,0 +1,30 @@
+// 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(specialization)]
+
+trait SpaceLlama {
+    fn fly(&self);
+}
+
+impl<T> SpaceLlama for T {
+    default fn fly(&self) {}
+}
+
+impl<T: Clone> SpaceLlama for T {
+    fn fly(&self) {}
+}
+
+impl SpaceLlama for i32 {
+    default fn fly(&self) {} //~ ERROR E0520
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0522.rs b/src/test/compile-fail/E0522.rs
new file mode 100644
index 00000000000..5103c83cafc
--- /dev/null
+++ b/src/test/compile-fail/E0522.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.
+
+#![feature(lang_items)]
+
+#[lang = "cookie"]
+fn cookie() -> ! { //~ E0522
+    loop {}
+}
diff --git a/src/test/compile-fail/E0527.rs b/src/test/compile-fail/E0527.rs
new file mode 100644
index 00000000000..f03f35a5710
--- /dev/null
+++ b/src/test/compile-fail/E0527.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.
+
+#![feature(slice_patterns)]
+
+fn main() {
+    let r = &[1, 2, 3, 4];
+    match r {
+        &[a, b] => { //~ ERROR E0527
+            println!("a={}, b={}", a, b);
+        }
+    }
+}