crashes: couple more tests

This commit is contained in:
Matthias Krüger 2025-03-07 23:17:25 +01:00
parent 07292ccccd
commit 088b125853
47 changed files with 569 additions and 0 deletions

7
tests/crashes/136138.rs Normal file
View file

@ -0,0 +1,7 @@
//@ known-bug: #136138
#![feature(min_generic_const_args)]
struct U;
struct S<const N: U>()
where
S<{ U }>:;
fn main() {}

13
tests/crashes/136175-2.rs Normal file
View file

@ -0,0 +1,13 @@
//@ known-bug: #136175
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Trait {}
struct A<T>(T)
where
[(); std::mem::offset_of!((T,), 0)]:;
fn main() {
let x: A<dyn Trait>;
}

13
tests/crashes/136175.rs Normal file
View file

@ -0,0 +1,13 @@
//@ known-bug: #136175
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Trait {}
struct A<T>(T)
where
[(); size_of::<T>()]:;
fn main() {
let x: A<dyn Trait>;
}

9
tests/crashes/136188.rs Normal file
View file

@ -0,0 +1,9 @@
//@ known-bug: #136188
//@ compile-flags: --crate-type=lib -Znext-solver
#![feature(type_alias_impl_trait)]
type Opaque = Box<impl Sized>;
fn define() -> Opaque { Box::new(()) }
impl Copy for Opaque {}

7
tests/crashes/136286.rs Normal file
View file

@ -0,0 +1,7 @@
//@ known-bug: #136286
//@ compile-flags: --edition=2024
#![feature(async_fn_in_dyn_trait)]
trait A {
async fn b(self: A);
}

11
tests/crashes/136379.rs Normal file
View file

@ -0,0 +1,11 @@
//@ known-bug: #136379
#![feature(min_generic_const_args)]
pub struct S();
impl S {
pub fn f() -> [u8; S] {
[]
}
}
pub fn main() {}

18
tests/crashes/136381.rs Normal file
View file

@ -0,0 +1,18 @@
//@ known-bug: #136381
//@ compile-flags: -Zvalidate-mir -Zmir-enable-passes=+GVN
#![feature(trait_upcasting)]
trait A {}
trait B: A {
fn c(&self);
}
impl B for i32 {
fn c(self) {
todo!();
}
}
fn main() {
let baz: &dyn B = &1;
let bar: &dyn A = baz;
}

6
tests/crashes/136416.rs Normal file
View file

@ -0,0 +1,6 @@
//@ known-bug: #136416
#![feature(generic_const_exprs)]
struct State<const S : usize = {}> where[(); S] :;
struct Foo;
struct State2<const S: usize = Foo> where [(); S]:;

9
tests/crashes/136442.rs Normal file
View file

@ -0,0 +1,9 @@
//@ known-bug: #136442
//@ compile-flags: -Copt-level=0 -Zmir-enable-passes=+Inline -Zmir-enable-passes=+JumpThreading --crate-type lib
pub fn problem_thingy(items: &mut impl Iterator<Item = str>) {
let mut peeker = items.peekable();
match peeker.peek() {
Some(_) => (),
None => return (),
}
}

25
tests/crashes/136661.rs Normal file
View file

@ -0,0 +1,25 @@
//@ known-bug: #136661
#![allow(unused)]
trait Supertrait<T> {}
trait Other {
fn method(&self) {}
}
impl WithAssoc for &'static () {
type As = ();
}
trait WithAssoc {
type As;
}
trait Trait<P: WithAssoc>: Supertrait<P::As> {
fn method(&self) {}
}
fn hrtb<T: for<'a> Trait<&'a ()>>() {}
pub fn main() {}

36
tests/crashes/136666.rs Normal file
View file

@ -0,0 +1,36 @@
//@ known-bug: #136666
// Needed so that rust can infer that the A in what() is &()
trait IsRef<T> {}
struct Dummy;
impl<'a> IsRef<&'a ()> for Dummy {}
trait WithLifetime {
type Output<'a>;
}
impl<'t> WithLifetime for &'t () {
type Output<'a> = &'a ();
}
// Needed to prevent the two Foo impls from overlapping
struct Wrap<A>(A);
trait Unimplemented {}
trait Foo {}
impl<T> Foo for T where T: Unimplemented {}
impl<A> Foo for Wrap<A>
where
Dummy: IsRef<A>,
for<'a> A: WithLifetime<Output<'a> = A>,
{
}
fn what<A>()
where
Wrap<A>: Foo,
{
}
fn main() {
what();
}

18
tests/crashes/136678.rs Normal file
View file

@ -0,0 +1,18 @@
//@ known-bug: #136678
#![feature(inherent_associated_types)]
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
struct B<const A: usize>;
struct Test<const A: usize>;
impl<const A: usize> Test<A> {
type B = B<{ A }>;
fn test(a: Self::B) -> Self::B {
a
}
}
pub fn main() {}

6
tests/crashes/136766.rs Normal file
View file

@ -0,0 +1,6 @@
//@ known-bug: #136766
#![feature(generic_const_exprs)]
trait A<const B: bool>{}
impl A<true> for () {}
fn c<const D: usize>(E: [u8; D * D]) where() : A<D>{}
fn main() { c }

27
tests/crashes/136859.rs Normal file
View file

@ -0,0 +1,27 @@
//@ known-bug: #136859
#![feature(generic_const_exprs)]
trait If<const COND: bool> {}
impl If<true> for () {}
trait IsZero<const N: u8> {
type Answer;
}
struct True;
struct False;
impl<const N: u8> IsZero<N> for ()
where (): If<{N == 0}> {
type Msg = True;
}
trait Foobar<const N: u8> {}
impl<const N: u8> Foobar<N> for ()
where (): IsZero<N, Answer = True> {}
impl<const N: u8> Foobar<{{ N }}> for ()
where (): IsZero<N, Answer = False> {}
fn main() {}

8
tests/crashes/136894.rs Normal file
View file

@ -0,0 +1,8 @@
//@ known-bug: #136894
#![feature(generic_const_exprs)]
#![crate_type = "lib"]
#![allow(incomplete_features, dead_code)]
struct X<T>([(); f::<T>()]) where [(); f::<T>()]:;
const fn f<T>() -> usize { panic!() }

29
tests/crashes/137049.rs Normal file
View file

@ -0,0 +1,29 @@
//@ known-bug: #137049
//@ compile-flags: --crate-type=lib
#![feature(type_alias_impl_trait)]
use std::marker::PhantomData;
trait Project1 {
type Assoc1;
}
impl<T> Project1 for T {
type Assoc1 = ();
}
trait Project2 {
type Assoc2;
}
impl<T: Project1<Assoc1 = ()>> Project2 for PhantomData<T> {
type Assoc2 = ();
}
type Alias<T> = impl Project2;
fn constrain<T>() -> Alias<T> {
PhantomData::<T>
}
struct AdtConstructor<T: Project1>(<Alias<T> as Project2>::Assoc2);

6
tests/crashes/137084.rs Normal file
View file

@ -0,0 +1,6 @@
//@ known-bug: #137084
#![feature(min_generic_const_args)]
fn a<const b: i32>() {}
fn d(e: &String) {
a::<d>
}

9
tests/crashes/137187.rs Normal file
View file

@ -0,0 +1,9 @@
//@ known-bug: #137187
use std::ops::Add;
trait A where
*const Self: Add,
{
const fn b(c: *const Self) -> <*const Self as Add>::Output {
c + c
}
}

6
tests/crashes/137188.rs Normal file
View file

@ -0,0 +1,6 @@
//@ known-bug: #137188
#![feature(min_generic_const_args)]
trait Trait {}
impl Trait for [(); N] {}
fn N<T>() {}
pub fn main() {}

10
tests/crashes/137190-1.rs Normal file
View file

@ -0,0 +1,10 @@
//@ known-bug: #137190
//@ compile-flags: -Zmir-opt-level=2 -Zvalidate-mir
trait A {
fn b(&self);
}
trait C: A {}
impl C for () {}
fn main() {
(&() as &dyn C as &dyn A).b();
}

18
tests/crashes/137190-2.rs Normal file
View file

@ -0,0 +1,18 @@
//@ known-bug: #137190
trait Supertrait<T> {
fn method(&self) {}
}
trait Trait<P>: Supertrait<()> {}
impl<P> Trait<P> for () {}
const fn upcast<P>(x: &dyn Trait<P>) -> &dyn Supertrait<()> {
x
}
const fn foo() -> &'static dyn Supertrait<()> {
upcast::<()>(&())
}
const _: &'static dyn Supertrait<()> = foo();

10
tests/crashes/137190-3.rs Normal file
View file

@ -0,0 +1,10 @@
//@ known-bug: #137190
trait Supertrait {
fn method(&self) {}
}
trait Trait: Supertrait {}
impl Trait for () {}
const _: &dyn Supertrait = &() as &dyn Trait as &dyn Supertrait;

11
tests/crashes/137260.rs Normal file
View file

@ -0,0 +1,11 @@
//@ known-bug: #137260
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Iter<const N: usize = { 1 + true }> {}
fn needs_iter<const N: usize, T: Iter<N>>() {}
fn test() {
needs_iter::<1, dyn Iter<()>>();
}

29
tests/crashes/137287.rs Normal file
View file

@ -0,0 +1,29 @@
//@ known-bug: #137287
mod defining_scope {
use super::*;
pub type Alias<T> = impl Sized;
pub fn cast<T>(x: Container<Alias<T>, T>) -> Container<T, T> {
x
}
}
struct Container<T: Trait<U>, U> {
x: <T as Trait<U>>::Assoc,
}
trait Trait<T> {
type Assoc;
}
impl<T> Trait<T> for T {
type Assoc = Box<u32>;
}
impl<T> Trait<T> for defining_scope::Alias<T> {
type Assoc = usize;
}
fn main() {
let x: Box<u32> = defining_scope::cast::<()>(Container { x: 0 }).x;
}

17
tests/crashes/137467-1.rs Normal file
View file

@ -0,0 +1,17 @@
//@ known-bug: #137467
//@ compile-flags: --edition=2021
enum Camera {
Normal { base_transform: i32 },
Volume { transform: i32 },
}
fn draw_ui(camera: &mut Camera) {
|| {
let (Camera::Normal {
base_transform: _transform,
}
| Camera::Volume {
transform: _transform,
}) = camera;
};
}

18
tests/crashes/137467-2.rs Normal file
View file

@ -0,0 +1,18 @@
//@ known-bug: #137467
//@ compile-flags: --edition=2021
enum Camera {
Normal { base_transform: i32 },
Volume { transform: i32 },
}
fn draw_ui(camera: &mut Camera) {
|| {
let (Camera::Normal {
base_transform: _,
}
| Camera::Volume {
transform: _,
}) = camera;
};
}

View file

@ -0,0 +1,8 @@
//@ known-bug: #137467
//@ compile-flags: --edition=2021
fn meow(x: (u32, u32, u32)) {
let f = || {
let ((0, a, _) | (_, _, a)) = x;
};
}

16
tests/crashes/137468.rs Normal file
View file

@ -0,0 +1,16 @@
//@ known-bug: #137468
//@ compile-flags: -Copt-level=0 -Zmir-enable-passes=+GVN -Zvalidate-mir
trait Supertrait<T> {}
trait Identity {
type Selff;
}
trait Trait<P>: Supertrait<()> + Supertrait<<P as Identity>::Selff> {}
impl<P> Trait<P> for () {}
fn main() {
let x: &dyn Trait<()> = &();
let x: &dyn Supertrait<()> = x;
}

9
tests/crashes/137514.rs Normal file
View file

@ -0,0 +1,9 @@
//@ known-bug: #137514
//@ needs-rustc-debug-assertions
#![feature(generic_const_exprs)]
trait Bar<const N: usize> {}
trait BB = Bar<{ 1i32 + 1 }>;
fn foo(x: &dyn BB) {}

4
tests/crashes/137580.rs Normal file
View file

@ -0,0 +1,4 @@
//@ known-bug: #137580
fn main() {
println!("%65536$", 1);
}

16
tests/crashes/137582.rs Normal file
View file

@ -0,0 +1,16 @@
//@ known-bug: #137582
#![feature(adt_const_params)]
mod lib {
pub type Matrix = [&'static u32];
const EMPTY_MATRIX: Matrix = [[0; 4]; 4];
pub struct Walk<const CURRENT: usize, const REMAINING: Matrix> {
_p: (),
}
impl<const CURRENT: usize> Walk<CURRENT, EMPTY_MATRIX> {}
}
fn main() {}

7
tests/crashes/137706.rs Normal file
View file

@ -0,0 +1,7 @@
//@ known-bug: #137706
//@ needs-rustc-debug-assertions
trait A {
fn b() -> impl IntoIterator<Item = ()>;
}
impl A<()> for dyn A {}

6
tests/crashes/137751.rs Normal file
View file

@ -0,0 +1,6 @@
//@ known-bug: #137751
//@ compile-flags: --edition=2021 -Znext-solver=globally
async fn test() {
Box::pin(test()).await;
}
fn main() {}

18
tests/crashes/137813.rs Normal file
View file

@ -0,0 +1,18 @@
//@ known-bug: #137813
trait AssocConst {
const A: u8;
}
impl<T> AssocConst for (T,) {
const A: u8 = 0;
}
trait Trait {}
impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {}
fn foo()
where
(): Trait,
{
}

5
tests/crashes/137865.rs Normal file
View file

@ -0,0 +1,5 @@
//@ known-bug: #137865
trait Foo {
type Assoc<const N: Self>;
fn foo() -> Self::Assoc<3>;
}

4
tests/crashes/137874.rs Normal file
View file

@ -0,0 +1,4 @@
//@ known-bug: #137874
fn a() {
match b { deref !(0c) };
}

11
tests/crashes/137888.rs Normal file
View file

@ -0,0 +1,11 @@
//@ known-bug: #137888
#![feature(generic_const_exprs)]
macro_rules! empty {
() => ();
}
fn bar<const N: i32>() -> [(); {
empty! {};
N
}] {
}
fn main() {}

6
tests/crashes/137895.rs Normal file
View file

@ -0,0 +1,6 @@
//@ known-bug: #137895
trait A {
fn b() -> impl ?Sized + 'a;
}
impl A for dyn A {}

13
tests/crashes/137916.rs Normal file
View file

@ -0,0 +1,13 @@
//@ known-bug: #137916
//@ compile-flags: --edition=2021
use std::ptr::null;
async fn a() -> Box<dyn Send> {
Box::new(async {
let non_send = null::<()>();
&non_send;
async {}.await
})
}
fn main() {}

8
tests/crashes/138008.rs Normal file
View file

@ -0,0 +1,8 @@
//@ known-bug: #138008
//@compile-flags: --crate-type=lib -Copt-level=0
#![feature(repr_simd)]
const C: usize = 16;
#[repr(simd)]
pub struct Foo([u8; C]);
pub unsafe fn foo(a: Foo) {}

6
tests/crashes/138009.rs Normal file
View file

@ -0,0 +1,6 @@
//@ known-bug: #138009
#![feature(min_generic_const_args)]
#[repr(simd)]
struct T([isize; N]);
static X: T = T();

8
tests/crashes/138048.rs Normal file
View file

@ -0,0 +1,8 @@
//@ known-bug: #138048
struct Foo;
impl<'b> Foo {
fn bar<const V: u8>() {
let V;
}
}

5
tests/crashes/138088.rs Normal file
View file

@ -0,0 +1,5 @@
//@ known-bug: #138088
#![feature(min_generic_const_args)]
trait Bar {
fn x(&self) -> [i32; Bar::x];
}

13
tests/crashes/138089.rs Normal file
View file

@ -0,0 +1,13 @@
//@ known-bug: #138089
#![feature(generic_const_exprs)]
#![feature(min_generic_const_args)]
#![feature(inherent_associated_types)]
struct OnDiskDirEntry<'a> {}
impl<'a> OnDiskDirEntry<'a> {
const LFN_FRAGMENT_LEN: i64 = 2;
fn lfn_contents() -> [char; Self::LFN_FRAGMENT_LEN] {
loop {}
}
}

12
tests/crashes/138131.rs Normal file
View file

@ -0,0 +1,12 @@
//@ known-bug: #138131
#![feature(min_generic_const_args)]
#![feature(inherent_associated_types)]
struct Foo<'a> {
x: &'a (),
}
impl<'a> Foo<'a> {
fn foo(_: [u8; Foo::X]) {}
}
fn main() {}

10
tests/crashes/138132.rs Normal file
View file

@ -0,0 +1,10 @@
//@ known-bug: #138132
#![feature(min_generic_const_args)]
struct b(Box<[u8; c]>);
impl b {
fn d(self) {
self.0.e()
}
}
struct c<'a>(&'a u8);
fn main() {}

8
tests/crashes/138166.rs Normal file
View file

@ -0,0 +1,8 @@
//@ known-bug: #138166
#![feature(min_generic_const_args)]
#![feature(inherent_associated_types)]
struct a(Box<[u8; Box::b]>);
impl a {
fn c(self) { self.0.d() }
}
fn main() {}