From bb5a7a42b1c6082149a7563c9b6342b559641c13 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 27 May 2016 22:06:24 +0200 Subject: [PATCH] Add new error code tests --- src/test/compile-fail/E0117.rs | 14 ++++++++++++++ src/test/compile-fail/E0118.rs | 18 ++++++++++++++++++ src/test/compile-fail/E0119.rs | 28 ++++++++++++++++++++++++++++ src/test/compile-fail/E0120.rs | 18 ++++++++++++++++++ src/test/compile-fail/E0121.rs | 16 ++++++++++++++++ src/test/compile-fail/E0124.rs | 17 +++++++++++++++++ src/test/compile-fail/E0128.rs | 17 +++++++++++++++++ src/test/compile-fail/E0130.rs | 16 ++++++++++++++++ src/test/compile-fail/E0131.rs | 12 ++++++++++++ src/test/compile-fail/E0132.rs | 17 +++++++++++++++++ src/test/compile-fail/E0133.rs | 15 +++++++++++++++ src/test/compile-fail/E0137.rs | 17 +++++++++++++++++ src/test/compile-fail/E0138.rs | 17 +++++++++++++++++ src/test/compile-fail/E0152.rs | 17 +++++++++++++++++ src/test/compile-fail/E0161.rs | 16 ++++++++++++++++ 15 files changed, 255 insertions(+) create mode 100644 src/test/compile-fail/E0117.rs create mode 100644 src/test/compile-fail/E0118.rs create mode 100644 src/test/compile-fail/E0119.rs create mode 100644 src/test/compile-fail/E0120.rs create mode 100644 src/test/compile-fail/E0121.rs create mode 100644 src/test/compile-fail/E0124.rs create mode 100644 src/test/compile-fail/E0128.rs create mode 100644 src/test/compile-fail/E0130.rs create mode 100644 src/test/compile-fail/E0131.rs create mode 100644 src/test/compile-fail/E0132.rs create mode 100644 src/test/compile-fail/E0133.rs create mode 100644 src/test/compile-fail/E0137.rs create mode 100644 src/test/compile-fail/E0138.rs create mode 100644 src/test/compile-fail/E0152.rs create mode 100644 src/test/compile-fail/E0161.rs diff --git a/src/test/compile-fail/E0117.rs b/src/test/compile-fail/E0117.rs new file mode 100644 index 0000000000000..16d713bba92ab --- /dev/null +++ b/src/test/compile-fail/E0117.rs @@ -0,0 +1,14 @@ +// 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. + +impl Drop for u32 {} //~ ERROR E0117 + +fn main() { +} diff --git a/src/test/compile-fail/E0118.rs b/src/test/compile-fail/E0118.rs new file mode 100644 index 0000000000000..d37ff34b861f4 --- /dev/null +++ b/src/test/compile-fail/E0118.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. + +impl (u8, u8) { //~ ERROR E0118 + fn get_state(&self) -> String { + String::new() + } +} + +fn main() { +} diff --git a/src/test/compile-fail/E0119.rs b/src/test/compile-fail/E0119.rs new file mode 100644 index 0000000000000..9528631b3047b --- /dev/null +++ b/src/test/compile-fail/E0119.rs @@ -0,0 +1,28 @@ +// 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 { + fn get(&self) -> usize; +} + +impl MyTrait for T { + fn get(&self) -> usize { 0 } +} + +struct Foo { + value: usize +} + +impl MyTrait for Foo { //~ ERROR E0119 + fn get(&self) -> usize { self.value } +} + +fn main() { +} diff --git a/src/test/compile-fail/E0120.rs b/src/test/compile-fail/E0120.rs new file mode 100644 index 0000000000000..de084274f6fb8 --- /dev/null +++ b/src/test/compile-fail/E0120.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. + +trait MyTrait {} + +impl Drop for MyTrait { //~ ERROR E0120 + fn drop(&mut self) {} +} + +fn main() { +} diff --git a/src/test/compile-fail/E0121.rs b/src/test/compile-fail/E0121.rs new file mode 100644 index 0000000000000..b26b5f41bfe47 --- /dev/null +++ b/src/test/compile-fail/E0121.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. + +fn foo() -> _ { 5 } //~ ERROR E0121 + +static BAR: _ = "test"; //~ ERROR E0121 + +fn main() { +} diff --git a/src/test/compile-fail/E0124.rs b/src/test/compile-fail/E0124.rs new file mode 100644 index 0000000000000..414b19ead624d --- /dev/null +++ b/src/test/compile-fail/E0124.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. + +struct Foo { + field1: i32, + field1: i32, //~ ERROR E0124 +} + +fn main() { +} diff --git a/src/test/compile-fail/E0128.rs b/src/test/compile-fail/E0128.rs new file mode 100644 index 0000000000000..37071012825ec --- /dev/null +++ b/src/test/compile-fail/E0128.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. + +struct Foo { //~ ERROR E0128 + field1: T, + field2: U, +} + +fn main() { +} diff --git a/src/test/compile-fail/E0130.rs b/src/test/compile-fail/E0130.rs new file mode 100644 index 0000000000000..ef5961e133894 --- /dev/null +++ b/src/test/compile-fail/E0130.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. + +extern { + fn foo((a, b): (u32, u32)); //~ ERROR E0130 +} + +fn main() { +} diff --git a/src/test/compile-fail/E0131.rs b/src/test/compile-fail/E0131.rs new file mode 100644 index 0000000000000..aa11577ccdf1e --- /dev/null +++ b/src/test/compile-fail/E0131.rs @@ -0,0 +1,12 @@ +// 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() { //~ ERROR E0131 +} diff --git a/src/test/compile-fail/E0132.rs b/src/test/compile-fail/E0132.rs new file mode 100644 index 0000000000000..ff19a577f903d --- /dev/null +++ b/src/test/compile-fail/E0132.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(start)] + +#[start] +fn f() {} //~ ERROR E0132 + +fn main() { +} diff --git a/src/test/compile-fail/E0133.rs b/src/test/compile-fail/E0133.rs new file mode 100644 index 0000000000000..630ee851d0af0 --- /dev/null +++ b/src/test/compile-fail/E0133.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. + +unsafe fn f() { return; } + +fn main() { + f(); //~ ERROR E0133 +} diff --git a/src/test/compile-fail/E0137.rs b/src/test/compile-fail/E0137.rs new file mode 100644 index 0000000000000..695ce7995a9a4 --- /dev/null +++ b/src/test/compile-fail/E0137.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(main)] + +#[main] +fn foo() {} + +#[main] +fn f() {} //~ ERROR E0137 diff --git a/src/test/compile-fail/E0138.rs b/src/test/compile-fail/E0138.rs new file mode 100644 index 0000000000000..97d85e5e71e08 --- /dev/null +++ b/src/test/compile-fail/E0138.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(start)] + +#[start] +fn foo(argc: isize, argv: *const *const u8) -> isize {} + +#[start] +fn f(argc: isize, argv: *const *const u8) -> isize {} //~ ERROR E0138 diff --git a/src/test/compile-fail/E0152.rs b/src/test/compile-fail/E0152.rs new file mode 100644 index 0000000000000..ae501b94e3f05 --- /dev/null +++ b/src/test/compile-fail/E0152.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(lang_items)] + +#[lang = "panic_fmt"] +struct Foo; //~ ERROR E0152 + +fn main() { +} diff --git a/src/test/compile-fail/E0161.rs b/src/test/compile-fail/E0161.rs new file mode 100644 index 0000000000000..81adf9083024d --- /dev/null +++ b/src/test/compile-fail/E0161.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. + +#![feature(box_syntax)] + +fn main() { + let _x: Box = box *"hello"; //~ ERROR E0161 + //~^ ERROR E0507 +}