From ff5b0fee33b38f15d1bac51e19c6cb2b739e2879 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 11 Jul 2018 21:07:17 +0200 Subject: [PATCH 1/4] fix many tests and ignore some others; enable compile_fail tests again --- tests/compile-fail-fullmir/undefined_byte_read.rs | 3 ++- tests/compile-fail/deallocate-bad-alignment.rs | 2 +- tests/compile-fail/deallocate-bad-size.rs | 2 +- tests/compile-fail/deallocate-twice.rs | 2 +- tests/compile-fail/match_char.rs | 2 ++ tests/compile-fail/memleak.rs | 1 + tests/compile-fail/memleak_rc.rs | 1 + tests/compile-fail/overflowing-rsh-2.rs | 2 +- tests/compile-fail/reallocate-bad-size.rs | 4 ++-- tests/compile-fail/reallocate-change-alloc.rs | 6 +++--- tests/compile-fail/reallocate-dangling.rs | 4 ++-- tests/compile-fail/static_memory_modification.rs | 1 + tests/compiletest.rs | 6 +++--- 13 files changed, 21 insertions(+), 15 deletions(-) diff --git a/tests/compile-fail-fullmir/undefined_byte_read.rs b/tests/compile-fail-fullmir/undefined_byte_read.rs index 99404b7d5f3..24718bce7db 100644 --- a/tests/compile-fail-fullmir/undefined_byte_read.rs +++ b/tests/compile-fail-fullmir/undefined_byte_read.rs @@ -4,6 +4,7 @@ fn main() { let v: Vec = Vec::with_capacity(10); let undef = unsafe { *v.get_unchecked(5) }; - let x = undef + 1; //~ ERROR: attempted to read undefined bytes + let x = undef + 1; //~ ERROR: error + //~^ NOTE attempted to read undefined bytes panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/deallocate-bad-alignment.rs b/tests/compile-fail/deallocate-bad-alignment.rs index 36e99cb11f7..4b89f0ac70c 100644 --- a/tests/compile-fail/deallocate-bad-alignment.rs +++ b/tests/compile-fail/deallocate-bad-alignment.rs @@ -9,7 +9,7 @@ use std::alloc::*; fn main() { unsafe { - let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)); + let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap(); Global.dealloc(x, Layout::from_size_align_unchecked(1, 2)); } } diff --git a/tests/compile-fail/deallocate-bad-size.rs b/tests/compile-fail/deallocate-bad-size.rs index f1271cefd1a..3a74245816c 100644 --- a/tests/compile-fail/deallocate-bad-size.rs +++ b/tests/compile-fail/deallocate-bad-size.rs @@ -9,7 +9,7 @@ use std::alloc::*; fn main() { unsafe { - let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)); + let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap(); Global.dealloc(x, Layout::from_size_align_unchecked(2, 1)); } } diff --git a/tests/compile-fail/deallocate-twice.rs b/tests/compile-fail/deallocate-twice.rs index 58fcb740949..613edf3c6af 100644 --- a/tests/compile-fail/deallocate-twice.rs +++ b/tests/compile-fail/deallocate-twice.rs @@ -9,7 +9,7 @@ use std::alloc::*; fn main() { unsafe { - let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)); + let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap(); Global.dealloc(x, Layout::from_size_align_unchecked(1, 1)); Global.dealloc(x, Layout::from_size_align_unchecked(1, 1)); } diff --git a/tests/compile-fail/match_char.rs b/tests/compile-fail/match_char.rs index 15ce2f2f795..0d45d70eb78 100644 --- a/tests/compile-fail/match_char.rs +++ b/tests/compile-fail/match_char.rs @@ -1,3 +1,5 @@ +// ignore-test FIXME: we are not checking these things on match any more? + fn main() { assert!(std::char::from_u32(-1_i32 as u32).is_none()); match unsafe { std::mem::transmute::(-1) } { //~ ERROR constant evaluation error [E0080] diff --git a/tests/compile-fail/memleak.rs b/tests/compile-fail/memleak.rs index 71b4e2f442f..c03cf50eb27 100644 --- a/tests/compile-fail/memleak.rs +++ b/tests/compile-fail/memleak.rs @@ -1,3 +1,4 @@ +// ignore-test FIXME: leak detection is disabled //error-pattern: the evaluated program leaked memory fn main() { diff --git a/tests/compile-fail/memleak_rc.rs b/tests/compile-fail/memleak_rc.rs index b2bc6722afb..da3a58118a2 100644 --- a/tests/compile-fail/memleak_rc.rs +++ b/tests/compile-fail/memleak_rc.rs @@ -1,3 +1,4 @@ +// ignore-test FIXME: leak detection is disabled //error-pattern: the evaluated program leaked memory use std::rc::Rc; diff --git a/tests/compile-fail/overflowing-rsh-2.rs b/tests/compile-fail/overflowing-rsh-2.rs index 4447b9d7579..967c8b020cc 100644 --- a/tests/compile-fail/overflowing-rsh-2.rs +++ b/tests/compile-fail/overflowing-rsh-2.rs @@ -13,5 +13,5 @@ fn main() { // Make sure we catch overflows that would be hidden by first casting the RHS to u32 let _n = 1i64 >> (u32::max_value() as i64 + 1); //~ ERROR constant evaluation error [E0080] - //~^ NOTE suiriuruihrihue + //~^ NOTE attempt to shift right with overflow } diff --git a/tests/compile-fail/reallocate-bad-size.rs b/tests/compile-fail/reallocate-bad-size.rs index d75c195d521..f85b651e857 100644 --- a/tests/compile-fail/reallocate-bad-size.rs +++ b/tests/compile-fail/reallocate-bad-size.rs @@ -9,7 +9,7 @@ use std::alloc::*; fn main() { unsafe { - let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)); - let _y = Global.realloc(x, Layout::from_size_align_unchecked(2, 1), 1); + 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(); } } diff --git a/tests/compile-fail/reallocate-change-alloc.rs b/tests/compile-fail/reallocate-change-alloc.rs index d8234e93330..03040cd178d 100644 --- a/tests/compile-fail/reallocate-change-alloc.rs +++ b/tests/compile-fail/reallocate-change-alloc.rs @@ -7,9 +7,9 @@ use std::alloc::*; fn main() { unsafe { - let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)); - let _y = Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1); - let _z = *(x as *mut u8); //~ ERROR constant evaluation error [E0080] + 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(); + let _z = *(x.as_ptr() as *mut u8); //~ ERROR constant evaluation error [E0080] //~^ NOTE dangling pointer was dereferenced } } diff --git a/tests/compile-fail/reallocate-dangling.rs b/tests/compile-fail/reallocate-dangling.rs index 39b60407160..6dfb7fe2b96 100644 --- a/tests/compile-fail/reallocate-dangling.rs +++ b/tests/compile-fail/reallocate-dangling.rs @@ -9,8 +9,8 @@ use std::alloc::*; fn main() { unsafe { - let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)); + let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap(); Global.dealloc(x, Layout::from_size_align_unchecked(1, 1)); - Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1); + Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1).unwrap(); } } diff --git a/tests/compile-fail/static_memory_modification.rs b/tests/compile-fail/static_memory_modification.rs index 7182f40d994..a85ff545ee4 100644 --- a/tests/compile-fail/static_memory_modification.rs +++ b/tests/compile-fail/static_memory_modification.rs @@ -1,3 +1,4 @@ +// ignore-test FIXME: we are not making these statics read-only any more? static X: usize = 5; #[allow(mutable_transmutes)] diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 342ea92280d..401499f6c5f 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -192,7 +192,9 @@ fn run_pass_miri_noopt() { } #[test] -#[ignore] // FIXME: Disabled for now, as the optimizer is pretty broken and crashes... +#[ignore] +// FIXME: Disabled for now, as the optimizer is pretty broken and crashes... +// See https://github.com/rust-lang/rust/issues/50411 fn run_pass_miri_opt() { run_pass_miri(true); } @@ -204,13 +206,11 @@ fn run_pass_rustc() { } #[test] -#[should_panic] // TODO: update test errors fn compile_fail_miri() { let sysroot = get_sysroot(); let host = get_host(); // FIXME: run tests for other targets, too compile_fail(&sysroot, "tests/compile-fail", &host, &host, true); - compile_fail(&sysroot, "tests/compile-fail-fullmir", &host, &host, true); } From 5f2f2546957e473bf146bcb35a96d80d60e4022d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 11 Jul 2018 21:13:42 +0200 Subject: [PATCH 2/4] move tests that no longer need MIR out of fullmir --- README.md | 2 +- .../undefined_byte_read.rs | 0 tests/compiletest.rs | 2 +- tests/{run-pass-fullmir => run-pass}/heap.rs | 0 tests/{run-pass-fullmir => run-pass}/issue-15080.rs | 0 tests/{run-pass-fullmir => run-pass}/move-arg-2-unique.rs | 0 tests/{run-pass-fullmir => run-pass}/regions-mock-trans.rs | 0 tests/{run-pass-fullmir => run-pass}/vecs.rs | 0 8 files changed, 2 insertions(+), 2 deletions(-) rename tests/{compile-fail-fullmir => compile-fail}/undefined_byte_read.rs (100%) rename tests/{run-pass-fullmir => run-pass}/heap.rs (100%) rename tests/{run-pass-fullmir => run-pass}/issue-15080.rs (100%) rename tests/{run-pass-fullmir => run-pass}/move-arg-2-unique.rs (100%) rename tests/{run-pass-fullmir => run-pass}/regions-mock-trans.rs (100%) rename tests/{run-pass-fullmir => run-pass}/vecs.rs (100%) diff --git a/README.md b/README.md index 32eca365294..38bf1147dab 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ RUSTFLAGS='-Zalways-encode-mir' xargo build Now you can run miri against the libstd compiled by xargo: ```sh -MIRI_SYSROOT=~/.xargo/HOST cargo run --bin miri tests/run-pass-fullmir/vecs.rs +MIRI_SYSROOT=~/.xargo/HOST cargo run --bin miri tests/run-pass-fullmir/hashmap.rs ``` Notice that you will have to re-run the last step of the preparations above when diff --git a/tests/compile-fail-fullmir/undefined_byte_read.rs b/tests/compile-fail/undefined_byte_read.rs similarity index 100% rename from tests/compile-fail-fullmir/undefined_byte_read.rs rename to tests/compile-fail/undefined_byte_read.rs diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 401499f6c5f..d5ed02504ab 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -212,5 +212,5 @@ fn compile_fail_miri() { // FIXME: run tests for other targets, too compile_fail(&sysroot, "tests/compile-fail", &host, &host, true); - compile_fail(&sysroot, "tests/compile-fail-fullmir", &host, &host, true); + //compile_fail(&sysroot, "tests/compile-fail-fullmir", &host, &host, true); } diff --git a/tests/run-pass-fullmir/heap.rs b/tests/run-pass/heap.rs similarity index 100% rename from tests/run-pass-fullmir/heap.rs rename to tests/run-pass/heap.rs diff --git a/tests/run-pass-fullmir/issue-15080.rs b/tests/run-pass/issue-15080.rs similarity index 100% rename from tests/run-pass-fullmir/issue-15080.rs rename to tests/run-pass/issue-15080.rs diff --git a/tests/run-pass-fullmir/move-arg-2-unique.rs b/tests/run-pass/move-arg-2-unique.rs similarity index 100% rename from tests/run-pass-fullmir/move-arg-2-unique.rs rename to tests/run-pass/move-arg-2-unique.rs diff --git a/tests/run-pass-fullmir/regions-mock-trans.rs b/tests/run-pass/regions-mock-trans.rs similarity index 100% rename from tests/run-pass-fullmir/regions-mock-trans.rs rename to tests/run-pass/regions-mock-trans.rs diff --git a/tests/run-pass-fullmir/vecs.rs b/tests/run-pass/vecs.rs similarity index 100% rename from tests/run-pass-fullmir/vecs.rs rename to tests/run-pass/vecs.rs From eb8195f095e651842a93710ad005e6f1724373f4 Mon Sep 17 00:00:00 2001 From: memoryleak47 Date: Thu, 5 Apr 2018 04:25:43 +0200 Subject: [PATCH 3/4] typo --- tests/run-pass/regions-mock-trans.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run-pass/regions-mock-trans.rs b/tests/run-pass/regions-mock-trans.rs index cef62e47a56..74e94ddbf84 100644 --- a/tests/run-pass/regions-mock-trans.rs +++ b/tests/run-pass/regions-mock-trans.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// FIXME: We handle uninitialzied storage here, which currently makes validation fail. +// FIXME: We handle uninitialized storage here, which currently makes validation fail. // compile-flags: -Zmir-emit-validate=0 //ignore-msvc From 949106148cb7611ee2d8288b1092d1fa3ccdcbb0 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 12 Jul 2018 10:24:25 +0200 Subject: [PATCH 4/4] ignore panic test on Windows --- tests/compile-fail/panic.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/compile-fail/panic.rs b/tests/compile-fail/panic.rs index 80149eeffaa..1f9e8f6e1d0 100644 --- a/tests/compile-fail/panic.rs +++ b/tests/compile-fail/panic.rs @@ -1,3 +1,4 @@ +//ignore-windows // FIXME: Something in panic handling fails validation with full-MIR // compile-flags: -Zmir-emit-validate=0 //error-pattern: the evaluated program panicked