From 8d78237701f9646cd0ddc4645512e7cde3c58e5e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 17 Aug 2016 23:45:10 +0200 Subject: [PATCH] Add new error code tests --- src/librustc_resolve/diagnostics.rs | 2 +- src/test/compile-fail/E0423.rs | 15 +++++++++++++++ src/test/compile-fail/E0424.rs | 22 ++++++++++++++++++++++ src/test/compile-fail/E0425.rs | 18 ++++++++++++++++++ src/test/compile-fail/E0426.rs | 15 +++++++++++++++ src/test/compile-fail/E0428.rs | 16 ++++++++++++++++ src/test/compile-fail/E0429.rs | 15 +++++++++++++++ src/test/compile-fail/E0430.rs | 15 +++++++++++++++ src/test/compile-fail/E0431.rs | 14 ++++++++++++++ src/test/compile-fail/E0432.rs | 14 ++++++++++++++ src/test/compile-fail/E0433.rs | 13 +++++++++++++ src/test/compile-fail/E0434.rs | 19 +++++++++++++++++++ src/test/compile-fail/E0435.rs | 14 ++++++++++++++ src/test/compile-fail/E0437.rs | 18 ++++++++++++++++++ src/test/compile-fail/E0438.rs | 20 ++++++++++++++++++++ src/test/compile-fail/E0439.rs | 18 ++++++++++++++++++ src/test/compile-fail/E0440.rs | 22 ++++++++++++++++++++++ 17 files changed, 269 insertions(+), 1 deletion(-) create mode 100644 src/test/compile-fail/E0423.rs create mode 100644 src/test/compile-fail/E0424.rs create mode 100644 src/test/compile-fail/E0425.rs create mode 100644 src/test/compile-fail/E0426.rs create mode 100644 src/test/compile-fail/E0428.rs create mode 100644 src/test/compile-fail/E0429.rs create mode 100644 src/test/compile-fail/E0430.rs create mode 100644 src/test/compile-fail/E0431.rs create mode 100644 src/test/compile-fail/E0432.rs create mode 100644 src/test/compile-fail/E0433.rs create mode 100644 src/test/compile-fail/E0434.rs create mode 100644 src/test/compile-fail/E0435.rs create mode 100644 src/test/compile-fail/E0437.rs create mode 100644 src/test/compile-fail/E0438.rs create mode 100644 src/test/compile-fail/E0439.rs create mode 100644 src/test/compile-fail/E0440.rs diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 11ef75ee6a8..5183d68065c 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -891,7 +891,7 @@ A `struct` variant name was used like a function name. Erroneous code example: ```compile_fail,E0423 -struct Foo { a: bool}; +struct Foo { a: bool }; let f = Foo(); // error: `Foo` is a struct variant name, but this expression uses diff --git a/src/test/compile-fail/E0423.rs b/src/test/compile-fail/E0423.rs new file mode 100644 index 00000000000..f5fea77cf96 --- /dev/null +++ b/src/test/compile-fail/E0423.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 main () { + struct Foo { a: bool }; + + let f = Foo(); //~ ERROR E0423 +} diff --git a/src/test/compile-fail/E0424.rs b/src/test/compile-fail/E0424.rs new file mode 100644 index 00000000000..445d0c5f3ed --- /dev/null +++ b/src/test/compile-fail/E0424.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. + +struct Foo; + +impl Foo { + fn bar(self) {} + + fn foo() { + self.bar(); //~ ERROR E0424 + } +} + +fn main () { +} diff --git a/src/test/compile-fail/E0425.rs b/src/test/compile-fail/E0425.rs new file mode 100644 index 00000000000..70f4b1107ad --- /dev/null +++ b/src/test/compile-fail/E0425.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 Foo { + fn bar() { + Self; //~ ERROR E0425 + } +} + +fn main () { +} diff --git a/src/test/compile-fail/E0426.rs b/src/test/compile-fail/E0426.rs new file mode 100644 index 00000000000..2eb4c2d3b5e --- /dev/null +++ b/src/test/compile-fail/E0426.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 main () { + loop { + break 'a; //~ ERROR E0426 + } +} diff --git a/src/test/compile-fail/E0428.rs b/src/test/compile-fail/E0428.rs new file mode 100644 index 00000000000..42e237d31cb --- /dev/null +++ b/src/test/compile-fail/E0428.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. + +struct Bar; +struct Bar; //~ ERROR E0428 + //~^ ERROR E0428 + +fn main () { +} diff --git a/src/test/compile-fail/E0429.rs b/src/test/compile-fail/E0429.rs new file mode 100644 index 00000000000..a7d19744f3f --- /dev/null +++ b/src/test/compile-fail/E0429.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. + +use std::fmt::self; //~ ERROR E0429 + //~^ ERROR E0432 + +fn main () { +} diff --git a/src/test/compile-fail/E0430.rs b/src/test/compile-fail/E0430.rs new file mode 100644 index 00000000000..992876dd294 --- /dev/null +++ b/src/test/compile-fail/E0430.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. + +use std::fmt::{self, self}; //~ ERROR E0430 + //~^ ERROR E0252 + +fn main () { +} diff --git a/src/test/compile-fail/E0431.rs b/src/test/compile-fail/E0431.rs new file mode 100644 index 00000000000..09ddc1efaf4 --- /dev/null +++ b/src/test/compile-fail/E0431.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. + +use {self}; //~ ERROR E0431 + +fn main () { +} diff --git a/src/test/compile-fail/E0432.rs b/src/test/compile-fail/E0432.rs new file mode 100644 index 00000000000..08d699ee4ca --- /dev/null +++ b/src/test/compile-fail/E0432.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. + +use something::Foo; //~ ERROR E0432 + +fn main () { +} diff --git a/src/test/compile-fail/E0433.rs b/src/test/compile-fail/E0433.rs new file mode 100644 index 00000000000..916d6220eb9 --- /dev/null +++ b/src/test/compile-fail/E0433.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 map = HashMap::new(); //~ ERROR E0433 +} diff --git a/src/test/compile-fail/E0434.rs b/src/test/compile-fail/E0434.rs new file mode 100644 index 00000000000..747d9f72c42 --- /dev/null +++ b/src/test/compile-fail/E0434.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. + +fn foo() { + let y = 5; + fn bar() -> u32 { + y //~ ERROR E0434 + } +} + +fn main () { +} diff --git a/src/test/compile-fail/E0435.rs b/src/test/compile-fail/E0435.rs new file mode 100644 index 00000000000..f6cba15a0bf --- /dev/null +++ b/src/test/compile-fail/E0435.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 foo = 42u32; + const FOO : u32 = foo; //~ ERROR E0435 +} diff --git a/src/test/compile-fail/E0437.rs b/src/test/compile-fail/E0437.rs new file mode 100644 index 00000000000..7440a82773e --- /dev/null +++ b/src/test/compile-fail/E0437.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 Foo {} + +impl Foo for i32 { + type Bar = bool; //~ ERROR E0437 +} + +fn main () { +} diff --git a/src/test/compile-fail/E0438.rs b/src/test/compile-fail/E0438.rs new file mode 100644 index 00000000000..b3d45307204 --- /dev/null +++ b/src/test/compile-fail/E0438.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. + +#![feature(associated_consts)] + +trait Foo {} + +impl Foo for i32 { + const BAR: bool = true; //~ ERROR E0438 +} + +fn main () { +} diff --git a/src/test/compile-fail/E0439.rs b/src/test/compile-fail/E0439.rs new file mode 100644 index 00000000000..52443432021 --- /dev/null +++ b/src/test/compile-fail/E0439.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(platform_intrinsics)] + +extern "platform-intrinsic" { + fn simd_shuffle(a: A, b: A, c: [u32; 8]) -> B; //~ ERROR E0439 +} + +fn main () { +} diff --git a/src/test/compile-fail/E0440.rs b/src/test/compile-fail/E0440.rs new file mode 100644 index 00000000000..04e7584008d --- /dev/null +++ b/src/test/compile-fail/E0440.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. + +#![feature(repr_simd)] +#![feature(platform_intrinsics)] + +#[repr(simd)] +struct f64x2(f64, f64); + +extern "platform-intrinsic" { + fn x86_mm_movemask_pd(x: f64x2) -> i32; //~ ERROR E0440 +} + +fn main () { +}