about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-08-05 13:17:39 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-08-05 13:17:39 +0200
commit7cd1779c314e85d8cd8b5512e47f34cdcf3c7b63 (patch)
tree6d21ecaff3ce67051c8b89dca2b2ece65449ac4c
parent87872376514ad37e0737c8568b82225980bb7b27 (diff)
downloadrust-7cd1779c314e85d8cd8b5512e47f34cdcf3c7b63.tar.gz
rust-7cd1779c314e85d8cd8b5512e47f34cdcf3c7b63.zip
Add new error code tests
-rw-r--r--src/librustc_passes/diagnostics.rs8
-rw-r--r--src/librustc_resolve/diagnostics.rs1
-rw-r--r--src/test/compile-fail/E0253.rs19
-rw-r--r--src/test/compile-fail/E0254.rs21
-rw-r--r--src/test/compile-fail/E0255.rs19
-rw-r--r--src/test/compile-fail/E0259.rs14
-rw-r--r--src/test/compile-fail/E0260.rs19
-rw-r--r--src/test/compile-fail/E0261.rs17
-rw-r--r--src/test/compile-fail/E0262.rs13
-rw-r--r--src/test/compile-fail/E0263.rs13
-rw-r--r--src/test/compile-fail/E0264.rs18
-rw-r--r--src/test/compile-fail/E0267.rs13
-rw-r--r--src/test/compile-fail/E0268.rs13
13 files changed, 184 insertions, 4 deletions
diff --git a/src/librustc_passes/diagnostics.rs b/src/librustc_passes/diagnostics.rs
index 3e2dd477bcc..7049040678e 100644
--- a/src/librustc_passes/diagnostics.rs
+++ b/src/librustc_passes/diagnostics.rs
@@ -121,11 +121,11 @@ All statics and constants need to resolve to a value in an acyclic manner.
 
 For example, neither of the following can be sensibly compiled:
 
-```compile_fail
+```compile_fail,E0265
 const X: u32 = X;
 ```
 
-```compile_fail
+```compile_fail,E0265
 const X: u32 = Y;
 const Y: u32 = X;
 ```
@@ -135,7 +135,7 @@ E0267: r##"
 This error indicates the use of a loop keyword (`break` or `continue`) inside a
 closure but outside of any loop. Erroneous code example:
 
-```compile_fail
+```compile_fail,E0267
 let w = || { break; }; // error: `break` inside of a closure
 ```
 
@@ -159,7 +159,7 @@ This error indicates the use of a loop keyword (`break` or `continue`) outside
 of a loop. Without a loop to break out of or continue in, no sensible action can
 be taken. Erroneous code example:
 
-```compile_fail
+```compile_fail,E0268
 fn some_func() {
     break; // error: `break` outside of loop
 }
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index af830d92074..11ef75ee6a8 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -146,6 +146,7 @@ mod foo {
 }
 
 use foo::MyTrait::do_something;
+// error: `do_something` is not directly importable
 
 fn main() {}
 ```
diff --git a/src/test/compile-fail/E0253.rs b/src/test/compile-fail/E0253.rs
new file mode 100644
index 00000000000..28fcf4452b3
--- /dev/null
+++ b/src/test/compile-fail/E0253.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.
+
+mod foo {
+    pub trait MyTrait {
+        fn do_something();
+    }
+}
+
+use foo::MyTrait::do_something; //~ ERROR E0253
+
+fn main() {}
diff --git a/src/test/compile-fail/E0254.rs b/src/test/compile-fail/E0254.rs
new file mode 100644
index 00000000000..28f9aea9657
--- /dev/null
+++ b/src/test/compile-fail/E0254.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.
+
+extern crate collections;
+
+mod foo {
+    pub trait collections {
+        fn do_something();
+    }
+}
+
+use foo::collections; //~ ERROR E0254
+
+fn main() {}
diff --git a/src/test/compile-fail/E0255.rs b/src/test/compile-fail/E0255.rs
new file mode 100644
index 00000000000..e05c6bede7e
--- /dev/null
+++ b/src/test/compile-fail/E0255.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.
+
+use bar::foo;
+
+fn foo() {} //~ ERROR E0255
+
+mod bar {
+     pub fn foo() {}
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0259.rs b/src/test/compile-fail/E0259.rs
new file mode 100644
index 00000000000..6b7e8613859
--- /dev/null
+++ b/src/test/compile-fail/E0259.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.
+
+extern crate collections;
+extern crate libc as collections; //~ ERROR E0259
+
+fn main() {}
diff --git a/src/test/compile-fail/E0260.rs b/src/test/compile-fail/E0260.rs
new file mode 100644
index 00000000000..d20829bf4d4
--- /dev/null
+++ b/src/test/compile-fail/E0260.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.
+
+extern crate collections;
+
+mod collections { //~ ERROR E0260
+    pub trait MyTrait {
+        fn do_something();
+    }
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0261.rs b/src/test/compile-fail/E0261.rs
new file mode 100644
index 00000000000..4196ad370b8
--- /dev/null
+++ b/src/test/compile-fail/E0261.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.
+
+fn foo(x: &'a str) { } //~ ERROR E0261
+
+struct Foo {
+    x: &'a str, //~ ERROR E0261
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0262.rs b/src/test/compile-fail/E0262.rs
new file mode 100644
index 00000000000..e09e4766d51
--- /dev/null
+++ b/src/test/compile-fail/E0262.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 foo<'static>(x: &'static str) { } //~ ERROR E0262
+
+fn main() {}
diff --git a/src/test/compile-fail/E0263.rs b/src/test/compile-fail/E0263.rs
new file mode 100644
index 00000000000..09f654c368c
--- /dev/null
+++ b/src/test/compile-fail/E0263.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 foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { } //~ ERROR E0263
+
+fn main() {}
diff --git a/src/test/compile-fail/E0264.rs b/src/test/compile-fail/E0264.rs
new file mode 100644
index 00000000000..92332977e76
--- /dev/null
+++ b/src/test/compile-fail/E0264.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(lang_items)]
+
+extern "C" {
+    #[lang = "cake"]
+    fn cake(); //~ ERROR E0264
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0267.rs b/src/test/compile-fail/E0267.rs
new file mode 100644
index 00000000000..6287256e866
--- /dev/null
+++ b/src/test/compile-fail/E0267.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 w = || { break; }; //~ ERROR E0267
+}
diff --git a/src/test/compile-fail/E0268.rs b/src/test/compile-fail/E0268.rs
new file mode 100644
index 00000000000..41e88e2f492
--- /dev/null
+++ b/src/test/compile-fail/E0268.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() {
+    break; //~ ERROR E0268
+}