Skip to content

Commit f2534de

Browse files
committed
crashes: more tests
1 parent 414da5b commit f2534de

27 files changed

+358
-0
lines changed

tests/crashes/138156.rs

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//@ known-bug: #138156
2+
3+
#![feature(generic_const_exprs)]
4+
5+
#[derive(Default)]
6+
pub struct GenId<const IDX: usize>;
7+
8+
pub trait IndexTrait: Default {
9+
const IDX: usize;
10+
}
11+
pub trait ToplogyIndex {
12+
type Idx: IndexTrait;
13+
}
14+
15+
#[derive(Default)]
16+
pub struct Expression<T: ToplogyIndex> {
17+
pub data: T,
18+
}
19+
20+
fn i<T: ToplogyIndex, const IDX0: usize, const IDX1: usize>(s: Expression<T>) ->
21+
Expression<GenId<{ IDX0 | IDX1 }>>
22+
where
23+
GenId<{ IDX0 | IDX1 }>: ToplogyIndex,
24+
{
25+
Expression::default()
26+
}
27+
28+
pub fn sum<In: ToplogyIndex>(s: Expression<In>) -> Expression<In>
29+
where
30+
[(); In::Idx::IDX]:,
31+
{
32+
s
33+
}
34+
35+
fn param_position<In: ToplogyIndex>(s: Expression<In>)
36+
where
37+
GenId<{ 1 | 2 }>: ToplogyIndex,
38+
{
39+
sum(i::<_, 1, 2>(s));
40+
}
41+
42+
fn main() {}

tests/crashes/138214.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ known-bug: #138214
2+
3+
struct Demo<X, Y: A = X, Z = <<Y as A>::U as B>::V>(X, Y, Z);
4+
5+
impl<V> Demo<V> {
6+
fn new() {}
7+
}
8+
9+
pub trait A<Group = ()> {
10+
type U: B;
11+
}
12+
13+
pub trait B {
14+
type V;
15+
}

tests/crashes/138240.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ known-bug: #138240
2+
//@edition:2024
3+
#![feature(min_generic_const_args)]
4+
#![feature(inherent_associated_types)]
5+
async fn _CF() -> Box<[u8; Box::b]> {
6+
Box::new(true)
7+
}
8+
9+
fn main() {}

tests/crashes/138265.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ known-bug: #138265
2+
3+
#![feature(coerce_unsized)]
4+
#![crate_type = "lib"]
5+
impl<A> std::ops::CoerceUnsized<A> for A {}
6+
pub fn f() {
7+
[0; {
8+
let mut c = &0;
9+
c = &0;
10+
0
11+
}]
12+
}

tests/crashes/138266.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//@ known-bug: #138266
2+
//@compile-flags: --crate-type=lib
3+
#![feature(min_generic_const_args)]
4+
#![feature(inherent_associated_types)]
5+
pub fn f(mut x: [u8; Box::b]) {
6+
x[72] = 1;
7+
}

tests/crashes/138359.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ known-bug: #138359
2+
#![feature(min_generic_const_args)]
3+
#![feature(inherent_associated_types)]
4+
struct a(Box<[u8; Box::b]>);
5+
impl a {
6+
fn c(self) { self.0.da }
7+
}
8+
fn main() {}

tests/crashes/138361.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ known-bug: #138361
2+
3+
fn main() {
4+
[0; loop{}];
5+
std::mem::transmute(4)
6+
}

tests/crashes/138510.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//@ known-bug: #138510
2+
fn main()
3+
where
4+
#[repr()]
5+
_: Sized,
6+
{
7+
}

tests/crashes/138534.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ known-bug: #138534
2+
//@compile-flags: -Zunpretty=expanded
3+
#[repr(bool)]
4+
pub enum TopFg {
5+
Bar,
6+
}

tests/crashes/138564.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//@ known-bug: #138564
2+
//@compile-flags: -Copt-level=0 -Cdebuginfo=2 --crate-type lib
3+
#![feature(unsize, dispatch_from_dyn, arbitrary_self_types)]
4+
5+
use std::marker::Unsize;
6+
use std::ops::{Deref, DispatchFromDyn};
7+
8+
#[repr(align(16))]
9+
pub struct MyPointer<T: ?Sized>(*const T);
10+
11+
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<MyPointer<U>> for MyPointer<T> {}
12+
impl<T: ?Sized> Deref for MyPointer<T> {
13+
type Target = T;
14+
fn deref(&self) -> &T {
15+
unimplemented!()
16+
}
17+
}
18+
19+
pub trait Trait {
20+
fn foo(self: MyPointer<Self>) {}
21+
}
22+
23+
// make sure some usage of `<dyn Trait>::foo` makes it to codegen
24+
pub fn user() -> *const () {
25+
<dyn Trait>::foo as *const ()
26+
}

tests/crashes/138707.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//@ known-bug: #138707
2+
//@edition:2024
3+
//@compile-flags: --crate-type lib
4+
use core::marker::PhantomData;
5+
6+
struct LeftReflector<S> {
7+
_phantom: PhantomData<S>,
8+
}
9+
10+
struct DefaultAllocator {}
11+
12+
trait Allocator<R> {
13+
type Buffer;
14+
}
15+
16+
struct U2 {}
17+
18+
impl Allocator<U2> for DefaultAllocator {
19+
type Buffer = [u8; 2];
20+
}
21+
22+
impl<R> From<R> for LeftReflector<<DefaultAllocator as Allocator<R>>::Buffer>
23+
where
24+
DefaultAllocator: Allocator<R>,
25+
{
26+
fn from(_: R) -> Self {
27+
todo!()
28+
}
29+
}
30+
31+
fn ice<D>(a: U2)
32+
where
33+
DefaultAllocator: Allocator<D>,
34+
{
35+
// ICE
36+
let _ = LeftReflector::from(a);
37+
}

tests/crashes/138738.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//@ known-bug: #138738
2+
//@ only-x86_64
3+
4+
#![feature(abi_ptx)]
5+
fn main() {
6+
let a = unsafe { core::mem::transmute::<usize, extern "ptx-kernel" fn(i32)>(4) }(2);
7+
}

tests/crashes/139089.rs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//@ known-bug: #139089
2+
pub fn foo3(x:Vec<u8>) { x.push(0); }

tests/crashes/139120.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@ known-bug: #139120
2+
3+
4+
5+
pub trait Foo {
6+
type Bar<'a>;
7+
}
8+
9+
pub struct FooImpl {}
10+
11+
impl Foo for FooImpl {
12+
type Bar<'a> = ();
13+
}
14+
15+
pub trait FooFn {
16+
fn bar(&self);
17+
}
18+
19+
impl<T: Foo> FooFn for fn(T, T::Bar<'_>) {
20+
fn bar(&self) {}
21+
}
22+
23+
fn foo<T: Foo>(f: fn(T, T::Bar<'_>)) {
24+
let _: &dyn FooFn = &f;
25+
}
26+
27+
fn main() {
28+
foo(|_: FooImpl, _| {});
29+
}

tests/crashes/139381.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ known-bug: #139381
2+
//@ needs-rustc-debug-assertions
3+
trait A<'a> {
4+
type Assoc: ?Sized;
5+
}
6+
7+
impl<'a> A<'a> for () {
8+
type Assoc = &'a ();
9+
}
10+
11+
fn hello() -> impl for<'a> A<'a, Assoc: Into<u8> + 'static + Copy> {
12+
()
13+
}

tests/crashes/139387.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ known-bug: #139387
2+
//@ needs-rustc-debug-assertions
3+
4+
trait A {
5+
fn method() -> impl Sized;
6+
}
7+
trait B {
8+
fn method(Hash: Wrap<impl Beta<U: Copy + for<'a> Epsilon<'_, SI1: Eta>>>) -> impl Sized;
9+
}
10+
11+
fn ambiguous<T: A + B>()
12+
where
13+
T::method(..): Send,
14+
{
15+
}

tests/crashes/139409.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ known-bug: #139409
2+
//@ compile-flags: -Znext-solver=globally
3+
4+
fn main() {
5+
trait B<C> {}
6+
impl<C> B<C> for () {}
7+
trait D<C, E>: B<C> + B<E> {
8+
fn f(&self) {}
9+
}
10+
impl<C, E> D<C, E> for () {}
11+
(&() as &dyn D<&(), &()>).f()
12+
}

tests/crashes/139462.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ known-bug: #139462
2+
//@ compile-flags: -Cdebuginfo=2
3+
#![feature(unsafe_binders)]
4+
use std::unsafe_binder::wrap_binder;
5+
fn main() {
6+
let foo = 0;
7+
let foo: unsafe<'a> &'a u32 = unsafe { wrap_binder!(&foo) };
8+
}

tests/crashes/139556.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ known-bug: #139556
2+
3+
trait T {}
4+
5+
type Alias<'a> = impl T;
6+
7+
struct S;
8+
impl<'a> T for &'a S {}
9+
10+
#[define_opaque(Alias)]
11+
fn with_positive(fun: impl Fn(Alias<'_>)) {
12+
with_positive(|&n| ());
13+
}

tests/crashes/139570.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//@ known-bug: #139570
2+
fn main() {
3+
|(1, 42), ()| yield;
4+
}

tests/crashes/139596.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ known-bug: #139596
2+
3+
#![feature(min_generic_const_args)]
4+
struct Colour;
5+
6+
struct Led<const C: Colour>;
7+
8+
fn main() {
9+
Led::<{ Colour}>;
10+
}

tests/crashes/139659.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@ known-bug: #139659
2+
//@compile-flags: -Cdebuginfo=2 -Copt-level=0 --crate-type lib
3+
trait Trait {
4+
type Output;
5+
}
6+
7+
impl<O, F: Fn() -> O> Trait for F {
8+
type Output = O;
9+
}
10+
11+
struct Wrap<P>(P);
12+
struct WrapOutput<O>(O);
13+
14+
impl<P: Trait> Trait for Wrap<P> {
15+
type Output = WrapOutput<P::Output>;
16+
}
17+
18+
fn wrap<P: Trait>(x: P) -> impl Trait {
19+
Wrap(x)
20+
}
21+
22+
fn consume<P: Trait>(_: P) -> P::Output {
23+
unimplemented!()
24+
}
25+
26+
pub fn recurse() -> impl Sized {
27+
consume(wrap(recurse))
28+
}
29+
pub fn main() {}

tests/crashes/139738.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//@ known-bug: #139738
2+
#![feature(generic_const_exprs)]
3+
fn b<'a>() -> impl IntoIterator<[(); (|_: &'a u8| 0, 0).1]> {}

tests/crashes/139815.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ known-bug: #139815
2+
3+
#![feature(generic_const_exprs)]
4+
fn is_123<const N: usize>(
5+
x: [u32; {
6+
N + 1;
7+
5
8+
}],
9+
) -> bool {
10+
match x {
11+
[1, 2] => true,
12+
_ => false,
13+
}
14+
}

tests/crashes/139817.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ known-bug: #139817
2+
fn enum_upvar() {
3+
type T = impl Copy;
4+
let foo: T = Some((42, std::marker::PhantomData::<T>));
5+
let x = move || match foo {
6+
None => (),
7+
};
8+
}

tests/crashes/139825.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//@ known-bug: #139825
2+
//@compile-flags: --check-cfg=cfg(docsrs,test) --crate-type lib
3+
struct a
4+
where
5+
for<#[cfg(b)] c> u8:;

tests/crashes/139872.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ known-bug: #139872
2+
//@ only-x86_64
3+
pub fn main() {
4+
enum A {
5+
B(u32),
6+
}
7+
static C: (A, u16, str);
8+
fn d() {
9+
let (_, e, _) = C;
10+
}
11+
}

0 commit comments

Comments
 (0)