about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJonathan Turner <jonathandturner@users.noreply.github.com>2016-08-31 06:29:11 -0700
committerGitHub <noreply@github.com>2016-08-31 06:29:11 -0700
commit93c5d6cfd79f785eb8c69ba97308f9144fa665b0 (patch)
tree8966bedd564cb95b35a40d85e0c60018c00520c4
parentad5430f397185f5250b3ede5691597eb4125e9b4 (diff)
parent37bf449de4ff1d6519b577d014fbe17ccdce29b9 (diff)
downloadrust-93c5d6cfd79f785eb8c69ba97308f9144fa665b0.tar.gz
rust-93c5d6cfd79f785eb8c69ba97308f9144fa665b0.zip
Rollup merge of #36141 - GuillaumeGomez:err_codes, r=jonathandturner
Err codes

r? @jonathandturner
-rw-r--r--src/librustc_resolve/diagnostics.rs38
-rw-r--r--src/test/compile-fail/E0528.rs19
-rw-r--r--src/test/compile-fail/E0529.rs19
-rw-r--r--src/test/compile-fail/E0530.rs18
-rw-r--r--src/test/compile-fail/E0534.rs14
-rw-r--r--src/test/compile-fail/E0535.rs14
-rw-r--r--src/test/compile-fail/E0536.rs14
-rw-r--r--src/test/compile-fail/E0537.rs14
-rw-r--r--src/test/compile-fail/E0558.rs14
-rw-r--r--src/test/compile-fail/E0559.rs17
-rw-r--r--src/test/compile-fail/E560.rs17
11 files changed, 196 insertions, 2 deletions
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 5183d68065c..f8f90bdb4e7 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -1270,7 +1270,42 @@ trait Foo {}
 
 impl Foo for i32 {}
 ```
-"##
+"##,
+
+E0530: r##"
+A binding shadowed something it shouldn't.
+
+Erroneous code example:
+
+```compile_fail,E0530
+static TEST: i32 = 0;
+
+let r: (i32, i32) = (0, 0);
+match r {
+    TEST => {} // error: match bindings cannot shadow statics
+}
+```
+
+To fix this error, just change the binding's name in order to avoid shadowing
+one of the following:
+
+* struct name
+* struct/enum variant
+* static
+* const
+* associated const
+
+Fixed example:
+
+```
+static TEST: i32 = 0;
+
+let r: (i32, i32) = (0, 0);
+match r {
+    something => {} // ok!
+}
+```
+"##,
 
 }
 
@@ -1289,7 +1324,6 @@ register_diagnostics! {
 //  E0419, merged into 531
 //  E0420, merged into 532
 //  E0421, merged into 531
-    E0530, // X bindings cannot shadow Ys
     E0531, // unresolved pattern path kind `name`
     E0532, // expected pattern path kind, found another pattern path kind
 //  E0427, merged into 530
diff --git a/src/test/compile-fail/E0528.rs b/src/test/compile-fail/E0528.rs
new file mode 100644
index 00000000000..27187bb5aba
--- /dev/null
+++ b/src/test/compile-fail/E0528.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(slice_patterns)]
+
+fn main() {
+    let r = &[1, 2];
+    match r {
+        &[a, b, c, rest..] => { //~ ERROR E0528
+        }
+    }
+}
diff --git a/src/test/compile-fail/E0529.rs b/src/test/compile-fail/E0529.rs
new file mode 100644
index 00000000000..488fe7c7763
--- /dev/null
+++ b/src/test/compile-fail/E0529.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(slice_patterns)]
+
+fn main() {
+    let r: f32 = 1.0;
+    match r {
+        [a, b] => { //~ ERROR E0529
+        }
+    }
+}
diff --git a/src/test/compile-fail/E0530.rs b/src/test/compile-fail/E0530.rs
new file mode 100644
index 00000000000..4f674d0e671
--- /dev/null
+++ b/src/test/compile-fail/E0530.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() {
+    static TEST: i32 = 0;
+
+    let r: (i32, i32) = (0, 0);
+    match r {
+        TEST => {} //~ ERROR E0530
+    }
+}
diff --git a/src/test/compile-fail/E0534.rs b/src/test/compile-fail/E0534.rs
new file mode 100644
index 00000000000..8c036e6076d
--- /dev/null
+++ b/src/test/compile-fail/E0534.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.
+
+#[inline()] //~ ERROR E0534
+pub fn something() {}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0535.rs b/src/test/compile-fail/E0535.rs
new file mode 100644
index 00000000000..17558cc05c6
--- /dev/null
+++ b/src/test/compile-fail/E0535.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.
+
+#[inline(unknown)] //~ ERROR E0535
+pub fn something() {}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0536.rs b/src/test/compile-fail/E0536.rs
new file mode 100644
index 00000000000..127bdc258d9
--- /dev/null
+++ b/src/test/compile-fail/E0536.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.
+
+#[cfg(not())] //~ ERROR E0536
+pub fn something() {}
+
+pub fn main() {}
diff --git a/src/test/compile-fail/E0537.rs b/src/test/compile-fail/E0537.rs
new file mode 100644
index 00000000000..497936fbcd2
--- /dev/null
+++ b/src/test/compile-fail/E0537.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.
+
+#[cfg(unknown())] //~ ERROR E0537
+pub fn something() {}
+
+pub fn main() {}
diff --git a/src/test/compile-fail/E0558.rs b/src/test/compile-fail/E0558.rs
new file mode 100644
index 00000000000..4ab0506a9c0
--- /dev/null
+++ b/src/test/compile-fail/E0558.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.
+
+#[export_name] //~ ERROR E0558
+pub fn something() {}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0559.rs b/src/test/compile-fail/E0559.rs
new file mode 100644
index 00000000000..80eeb203a85
--- /dev/null
+++ b/src/test/compile-fail/E0559.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.
+
+enum Field {
+    Fool { x: u32 },
+}
+
+fn main() {
+    let s = Field::Fool { joke: 0 }; //~ ERROR E0559
+}
diff --git a/src/test/compile-fail/E560.rs b/src/test/compile-fail/E560.rs
new file mode 100644
index 00000000000..ec9b86ee1f0
--- /dev/null
+++ b/src/test/compile-fail/E560.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.
+
+struct Simba {
+    mother: u32,
+}
+
+fn main() {
+    let s = Simba { mother: 1, father: 0 }; //~ ERROR E0560
+}