Skip to content

Commit 71b8958

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35363 - GuillaumeGomez:err_codes, r=jonathandturner
Err codes r? @jonathandturner
2 parents 39a1a25 + 7cd1779 commit 71b8958

File tree

13 files changed

+223
-5
lines changed

13 files changed

+223
-5
lines changed

src/librustc_passes/diagnostics.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ All statics and constants need to resolve to a value in an acyclic manner.
121121
122122
For example, neither of the following can be sensibly compiled:
123123
124-
```compile_fail
124+
```compile_fail,E0265
125125
const X: u32 = X;
126126
```
127127
128-
```compile_fail
128+
```compile_fail,E0265
129129
const X: u32 = Y;
130130
const Y: u32 = X;
131131
```
@@ -135,7 +135,7 @@ E0267: r##"
135135
This error indicates the use of a loop keyword (`break` or `continue`) inside a
136136
closure but outside of any loop. Erroneous code example:
137137
138-
```compile_fail
138+
```compile_fail,E0267
139139
let w = || { break; }; // error: `break` inside of a closure
140140
```
141141
@@ -159,7 +159,7 @@ This error indicates the use of a loop keyword (`break` or `continue`) outside
159159
of a loop. Without a loop to break out of or continue in, no sensible action can
160160
be taken. Erroneous code example:
161161
162-
```compile_fail
162+
```compile_fail,E0268
163163
fn some_func() {
164164
break; // error: `break` outside of loop
165165
}

src/librustc_resolve/diagnostics.rs

+40-1
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,53 @@ mod foo {
146146
}
147147
148148
use foo::MyTrait::do_something;
149+
// error: `do_something` is not directly importable
149150
150151
fn main() {}
151152
```
152153
153154
It's invalid to directly import methods belonging to a trait or concrete type.
154155
"##,
155156

157+
E0254: r##"
158+
Attempt was made to import an item whereas an extern crate with this name has
159+
already been imported.
160+
161+
Erroneous code example:
162+
163+
```compile_fail,E0254
164+
extern crate collections;
165+
166+
mod foo {
167+
pub trait collections {
168+
fn do_something();
169+
}
170+
}
171+
172+
use foo::collections; // error: an extern crate named `collections` has already
173+
// been imported in this module
174+
175+
fn main() {}
176+
```
177+
178+
To fix issue issue, you have to rename at least one of the two imports.
179+
Example:
180+
181+
```ignore
182+
extern crate collections as libcollections; // ok!
183+
184+
mod foo {
185+
pub trait collections {
186+
fn do_something();
187+
}
188+
}
189+
190+
use foo::collections;
191+
192+
fn main() {}
193+
```
194+
"##,
195+
156196
E0255: r##"
157197
You can't import a value whose name is the same as another value defined in the
158198
module.
@@ -1237,7 +1277,6 @@ impl Foo for i32 {}
12371277
register_diagnostics! {
12381278
// E0153, unused error code
12391279
// E0157, unused error code
1240-
E0254, // import conflicts with imported crate in this module
12411280
// E0257,
12421281
// E0258,
12431282
E0402, // cannot use an outer type parameter in this context

src/test/compile-fail/E0253.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
mod foo {
12+
pub trait MyTrait {
13+
fn do_something();
14+
}
15+
}
16+
17+
use foo::MyTrait::do_something; //~ ERROR E0253
18+
19+
fn main() {}

src/test/compile-fail/E0254.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
extern crate collections;
12+
13+
mod foo {
14+
pub trait collections {
15+
fn do_something();
16+
}
17+
}
18+
19+
use foo::collections; //~ ERROR E0254
20+
21+
fn main() {}

src/test/compile-fail/E0255.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
use bar::foo;
12+
13+
fn foo() {} //~ ERROR E0255
14+
15+
mod bar {
16+
pub fn foo() {}
17+
}
18+
19+
fn main() {}

src/test/compile-fail/E0259.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
extern crate collections;
12+
extern crate libc as collections; //~ ERROR E0259
13+
14+
fn main() {}

src/test/compile-fail/E0260.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
extern crate collections;
12+
13+
mod collections { //~ ERROR E0260
14+
pub trait MyTrait {
15+
fn do_something();
16+
}
17+
}
18+
19+
fn main() {}

src/test/compile-fail/E0261.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 foo(x: &'a str) { } //~ ERROR E0261
12+
13+
struct Foo {
14+
x: &'a str, //~ ERROR E0261
15+
}
16+
17+
fn main() {}

src/test/compile-fail/E0262.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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 foo<'static>(x: &'static str) { } //~ ERROR E0262
12+
13+
fn main() {}

src/test/compile-fail/E0263.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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 foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { } //~ ERROR E0263
12+
13+
fn main() {}

src/test/compile-fail/E0264.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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(lang_items)]
12+
13+
extern "C" {
14+
#[lang = "cake"]
15+
fn cake(); //~ ERROR E0264
16+
}
17+
18+
fn main() {}

src/test/compile-fail/E0267.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
let w = || { break; }; //~ ERROR E0267
13+
}

src/test/compile-fail/E0268.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
break; //~ ERROR E0268
13+
}

0 commit comments

Comments
 (0)