From 8502c6cb7c7d9fe5624ded221b6a6db1c7693524 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 4 Aug 2016 01:51:52 +0200 Subject: [PATCH] Add new error code tests --- src/test/compile-fail/E0201.rs | 32 ++++++++++++++++++++++++++++++++ src/test/compile-fail/E0204.rs | 23 +++++++++++++++++++++++ src/test/compile-fail/E0205.rs | 25 +++++++++++++++++++++++++ src/test/compile-fail/E0206.rs | 22 ++++++++++++++++++++++ src/test/compile-fail/E0207.rs | 20 ++++++++++++++++++++ src/test/compile-fail/E0214.rs | 13 +++++++++++++ src/test/compile-fail/E0220.rs | 19 +++++++++++++++++++ src/test/compile-fail/E0221.rs | 26 ++++++++++++++++++++++++++ src/test/compile-fail/E0223.rs | 15 +++++++++++++++ src/test/compile-fail/E0225.rs | 13 +++++++++++++ src/test/compile-fail/E0229.rs | 26 ++++++++++++++++++++++++++ src/test/compile-fail/E0232.rs | 17 +++++++++++++++++ src/test/compile-fail/E0243.rs | 15 +++++++++++++++ src/test/compile-fail/E0244.rs | 15 +++++++++++++++ src/test/compile-fail/E0248.rs | 18 ++++++++++++++++++ src/test/compile-fail/E0252.rs | 23 +++++++++++++++++++++++ src/test/compile-fail/E0306.rs | 16 ++++++++++++++++ src/test/compile-fail/E0308-2.rs | 20 ++++++++++++++++++++ src/test/compile-fail/E0308-3.rs | 11 +++++++++++ src/test/compile-fail/E0308-4.rs | 17 +++++++++++++++++ src/test/compile-fail/E0308.rs | 18 ++++++++++++++++++ 21 files changed, 404 insertions(+) create mode 100644 src/test/compile-fail/E0201.rs create mode 100644 src/test/compile-fail/E0204.rs create mode 100644 src/test/compile-fail/E0205.rs create mode 100644 src/test/compile-fail/E0206.rs create mode 100644 src/test/compile-fail/E0207.rs create mode 100644 src/test/compile-fail/E0214.rs create mode 100644 src/test/compile-fail/E0220.rs create mode 100644 src/test/compile-fail/E0221.rs create mode 100644 src/test/compile-fail/E0223.rs create mode 100644 src/test/compile-fail/E0225.rs create mode 100644 src/test/compile-fail/E0229.rs create mode 100644 src/test/compile-fail/E0232.rs create mode 100644 src/test/compile-fail/E0243.rs create mode 100644 src/test/compile-fail/E0244.rs create mode 100644 src/test/compile-fail/E0248.rs create mode 100644 src/test/compile-fail/E0252.rs create mode 100644 src/test/compile-fail/E0306.rs create mode 100644 src/test/compile-fail/E0308-2.rs create mode 100644 src/test/compile-fail/E0308-3.rs create mode 100644 src/test/compile-fail/E0308-4.rs create mode 100644 src/test/compile-fail/E0308.rs diff --git a/src/test/compile-fail/E0201.rs b/src/test/compile-fail/E0201.rs new file mode 100644 index 0000000000000..ff6cb55f388c3 --- /dev/null +++ b/src/test/compile-fail/E0201.rs @@ -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 or the MIT license +// , 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() { +} diff --git a/src/test/compile-fail/E0204.rs b/src/test/compile-fail/E0204.rs new file mode 100644 index 0000000000000..2fa2afa12eb43 --- /dev/null +++ b/src/test/compile-fail/E0204.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + foo: Vec, +} + +impl Copy for Foo { } //~ ERROR E0204 + +#[derive(Copy)] //~ ERROR E0204 +struct Foo2<'a> { + ty: &'a mut bool, +} + +fn main() { +} diff --git a/src/test/compile-fail/E0205.rs b/src/test/compile-fail/E0205.rs new file mode 100644 index 0000000000000..e4781bba08aab --- /dev/null +++ b/src/test/compile-fail/E0205.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Foo { + Bar(Vec), + Baz, +} + +impl Copy for Foo { } //~ ERROR E0205 + +#[derive(Copy)] //~ ERROR E0205 +enum Foo2<'a> { + Bar(&'a mut bool), + Baz, +} + +fn main() { +} diff --git a/src/test/compile-fail/E0206.rs b/src/test/compile-fail/E0206.rs new file mode 100644 index 0000000000000..31b01da3d75b5 --- /dev/null +++ b/src/test/compile-fail/E0206.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 or the MIT license +// , 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() { +} diff --git a/src/test/compile-fail/E0207.rs b/src/test/compile-fail/E0207.rs new file mode 100644 index 0000000000000..bd87dbaf786a5 --- /dev/null +++ b/src/test/compile-fail/E0207.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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo; + +impl Foo { //~ ERROR E0207 + fn get(&self) -> T { + ::default() + } +} + +fn main() { +} diff --git a/src/test/compile-fail/E0214.rs b/src/test/compile-fail/E0214.rs new file mode 100644 index 0000000000000..59609345ee523 --- /dev/null +++ b/src/test/compile-fail/E0214.rs @@ -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 or the MIT license +// , 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 +} diff --git a/src/test/compile-fail/E0220.rs b/src/test/compile-fail/E0220.rs new file mode 100644 index 0000000000000..17e2b18b3745e --- /dev/null +++ b/src/test/compile-fail/E0220.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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Trait { + type Bar; +} + +type Foo = Trait; //~ ERROR E0220 + //~^ ERROR E0191 + +fn main() { +} diff --git a/src/test/compile-fail/E0221.rs b/src/test/compile-fail/E0221.rs new file mode 100644 index 0000000000000..213ec5a048880 --- /dev/null +++ b/src/test/compile-fail/E0221.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 or the MIT license +// , 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() { +} diff --git a/src/test/compile-fail/E0223.rs b/src/test/compile-fail/E0223.rs new file mode 100644 index 0000000000000..bbf7d762ef00b --- /dev/null +++ b/src/test/compile-fail/E0223.rs @@ -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 or the MIT license +// , 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 +} diff --git a/src/test/compile-fail/E0225.rs b/src/test/compile-fail/E0225.rs new file mode 100644 index 0000000000000..190350c5a5571 --- /dev/null +++ b/src/test/compile-fail/E0225.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let _: Box; //~ ERROR E0225 +} diff --git a/src/test/compile-fail/E0229.rs b/src/test/compile-fail/E0229.rs new file mode 100644 index 0000000000000..45d5c59592f75 --- /dev/null +++ b/src/test/compile-fail/E0229.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 or the MIT license +// , 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) -> ::A; +} + +struct Bar; + +impl Foo for isize { + type A = usize; + fn boo(&self) -> usize { 42 } +} + +fn baz(x: &>::A) {} //~ ERROR E0229 + +fn main() { +} diff --git a/src/test/compile-fail/E0232.rs b/src/test/compile-fail/E0232.rs new file mode 100644 index 0000000000000..efeb869d71fa5 --- /dev/null +++ b/src/test/compile-fail/E0232.rs @@ -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 or the MIT license +// , 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() { +} diff --git a/src/test/compile-fail/E0243.rs b/src/test/compile-fail/E0243.rs new file mode 100644 index 0000000000000..8cc245c10cbe9 --- /dev/null +++ b/src/test/compile-fail/E0243.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { x: T } +struct Bar { x: Foo } //~ ERROR E0243 + +fn main() { +} diff --git a/src/test/compile-fail/E0244.rs b/src/test/compile-fail/E0244.rs new file mode 100644 index 0000000000000..4c57447109296 --- /dev/null +++ b/src/test/compile-fail/E0244.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { x: bool } +struct Bar { x: Foo } //~ ERROR E0244 + +fn main() { +} diff --git a/src/test/compile-fail/E0248.rs b/src/test/compile-fail/E0248.rs new file mode 100644 index 0000000000000..fdfd41a456bf6 --- /dev/null +++ b/src/test/compile-fail/E0248.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 or the MIT license +// , 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() { +} diff --git a/src/test/compile-fail/E0252.rs b/src/test/compile-fail/E0252.rs new file mode 100644 index 0000000000000..6b353c8cd1a62 --- /dev/null +++ b/src/test/compile-fail/E0252.rs @@ -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 or the MIT license +// , 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() { +} diff --git a/src/test/compile-fail/E0306.rs b/src/test/compile-fail/E0306.rs new file mode 100644 index 0000000000000..61cc8902036ec --- /dev/null +++ b/src/test/compile-fail/E0306.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 or the MIT license +// , 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() { +} diff --git a/src/test/compile-fail/E0308-2.rs b/src/test/compile-fail/E0308-2.rs new file mode 100644 index 0000000000000..8c9fc9551561d --- /dev/null +++ b/src/test/compile-fail/E0308-2.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 or the MIT license +// , 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) {} //~ ERROR E0308 +} + +fn main() { +} diff --git a/src/test/compile-fail/E0308-3.rs b/src/test/compile-fail/E0308-3.rs new file mode 100644 index 0000000000000..d7dca056f3fa6 --- /dev/null +++ b/src/test/compile-fail/E0308-3.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() -> i32 { 0 } //~ ERROR E0308 diff --git a/src/test/compile-fail/E0308-4.rs b/src/test/compile-fail/E0308-4.rs new file mode 100644 index 0000000000000..bb4cd1434167b --- /dev/null +++ b/src/test/compile-fail/E0308-4.rs @@ -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 or the MIT license +// , 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 + _ => () + } +} diff --git a/src/test/compile-fail/E0308.rs b/src/test/compile-fail/E0308.rs new file mode 100644 index 0000000000000..078f1d3a9a1ab --- /dev/null +++ b/src/test/compile-fail/E0308.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 or the MIT license +// , 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(); //~ ERROR E0308 +} + +fn main() { +}