tests: add more crashes

This commit is contained in:
Matthias Krüger 2024-06-08 18:36:21 +02:00
parent 13423befc4
commit 0f8513a51c
19 changed files with 323 additions and 0 deletions

8
tests/crashes/125655.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: rust-lang/rust#125655
fn main() {
static foo: dyn Fn() -> u32 = || -> u32 {
...
0
};
}

15
tests/crashes/125680.rs Normal file
View File

@ -0,0 +1,15 @@
//@ known-bug: rust-lang/rust#125680
//@ edition:2021
#![feature(generic_const_exprs)]
use core::fmt::Debug;
struct Inline<T>
where
[(); std::mem::offset_of!((T,), 0)]:,
{}
fn main() {
let dst = Inline::<dyn Debug>::new(0); // BANG!
}

26
tests/crashes/125758.rs Normal file
View File

@ -0,0 +1,26 @@
//@ known-bug: rust-lang/rust#125758
#![feature(impl_trait_in_assoc_type)]
trait Trait: Sized {
type Assoc2;
}
impl Trait for Bar {
type Assoc2 = impl std::fmt::Debug;
}
struct Foo {
field: <Bar as Trait>::Assoc2,
}
enum Bar {
C = 42,
D = 99,
}
static BAR: u8 = 42;
static FOO2: (&Foo, &<Bar as Trait>::Assoc2) =
unsafe { (std::mem::transmute(&BAR), std::mem::transmute(&BAR)) };
fn main() {}

15
tests/crashes/125768.rs Normal file
View File

@ -0,0 +1,15 @@
//@ known-bug: rust-lang/rust#125768
#![feature(generic_const_exprs)]
struct Outer<const A: i64, const B: usize>();
impl<const A: usize, const B: usize> Outer<A, B>
where
[(); A + (B * 2)]:,
{
fn o() -> Union {}
}
fn main() {
Outer::<1, 1>::o();
}

14
tests/crashes/125769.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: rust-lang/rust#125769
#![feature(generic_const_exprs)]
trait Trait {}
struct HasCastInTraitImpl<const N: usize, const M: u128>;
impl<const O: f64> Trait for HasCastInTraitImpl<O, { O as u128 }> {}
pub fn use_trait_impl() {
fn assert_impl<T: Trait>() {}
assert_impl::<HasCastInTraitImpl<13, 13>>();
}

17
tests/crashes/125772.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: rust-lang/rust#125772
//@ only-x86_64
#![feature(generic_const_exprs)]
struct Outer<const A: i64, const B: i64>();
impl<const A: usize, const B: usize> Outer<A, B>
where
[(); A + (B * 2)]:,
{
fn i() -> Self {
Self
}
}
fn main() {
Outer::<1, 1>::o();
}

22
tests/crashes/125799.rs Normal file
View File

@ -0,0 +1,22 @@
//@ known-bug: rust-lang/rust#125799
//@ only-x86_64
trait Trait<T> {
type Assoc;
}
impl<T> Trait<T> for Vec<T> {
type Assoc = ();
}
impl Trait<u8> for Vec<u8> {}
const BAR: <Vec<u8> as Trait<u8>>::Assoc = 3;
pub fn main() {
let x: isize = 3;
let _ = match x {
BAR => 2,
_ => 3,
};
}

20
tests/crashes/125801.rs Normal file
View File

@ -0,0 +1,20 @@
//@ known-bug: rust-lang/rust#125801
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Foo {
type Output;
}
impl Foo for [u8; 3] {
type Output = [u8; 3];
}
static A: <[u8; N] as Foo>::Output = [1, 2, 3];
fn main() {
|| {
let _ = A[1];
};
}

10
tests/crashes/125810.rs Normal file
View File

@ -0,0 +1,10 @@
//@ known-bug: rust-lang/rust#125810
#![feature(arbitrary_self_types, dispatch_from_dyn)]
use std::ops::{Deref, DispatchFromDyn};
trait Trait<T: Deref<Target = Self> + DispatchFromDyn<T>> {
fn MONO_BUF(self: T) -> dyn Trait<T>;
}
fn main() {}

34
tests/crashes/125811.rs Normal file
View File

@ -0,0 +1,34 @@
//@ known-bug: rust-lang/rust#125811
mod assert {
use std::mem::{Assume, BikeshedIntrinsicFrom};
pub fn is_transmutable<Src, Dst>()
where
Dst: BikeshedIntrinsicFrom<Src>,
{
}
}
#[repr(C)]
struct Zst;
enum V0 {
B(!),
}
enum V2 {
V = 2,
}
enum Lopsided {
Smol(Zst),
Lorg(V0),
}
#[repr(C)]
#[repr(C)]
struct Dst(Lopsided, V2);
fn should_pad_variants() {
assert::is_transmutable::<Src, Dst>();
}

14
tests/crashes/125841.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: rust-lang/rust#125841
#![feature(non_lifetime_binders)]
fn take(id: impl for<T> Fn(T) -> T) {
id(0);
id("");
}
fn take2() -> impl for<T> Fn(T) -> T {
|x| x
}
fn main() {
take(|x| take2)
}

4
tests/crashes/125843.rs Normal file
View File

@ -0,0 +1,4 @@
//@ known-bug: rust-lang/rust#125843
#![feature(non_lifetime_binders)]
trait v0<> {}
fn kind :(v3main impl for<v4> v0<'_, v2 = impl v0<v4> + '_>) {}

22
tests/crashes/125874.rs Normal file
View File

@ -0,0 +1,22 @@
//@ known-bug: rust-lang/rust#125874
pub trait A {}
pub trait Mirror {
type Assoc: ?Sized;
}
impl<T: ?Sized> Mirror for dyn A {
type Assoc = T;
}
struct Bar {
foo: <dyn A + 'static as Mirror>::Assoc,
}
pub fn main() {
let strct = Bar { foo: 3 };
match strct {
Bar { foo: 1, .. } => {}
_ => (),
};
}

18
tests/crashes/125879.rs Normal file
View File

@ -0,0 +1,18 @@
//@ known-bug: rust-lang/rust#125879
#![feature(inherent_associated_types)]
#![allow(incomplete_features)]
pub type PubAlias0 = PubTy::PrivAssocTy;
pub struct PubTy;
impl PubTy {
type PrivAssocTy = ();
}
pub struct S(pub PubAlias0);
pub unsafe fn foo(a: S) -> S {
a
}
fn main() {}

8
tests/crashes/125881.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: rust-lang/rust#125881
#![crate_type = "lib"]
#![feature(transmutability)]
#![feature(unboxed_closures,effects)]
const fn test() -> impl std::mem::BikeshedIntrinsicFrom() {
|| {}
}

17
tests/crashes/125888.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: rust-lang/rust#125888
enum NestedEnum {
First,
Second,
}
enum Enum {
Variant(*const &'a ()),
}
fn foo(x: Enum) {
match x {
Enum::Variant(NestedEnum::Second) => {}
}
}
fn main() {}

20
tests/crashes/125914.rs Normal file
View File

@ -0,0 +1,20 @@
//@ known-bug: rust-lang/rust#125914
enum AstKind<'ast> {
ExprInt,
}
enum Foo {
Bar(isize),
Baz,
}
enum Other {
Other1(Foo),
Other2(AstKind),
}
fn main() {
match Other::Other1(Foo::Baz) {
::Other::Other2(::Foo::Bar(..)) => {}
}
}

20
tests/crashes/125957.rs Normal file
View File

@ -0,0 +1,20 @@
//@ known-bug: rust-lang/rust#125957
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
#![feature(associated_const_equality)]
pub struct Equal<const T: usize, const R: usize>();
pub enum ParseMode {
Raw,
}
pub trait Parse {
const PARSE_MODE: ParseMode;
}
pub trait RenderRaw: Parse<PARSE_MODE = { ParseMode::Raw }> {}
trait GenericVec<T> {
fn unwrap() -> dyn RenderRaw;
}
fn main() {}

19
tests/crashes/125992.rs Normal file
View File

@ -0,0 +1,19 @@
//@ known-bug: rust-lang/rust#125992
//@ compile-flags: -Zpolonius=next
#![feature(inherent_associated_types)]
type Function = for<'a> fn(&'a i32) -> S<'a>::P;
struct S<'a>(&'a ());
impl<'a> S {
type P = &'a i32;
}
fn ret_ref_local<'e>() -> &'e i32 {
let f: Function = |x| x;
let local = 0;
f(&local)
}