diff options
| author | bors <bors@rust-lang.org> | 2016-05-18 15:12:56 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-05-18 15:12:56 -0700 |
| commit | 9c6904ca1e4ab95f6c48973dea718326735ad564 (patch) | |
| tree | 8e761324f7ddf3128514708bbc73404c6fa7d4a7 /src | |
| parent | 9a140454ea47b7fd107b6e963b7ea2aef74e9518 (diff) | |
| parent | afd4cccd621c11304822d4550dc39a62b57d1a64 (diff) | |
Auto merge of #33686 - GuillaumeGomez:error-code-tests, r=steveklabnik
Add new error code tests r? @steveklabnik
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/compile-fail/E0027.rs | 22 | ||||
| -rw-r--r-- | src/test/compile-fail/E0029.rs | 18 | ||||
| -rw-r--r-- | src/test/compile-fail/E0030.rs | 16 | ||||
| -rw-r--r-- | src/test/compile-fail/E0033.rs | 19 | ||||
| -rw-r--r-- | src/test/compile-fail/E0034.rs | 26 | ||||
| -rw-r--r-- | src/test/compile-fail/E0035.rs | 20 |
6 files changed, 121 insertions, 0 deletions
diff --git a/src/test/compile-fail/E0027.rs b/src/test/compile-fail/E0027.rs new file mode 100644 index 00000000000..b2f20442b77 --- /dev/null +++ b/src/test/compile-fail/E0027.rs @@ -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 + } +} diff --git a/src/test/compile-fail/E0029.rs b/src/test/compile-fail/E0029.rs new file mode 100644 index 00000000000..9cbdec99520 --- /dev/null +++ b/src/test/compile-fail/E0029.rs @@ -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 + _ => {} + } +} diff --git a/src/test/compile-fail/E0030.rs b/src/test/compile-fail/E0030.rs new file mode 100644 index 00000000000..7f26f6cdb84 --- /dev/null +++ b/src/test/compile-fail/E0030.rs @@ -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 + } +} diff --git a/src/test/compile-fail/E0033.rs b/src/test/compile-fail/E0033.rs new file mode 100644 index 00000000000..946600013f3 --- /dev/null +++ b/src/test/compile-fail/E0033.rs @@ -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 +} diff --git a/src/test/compile-fail/E0034.rs b/src/test/compile-fail/E0034.rs new file mode 100644 index 00000000000..669bece0f7d --- /dev/null +++ b/src/test/compile-fail/E0034.rs @@ -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 +} diff --git a/src/test/compile-fail/E0035.rs b/src/test/compile-fail/E0035.rs new file mode 100644 index 00000000000..43f46e3578c --- /dev/null +++ b/src/test/compile-fail/E0035.rs @@ -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 +} |
