From 4a286639e8448476b0235c8fb2c8eeb7779b9251 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 16 May 2017 15:11:34 +0200 Subject: [PATCH] Move some tests from compile-fail to ui --- .../ui-fulldeps/auxiliary/attr_proc_macro.rs | 23 ++++++ .../ui-fulldeps/auxiliary/bang_proc_macro.rs | 23 ++++++ .../ui-fulldeps/auxiliary/derive-clona.rs | 23 ++++++ src/test/ui-fulldeps/auxiliary/derive-foo.rs | 23 ++++++ .../resolve-error.rs | 17 ----- src/test/ui-fulldeps/resolve-error.stderr | 76 +++++++++++++++++++ ...cast-to-unsized-trait-object-suggestion.rs | 6 -- ...-to-unsized-trait-object-suggestion.stderr | 18 +++++ src/test/{compile-fail => ui}/issue-35675.rs | 0 src/test/ui/issue-35675.stderr | 74 ++++++++++++++++++ .../macros}/macro-name-typo.rs | 2 - src/test/ui/macros/macro-name-typo.stderr | 10 +++ .../macros}/macro_undefined.rs | 4 - src/test/ui/macros/macro_undefined.stderr | 18 +++++ src/test/ui/resolve-error.stderr | 76 +++++++++++++++++++ 15 files changed, 364 insertions(+), 29 deletions(-) create mode 100644 src/test/ui-fulldeps/auxiliary/attr_proc_macro.rs create mode 100644 src/test/ui-fulldeps/auxiliary/bang_proc_macro.rs create mode 100644 src/test/ui-fulldeps/auxiliary/derive-clona.rs create mode 100644 src/test/ui-fulldeps/auxiliary/derive-foo.rs rename src/test/{compile-fail-fulldeps/proc-macro => ui-fulldeps}/resolve-error.rs (57%) create mode 100644 src/test/ui-fulldeps/resolve-error.stderr rename src/test/{compile-fail => ui}/cast-to-unsized-trait-object-suggestion.rs (67%) create mode 100644 src/test/ui/cast-to-unsized-trait-object-suggestion.stderr rename src/test/{compile-fail => ui}/issue-35675.rs (100%) create mode 100644 src/test/ui/issue-35675.stderr rename src/test/{compile-fail => ui/macros}/macro-name-typo.rs (87%) create mode 100644 src/test/ui/macros/macro-name-typo.stderr rename src/test/{compile-fail => ui/macros}/macro_undefined.rs (74%) create mode 100644 src/test/ui/macros/macro_undefined.stderr create mode 100644 src/test/ui/resolve-error.stderr diff --git a/src/test/ui-fulldeps/auxiliary/attr_proc_macro.rs b/src/test/ui-fulldeps/auxiliary/attr_proc_macro.rs new file mode 100644 index 000000000000..db0c19e96f82 --- /dev/null +++ b/src/test/ui-fulldeps/auxiliary/attr_proc_macro.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. + +// force-host +// no-prefer-dynamic +#![feature(proc_macro)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn attr_proc_macro(_: TokenStream, input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/ui-fulldeps/auxiliary/bang_proc_macro.rs b/src/test/ui-fulldeps/auxiliary/bang_proc_macro.rs new file mode 100644 index 000000000000..89ac11b309d7 --- /dev/null +++ b/src/test/ui-fulldeps/auxiliary/bang_proc_macro.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. + +// force-host +// no-prefer-dynamic +#![feature(proc_macro)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro] +pub fn bang_proc_macro(input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/ui-fulldeps/auxiliary/derive-clona.rs b/src/test/ui-fulldeps/auxiliary/derive-clona.rs new file mode 100644 index 000000000000..719fbdb15ef2 --- /dev/null +++ b/src/test/ui-fulldeps/auxiliary/derive-clona.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. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Clona)] +pub fn derive_clonea(input: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/ui-fulldeps/auxiliary/derive-foo.rs b/src/test/ui-fulldeps/auxiliary/derive-foo.rs new file mode 100644 index 000000000000..64dcf72ba202 --- /dev/null +++ b/src/test/ui-fulldeps/auxiliary/derive-foo.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. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(FooWithLongName)] +pub fn derive_foo(input: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/compile-fail-fulldeps/proc-macro/resolve-error.rs b/src/test/ui-fulldeps/resolve-error.rs similarity index 57% rename from src/test/compile-fail-fulldeps/proc-macro/resolve-error.rs rename to src/test/ui-fulldeps/resolve-error.rs index ddd8631f02e6..dfaa1d7a32e5 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/resolve-error.rs +++ b/src/test/ui-fulldeps/resolve-error.rs @@ -35,46 +35,29 @@ macro_rules! attr_proc_mac { } #[derive(FooWithLongNan)] -//~^ ERROR cannot find derive macro `FooWithLongNan` in this scope -//~^^ HELP did you mean `FooWithLongName`? struct Foo; #[attr_proc_macra] -//~^ ERROR cannot find attribute macro `attr_proc_macra` in this scope -//~^^ HELP did you mean `attr_proc_macro`? struct Bar; #[FooWithLongNan] -//~^ ERROR cannot find attribute macro `FooWithLongNan` in this scope struct Asdf; #[derive(Dlone)] -//~^ ERROR cannot find derive macro `Dlone` in this scope -//~^^ HELP did you mean `Clone`? struct A; #[derive(Dlona)] -//~^ ERROR cannot find derive macro `Dlona` in this scope -//~^^ HELP did you mean `Clona`? struct B; #[derive(attr_proc_macra)] -//~^ ERROR cannot find derive macro `attr_proc_macra` in this scope struct C; fn main() { FooWithLongNama!(); - //~^ ERROR cannot find macro `FooWithLongNama!` in this scope - //~^^ HELP did you mean `FooWithLongNam!`? attr_proc_macra!(); - //~^ ERROR cannot find macro `attr_proc_macra!` in this scope - //~^^ HELP did you mean `attr_proc_mac!`? Dlona!(); - //~^ ERROR cannot find macro `Dlona!` in this scope bang_proc_macrp!(); - //~^ ERROR cannot find macro `bang_proc_macrp!` in this scope - //~^^ HELP did you mean `bang_proc_macro!`? } diff --git a/src/test/ui-fulldeps/resolve-error.stderr b/src/test/ui-fulldeps/resolve-error.stderr new file mode 100644 index 000000000000..cfc15d69feb6 --- /dev/null +++ b/src/test/ui-fulldeps/resolve-error.stderr @@ -0,0 +1,76 @@ +error: cannot find derive macro `FooWithLongNan` in this scope + --> $DIR/resolve-error.rs:36:10 + | +36 | #[derive(FooWithLongNan)] + | ^^^^^^^^^^^^^^ + | + = help: did you mean `FooWithLongName`? + +error: cannot find attribute macro `attr_proc_macra` in this scope + --> $DIR/resolve-error.rs:39:3 + | +39 | #[attr_proc_macra] + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `attr_proc_macro`? + +error: cannot find attribute macro `FooWithLongNan` in this scope + --> $DIR/resolve-error.rs:42:3 + | +42 | #[FooWithLongNan] + | ^^^^^^^^^^^^^^ + +error: cannot find derive macro `Dlone` in this scope + --> $DIR/resolve-error.rs:45:10 + | +45 | #[derive(Dlone)] + | ^^^^^ + | + = help: did you mean `Clone`? + +error: cannot find derive macro `Dlona` in this scope + --> $DIR/resolve-error.rs:48:10 + | +48 | #[derive(Dlona)] + | ^^^^^ + | + = help: did you mean `Clona`? + +error: cannot find derive macro `attr_proc_macra` in this scope + --> $DIR/resolve-error.rs:51:10 + | +51 | #[derive(attr_proc_macra)] + | ^^^^^^^^^^^^^^^ + +error: cannot find macro `FooWithLongNama!` in this scope + --> $DIR/resolve-error.rs:55:5 + | +55 | FooWithLongNama!(); + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `FooWithLongNam!`? + +error: cannot find macro `attr_proc_macra!` in this scope + --> $DIR/resolve-error.rs:57:5 + | +57 | attr_proc_macra!(); + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `attr_proc_mac!`? + +error: cannot find macro `Dlona!` in this scope + --> $DIR/resolve-error.rs:59:5 + | +59 | Dlona!(); + | ^^^^^ + +error: cannot find macro `bang_proc_macrp!` in this scope + --> $DIR/resolve-error.rs:61:5 + | +61 | bang_proc_macrp!(); + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `bang_proc_macro!`? + +error: aborting due to 10 previous errors + diff --git a/src/test/compile-fail/cast-to-unsized-trait-object-suggestion.rs b/src/test/ui/cast-to-unsized-trait-object-suggestion.rs similarity index 67% rename from src/test/compile-fail/cast-to-unsized-trait-object-suggestion.rs rename to src/test/ui/cast-to-unsized-trait-object-suggestion.rs index d18746cdf0ba..c79345479827 100644 --- a/src/test/compile-fail/cast-to-unsized-trait-object-suggestion.rs +++ b/src/test/ui/cast-to-unsized-trait-object-suggestion.rs @@ -10,11 +10,5 @@ fn main() { &1 as Send; - //~^ ERROR cast to unsized type - //~| HELP try casting to a reference instead: - //~| SUGGESTION &1 as &Send; Box::new(1) as Send; - //~^ ERROR cast to unsized type - //~| HELP try casting to a `Box` instead: - //~| SUGGESTION Box::new(1) as Box; } diff --git a/src/test/ui/cast-to-unsized-trait-object-suggestion.stderr b/src/test/ui/cast-to-unsized-trait-object-suggestion.stderr new file mode 100644 index 000000000000..dd9c2d14ef24 --- /dev/null +++ b/src/test/ui/cast-to-unsized-trait-object-suggestion.stderr @@ -0,0 +1,18 @@ +error: cast to unsized type: `&{integer}` as `std::marker::Send` + --> $DIR/cast-to-unsized-trait-object-suggestion.rs:12:5 + | +12 | &1 as Send; + | ^^^^^^---- + | | + | help: try casting to a reference instead: `&Send` + +error: cast to unsized type: `std::boxed::Box<{integer}>` as `std::marker::Send` + --> $DIR/cast-to-unsized-trait-object-suggestion.rs:13:5 + | +13 | Box::new(1) as Send; + | ^^^^^^^^^^^^^^^---- + | | + | help: try casting to a `Box` instead: `Box` + +error: aborting due to previous error(s) + diff --git a/src/test/compile-fail/issue-35675.rs b/src/test/ui/issue-35675.rs similarity index 100% rename from src/test/compile-fail/issue-35675.rs rename to src/test/ui/issue-35675.rs diff --git a/src/test/ui/issue-35675.stderr b/src/test/ui/issue-35675.stderr new file mode 100644 index 000000000000..22322a388c5f --- /dev/null +++ b/src/test/ui/issue-35675.stderr @@ -0,0 +1,74 @@ +error[E0412]: cannot find type `Apple` in this scope + --> $DIR/issue-35675.rs:20:29 + | +20 | fn should_return_fruit() -> Apple { + | ^^^^^ not found in this scope + | +help: there is an enum variant `Fruit::Apple`, did you mean to use `Fruit`? + --> $DIR/issue-35675.rs:14:5 + | +14 | Apple(i64), + | ^^^^^^^^^^ + +error[E0425]: cannot find function `Apple` in this scope + --> $DIR/issue-35675.rs:23:5 + | +23 | Apple(5) + | ^^^^^ not found in this scope + | +help: possible candidate is found in another module, you can import it into scope + | use Fruit::Apple; + +error[E0573]: expected type, found variant `Fruit::Apple` + --> $DIR/issue-35675.rs:28:33 + | +28 | fn should_return_fruit_too() -> Fruit::Apple { + | ^^^^^^^^^^^^ not a type + | +help: there is an enum variant `Fruit::Apple`, did you mean to use `Fruit`? + --> $DIR/issue-35675.rs:14:5 + | +14 | Apple(i64), + | ^^^^^^^^^^ + +error[E0425]: cannot find function `Apple` in this scope + --> $DIR/issue-35675.rs:31:5 + | +31 | Apple(5) + | ^^^^^ not found in this scope + | +help: possible candidate is found in another module, you can import it into scope + | use Fruit::Apple; + +error[E0573]: expected type, found variant `Ok` + --> $DIR/issue-35675.rs:36:13 + | +36 | fn foo() -> Ok { + | ^^ not a type + | + = help: there is an enum variant `std::prelude::v1::Ok`, did you mean to use `std::prelude::v1`? + = help: there is an enum variant `std::prelude::v1::Result::Ok`, did you mean to use `std::prelude::v1::Result`? + +error[E0412]: cannot find type `Variant3` in this scope + --> $DIR/issue-35675.rs:44:13 + | +44 | fn bar() -> Variant3 { + | ^^^^^^^^ not found in this scope + | +help: there is an enum variant `x::Enum::Variant3`, did you mean to use `x::Enum`? + --> $DIR/issue-35675.rs:63:9 + | +63 | Variant3(usize), + | ^^^^^^^^^^^^^^^ + +error[E0573]: expected type, found variant `Some` + --> $DIR/issue-35675.rs:49:13 + | +49 | fn qux() -> Some { + | ^^^^ not a type + | + = help: there is an enum variant `std::option::Option::Some`, did you mean to use `std::option::Option`? + = help: there is an enum variant `std::prelude::v1::Some`, did you mean to use `std::prelude::v1`? + +error: aborting due to previous error(s) + diff --git a/src/test/compile-fail/macro-name-typo.rs b/src/test/ui/macros/macro-name-typo.rs similarity index 87% rename from src/test/compile-fail/macro-name-typo.rs rename to src/test/ui/macros/macro-name-typo.rs index 4840205fee4c..ec8d27f9138f 100644 --- a/src/test/compile-fail/macro-name-typo.rs +++ b/src/test/ui/macros/macro-name-typo.rs @@ -10,6 +10,4 @@ fn main() { printlx!("oh noes!"); - //~^ ERROR cannot find macro - //~^^ HELP did you mean `println!`? } diff --git a/src/test/ui/macros/macro-name-typo.stderr b/src/test/ui/macros/macro-name-typo.stderr new file mode 100644 index 000000000000..c54de468d133 --- /dev/null +++ b/src/test/ui/macros/macro-name-typo.stderr @@ -0,0 +1,10 @@ +error: cannot find macro `printlx!` in this scope + --> $DIR/macro-name-typo.rs:12:5 + | +12 | printlx!("oh noes!"); + | ^^^^^^^ + | + = help: did you mean `println!`? + +error: aborting due to previous error(s) + diff --git a/src/test/compile-fail/macro_undefined.rs b/src/test/ui/macros/macro_undefined.rs similarity index 74% rename from src/test/compile-fail/macro_undefined.rs rename to src/test/ui/macros/macro_undefined.rs index 00c8d44f3060..db93ba5e2c41 100644 --- a/src/test/compile-fail/macro_undefined.rs +++ b/src/test/ui/macros/macro_undefined.rs @@ -19,9 +19,5 @@ mod m { fn main() { k!(); - //~^ ERROR cannot find macro `k!` in this scope - //~^^ HELP did you mean `kl!`? kl!(); - //~^ ERROR cannot find macro `kl!` in this scope - //~^^ HELP have you added the `#[macro_use]` on the module/import? } diff --git a/src/test/ui/macros/macro_undefined.stderr b/src/test/ui/macros/macro_undefined.stderr new file mode 100644 index 000000000000..152de056991c --- /dev/null +++ b/src/test/ui/macros/macro_undefined.stderr @@ -0,0 +1,18 @@ +error: cannot find macro `kl!` in this scope + --> $DIR/macro_undefined.rs:22:5 + | +22 | kl!(); + | ^^ + | + = help: have you added the `#[macro_use]` on the module/import? + +error: cannot find macro `k!` in this scope + --> $DIR/macro_undefined.rs:21:5 + | +21 | k!(); + | ^ + | + = help: did you mean `kl!`? + +error: aborting due to previous error(s) + diff --git a/src/test/ui/resolve-error.stderr b/src/test/ui/resolve-error.stderr new file mode 100644 index 000000000000..946eaba45fc1 --- /dev/null +++ b/src/test/ui/resolve-error.stderr @@ -0,0 +1,76 @@ +error: cannot find derive macro `FooWithLongNan` in this scope + --> $DIR/resolve-error.rs:37:10 + | +37 | #[derive(FooWithLongNan)] + | ^^^^^^^^^^^^^^ + | + = help: did you mean `FooWithLongName`? + +error: cannot find attribute macro `attr_proc_macra` in this scope + --> $DIR/resolve-error.rs:40:3 + | +40 | #[attr_proc_macra] + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `attr_proc_macro`? + +error: cannot find attribute macro `FooWithLongNan` in this scope + --> $DIR/resolve-error.rs:43:3 + | +43 | #[FooWithLongNan] + | ^^^^^^^^^^^^^^ + +error: cannot find derive macro `Dlone` in this scope + --> $DIR/resolve-error.rs:46:10 + | +46 | #[derive(Dlone)] + | ^^^^^ + | + = help: did you mean `Clone`? + +error: cannot find derive macro `Dlona` in this scope + --> $DIR/resolve-error.rs:49:10 + | +49 | #[derive(Dlona)] + | ^^^^^ + | + = help: did you mean `Clona`? + +error: cannot find derive macro `attr_proc_macra` in this scope + --> $DIR/resolve-error.rs:52:10 + | +52 | #[derive(attr_proc_macra)] + | ^^^^^^^^^^^^^^^ + +error: cannot find macro `FooWithLongNama!` in this scope + --> $DIR/resolve-error.rs:56:5 + | +56 | FooWithLongNama!(); + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `FooWithLongNam!`? + +error: cannot find macro `attr_proc_macra!` in this scope + --> $DIR/resolve-error.rs:58:5 + | +58 | attr_proc_macra!(); + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `attr_proc_mac!`? + +error: cannot find macro `Dlona!` in this scope + --> $DIR/resolve-error.rs:60:5 + | +60 | Dlona!(); + | ^^^^^ + +error: cannot find macro `bang_proc_macrp!` in this scope + --> $DIR/resolve-error.rs:62:5 + | +62 | bang_proc_macrp!(); + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `bang_proc_macro!`? + +error: aborting due to previous error(s) +