From 6d9175f98e78118dd2467f285b16663842be5b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 30 Mar 2024 00:41:57 +0100 Subject: [PATCH] crashes: fix ice detection which did not trigger if code compiled without error by accident --- src/tools/compiletest/src/runtest.rs | 16 ++++++++-------- tests/crashes/101557.rs | 1 + tests/crashes/111699.rs | 2 ++ tests/crashes/115435.rs | 2 ++ tests/crashes/118320.rs | 1 + tests/crashes/119692.rs | 1 + tests/crashes/120241-2.rs | 1 + tests/crashes/120241.rs | 1 + tests/crashes/120482.rs | 1 + tests/crashes/121444.rs | 2 ++ tests/crashes/123157.rs | 1 + tests/crashes/README.md | 2 +- 12 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 9b98e78b15b..759b07abc6e 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -364,13 +364,16 @@ fn run_cfail_test(&self) { fn run_crash_test(&self) { let pm = self.pass_mode(); let proc_res = self.compile_test(WillExecute::No, self.should_emit_metadata(pm)); + /* + eprintln!("{}", proc_res.status); + eprintln!("{}", proc_res.stdout); + eprintln!("{}", proc_res.stderr); + eprintln!("{}", proc_res.cmdline); + */ // if a test does not crash, consider it an error - if !proc_res.status.success() { - match proc_res.status.code() { - Some(1 | 0) => self.fatal(&format!("test no longer crashes/triggers ICE! Please annotate it and add it as test to tests/ui or wherever you see fit")), - _ => (), - } + if proc_res.status.success() || matches!(proc_res.status.code(), Some(1 | 0)) { + self.fatal(&format!("test no longer crashes/triggers ICE! Please annotate it and add it as test to tests/ui or wherever you see fit")); } } @@ -2322,9 +2325,6 @@ fn compose_and_run( } let (Output { status, stdout, stderr }, truncated) = self.read2_abbreviated(child); - eprintln!("{:?}", status); - eprintln!("{}", String::from_utf8_lossy(&stdout).into_owned()); - eprintln!("{}", String::from_utf8_lossy(&stdout).into_owned()); let result = ProcRes { status, diff --git a/tests/crashes/101557.rs b/tests/crashes/101557.rs index da32660903e..a0290361ed1 100644 --- a/tests/crashes/101557.rs +++ b/tests/crashes/101557.rs @@ -1,4 +1,5 @@ //@ known-bug: #101557 +//@ compile-flags: -Copt-level=0 #![feature(generic_const_exprs)] use std::marker::PhantomData; diff --git a/tests/crashes/111699.rs b/tests/crashes/111699.rs index b3d12fb4a0b..5ba17c2aa1a 100644 --- a/tests/crashes/111699.rs +++ b/tests/crashes/111699.rs @@ -1,4 +1,6 @@ //@ known-bug: #111699 +//@ edition:2021 +//@ compile-flags: -Copt-level=0 #![feature(core_intrinsics)] use std::intrinsics::offset; diff --git a/tests/crashes/115435.rs b/tests/crashes/115435.rs index c846c95961d..c6e749867e8 100644 --- a/tests/crashes/115435.rs +++ b/tests/crashes/115435.rs @@ -1,4 +1,6 @@ //@ known-bug: #115435 +//@ edition:2021 +//@ compile-flags: -Copt-level=0 trait MyTrait { type Target: ?Sized; } diff --git a/tests/crashes/118320.rs b/tests/crashes/118320.rs index 0f47c923e10..093c58e1c05 100644 --- a/tests/crashes/118320.rs +++ b/tests/crashes/118320.rs @@ -1,4 +1,5 @@ //@ known-bug: #118320 +//@ edition:2021 #![feature(const_trait_impl, effects, const_closures)] #[const_trait] diff --git a/tests/crashes/119692.rs b/tests/crashes/119692.rs index 3b7457a7abe..2e230f98d81 100644 --- a/tests/crashes/119692.rs +++ b/tests/crashes/119692.rs @@ -1,4 +1,5 @@ //@ known-bug: #119692 +//@ compile-flags: -Copt-level=0 #![allow(incomplete_features)] #![feature(adt_const_params)] #![feature(generic_const_exprs)] diff --git a/tests/crashes/120241-2.rs b/tests/crashes/120241-2.rs index c7044950211..9c4a3a50293 100644 --- a/tests/crashes/120241-2.rs +++ b/tests/crashes/120241-2.rs @@ -1,4 +1,5 @@ //@ known-bug: #120241 +//@ edition:2021 #![feature(object_safe_for_dispatch)] #![feature(unsized_fn_params)] diff --git a/tests/crashes/120241.rs b/tests/crashes/120241.rs index f19fdf1a902..f18347a006c 100644 --- a/tests/crashes/120241.rs +++ b/tests/crashes/120241.rs @@ -1,4 +1,5 @@ //@ known-bug: #120241 +//@ edition:2021 #![feature(object_safe_for_dispatch)] trait B { diff --git a/tests/crashes/120482.rs b/tests/crashes/120482.rs index 1045aeb19c8..6cbc2009c5f 100644 --- a/tests/crashes/120482.rs +++ b/tests/crashes/120482.rs @@ -1,4 +1,5 @@ //@ known-bug: #120482 +//@ edition:2021 #![feature(object_safe_for_dispatch)] trait B { diff --git a/tests/crashes/121444.rs b/tests/crashes/121444.rs index 5a4289203dd..d3e5c385129 100644 --- a/tests/crashes/121444.rs +++ b/tests/crashes/121444.rs @@ -1,4 +1,6 @@ //@ known-bug: #121444 +//@ compile-flags: -Copt-level=0 +//@ edition:2021 #[repr(align(536870912))] pub struct A(i64); diff --git a/tests/crashes/123157.rs b/tests/crashes/123157.rs index 0c0721d02ec..d6cc55ba052 100644 --- a/tests/crashes/123157.rs +++ b/tests/crashes/123157.rs @@ -1,4 +1,5 @@ //@ known-bug: #123157 +//@ edition:2021 #![feature(type_alias_impl_trait)] #[derive(Copy, Clone)] diff --git a/tests/crashes/README.md b/tests/crashes/README.md index 28346b26e37..de25c6c1340 100644 --- a/tests/crashes/README.md +++ b/tests/crashes/README.md @@ -4,7 +4,7 @@ the rustc testsuite is more convenient. It is imperative that a test in the suite causes an internal compiler error/panic or makes rustc crash in some other way. -Accepted exit codes are: 101 (may be expanded later) +A test will "pass" if rustc exits with something other than 1 or 0. When adding crashes from https://github.com/rust-lang/rust/issues, the issue number should be noted in the file name (12345.rs should suffice)