File tree Expand file tree Collapse file tree 11 files changed +196
-2
lines changed Expand file tree Collapse file tree 11 files changed +196
-2
lines changed Original file line number Diff line number Diff line change @@ -1270,7 +1270,42 @@ trait Foo {}
12701270
12711271impl Foo for i32 {}
12721272```
1273- "##
1273+ "## ,
1274+
1275+ E0530 : r##"
1276+ A binding shadowed something it shouldn't.
1277+
1278+ Erroneous code example:
1279+
1280+ ```compile_fail,E0530
1281+ static TEST: i32 = 0;
1282+
1283+ let r: (i32, i32) = (0, 0);
1284+ match r {
1285+ TEST => {} // error: match bindings cannot shadow statics
1286+ }
1287+ ```
1288+
1289+ To fix this error, just change the binding's name in order to avoid shadowing
1290+ one of the following:
1291+
1292+ * struct name
1293+ * struct/enum variant
1294+ * static
1295+ * const
1296+ * associated const
1297+
1298+ Fixed example:
1299+
1300+ ```
1301+ static TEST: i32 = 0;
1302+
1303+ let r: (i32, i32) = (0, 0);
1304+ match r {
1305+ something => {} // ok!
1306+ }
1307+ ```
1308+ "## ,
12741309
12751310}
12761311
@@ -1289,7 +1324,6 @@ register_diagnostics! {
12891324// E0419, merged into 531
12901325// E0420, merged into 532
12911326// E0421, merged into 531
1292- E0530 , // X bindings cannot shadow Ys
12931327 E0531 , // unresolved pattern path kind `name`
12941328 E0532 , // expected pattern path kind, found another pattern path kind
12951329// E0427, merged into 530
Original file line number Diff line number Diff line change 1+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #![ feature( slice_patterns) ]
12+
13+ fn main ( ) {
14+ let r = & [ 1 , 2 ] ;
15+ match r {
16+ & [ a, b, c, rest..] => { //~ ERROR E0528
17+ }
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #![ feature( slice_patterns) ]
12+
13+ fn main ( ) {
14+ let r: f32 = 1.0 ;
15+ match r {
16+ [ a, b] => { //~ ERROR E0529
17+ }
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ fn main ( ) {
12+ static TEST : i32 = 0 ;
13+
14+ let r: ( i32 , i32 ) = ( 0 , 0 ) ;
15+ match r {
16+ TEST => { } //~ ERROR E0530
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #[ inline( ) ] //~ ERROR E0534
12+ pub fn something ( ) { }
13+
14+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #[ inline( unknown) ] //~ ERROR E0535
12+ pub fn something ( ) { }
13+
14+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #[ cfg( not( ) ) ] //~ ERROR E0536
12+ pub fn something ( ) { }
13+
14+ pub fn main ( ) { }
Original file line number Diff line number Diff line change 1+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #[ cfg( unknown( ) ) ] //~ ERROR E0537
12+ pub fn something ( ) { }
13+
14+ pub fn main ( ) { }
Original file line number Diff line number Diff line change 1+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #[ export_name] //~ ERROR E0558
12+ pub fn something ( ) { }
13+
14+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ enum Field {
12+ Fool { x : u32 } ,
13+ }
14+
15+ fn main ( ) {
16+ let s = Field :: Fool { joke : 0 } ; //~ ERROR E0559
17+ }
You can’t perform that action at this time.
0 commit comments