From d11c668a3900fcbad336eb470da8748a04000253 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 16 Jul 2018 08:39:06 +0200 Subject: [PATCH] no longer run rustc on the tests; instead make sure we actually deny all warnings Also fix the fallout from that --- .../reallocate-bad-size.rs | 2 +- .../reallocate-change-alloc.rs | 2 +- tests/compiletest.rs | 28 ++----------------- tests/run-pass/box_box_trait.rs | 2 ++ 4 files changed, 6 insertions(+), 28 deletions(-) diff --git a/tests/compile-fail-fullmir/reallocate-bad-size.rs b/tests/compile-fail-fullmir/reallocate-bad-size.rs index f85b651e8573..489b7bebcdc8 100644 --- a/tests/compile-fail-fullmir/reallocate-bad-size.rs +++ b/tests/compile-fail-fullmir/reallocate-bad-size.rs @@ -10,6 +10,6 @@ use std::alloc::*; fn main() { unsafe { let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap(); - let _y = Global.realloc(x, Layout::from_size_align_unchecked(2, 1), 1).unwrap(); + Global.realloc(x, Layout::from_size_align_unchecked(2, 1), 1).unwrap(); } } diff --git a/tests/compile-fail-fullmir/reallocate-change-alloc.rs b/tests/compile-fail-fullmir/reallocate-change-alloc.rs index a44ccf4c49cd..c73f86bc1721 100644 --- a/tests/compile-fail-fullmir/reallocate-change-alloc.rs +++ b/tests/compile-fail-fullmir/reallocate-change-alloc.rs @@ -8,7 +8,7 @@ use std::alloc::*; fn main() { unsafe { let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap(); - let _y = Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1).unwrap(); + Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1).unwrap(); let _z = *(x.as_ptr() as *mut u8); //~ ERROR constant evaluation error //~^ NOTE dangling pointer was dereferenced } diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 896d1cae5969..38d806967281 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -62,6 +62,7 @@ fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, need_fullm config.compile_lib_path = rustc_lib_path(); } flags.push(format!("--sysroot {}", sysroot.display())); + flags.push("-Dwarnings -Dunused".to_owned()); // overwrite the -Aunused in compiletest-rs config.src_base = PathBuf::from(path.to_string()); flags.push("-Zmir-emit-validate=1".to_owned()); config.target_rustcflags = Some(flags.join(" ")); @@ -70,23 +71,6 @@ fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, need_fullm compiletest::run_tests(&config); } -fn rustc_pass(sysroot: &Path, path: &str) { - eprintln!("{}", format!("## Running run-pass tests in {} against rustc", path).green().bold()); - let mut config = compiletest::Config::default().tempdir(); - config.mode = "run-pass".parse().expect("Invalid mode"); - config.src_base = PathBuf::from(path); - if let Some(rustc_path) = rustc_test_suite() { - config.rustc_path = rustc_path; - config.run_lib_path = rustc_lib_path(); - config.compile_lib_path = rustc_lib_path(); - config.target_rustcflags = Some(format!("-Dwarnings --sysroot {}", sysroot.display())); - } else { - config.target_rustcflags = Some("-Dwarnings".to_owned()); - } - config.host_rustcflags = Some("-Dwarnings".to_string()); - compiletest::run_tests(&config); -} - fn miri_pass(sysroot: &Path, path: &str, target: &str, host: &str, need_fullmir: bool, opt: bool) { if need_fullmir && !have_fullmir() { eprintln!("{}", format!( @@ -116,6 +100,7 @@ fn miri_pass(sysroot: &Path, path: &str, target: &str, host: &str, need_fullmir: } let mut flags = Vec::new(); flags.push(format!("--sysroot {}", sysroot.display())); + flags.push("-Dwarnings -Dunused".to_owned()); // overwrite the -Aunused in compiletest-rs if have_fullmir() { flags.push("-Zmiri-start-fn".to_owned()); } @@ -190,12 +175,6 @@ fn run_pass_miri(opt: bool) { miri_pass(&sysroot, "tests/run-pass-fullmir", &host, &host, true, opt); } -fn run_pass_rustc() { - let sysroot = get_sysroot(); - rustc_pass(&sysroot, "tests/run-pass"); - rustc_pass(&sysroot, "tests/run-pass-fullmir"); -} - fn compile_fail_miri() { let sysroot = get_sysroot(); let host = get_host(); @@ -211,10 +190,7 @@ fn test() { // introduces. We still get parallelism within our tests because `compiletest` // uses `libtest` which runs jobs in parallel. - run_pass_rustc(); - run_pass_miri(false); - // FIXME: Disabled for now, as the optimizer is pretty broken and crashes... // See https://github.com/rust-lang/rust/issues/50411 //run_pass_miri(true); diff --git a/tests/run-pass/box_box_trait.rs b/tests/run-pass/box_box_trait.rs index 57eef52d573b..7fe568522d53 100644 --- a/tests/run-pass/box_box_trait.rs +++ b/tests/run-pass/box_box_trait.rs @@ -13,7 +13,9 @@ impl Drop for DroppableStruct { trait MyTrait { fn dummy(&self) { } } impl MyTrait for Box {} +#[allow(dead_code)] struct Whatever { w: Box } + impl Whatever { fn new(w: Box) -> Whatever { Whatever { w: w }