Skip to content

Commit 5c5f483

Browse files
Add new error code tests
1 parent f200061 commit 5c5f483

File tree

7 files changed

+137
-0
lines changed

7 files changed

+137
-0
lines changed

src/test/compile-fail/E0478.rs

Lines changed: 18 additions & 0 deletions
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+
trait Wedding<'t>: 't { }
12+
13+
struct Prince<'kiss, 'SnowWhite> {
14+
child: Box<Wedding<'kiss> + 'SnowWhite>, //~ ERROR E0478
15+
}
16+
17+
fn main() {
18+
}

src/test/compile-fail/E0492.rs

Lines changed: 17 additions & 0 deletions
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+
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT};
12+
13+
const A: AtomicUsize = ATOMIC_USIZE_INIT;
14+
static B: &'static AtomicUsize = &A; //~ ERROR E0492
15+
16+
fn main() {
17+
}

src/test/compile-fail/E0493.rs

Lines changed: 22 additions & 0 deletions
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+
struct Foo {
12+
a: u32
13+
}
14+
15+
impl Drop for Foo {
16+
fn drop(&mut self) {}
17+
}
18+
19+
const F : Foo = Foo { a : 0 }; //~ ERROR E0493
20+
21+
fn main() {
22+
}

src/test/compile-fail/E0494.rs

Lines changed: 19 additions & 0 deletions
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+
struct Foo {
12+
a: u32
13+
}
14+
15+
static S : Foo = Foo { a : 0 };
16+
static A : &'static u32 = &S.a; //~ ERROR E0494
17+
18+
fn main() {
19+
}

src/test/compile-fail/E0496.rs

Lines changed: 21 additions & 0 deletions
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+
struct Foo<'a> {
12+
a: &'a i32,
13+
}
14+
15+
impl<'a> Foo<'a> {
16+
fn f<'a>(x: &'a i32) { //~ ERROR E0496
17+
}
18+
}
19+
20+
fn main() {
21+
}

src/test/compile-fail/E0499.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 mut i = 0;
13+
let mut x = &mut i;
14+
let mut a = &mut i; //~ ERROR E0499
15+
}

src/test/compile-fail/E0501.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 inside_closure(x: &mut i32) {
12+
}
13+
14+
fn outside_closure(x: &mut i32) {
15+
}
16+
17+
fn foo(a: &mut i32) {
18+
let bar = || {
19+
inside_closure(a)
20+
};
21+
outside_closure(a); //~ ERROR E0501
22+
}
23+
24+
fn main() {
25+
}

0 commit comments

Comments
 (0)