From 7d99549073b8785feec85c9ed25eb29bb09daa29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 15 Aug 2024 22:44:16 +0200 Subject: [PATCH] crashes: more tests --- tests/crashes/128695.rs | 11 +++++++++++ tests/crashes/128810.rs | 25 +++++++++++++++++++++++++ tests/crashes/128848.rs | 5 +++++ tests/crashes/128870.rs | 18 ++++++++++++++++++ tests/crashes/129075.rs | 16 ++++++++++++++++ tests/crashes/129095.rs | 10 ++++++++++ tests/crashes/129099.rs | 15 +++++++++++++++ tests/crashes/129109.rs | 10 ++++++++++ tests/crashes/129127.rs | 21 +++++++++++++++++++++ 9 files changed, 131 insertions(+) create mode 100644 tests/crashes/128695.rs create mode 100644 tests/crashes/128810.rs create mode 100644 tests/crashes/128848.rs create mode 100644 tests/crashes/128870.rs create mode 100644 tests/crashes/129075.rs create mode 100644 tests/crashes/129095.rs create mode 100644 tests/crashes/129099.rs create mode 100644 tests/crashes/129109.rs create mode 100644 tests/crashes/129127.rs diff --git a/tests/crashes/128695.rs b/tests/crashes/128695.rs new file mode 100644 index 0000000000000..661f427dc0e99 --- /dev/null +++ b/tests/crashes/128695.rs @@ -0,0 +1,11 @@ +//@ known-bug: rust-lang/rust#128695 +//@ edition: 2021 + +use core::pin::{pin, Pin}; + +fn main() { + let fut = pin!(async { + let async_drop_fut = pin!(core::future::async_drop(async {})); + (async_drop_fut).await; + }); +} diff --git a/tests/crashes/128810.rs b/tests/crashes/128810.rs new file mode 100644 index 0000000000000..68214ff010c99 --- /dev/null +++ b/tests/crashes/128810.rs @@ -0,0 +1,25 @@ +//@ known-bug: rust-lang/rust#128810 + +#![feature(fn_delegation)] + +use std::marker::PhantomData; + +pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>); + +impl<'a> InvariantRef<'a, ()> { + pub const NEW: Self = InvariantRef::new(&()); +} + +trait Trait { + fn foo(&self) -> u8 { 0 } + fn bar(&self) -> u8 { 1 } + fn meh(&self) -> u8 { 2 } +} + +struct Z(u8); + +impl Trait for Z { + reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } } +} + +fn main() { } diff --git a/tests/crashes/128848.rs b/tests/crashes/128848.rs new file mode 100644 index 0000000000000..636811fc6b504 --- /dev/null +++ b/tests/crashes/128848.rs @@ -0,0 +1,5 @@ +//@ known-bug: rust-lang/rust#128848 + +fn f(a: T, b: T, c: T) { + f.call_once() +} diff --git a/tests/crashes/128870.rs b/tests/crashes/128870.rs new file mode 100644 index 0000000000000..2b7319621440c --- /dev/null +++ b/tests/crashes/128870.rs @@ -0,0 +1,18 @@ +//@ known-bug: rust-lang/rust#128870 +//@ compile-flags: -Zvalidate-mir + +#[repr(packed)] +#[repr(u32)] +enum E { + A, + B, + C, +} + +fn main() { + union InvalidTag { + int: u32, + e: E, + } + let _invalid_tag = InvalidTag { int: 4 }; +} diff --git a/tests/crashes/129075.rs b/tests/crashes/129075.rs new file mode 100644 index 0000000000000..4a0e920914cc5 --- /dev/null +++ b/tests/crashes/129075.rs @@ -0,0 +1,16 @@ +//@ known-bug: rust-lang/rust#129075 +//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes + +struct Foo([T; 2]); + +impl Default for Foo { + fn default(&mut self) -> Self { + Foo([Default::default(); 2]) + } +} + +fn field_array() { + let a: i32; + let b; + Foo([a, b]) = Default::default(); +} diff --git a/tests/crashes/129095.rs b/tests/crashes/129095.rs new file mode 100644 index 0000000000000..ea70c0565fc36 --- /dev/null +++ b/tests/crashes/129095.rs @@ -0,0 +1,10 @@ +//@ known-bug: rust-lang/rust#129095 +//@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir + +pub fn function_with_bytes() -> &'static [u8] { + BYTES +} + +pub fn main() { + assert_eq!(function_with_bytes::(), &[0x41, 0x41, 0x41, 0x41]); +} diff --git a/tests/crashes/129099.rs b/tests/crashes/129099.rs new file mode 100644 index 0000000000000..9aaab756b5b8d --- /dev/null +++ b/tests/crashes/129099.rs @@ -0,0 +1,15 @@ +//@ known-bug: rust-lang/rust#129099 + +#![feature(type_alias_impl_trait)] + +fn dyn_hoops() -> dyn for<'a> Iterator> { + loop {} +} + +pub fn main() { + type Opaque = impl Sized; + fn define() -> Opaque { + let x: Opaque = dyn_hoops::<()>(0); + x + } +} diff --git a/tests/crashes/129109.rs b/tests/crashes/129109.rs new file mode 100644 index 0000000000000..8b9ebdf03c779 --- /dev/null +++ b/tests/crashes/129109.rs @@ -0,0 +1,10 @@ +//@ known-bug: rust-lang/rust#129109 +//@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir + +extern "C" { + pub static mut symbol: [i8]; +} + +fn main() { + println!("C", unsafe { &symbol }); +} diff --git a/tests/crashes/129127.rs b/tests/crashes/129127.rs new file mode 100644 index 0000000000000..8ec848dbd0578 --- /dev/null +++ b/tests/crashes/129127.rs @@ -0,0 +1,21 @@ +//@ known-bug: rust-lang/rust#129127 +//@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir -Zcross-crate-inline-threshold=always + + + + +pub struct Rows<'a>(); + +impl<'a> Iterator for Rows<'a> { + type Item = (); + + fn next() -> Option { + let mut rows = Rows(); + rows.map(|row| row).next() + } +} + +fn main() { + let mut rows = Rows(); + rows.next(); +}