mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
Add new error code tests
This commit is contained in:
parent
5743564f2d
commit
afd4cccd62
22
src/test/compile-fail/E0027.rs
Normal file
22
src/test/compile-fail/E0027.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.
|
||||
|
||||
struct Dog {
|
||||
name: String,
|
||||
age: u32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let d = Dog { name: "Rusty".to_string(), age: 8 };
|
||||
|
||||
match d {
|
||||
Dog { age: x } => {} //~ ERROR E0027
|
||||
}
|
||||
}
|
18
src/test/compile-fail/E0029.rs
Normal file
18
src/test/compile-fail/E0029.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.
|
||||
|
||||
fn main() {
|
||||
let s = "hoho";
|
||||
|
||||
match s {
|
||||
"hello" ... "world" => {} //~ ERROR E0029
|
||||
_ => {}
|
||||
}
|
||||
}
|
16
src/test/compile-fail/E0030.rs
Normal file
16
src/test/compile-fail/E0030.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.
|
||||
|
||||
|
||||
fn main() {
|
||||
match 5u32 {
|
||||
1000 ... 5 => {} //~ ERROR E0030
|
||||
}
|
||||
}
|
19
src/test/compile-fail/E0033.rs
Normal file
19
src/test/compile-fail/E0033.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 SomeTrait {
|
||||
fn foo();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let trait_obj: &SomeTrait = SomeTrait; //~ ERROR E0425
|
||||
//~^ ERROR E0038
|
||||
let &invalid = trait_obj; //~ ERROR E0033
|
||||
}
|
26
src/test/compile-fail/E0034.rs
Normal file
26
src/test/compile-fail/E0034.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.
|
||||
|
||||
struct Test;
|
||||
|
||||
trait Trait1 {
|
||||
fn foo();
|
||||
}
|
||||
|
||||
trait Trait2 {
|
||||
fn foo();
|
||||
}
|
||||
|
||||
impl Trait1 for Test { fn foo() {} }
|
||||
impl Trait2 for Test { fn foo() {} }
|
||||
|
||||
fn main() {
|
||||
Test::foo() //~ ERROR E0034
|
||||
}
|
20
src/test/compile-fail/E0035.rs
Normal file
20
src/test/compile-fail/E0035.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 Test;
|
||||
|
||||
impl Test {
|
||||
fn method(&self) {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = Test;
|
||||
x.method::<i32>(); //~ ERROR E0035
|
||||
}
|
Loading…
Reference in New Issue
Block a user