Skip to content

crashes: more tests #139883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions tests/crashes/138156.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//@ known-bug: #138156

#![feature(generic_const_exprs)]

#[derive(Default)]
pub struct GenId<const IDX: usize>;

pub trait IndexTrait: Default {
const IDX: usize;
}
pub trait ToplogyIndex {
type Idx: IndexTrait;
}

#[derive(Default)]
pub struct Expression<T: ToplogyIndex> {
pub data: T,
}

fn i<T: ToplogyIndex, const IDX0: usize, const IDX1: usize>(s: Expression<T>) ->
Expression<GenId<{ IDX0 | IDX1 }>>
where
GenId<{ IDX0 | IDX1 }>: ToplogyIndex,
{
Expression::default()
}

pub fn sum<In: ToplogyIndex>(s: Expression<In>) -> Expression<In>
where
[(); In::Idx::IDX]:,
{
s
}

fn param_position<In: ToplogyIndex>(s: Expression<In>)
where
GenId<{ 1 | 2 }>: ToplogyIndex,
{
sum(i::<_, 1, 2>(s));
}

fn main() {}
9 changes: 9 additions & 0 deletions tests/crashes/138240.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ known-bug: #138240
//@edition:2024
#![feature(min_generic_const_args)]
#![feature(inherent_associated_types)]
async fn _CF() -> Box<[u8; Box::b]> {
Box::new(true)
}

fn main() {}
12 changes: 12 additions & 0 deletions tests/crashes/138265.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ known-bug: #138265

#![feature(coerce_unsized)]
#![crate_type = "lib"]
impl<A> std::ops::CoerceUnsized<A> for A {}
pub fn f() {
[0; {
let mut c = &0;
c = &0;
0
}]
}
7 changes: 7 additions & 0 deletions tests/crashes/138266.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//@ known-bug: #138266
//@compile-flags: --crate-type=lib
#![feature(min_generic_const_args)]
#![feature(inherent_associated_types)]
pub fn f(mut x: [u8; Box::b]) {
x[72] = 1;
}
8 changes: 8 additions & 0 deletions tests/crashes/138359.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ known-bug: #138359
#![feature(min_generic_const_args)]
#![feature(inherent_associated_types)]
struct a(Box<[u8; Box::b]>);
impl a {
fn c(self) { self.0.da }
}
fn main() {}
6 changes: 6 additions & 0 deletions tests/crashes/138361.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@ known-bug: #138361

fn main() {
[0; loop{}];
std::mem::transmute(4)
}
7 changes: 7 additions & 0 deletions tests/crashes/138510.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//@ known-bug: #138510
fn main()
where
#[repr()]
_: Sized,
{
}
6 changes: 6 additions & 0 deletions tests/crashes/138534.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@ known-bug: #138534
//@compile-flags: -Zunpretty=expanded
#[repr(bool)]
pub enum TopFg {
Bar,
}
26 changes: 26 additions & 0 deletions tests/crashes/138564.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//@ known-bug: #138564
//@compile-flags: -Copt-level=0 -Cdebuginfo=2 --crate-type lib
#![feature(unsize, dispatch_from_dyn, arbitrary_self_types)]

use std::marker::Unsize;
use std::ops::{Deref, DispatchFromDyn};

#[repr(align(16))]
pub struct MyPointer<T: ?Sized>(*const T);

impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<MyPointer<U>> for MyPointer<T> {}
impl<T: ?Sized> Deref for MyPointer<T> {
type Target = T;
fn deref(&self) -> &T {
unimplemented!()
}
}

pub trait Trait {
fn foo(self: MyPointer<Self>) {}
}

// make sure some usage of `<dyn Trait>::foo` makes it to codegen
pub fn user() -> *const () {
<dyn Trait>::foo as *const ()
}
37 changes: 37 additions & 0 deletions tests/crashes/138707.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//@ known-bug: #138707
//@edition:2024
//@compile-flags: --crate-type lib
use core::marker::PhantomData;

struct LeftReflector<S> {
_phantom: PhantomData<S>,
}

struct DefaultAllocator {}

trait Allocator<R> {
type Buffer;
}

struct U2 {}

impl Allocator<U2> for DefaultAllocator {
type Buffer = [u8; 2];
}

impl<R> From<R> for LeftReflector<<DefaultAllocator as Allocator<R>>::Buffer>
where
DefaultAllocator: Allocator<R>,
{
fn from(_: R) -> Self {
todo!()
}
}

fn ice<D>(a: U2)
where
DefaultAllocator: Allocator<D>,
{
// ICE
let _ = LeftReflector::from(a);
}
7 changes: 7 additions & 0 deletions tests/crashes/138738.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//@ known-bug: #138738
//@ only-x86_64

#![feature(abi_ptx)]
fn main() {
let a = unsafe { core::mem::transmute::<usize, extern "ptx-kernel" fn(i32)>(4) }(2);
}
2 changes: 2 additions & 0 deletions tests/crashes/139089.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//@ known-bug: #139089
pub fn foo3(x: &Vec<u8>) { x.push(0); }
29 changes: 29 additions & 0 deletions tests/crashes/139120.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//@ known-bug: #139120



pub trait Foo {
type Bar<'a>;
}

pub struct FooImpl {}

impl Foo for FooImpl {
type Bar<'a> = ();
}

pub trait FooFn {
fn bar(&self);
}

impl<T: Foo> FooFn for fn(T, T::Bar<'_>) {
fn bar(&self) {}
}

fn foo<T: Foo>(f: fn(T, T::Bar<'_>)) {
let _: &dyn FooFn = &f;
}

fn main() {
foo(|_: FooImpl, _| {});
}
13 changes: 13 additions & 0 deletions tests/crashes/139381.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@ known-bug: #139381
//@ needs-rustc-debug-assertions
trait A<'a> {
type Assoc: ?Sized;
}

impl<'a> A<'a> for () {
type Assoc = &'a ();
}

fn hello() -> impl for<'a> A<'a, Assoc: Into<u8> + 'static + Copy> {
()
}
15 changes: 15 additions & 0 deletions tests/crashes/139387.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ known-bug: #139387
//@ needs-rustc-debug-assertions

trait A {
fn method() -> impl Sized;
}
trait B {
fn method(Hash: Wrap<impl Beta<U: Copy + for<'a> Epsilon<'_, SI1: Eta>>>) -> impl Sized;
}

fn ambiguous<T: A + B>()
where
T::method(..): Send,
{
}
12 changes: 12 additions & 0 deletions tests/crashes/139409.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ known-bug: #139409
//@ compile-flags: -Znext-solver=globally

fn main() {
trait B<C> {}
impl<C> B<C> for () {}
trait D<C, E>: B<C> + B<E> {
fn f(&self) {}
}
impl<C, E> D<C, E> for () {}
(&() as &dyn D<&(), &()>).f()
}
8 changes: 8 additions & 0 deletions tests/crashes/139462.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ known-bug: #139462
//@ compile-flags: -Cdebuginfo=2
#![feature(unsafe_binders)]
use std::unsafe_binder::wrap_binder;
fn main() {
let foo = 0;
let foo: unsafe<'a> &'a u32 = unsafe { wrap_binder!(&foo) };
}
13 changes: 13 additions & 0 deletions tests/crashes/139556.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@ known-bug: #139556

trait T {}

type Alias<'a> = impl T;

struct S;
impl<'a> T for &'a S {}

#[define_opaque(Alias)]
fn with_positive(fun: impl Fn(Alias<'_>)) {
with_positive(|&n| ());
}
4 changes: 4 additions & 0 deletions tests/crashes/139570.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//@ known-bug: #139570
fn main() {
|(1, 42), ()| yield;
}
10 changes: 10 additions & 0 deletions tests/crashes/139596.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//@ known-bug: #139596

#![feature(min_generic_const_args)]
struct Colour;

struct Led<const C: Colour>;

fn main() {
Led::<{ Colour}>;
}
29 changes: 29 additions & 0 deletions tests/crashes/139659.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//@ known-bug: #139659
//@compile-flags: -Cdebuginfo=2 -Copt-level=0 --crate-type lib
trait Trait {
type Output;
}

impl<O, F: Fn() -> O> Trait for F {
type Output = O;
}

struct Wrap<P>(P);
struct WrapOutput<O>(O);

impl<P: Trait> Trait for Wrap<P> {
type Output = WrapOutput<P::Output>;
}

fn wrap<P: Trait>(x: P) -> impl Trait {
Wrap(x)
}

fn consume<P: Trait>(_: P) -> P::Output {
unimplemented!()
}

pub fn recurse() -> impl Sized {
consume(wrap(recurse))
}
pub fn main() {}
3 changes: 3 additions & 0 deletions tests/crashes/139738.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//@ known-bug: #139738
#![feature(generic_const_exprs)]
fn b<'a>() -> impl IntoIterator<[(); (|_: &'a u8| 0, 0).1]> {}
14 changes: 14 additions & 0 deletions tests/crashes/139815.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ known-bug: #139815

#![feature(generic_const_exprs)]
fn is_123<const N: usize>(
x: [u32; {
N + 1;
5
}],
) -> bool {
match x {
[1, 2] => true,
_ => false,
}
}
8 changes: 8 additions & 0 deletions tests/crashes/139817.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ known-bug: #139817
fn enum_upvar() {
type T = impl Copy;
let foo: T = Some((42, std::marker::PhantomData::<T>));
let x = move || match foo {
None => (),
};
}
5 changes: 5 additions & 0 deletions tests/crashes/139825.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//@ known-bug: #139825
//@compile-flags: --check-cfg=cfg(docsrs,test) --crate-type lib
struct a
where
for<#[cfg(b)] c> u8:;
11 changes: 11 additions & 0 deletions tests/crashes/139872.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ known-bug: #139872
//@ only-x86_64
pub fn main() {
enum A {
B(u32),
}
static C: (A, u16, str);
fn d() {
let (_, e, _) = C;
}
}
Loading