From 69de294c311cd38c85f3f143fb4cf997518e8bc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 4 Aug 2024 21:25:49 +0200 Subject: [PATCH] tests: more crashes --- tests/crashes/128094.rs | 14 ++++++++++++++ tests/crashes/128176.rs | 13 +++++++++++++ tests/crashes/128190.rs | 7 +++++++ tests/crashes/128327.rs | 5 +++++ tests/crashes/128346.rs | 13 +++++++++++++ tests/crashes/128621-2.rs | 16 ++++++++++++++++ tests/crashes/128621.rs | 19 +++++++++++++++++++ 7 files changed, 87 insertions(+) create mode 100644 tests/crashes/128094.rs create mode 100644 tests/crashes/128176.rs create mode 100644 tests/crashes/128190.rs create mode 100644 tests/crashes/128327.rs create mode 100644 tests/crashes/128346.rs create mode 100644 tests/crashes/128621-2.rs create mode 100644 tests/crashes/128621.rs diff --git a/tests/crashes/128094.rs b/tests/crashes/128094.rs new file mode 100644 index 0000000000000..105a1c84a6565 --- /dev/null +++ b/tests/crashes/128094.rs @@ -0,0 +1,14 @@ +//@ known-bug: rust-lang/rust#128094 +//@ compile-flags: -Zmir-opt-level=5 --edition=2018 + +pub enum Request { + TestSome(T), +} + +pub async fn handle_event(event: Request) { + async move { + static instance: Request = Request { bar: 17 }; + &instance + } + .await; +} diff --git a/tests/crashes/128176.rs b/tests/crashes/128176.rs new file mode 100644 index 0000000000000..70fada4f0fec2 --- /dev/null +++ b/tests/crashes/128176.rs @@ -0,0 +1,13 @@ +//@ known-bug: rust-lang/rust#128176 + +#![feature(generic_const_exprs)] +#![feature(object_safe_for_dispatch)] +trait X { + type Y; +} + +const _: () = { + fn f2<'a>(arg: Box = &'a ()>>) {} +}; + +fn main() {} diff --git a/tests/crashes/128190.rs b/tests/crashes/128190.rs new file mode 100644 index 0000000000000..0fa7027ae6091 --- /dev/null +++ b/tests/crashes/128190.rs @@ -0,0 +1,7 @@ +//@ known-bug: rust-lang/rust#128190 + +fn a(&self) { + 15 +} + +reuse a as b { struct S; } diff --git a/tests/crashes/128327.rs b/tests/crashes/128327.rs new file mode 100644 index 0000000000000..a63f758c317cf --- /dev/null +++ b/tests/crashes/128327.rs @@ -0,0 +1,5 @@ +//@ known-bug: rust-lang/rust#128327 + +use std::ops::Deref; +struct Apple((Apple, <&'static [f64] as Deref>::Target(Banana ? Citron))); +fn main(){} diff --git a/tests/crashes/128346.rs b/tests/crashes/128346.rs new file mode 100644 index 0000000000000..93d9c40a544e9 --- /dev/null +++ b/tests/crashes/128346.rs @@ -0,0 +1,13 @@ +//@ known-bug: rust-lang/rust#128346 + +macro_rules! one_rep { + ( $($a:ident)* ) => { + A( + const ${concat($a, Z)}: i32 = 3; + )* + }; +} + +fn main() { + one_rep!(A B C); +} diff --git a/tests/crashes/128621-2.rs b/tests/crashes/128621-2.rs new file mode 100644 index 0000000000000..b1cdaf94984a8 --- /dev/null +++ b/tests/crashes/128621-2.rs @@ -0,0 +1,16 @@ +//@ known-bug: rust-lang/rust#128621 + +#![feature(ptr_metadata)] +use std::{ops::FnMut, ptr::Pointee}; + +pub type EmplacerFn<'a, T> = dyn for<'b> FnMut(::Metadata) + 'a; + +pub struct Emplacer<'a, T>(EmplacerFn<'a, T>); + +impl<'a, T> Emplacer<'a, T> { + pub unsafe fn from_fn<'b>(emplacer_fn: &'b mut EmplacerFn<'a, T>) -> &'b mut Self { + unsafe { &mut *((emplacer_fn as *mut EmplacerFn<'a, T>) as *mut Self) } + } +} + +pub fn main() {} diff --git a/tests/crashes/128621.rs b/tests/crashes/128621.rs new file mode 100644 index 0000000000000..0a02352236dbb --- /dev/null +++ b/tests/crashes/128621.rs @@ -0,0 +1,19 @@ +//@ known-bug: rust-lang/rust#128621 + +trait Trait { + type Associated; +} + +impl Trait for i32 { + type Associated = i64; +} + +trait Generic {} + +type TraitObject = dyn Generic<::Associated>; + +struct Wrap(TraitObject); + +fn cast(x: *mut TraitObject) { + x as *mut Wrap; +}