Skip to content

Commit 212841e

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

19 files changed

+323
-0
lines changed

Diff for: tests/crashes/125655.rs

+8
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+
}

Diff for: tests/crashes/125680.rs

+15
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+
}

Diff for: tests/crashes/125758.rs

+26
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() {}

Diff for: tests/crashes/125768.rs

+15
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+
}

Diff for: tests/crashes/125769.rs

+14
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+
}

Diff for: tests/crashes/125772.rs

+17
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+
}

Diff for: tests/crashes/125799.rs

+22
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+
}

Diff for: tests/crashes/125801.rs

+20
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+
}

Diff for: tests/crashes/125810.rs

+10
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() {}

Diff for: tests/crashes/125811.rs

+34
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+
}

Diff for: tests/crashes/125841.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ known-bug: rust-lang/rust#125841
2+
#![feature(non_lifetime_binders)]
3+
fn take(id: impl for<T> Fn(T) -> T) {
4+
id(0);
5+
id("");
6+
}
7+
8+
fn take2() -> impl for<T> Fn(T) -> T {
9+
|x| x
10+
}
11+
12+
fn main() {
13+
take(|x| take2)
14+
}

Diff for: tests/crashes/125843.rs

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

Diff for: tests/crashes/125874.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ known-bug: rust-lang/rust#125874
2+
pub trait A {}
3+
4+
pub trait Mirror {
5+
type Assoc: ?Sized;
6+
}
7+
impl<T: ?Sized> Mirror for dyn A {
8+
type Assoc = T;
9+
}
10+
11+
struct Bar {
12+
foo: <dyn A + 'static as Mirror>::Assoc,
13+
}
14+
15+
pub fn main() {
16+
let strct = Bar { foo: 3 };
17+
18+
match strct {
19+
Bar { foo: 1, .. } => {}
20+
_ => (),
21+
};
22+
}

Diff for: tests/crashes/125879.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ known-bug: rust-lang/rust#125879
2+
#![feature(inherent_associated_types)]
3+
#![allow(incomplete_features)]
4+
5+
pub type PubAlias0 = PubTy::PrivAssocTy;
6+
7+
pub struct PubTy;
8+
impl PubTy {
9+
type PrivAssocTy = ();
10+
}
11+
12+
pub struct S(pub PubAlias0);
13+
14+
pub unsafe fn foo(a: S) -> S {
15+
a
16+
}
17+
18+
fn main() {}

Diff for: tests/crashes/125881.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ known-bug: rust-lang/rust#125881
2+
#![crate_type = "lib"]
3+
#![feature(transmutability)]
4+
#![feature(unboxed_closures,effects)]
5+
6+
const fn test() -> impl std::mem::BikeshedIntrinsicFrom() {
7+
|| {}
8+
}

Diff for: tests/crashes/125888.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ known-bug: rust-lang/rust#125888
2+
enum NestedEnum {
3+
First,
4+
Second,
5+
}
6+
7+
enum Enum {
8+
Variant(*const &'a ()),
9+
}
10+
11+
fn foo(x: Enum) {
12+
match x {
13+
Enum::Variant(NestedEnum::Second) => {}
14+
}
15+
}
16+
17+
fn main() {}

Diff for: tests/crashes/125914.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ known-bug: rust-lang/rust#125914
2+
enum AstKind<'ast> {
3+
ExprInt,
4+
}
5+
6+
enum Foo {
7+
Bar(isize),
8+
Baz,
9+
}
10+
11+
enum Other {
12+
Other1(Foo),
13+
Other2(AstKind),
14+
}
15+
16+
fn main() {
17+
match Other::Other1(Foo::Baz) {
18+
::Other::Other2(::Foo::Bar(..)) => {}
19+
}
20+
}

Diff for: tests/crashes/125957.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ known-bug: rust-lang/rust#125957
2+
#![feature(generic_const_exprs)]
3+
#![allow(incomplete_features)]
4+
#![feature(associated_const_equality)]
5+
6+
pub struct Equal<const T: usize, const R: usize>();
7+
8+
pub enum ParseMode {
9+
Raw,
10+
}
11+
pub trait Parse {
12+
const PARSE_MODE: ParseMode;
13+
}
14+
pub trait RenderRaw: Parse<PARSE_MODE = { ParseMode::Raw }> {}
15+
16+
trait GenericVec<T> {
17+
fn unwrap() -> dyn RenderRaw;
18+
}
19+
20+
fn main() {}

Diff for: tests/crashes/125992.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ known-bug: rust-lang/rust#125992
2+
//@ compile-flags: -Zpolonius=next
3+
4+
#![feature(inherent_associated_types)]
5+
6+
type Function = for<'a> fn(&'a i32) -> S<'a>::P;
7+
8+
struct S<'a>(&'a ());
9+
10+
impl<'a> S {
11+
type P = &'a i32;
12+
}
13+
14+
fn ret_ref_local<'e>() -> &'e i32 {
15+
let f: Function = |x| x;
16+
17+
let local = 0;
18+
f(&local)
19+
}

0 commit comments

Comments
 (0)