From a586f52a0fa14d60a9a19cfe4e530f9e31e343a4 Mon Sep 17 00:00:00 2001 From: Philipp Hansch <dev@phansch.net> Date: Wed, 6 Feb 2019 07:45:57 +0100 Subject: [PATCH] Move run-pass tests to UI tests This should give us more UI coverage for free. It also removes the `run-pass` suite, so we now only have the `ui` suite. --- tests/compile-test.rs | 1 - tests/run-pass/ice-2727.rs | 5 ----- tests/run-pass/ice-700.rs | 7 ------- .../crashes}/associated-constant-ice.rs | 2 ++ tests/{run-pass => ui/crashes}/cc_seme.rs | 3 +++ .../crashes}/enum-glob-import-crate.rs | 0 tests/{run-pass => ui/crashes}/ice-1588.rs | 2 ++ tests/{run-pass => ui/crashes}/ice-1782.rs | 0 tests/{run-pass => ui/crashes}/ice-1969.rs | 2 ++ tests/{run-pass => ui/crashes}/ice-2499.rs | 0 tests/{run-pass => ui/crashes}/ice-2594.rs | 0 tests/ui/crashes/ice-2727.rs | 7 +++++++ tests/{run-pass => ui/crashes}/ice-2760.rs | 10 +++++----- tests/{run-pass => ui/crashes}/ice-2774.rs | 2 +- tests/{run-pass => ui/crashes}/ice-2865.rs | 3 +++ tests/{run-pass => ui/crashes}/ice-3151.rs | 2 ++ tests/{run-pass => ui/crashes}/ice-3462.rs | 2 ++ tests/ui/crashes/ice-700.rs | 9 +++++++++ tests/{run-pass => ui/crashes}/ice_exacte_size.rs | 2 ++ .../{run-pass => ui/crashes}/if_same_then_else.rs | 2 ++ tests/{run-pass => ui/crashes}/issue-2862.rs | 2 ++ tests/{run-pass => ui/crashes}/issue-825.rs | 2 ++ .../crashes}/issues_loop_mut_cond.rs | 0 .../crashes}/match_same_arms_const.rs | 2 ++ tests/{run-pass => ui/crashes}/mut_mut_macro.rs | 14 ++++++++------ .../{run-pass => ui/crashes}/needless_borrow_fp.rs | 0 .../crashes}/needless_lifetimes_impl_trait.rs | 0 tests/{run-pass => ui/crashes}/procedural_macro.rs | 0 tests/{run-pass => ui/crashes}/regressions.rs | 0 tests/{run-pass => ui/crashes}/returns.rs | 2 ++ .../{run-pass => ui/crashes}/single-match-else.rs | 2 ++ .../crashes}/used_underscore_binding_macro.rs | 0 .../{run-pass => ui/crashes}/whitelist/clippy.toml | 0 .../crashes}/whitelist/conf_whitelisted.rs | 0 34 files changed, 60 insertions(+), 25 deletions(-) delete mode 100644 tests/run-pass/ice-2727.rs delete mode 100644 tests/run-pass/ice-700.rs rename tests/{run-pass => ui/crashes}/associated-constant-ice.rs (68%) rename tests/{run-pass => ui/crashes}/cc_seme.rs (85%) rename tests/{run-pass => ui/crashes}/enum-glob-import-crate.rs (100%) rename tests/{run-pass => ui/crashes}/ice-1588.rs (67%) rename tests/{run-pass => ui/crashes}/ice-1782.rs (100%) rename tests/{run-pass => ui/crashes}/ice-1969.rs (71%) rename tests/{run-pass => ui/crashes}/ice-2499.rs (100%) rename tests/{run-pass => ui/crashes}/ice-2594.rs (100%) create mode 100644 tests/ui/crashes/ice-2727.rs rename tests/{run-pass => ui/crashes}/ice-2760.rs (57%) rename tests/{run-pass => ui/crashes}/ice-2774.rs (91%) rename tests/{run-pass => ui/crashes}/ice-2865.rs (76%) rename tests/{run-pass => ui/crashes}/ice-3151.rs (72%) rename tests/{run-pass => ui/crashes}/ice-3462.rs (79%) create mode 100644 tests/ui/crashes/ice-700.rs rename tests/{run-pass => ui/crashes}/ice_exacte_size.rs (79%) rename tests/{run-pass => ui/crashes}/if_same_then_else.rs (76%) rename tests/{run-pass => ui/crashes}/issue-2862.rs (76%) rename tests/{run-pass => ui/crashes}/issue-825.rs (89%) rename tests/{run-pass => ui/crashes}/issues_loop_mut_cond.rs (100%) rename tests/{run-pass => ui/crashes}/match_same_arms_const.rs (83%) rename tests/{run-pass => ui/crashes}/mut_mut_macro.rs (63%) rename tests/{run-pass => ui/crashes}/needless_borrow_fp.rs (100%) rename tests/{run-pass => ui/crashes}/needless_lifetimes_impl_trait.rs (100%) rename tests/{run-pass => ui/crashes}/procedural_macro.rs (100%) rename tests/{run-pass => ui/crashes}/regressions.rs (100%) rename tests/{run-pass => ui/crashes}/returns.rs (81%) rename tests/{run-pass => ui/crashes}/single-match-else.rs (71%) rename tests/{run-pass => ui/crashes}/used_underscore_binding_macro.rs (100%) rename tests/{run-pass => ui/crashes}/whitelist/clippy.toml (100%) rename tests/{run-pass => ui/crashes}/whitelist/conf_whitelisted.rs (100%) diff --git a/tests/compile-test.rs b/tests/compile-test.rs index c67b6f08c9f..b6a4beff046 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -133,7 +133,6 @@ fn prepare_env() { #[test] fn compile_test() { prepare_env(); - run_mode("run-pass", "tests/run-pass".into()); run_mode("ui", "tests/ui".into()); run_ui_toml(); } diff --git a/tests/run-pass/ice-2727.rs b/tests/run-pass/ice-2727.rs deleted file mode 100644 index 79c6f1c55db..00000000000 --- a/tests/run-pass/ice-2727.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub fn f(new: fn()) { - new(); -} - -fn main() {} diff --git a/tests/run-pass/ice-700.rs b/tests/run-pass/ice-700.rs deleted file mode 100644 index 10546850611..00000000000 --- a/tests/run-pass/ice-700.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![deny(clippy::all)] - -fn core() {} - -fn main() { - core(); -} diff --git a/tests/run-pass/associated-constant-ice.rs b/tests/ui/crashes/associated-constant-ice.rs similarity index 68% rename from tests/run-pass/associated-constant-ice.rs rename to tests/ui/crashes/associated-constant-ice.rs index 2c5c90683cc..948deba3ea6 100644 --- a/tests/run-pass/associated-constant-ice.rs +++ b/tests/ui/crashes/associated-constant-ice.rs @@ -1,3 +1,5 @@ +/// Test for https://github.com/rust-lang/rust-clippy/issues/1698 + pub trait Trait { const CONSTANT: u8; } diff --git a/tests/run-pass/cc_seme.rs b/tests/ui/crashes/cc_seme.rs similarity index 85% rename from tests/run-pass/cc_seme.rs rename to tests/ui/crashes/cc_seme.rs index 169403df562..98588be9cf8 100644 --- a/tests/run-pass/cc_seme.rs +++ b/tests/ui/crashes/cc_seme.rs @@ -1,4 +1,7 @@ #[allow(dead_code)] + +/// Test for https://github.com/rust-lang/rust-clippy/issues/478 + enum Baz { One, Two, diff --git a/tests/run-pass/enum-glob-import-crate.rs b/tests/ui/crashes/enum-glob-import-crate.rs similarity index 100% rename from tests/run-pass/enum-glob-import-crate.rs rename to tests/ui/crashes/enum-glob-import-crate.rs diff --git a/tests/run-pass/ice-1588.rs b/tests/ui/crashes/ice-1588.rs similarity index 67% rename from tests/run-pass/ice-1588.rs rename to tests/ui/crashes/ice-1588.rs index 6a5bf429f2d..b0a3d11bce4 100644 --- a/tests/run-pass/ice-1588.rs +++ b/tests/ui/crashes/ice-1588.rs @@ -1,5 +1,7 @@ #![allow(clippy::all)] +/// Test for https://github.com/rust-lang/rust-clippy/issues/1588 + fn main() { match 1 { 1 => {}, diff --git a/tests/run-pass/ice-1782.rs b/tests/ui/crashes/ice-1782.rs similarity index 100% rename from tests/run-pass/ice-1782.rs rename to tests/ui/crashes/ice-1782.rs diff --git a/tests/run-pass/ice-1969.rs b/tests/ui/crashes/ice-1969.rs similarity index 71% rename from tests/run-pass/ice-1969.rs rename to tests/ui/crashes/ice-1969.rs index eab4f338f97..96a8fe6c24d 100644 --- a/tests/run-pass/ice-1969.rs +++ b/tests/ui/crashes/ice-1969.rs @@ -1,5 +1,7 @@ #![allow(clippy::all)] +/// Test for https://github.com/rust-lang/rust-clippy/issues/1969 + fn main() {} pub trait Convert { diff --git a/tests/run-pass/ice-2499.rs b/tests/ui/crashes/ice-2499.rs similarity index 100% rename from tests/run-pass/ice-2499.rs rename to tests/ui/crashes/ice-2499.rs diff --git a/tests/run-pass/ice-2594.rs b/tests/ui/crashes/ice-2594.rs similarity index 100% rename from tests/run-pass/ice-2594.rs rename to tests/ui/crashes/ice-2594.rs diff --git a/tests/ui/crashes/ice-2727.rs b/tests/ui/crashes/ice-2727.rs new file mode 100644 index 00000000000..56024abc8f5 --- /dev/null +++ b/tests/ui/crashes/ice-2727.rs @@ -0,0 +1,7 @@ +/// Test for https://github.com/rust-lang/rust-clippy/issues/2727 + +pub fn f(new: fn()) { + new(); +} + +fn main() {} diff --git a/tests/run-pass/ice-2760.rs b/tests/ui/crashes/ice-2760.rs similarity index 57% rename from tests/run-pass/ice-2760.rs rename to tests/ui/crashes/ice-2760.rs index 949e273997c..fddf8252329 100644 --- a/tests/run-pass/ice-2760.rs +++ b/tests/ui/crashes/ice-2760.rs @@ -5,11 +5,11 @@ dead_code )] -// This should not compile-fail with: -// -// error[E0277]: the trait bound `T: Foo` is not satisfied -// -// See https://github.com/rust-lang/rust-clippy/issues/2760 +/// This should not compile-fail with: +/// +/// error[E0277]: the trait bound `T: Foo` is not satisfied +/// +/// See https://github.com/rust-lang/rust-clippy/issues/2760 trait Foo { type Bar; diff --git a/tests/run-pass/ice-2774.rs b/tests/ui/crashes/ice-2774.rs similarity index 91% rename from tests/run-pass/ice-2774.rs rename to tests/ui/crashes/ice-2774.rs index 2cc19ae32b8..fdc671a84e0 100644 --- a/tests/run-pass/ice-2774.rs +++ b/tests/ui/crashes/ice-2774.rs @@ -1,6 +1,6 @@ use std::collections::HashSet; -// See https://github.com/rust-lang/rust-clippy/issues/2774 +/// See https://github.com/rust-lang/rust-clippy/issues/2774 #[derive(Eq, PartialEq, Debug, Hash)] pub struct Bar { diff --git a/tests/run-pass/ice-2865.rs b/tests/ui/crashes/ice-2865.rs similarity index 76% rename from tests/run-pass/ice-2865.rs rename to tests/ui/crashes/ice-2865.rs index 64092afd53d..6b1ceb50569 100644 --- a/tests/run-pass/ice-2865.rs +++ b/tests/ui/crashes/ice-2865.rs @@ -1,4 +1,7 @@ #[allow(dead_code)] + +/// Test for https://github.com/rust-lang/rust-clippy/issues/2865 + struct Ice { size: String, } diff --git a/tests/run-pass/ice-3151.rs b/tests/ui/crashes/ice-3151.rs similarity index 72% rename from tests/run-pass/ice-3151.rs rename to tests/ui/crashes/ice-3151.rs index a03dd05e7d3..fef4d7db84d 100644 --- a/tests/run-pass/ice-3151.rs +++ b/tests/ui/crashes/ice-3151.rs @@ -1,3 +1,5 @@ +/// Test for https://github.com/rust-lang/rust-clippy/issues/2865 + #[derive(Clone)] pub struct HashMap<V, S> { hash_builder: S, diff --git a/tests/run-pass/ice-3462.rs b/tests/ui/crashes/ice-3462.rs similarity index 79% rename from tests/run-pass/ice-3462.rs rename to tests/ui/crashes/ice-3462.rs index d4f6f355c85..7d62e315da2 100644 --- a/tests/run-pass/ice-3462.rs +++ b/tests/ui/crashes/ice-3462.rs @@ -2,6 +2,8 @@ #![allow(clippy::blacklisted_name)] #![allow(unused)] +/// Test for https://github.com/rust-lang/rust-clippy/issues/3462 + enum Foo { Bar, Baz, diff --git a/tests/ui/crashes/ice-700.rs b/tests/ui/crashes/ice-700.rs new file mode 100644 index 00000000000..0cbceedbd6b --- /dev/null +++ b/tests/ui/crashes/ice-700.rs @@ -0,0 +1,9 @@ +#![deny(clippy::all)] + +/// Test for https://github.com/rust-lang/rust-clippy/issues/700 + +fn core() {} + +fn main() { + core(); +} diff --git a/tests/run-pass/ice_exacte_size.rs b/tests/ui/crashes/ice_exacte_size.rs similarity index 79% rename from tests/run-pass/ice_exacte_size.rs rename to tests/ui/crashes/ice_exacte_size.rs index ac643fafabc..30e4b11ec0b 100644 --- a/tests/run-pass/ice_exacte_size.rs +++ b/tests/ui/crashes/ice_exacte_size.rs @@ -1,5 +1,7 @@ #![deny(clippy::all)] +/// Test for https://github.com/rust-lang/rust-clippy/issues/1336 + #[allow(dead_code)] struct Foo; diff --git a/tests/run-pass/if_same_then_else.rs b/tests/ui/crashes/if_same_then_else.rs similarity index 76% rename from tests/run-pass/if_same_then_else.rs rename to tests/ui/crashes/if_same_then_else.rs index e6ab7cc9d8c..7b3b881316d 100644 --- a/tests/run-pass/if_same_then_else.rs +++ b/tests/ui/crashes/if_same_then_else.rs @@ -1,5 +1,7 @@ #![deny(clippy::if_same_then_else)] +/// Test for https://github.com/rust-lang/rust-clippy/issues/2426 + fn main() {} pub fn foo(a: i32, b: i32) -> Option<&'static str> { diff --git a/tests/run-pass/issue-2862.rs b/tests/ui/crashes/issue-2862.rs similarity index 76% rename from tests/run-pass/issue-2862.rs rename to tests/ui/crashes/issue-2862.rs index b35df667f27..38e2341e278 100644 --- a/tests/run-pass/issue-2862.rs +++ b/tests/ui/crashes/issue-2862.rs @@ -1,3 +1,5 @@ +/// Test for https://github.com/rust-lang/rust-clippy/issues/2826 + pub trait FooMap { fn map<B, F: Fn() -> B>(&self, f: F) -> B; } diff --git a/tests/run-pass/issue-825.rs b/tests/ui/crashes/issue-825.rs similarity index 89% rename from tests/run-pass/issue-825.rs rename to tests/ui/crashes/issue-825.rs index b1339212e6e..05696e3d7d5 100644 --- a/tests/run-pass/issue-825.rs +++ b/tests/ui/crashes/issue-825.rs @@ -1,5 +1,7 @@ #![allow(warnings)] +/// Test for https://github.com/rust-lang/rust-clippy/issues/825 + // this should compile in a reasonable amount of time fn rust_type_id(name: &str) { if "bool" == &name[..] diff --git a/tests/run-pass/issues_loop_mut_cond.rs b/tests/ui/crashes/issues_loop_mut_cond.rs similarity index 100% rename from tests/run-pass/issues_loop_mut_cond.rs rename to tests/ui/crashes/issues_loop_mut_cond.rs diff --git a/tests/run-pass/match_same_arms_const.rs b/tests/ui/crashes/match_same_arms_const.rs similarity index 83% rename from tests/run-pass/match_same_arms_const.rs rename to tests/ui/crashes/match_same_arms_const.rs index 50732475562..94c939665e6 100644 --- a/tests/run-pass/match_same_arms_const.rs +++ b/tests/ui/crashes/match_same_arms_const.rs @@ -1,5 +1,7 @@ #![deny(clippy::match_same_arms)] +/// Test for https://github.com/rust-lang/rust-clippy/issues/2427 + const PRICE_OF_SWEETS: u32 = 5; const PRICE_OF_KINDNESS: u32 = 0; const PRICE_OF_DRINKS: u32 = 5; diff --git a/tests/run-pass/mut_mut_macro.rs b/tests/ui/crashes/mut_mut_macro.rs similarity index 63% rename from tests/run-pass/mut_mut_macro.rs rename to tests/ui/crashes/mut_mut_macro.rs index af11c29d9b0..6ce3b37a855 100644 --- a/tests/run-pass/mut_mut_macro.rs +++ b/tests/ui/crashes/mut_mut_macro.rs @@ -1,14 +1,16 @@ #![deny(clippy::mut_mut, clippy::zero_ptr, clippy::cmp_nan)] #![allow(dead_code)] -// compiletest + extern crates doesn't work together -//#[macro_use] -//extern crate lazy_static; +// FIXME: compiletest + extern crates doesn't work together. To make this test work, it would need +// the following three lines and the lazy_static crate. +// +// #[macro_use] +// extern crate lazy_static; +// use std::collections::HashMap; -//use std::collections::HashMap; +/// ensure that we don't suggest `is_nan` and `is_null` inside constants +/// FIXME: once const fn is stable, suggest these functions again in constants -// ensure that we don't suggest `is_nan` and `is_null` inside constants -// FIXME: once const fn is stable, suggest these functions again in constants const BAA: *const i32 = 0 as *const i32; static mut BAR: *const i32 = BAA; static mut FOO: *const i32 = 0 as *const i32; diff --git a/tests/run-pass/needless_borrow_fp.rs b/tests/ui/crashes/needless_borrow_fp.rs similarity index 100% rename from tests/run-pass/needless_borrow_fp.rs rename to tests/ui/crashes/needless_borrow_fp.rs diff --git a/tests/run-pass/needless_lifetimes_impl_trait.rs b/tests/ui/crashes/needless_lifetimes_impl_trait.rs similarity index 100% rename from tests/run-pass/needless_lifetimes_impl_trait.rs rename to tests/ui/crashes/needless_lifetimes_impl_trait.rs diff --git a/tests/run-pass/procedural_macro.rs b/tests/ui/crashes/procedural_macro.rs similarity index 100% rename from tests/run-pass/procedural_macro.rs rename to tests/ui/crashes/procedural_macro.rs diff --git a/tests/run-pass/regressions.rs b/tests/ui/crashes/regressions.rs similarity index 100% rename from tests/run-pass/regressions.rs rename to tests/ui/crashes/regressions.rs diff --git a/tests/run-pass/returns.rs b/tests/ui/crashes/returns.rs similarity index 81% rename from tests/run-pass/returns.rs rename to tests/ui/crashes/returns.rs index d6b2a4ef170..8021ed4607d 100644 --- a/tests/run-pass/returns.rs +++ b/tests/ui/crashes/returns.rs @@ -1,3 +1,5 @@ +/// Test for https://github.com/rust-lang/rust-clippy/issues/1346 + #[deny(warnings)] fn cfg_return() -> i32 { #[cfg(unix)] diff --git a/tests/run-pass/single-match-else.rs b/tests/ui/crashes/single-match-else.rs similarity index 71% rename from tests/run-pass/single-match-else.rs rename to tests/ui/crashes/single-match-else.rs index efcc6363eb0..1ba7ac08213 100644 --- a/tests/run-pass/single-match-else.rs +++ b/tests/ui/crashes/single-match-else.rs @@ -1,5 +1,7 @@ #![warn(clippy::single_match_else)] +//! Test for https://github.com/rust-lang/rust-clippy/issues/1588 + fn main() { let n = match (42, 43) { (42, n) => n, diff --git a/tests/run-pass/used_underscore_binding_macro.rs b/tests/ui/crashes/used_underscore_binding_macro.rs similarity index 100% rename from tests/run-pass/used_underscore_binding_macro.rs rename to tests/ui/crashes/used_underscore_binding_macro.rs diff --git a/tests/run-pass/whitelist/clippy.toml b/tests/ui/crashes/whitelist/clippy.toml similarity index 100% rename from tests/run-pass/whitelist/clippy.toml rename to tests/ui/crashes/whitelist/clippy.toml diff --git a/tests/run-pass/whitelist/conf_whitelisted.rs b/tests/ui/crashes/whitelist/conf_whitelisted.rs similarity index 100% rename from tests/run-pass/whitelist/conf_whitelisted.rs rename to tests/ui/crashes/whitelist/conf_whitelisted.rs