Skip to content

Commit 212841e

Browse files
committed
Auto merge of #126166 - matthiaskrgr:crsh, r=jieyouxu
tests: add more crashes r? `@jieyouxu`
2 parents 4f3a276 + 0f8513a commit 212841e

19 files changed

+323
-0
lines changed

tests/crashes/125655.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ known-bug: rust-lang/rust#125655
2+
3+
fn main() {
4+
static foo: dyn Fn() -> u32 = || -> u32 {
5+
...
6+
0
7+
};
8+
}

tests/crashes/125680.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ known-bug: rust-lang/rust#125680
2+
//@ edition:2021
3+
4+
#![feature(generic_const_exprs)]
5+
6+
use core::fmt::Debug;
7+
8+
struct Inline<T>
9+
where
10+
[(); std::mem::offset_of!((T,), 0)]:,
11+
{}
12+
13+
fn main() {
14+
let dst = Inline::<dyn Debug>::new(0); // BANG!
15+
}

tests/crashes/125758.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//@ known-bug: rust-lang/rust#125758
2+
#![feature(impl_trait_in_assoc_type)]
3+
4+
trait Trait: Sized {
5+
type Assoc2;
6+
}
7+
8+
impl Trait for Bar {
9+
type Assoc2 = impl std::fmt::Debug;
10+
}
11+
12+
struct Foo {
13+
field: <Bar as Trait>::Assoc2,
14+
}
15+
16+
enum Bar {
17+
C = 42,
18+
D = 99,
19+
}
20+
21+
static BAR: u8 = 42;
22+
23+
static FOO2: (&Foo, &<Bar as Trait>::Assoc2) =
24+
unsafe { (std::mem::transmute(&BAR), std::mem::transmute(&BAR)) };
25+
26+
fn main() {}

tests/crashes/125768.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ known-bug: rust-lang/rust#125768
2+
3+
#![feature(generic_const_exprs)]
4+
5+
struct Outer<const A: i64, const B: usize>();
6+
impl<const A: usize, const B: usize> Outer<A, B>
7+
where
8+
[(); A + (B * 2)]:,
9+
{
10+
fn o() -> Union {}
11+
}
12+
13+
fn main() {
14+
Outer::<1, 1>::o();
15+
}

tests/crashes/125769.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ known-bug: rust-lang/rust#125769
2+
3+
#![feature(generic_const_exprs)]
4+
5+
trait Trait {}
6+
7+
struct HasCastInTraitImpl<const N: usize, const M: u128>;
8+
impl<const O: f64> Trait for HasCastInTraitImpl<O, { O as u128 }> {}
9+
10+
pub fn use_trait_impl() {
11+
fn assert_impl<T: Trait>() {}
12+
13+
assert_impl::<HasCastInTraitImpl<13, 13>>();
14+
}

tests/crashes/125772.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ known-bug: rust-lang/rust#125772
2+
//@ only-x86_64
3+
#![feature(generic_const_exprs)]
4+
5+
struct Outer<const A: i64, const B: i64>();
6+
impl<const A: usize, const B: usize> Outer<A, B>
7+
where
8+
[(); A + (B * 2)]:,
9+
{
10+
fn i() -> Self {
11+
Self
12+
}
13+
}
14+
15+
fn main() {
16+
Outer::<1, 1>::o();
17+
}

tests/crashes/125799.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ known-bug: rust-lang/rust#125799
2+
//@ only-x86_64
3+
4+
trait Trait<T> {
5+
type Assoc;
6+
}
7+
8+
impl<T> Trait<T> for Vec<T> {
9+
type Assoc = ();
10+
}
11+
12+
impl Trait<u8> for Vec<u8> {}
13+
14+
const BAR: <Vec<u8> as Trait<u8>>::Assoc = 3;
15+
16+
pub fn main() {
17+
let x: isize = 3;
18+
let _ = match x {
19+
BAR => 2,
20+
_ => 3,
21+
};
22+
}

tests/crashes/125801.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ known-bug: rust-lang/rust#125801
2+
3+
#![feature(generic_const_exprs)]
4+
#![allow(incomplete_features)]
5+
6+
trait Foo {
7+
type Output;
8+
}
9+
10+
impl Foo for [u8; 3] {
11+
type Output = [u8; 3];
12+
}
13+
14+
static A: <[u8; N] as Foo>::Output = [1, 2, 3];
15+
16+
fn main() {
17+
|| {
18+
let _ = A[1];
19+
};
20+
}

tests/crashes/125810.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ known-bug: rust-lang/rust#125810
2+
#![feature(arbitrary_self_types, dispatch_from_dyn)]
3+
4+
use std::ops::{Deref, DispatchFromDyn};
5+
6+
trait Trait<T: Deref<Target = Self> + DispatchFromDyn<T>> {
7+
fn MONO_BUF(self: T) -> dyn Trait<T>;
8+
}
9+
10+
fn main() {}

tests/crashes/125811.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//@ known-bug: rust-lang/rust#125811
2+
mod assert {
3+
use std::mem::{Assume, BikeshedIntrinsicFrom};
4+
5+
pub fn is_transmutable<Src, Dst>()
6+
where
7+
Dst: BikeshedIntrinsicFrom<Src>,
8+
{
9+
}
10+
}
11+
12+
#[repr(C)]
13+
struct Zst;
14+
15+
enum V0 {
16+
B(!),
17+
}
18+
19+
enum V2 {
20+
V = 2,
21+
}
22+
23+
enum Lopsided {
24+
Smol(Zst),
25+
Lorg(V0),
26+
}
27+
28+
#[repr(C)]
29+
#[repr(C)]
30+
struct Dst(Lopsided, V2);
31+
32+
fn should_pad_variants() {
33+
assert::is_transmutable::<Src, Dst>();
34+
}

0 commit comments

Comments
 (0)