Skip to content

Commit 802d081

Browse files
authored
Auto merge of #35274 - GuillaumeGomez:err_codes, r=jonathandturner
Add new error code tests r? @jonathandturner
2 parents 545a3a9 + 8502c6c commit 802d081

21 files changed

+404
-0
lines changed

src/test/compile-fail/E0201.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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(u8);
12+
13+
impl Foo {
14+
fn bar(&self) -> bool { self.0 > 5 }
15+
fn bar() {} //~ ERROR E0201
16+
}
17+
18+
trait Baz {
19+
type Quux;
20+
fn baz(&self) -> bool;
21+
}
22+
23+
impl Baz for Foo {
24+
type Quux = u32;
25+
26+
fn baz(&self) -> bool { true }
27+
fn baz(&self) -> bool { self.0 > 5 } //~ ERROR E0201
28+
type Quux = u32; //~ ERROR E0201
29+
}
30+
31+
fn main() {
32+
}

src/test/compile-fail/E0204.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
foo: Vec<u32>,
13+
}
14+
15+
impl Copy for Foo { } //~ ERROR E0204
16+
17+
#[derive(Copy)] //~ ERROR E0204
18+
struct Foo2<'a> {
19+
ty: &'a mut bool,
20+
}
21+
22+
fn main() {
23+
}

src/test/compile-fail/E0205.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+
enum Foo {
12+
Bar(Vec<u32>),
13+
Baz,
14+
}
15+
16+
impl Copy for Foo { } //~ ERROR E0205
17+
18+
#[derive(Copy)] //~ ERROR E0205
19+
enum Foo2<'a> {
20+
Bar(&'a mut bool),
21+
Baz,
22+
}
23+
24+
fn main() {
25+
}

src/test/compile-fail/E0206.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+
type Foo = i32;
12+
13+
impl Copy for Foo { } //~ ERROR E0206
14+
//~^ ERROR E0117
15+
16+
#[derive(Copy, Clone)]
17+
struct Bar;
18+
19+
impl Copy for &'static Bar { } //~ ERROR E0206
20+
21+
fn main() {
22+
}

src/test/compile-fail/E0207.rs

Lines changed: 20 additions & 0 deletions
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 Foo;
12+
13+
impl<T: Default> Foo { //~ ERROR E0207
14+
fn get(&self) -> T {
15+
<T as Default>::default()
16+
}
17+
}
18+
19+
fn main() {
20+
}

src/test/compile-fail/E0214.rs

Lines changed: 13 additions & 0 deletions
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 v: Vec(&str) = vec!["foo"]; //~ ERROR E0214
13+
}

src/test/compile-fail/E0220.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+
trait Trait {
12+
type Bar;
13+
}
14+
15+
type Foo = Trait<F=i32>; //~ ERROR E0220
16+
//~^ ERROR E0191
17+
18+
fn main() {
19+
}

src/test/compile-fail/E0221.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 T1 {}
12+
trait T2 {}
13+
14+
trait Foo {
15+
type A: T1;
16+
}
17+
18+
trait Bar : Foo {
19+
type A: T2;
20+
fn do_something() {
21+
let _: Self::A; //~ ERROR E0221
22+
}
23+
}
24+
25+
fn main() {
26+
}

src/test/compile-fail/E0223.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+
trait MyTrait { type X; }
12+
13+
fn main() {
14+
let foo: MyTrait::X; //~ ERROR E0223
15+
}

src/test/compile-fail/E0225.rs

Lines changed: 13 additions & 0 deletions
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 _: Box<std::io::Read + std::io::Write>; //~ ERROR E0225
13+
}

0 commit comments

Comments
 (0)