Skip to content

Commit 7cd1779

Browse files
Add new error code tests
1 parent 8787237 commit 7cd1779

File tree

13 files changed

+184
-4
lines changed

13 files changed

+184
-4
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

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ mod foo {
146146
}
147147
148148
use foo::MyTrait::do_something;
149+
// error: `do_something` is not directly importable
149150
150151
fn main() {}
151152
```

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)