Skip to content

Commit 0658941

Browse files
Add new error code tests
1 parent 4da9bdc commit 0658941

File tree

10 files changed

+190
-0
lines changed

10 files changed

+190
-0
lines changed

src/test/compile-fail/E0365.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+
mod foo {
12+
pub const X: u32 = 1;
13+
}
14+
15+
pub use foo as foo2; //~ ERROR E0365
16+
17+
fn main() {}

src/test/compile-fail/E0370.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
#![allow(dead_code)]
12+
13+
#[deny(overflowing_literals)]
14+
#[repr(i64)]
15+
enum Foo {
16+
X = 0x7fffffffffffffff,
17+
Y, //~ ERROR E0370
18+
}
19+
20+
fn main() {}

src/test/compile-fail/E0374.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+
#![feature(coerce_unsized)]
12+
use std::ops::CoerceUnsized;
13+
14+
struct Foo<T: ?Sized> {
15+
a: i32,
16+
}
17+
18+
impl<T, U> CoerceUnsized<Foo<U>> for Foo<T> //~ ERROR E0374
19+
where T: CoerceUnsized<U> {}
20+
21+
fn main() {}

src/test/compile-fail/E0375.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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(coerce_unsized)]
12+
use std::ops::CoerceUnsized;
13+
14+
struct Foo<T: ?Sized, U: ?Sized> {
15+
a: i32,
16+
b: T,
17+
c: U,
18+
}
19+
20+
impl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {} //~ ERROR E0375
21+
22+
fn main() {}

src/test/compile-fail/E0376.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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(coerce_unsized)]
12+
use std::ops::CoerceUnsized;
13+
14+
struct Foo<T: ?Sized> {
15+
a: T,
16+
}
17+
18+
impl<T, U> CoerceUnsized<U> for Foo<T> {} //~ ERROR E0376
19+
20+
fn main() {}

src/test/compile-fail/E0388.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
static X: i32 = 1;
12+
const C: i32 = 2;
13+
14+
const CR: &'static mut i32 = &mut C; //~ ERROR E0017
15+
//~| ERROR E0017
16+
static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
17+
//~| ERROR E0017
18+
//~| ERROR E0388
19+
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
20+
//~| ERROR E0017
21+
22+
fn main() {}

src/test/compile-fail/E0389.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
struct FancyNum {
12+
num: u8,
13+
}
14+
15+
fn main() {
16+
let mut fancy = FancyNum{ num: 5 };
17+
let fancy_ref = &(&mut fancy);
18+
fancy_ref.num = 6; //~ ERROR E0389
19+
println!("{}", fancy_ref.num);
20+
}

src/test/compile-fail/E0390.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+
struct Foo {
12+
x: i32
13+
}
14+
15+
impl *mut Foo {} //~ ERROR E0390
16+
17+
fn main() {
18+
}

src/test/compile-fail/E0392.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+
enum Foo<T> { Bar } //~ ERROR E0392
12+
13+
fn main() {
14+
}

src/test/compile-fail/E0393.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
trait A<T=Self> {}
12+
13+
fn together_we_will_rule_the_galaxy(son: &A) {} //~ ERROR E0393
14+
15+
fn main() {
16+
}

0 commit comments

Comments
 (0)