From d6e70df1a2b1b335a52d509287534e6e94ceb9e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 24 Mar 2024 13:07:30 +0100 Subject: [PATCH] crashes: add another test showing that everything works fine when we need compile-flags to repro an ice and add README --- src/tools/opt-dist/src/tests.rs | 2 +- tests/crashes/122909.rs | 15 +++++++++++++++ tests/crashes/README.md | 13 +++++++++++++ tests/crashes/no-ice.rs | 1 - 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tests/crashes/122909.rs create mode 100644 tests/crashes/README.md delete mode 100644 tests/crashes/no-ice.rs diff --git a/src/tools/opt-dist/src/tests.rs b/src/tools/opt-dist/src/tests.rs index b5dfd2fc5af..46b0a543802 100644 --- a/src/tools/opt-dist/src/tests.rs +++ b/src/tools/opt-dist/src/tests.rs @@ -96,7 +96,7 @@ pub fn run_tests(env: &Environment) -> anyhow::Result<()> { "tests/pretty", "tests/run-pass-valgrind", "tests/ui", - "tests/crases", + "tests/crashes", ]; for test_path in env.skipped_tests() { args.extend(["--skip", test_path]); diff --git a/tests/crashes/122909.rs b/tests/crashes/122909.rs new file mode 100644 index 00000000000..344fcd88010 --- /dev/null +++ b/tests/crashes/122909.rs @@ -0,0 +1,15 @@ +//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes +//@ known-bug: #12345 + + +use std::sync::{Arc, Context, Weak}; + +pub struct WeakOnce(); +impl WeakOnce { + extern "rust-call" fn try_get(&self) -> Option> {} + + pub fn get(&self) -> Arc { + self.try_get() + .unwrap_or_else(|| panic!("Singleton {} not available", std::any::type_name::())) + } +} diff --git a/tests/crashes/README.md b/tests/crashes/README.md new file mode 100644 index 00000000000..28346b26e37 --- /dev/null +++ b/tests/crashes/README.md @@ -0,0 +1,13 @@ +This is serves as a collection of crashes so that accidental ICE fixes are tracked. +This was formally done at https://github.com/rust-lang/glacier but doing it inside +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) + +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) +and perhaps also inside the file via `//@ known-bug #4321` + +If you happen to fix one of the crashes, please move it to `tests/ui`! :) diff --git a/tests/crashes/no-ice.rs b/tests/crashes/no-ice.rs deleted file mode 100644 index da0f5d925d1..00000000000 --- a/tests/crashes/no-ice.rs +++ /dev/null @@ -1 +0,0 @@ -pub fn main() {}