mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
Auto merge of #35274 - GuillaumeGomez:err_codes, r=jonathandturner
Add new error code tests r? @jonathandturner
This commit is contained in:
commit
802d0811a5
32
src/test/compile-fail/E0201.rs
Normal file
32
src/test/compile-fail/E0201.rs
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct Foo(u8);
|
||||
|
||||
impl Foo {
|
||||
fn bar(&self) -> bool { self.0 > 5 }
|
||||
fn bar() {} //~ ERROR E0201
|
||||
}
|
||||
|
||||
trait Baz {
|
||||
type Quux;
|
||||
fn baz(&self) -> bool;
|
||||
}
|
||||
|
||||
impl Baz for Foo {
|
||||
type Quux = u32;
|
||||
|
||||
fn baz(&self) -> bool { true }
|
||||
fn baz(&self) -> bool { self.0 > 5 } //~ ERROR E0201
|
||||
type Quux = u32; //~ ERROR E0201
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
23
src/test/compile-fail/E0204.rs
Normal file
23
src/test/compile-fail/E0204.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct Foo {
|
||||
foo: Vec<u32>,
|
||||
}
|
||||
|
||||
impl Copy for Foo { } //~ ERROR E0204
|
||||
|
||||
#[derive(Copy)] //~ ERROR E0204
|
||||
struct Foo2<'a> {
|
||||
ty: &'a mut bool,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
25
src/test/compile-fail/E0205.rs
Normal file
25
src/test/compile-fail/E0205.rs
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
enum Foo {
|
||||
Bar(Vec<u32>),
|
||||
Baz,
|
||||
}
|
||||
|
||||
impl Copy for Foo { } //~ ERROR E0205
|
||||
|
||||
#[derive(Copy)] //~ ERROR E0205
|
||||
enum Foo2<'a> {
|
||||
Bar(&'a mut bool),
|
||||
Baz,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
22
src/test/compile-fail/E0206.rs
Normal file
22
src/test/compile-fail/E0206.rs
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
type Foo = i32;
|
||||
|
||||
impl Copy for Foo { } //~ ERROR E0206
|
||||
//~^ ERROR E0117
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct Bar;
|
||||
|
||||
impl Copy for &'static Bar { } //~ ERROR E0206
|
||||
|
||||
fn main() {
|
||||
}
|
20
src/test/compile-fail/E0207.rs
Normal file
20
src/test/compile-fail/E0207.rs
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl<T: Default> Foo { //~ ERROR E0207
|
||||
fn get(&self) -> T {
|
||||
<T as Default>::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
13
src/test/compile-fail/E0214.rs
Normal file
13
src/test/compile-fail/E0214.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let v: Vec(&str) = vec!["foo"]; //~ ERROR E0214
|
||||
}
|
19
src/test/compile-fail/E0220.rs
Normal file
19
src/test/compile-fail/E0220.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait Trait {
|
||||
type Bar;
|
||||
}
|
||||
|
||||
type Foo = Trait<F=i32>; //~ ERROR E0220
|
||||
//~^ ERROR E0191
|
||||
|
||||
fn main() {
|
||||
}
|
26
src/test/compile-fail/E0221.rs
Normal file
26
src/test/compile-fail/E0221.rs
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait T1 {}
|
||||
trait T2 {}
|
||||
|
||||
trait Foo {
|
||||
type A: T1;
|
||||
}
|
||||
|
||||
trait Bar : Foo {
|
||||
type A: T2;
|
||||
fn do_something() {
|
||||
let _: Self::A; //~ ERROR E0221
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
15
src/test/compile-fail/E0223.rs
Normal file
15
src/test/compile-fail/E0223.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait MyTrait { type X; }
|
||||
|
||||
fn main() {
|
||||
let foo: MyTrait::X; //~ ERROR E0223
|
||||
}
|
13
src/test/compile-fail/E0225.rs
Normal file
13
src/test/compile-fail/E0225.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let _: Box<std::io::Read + std::io::Write>; //~ ERROR E0225
|
||||
}
|
26
src/test/compile-fail/E0229.rs
Normal file
26
src/test/compile-fail/E0229.rs
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub trait Foo {
|
||||
type A;
|
||||
fn boo(&self) -> <Self as Foo>::A;
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
||||
impl Foo for isize {
|
||||
type A = usize;
|
||||
fn boo(&self) -> usize { 42 }
|
||||
}
|
||||
|
||||
fn baz<I>(x: &<I as Foo<A=Bar>>::A) {} //~ ERROR E0229
|
||||
|
||||
fn main() {
|
||||
}
|
17
src/test/compile-fail/E0232.rs
Normal file
17
src/test/compile-fail/E0232.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(on_unimplemented)]
|
||||
|
||||
#[rustc_on_unimplemented] //~ ERROR E0232
|
||||
trait Bar {}
|
||||
|
||||
fn main() {
|
||||
}
|
15
src/test/compile-fail/E0243.rs
Normal file
15
src/test/compile-fail/E0243.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct Foo<T> { x: T }
|
||||
struct Bar { x: Foo } //~ ERROR E0243
|
||||
|
||||
fn main() {
|
||||
}
|
15
src/test/compile-fail/E0244.rs
Normal file
15
src/test/compile-fail/E0244.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct Foo { x: bool }
|
||||
struct Bar<S, T> { x: Foo<S, T> } //~ ERROR E0244
|
||||
|
||||
fn main() {
|
||||
}
|
18
src/test/compile-fail/E0248.rs
Normal file
18
src/test/compile-fail/E0248.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
enum Foo {
|
||||
Bar(u32),
|
||||
}
|
||||
|
||||
fn do_something(x: Foo::Bar) { } //~ ERROR E0248
|
||||
|
||||
fn main() {
|
||||
}
|
23
src/test/compile-fail/E0252.rs
Normal file
23
src/test/compile-fail/E0252.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use foo::baz;
|
||||
use bar::baz; //~ ERROR E0252
|
||||
|
||||
mod foo {
|
||||
pub struct baz;
|
||||
}
|
||||
|
||||
mod bar {
|
||||
pub mod baz {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
16
src/test/compile-fail/E0306.rs
Normal file
16
src/test/compile-fail/E0306.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
const A: [u32; "hello"] = []; //~ ERROR E0306
|
||||
const B: [u32; true] = []; //~ ERROR E0306
|
||||
const C: [u32; 0.0] = []; //~ ERROR E0306
|
||||
|
||||
fn main() {
|
||||
}
|
20
src/test/compile-fail/E0308-2.rs
Normal file
20
src/test/compile-fail/E0308-2.rs
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
fn x(self: Rc<Foo>) {} //~ ERROR E0308
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
11
src/test/compile-fail/E0308-3.rs
Normal file
11
src/test/compile-fail/E0308-3.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() -> i32 { 0 } //~ ERROR E0308
|
17
src/test/compile-fail/E0308-4.rs
Normal file
17
src/test/compile-fail/E0308-4.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let x = 1u8;
|
||||
match x {
|
||||
0u8...3i8 => (), //~ ERROR E0308
|
||||
_ => ()
|
||||
}
|
||||
}
|
18
src/test/compile-fail/E0308.rs
Normal file
18
src/test/compile-fail/E0308.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(intrinsics)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
fn size_of<T>(); //~ ERROR E0308
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
Loading…
Reference in New Issue
Block a user