From 93fb14ff427bc9196af87edc3d8be5aaf4fb6c11 Mon Sep 17 00:00:00 2001 From: ggomez Date: Thu, 19 May 2016 14:00:43 +0200 Subject: [PATCH] Add new error code tests --- src/test/compile-fail/E0036.rs | 23 +++++++++++++++++++++++ src/test/compile-fail/E0038.rs | 20 ++++++++++++++++++++ src/test/compile-fail/E0040.rs | 24 ++++++++++++++++++++++++ src/test/compile-fail/E0044.rs | 14 ++++++++++++++ src/test/compile-fail/E0045.rs | 14 ++++++++++++++ src/test/compile-fail/E0046.rs | 20 ++++++++++++++++++++ src/test/compile-fail/E0049.rs | 22 ++++++++++++++++++++++ src/test/compile-fail/E0050.rs | 22 ++++++++++++++++++++++ src/test/compile-fail/E0053.rs | 24 ++++++++++++++++++++++++ src/test/compile-fail/E0054.rs | 14 ++++++++++++++ src/test/compile-fail/E0055.rs | 23 +++++++++++++++++++++++ src/test/compile-fail/E0057.rs | 16 ++++++++++++++++ src/test/compile-fail/E0059.rs | 16 ++++++++++++++++ src/test/compile-fail/E0060.rs | 17 +++++++++++++++++ src/test/compile-fail/E0061.rs | 15 +++++++++++++++ 15 files changed, 284 insertions(+) create mode 100644 src/test/compile-fail/E0036.rs create mode 100644 src/test/compile-fail/E0038.rs create mode 100644 src/test/compile-fail/E0040.rs create mode 100644 src/test/compile-fail/E0044.rs create mode 100644 src/test/compile-fail/E0045.rs create mode 100644 src/test/compile-fail/E0046.rs create mode 100644 src/test/compile-fail/E0049.rs create mode 100644 src/test/compile-fail/E0050.rs create mode 100644 src/test/compile-fail/E0053.rs create mode 100644 src/test/compile-fail/E0054.rs create mode 100644 src/test/compile-fail/E0055.rs create mode 100644 src/test/compile-fail/E0057.rs create mode 100644 src/test/compile-fail/E0059.rs create mode 100644 src/test/compile-fail/E0060.rs create mode 100644 src/test/compile-fail/E0061.rs diff --git a/src/test/compile-fail/E0036.rs b/src/test/compile-fail/E0036.rs new file mode 100644 index 0000000000000..35fd6e8942fe7 --- /dev/null +++ b/src/test/compile-fail/E0036.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 Test; + +impl Test { + fn method(&self, v: &[T]) -> usize { + v.len() + } +} + +fn main() { + let x = Test; + let v = &[0]; + x.method::(v); //~ ERROR E0036 +} diff --git a/src/test/compile-fail/E0038.rs b/src/test/compile-fail/E0038.rs new file mode 100644 index 0000000000000..26d2f339763aa --- /dev/null +++ b/src/test/compile-fail/E0038.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. + +trait Trait { + fn foo(&self) -> Self; +} + +fn call_foo(x: Box) { //~ ERROR E0038 + let y = x.foo(); +} + +fn main() { +} diff --git a/src/test/compile-fail/E0040.rs b/src/test/compile-fail/E0040.rs new file mode 100644 index 0000000000000..f998778a50d66 --- /dev/null +++ b/src/test/compile-fail/E0040.rs @@ -0,0 +1,24 @@ +// 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: i32, +} + +impl Drop for Foo { + fn drop(&mut self) { + println!("kaboom"); + } +} + +fn main() { + let mut x = Foo { x: -7 }; + x.drop(); //~ ERROR E0040 +} diff --git a/src/test/compile-fail/E0044.rs b/src/test/compile-fail/E0044.rs new file mode 100644 index 0000000000000..48fe230003129 --- /dev/null +++ b/src/test/compile-fail/E0044.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. + +extern { fn some_func(x: T); } //~ ERROR E0044 + +fn main() { +} diff --git a/src/test/compile-fail/E0045.rs b/src/test/compile-fail/E0045.rs new file mode 100644 index 0000000000000..edec911d3c070 --- /dev/null +++ b/src/test/compile-fail/E0045.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. + +extern "rust-call" { fn foo(x: u8, ...); } //~ ERROR E0045 + +fn main() { +} diff --git a/src/test/compile-fail/E0046.rs b/src/test/compile-fail/E0046.rs new file mode 100644 index 0000000000000..63bd0a5ca2858 --- /dev/null +++ b/src/test/compile-fail/E0046.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. + +trait Foo { + fn foo(); +} + +struct Bar; + +impl Foo for Bar {} //~ ERROR E0046 + +fn main() { +} diff --git a/src/test/compile-fail/E0049.rs b/src/test/compile-fail/E0049.rs new file mode 100644 index 0000000000000..5867e11e9acc6 --- /dev/null +++ b/src/test/compile-fail/E0049.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. + +trait Foo { + fn foo(x: T) -> Self; +} + +struct Bar; + +impl Foo for Bar { + fn foo(x: bool) -> Self { Bar } //~ ERROR E0049 +} + +fn main() { +} diff --git a/src/test/compile-fail/E0050.rs b/src/test/compile-fail/E0050.rs new file mode 100644 index 0000000000000..2f7dc96361f9c --- /dev/null +++ b/src/test/compile-fail/E0050.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. + +trait Foo { + fn foo(&self, x: u8) -> bool; +} + +struct Bar; + +impl Foo for Bar { + fn foo(&self) -> bool { true } //~ ERROR E0050 +} + +fn main() { +} diff --git a/src/test/compile-fail/E0053.rs b/src/test/compile-fail/E0053.rs new file mode 100644 index 0000000000000..4effda3c49e8e --- /dev/null +++ b/src/test/compile-fail/E0053.rs @@ -0,0 +1,24 @@ +// 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 Foo { + fn foo(x: u16); + fn bar(&self); +} + +struct Bar; + +impl Foo for Bar { + fn foo(x: i16) { } //~ ERROR E0053 + fn bar(&mut self) { } //~ ERROR E0053 +} + +fn main() { +} diff --git a/src/test/compile-fail/E0054.rs b/src/test/compile-fail/E0054.rs new file mode 100644 index 0000000000000..158cd6ff9bbc4 --- /dev/null +++ b/src/test/compile-fail/E0054.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. + +fn main() { + let x = 5; + let x_is_nonzero = x as bool; //~ ERROR E0054 +} diff --git a/src/test/compile-fail/E0055.rs b/src/test/compile-fail/E0055.rs new file mode 100644 index 0000000000000..cb78f4b3bb597 --- /dev/null +++ b/src/test/compile-fail/E0055.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. + +#![recursion_limit="2"] +struct Foo; + +impl Foo { + fn foo(&self) {} +} + +fn main() { + let foo = Foo; + let ref_foo = &&Foo; + ref_foo.foo(); //~ ERROR E0055 + //~^ ERROR E0275 +} diff --git a/src/test/compile-fail/E0057.rs b/src/test/compile-fail/E0057.rs new file mode 100644 index 0000000000000..1fb5498b099c9 --- /dev/null +++ b/src/test/compile-fail/E0057.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 main() { + let f = |x| x * 3; + let a = f(); //~ ERROR E0057 + let b = f(4); + let c = f(2, 3); //~ ERROR E0057 +} diff --git a/src/test/compile-fail/E0059.rs b/src/test/compile-fail/E0059.rs new file mode 100644 index 0000000000000..4ae9b2f91d25f --- /dev/null +++ b/src/test/compile-fail/E0059.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(unboxed_closures)] + +fn foo>(f: F) -> F::Output { f(3) } //~ ERROR E0059 + +fn main() { +} diff --git a/src/test/compile-fail/E0060.rs b/src/test/compile-fail/E0060.rs new file mode 100644 index 0000000000000..b4a2898749792 --- /dev/null +++ b/src/test/compile-fail/E0060.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. + +extern "C" { + fn printf(_: *const u8, ...) -> u32; +} + +fn main() { + unsafe { printf(); } //~ ERROR E0060 +} diff --git a/src/test/compile-fail/E0061.rs b/src/test/compile-fail/E0061.rs new file mode 100644 index 0000000000000..4a8eac2a9e226 --- /dev/null +++ b/src/test/compile-fail/E0061.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. + +fn f(a: u16, b: &str) {} + +fn main() { + f(0); //~ ERROR E0061 +}