tests/crashes: add ICEs from matthiaskrgr/glacier2

This commit is contained in:
Matthias Krüger 2024-03-30 00:21:25 +01:00
parent 98dd566033
commit 7d826ae43e
133 changed files with 2620 additions and 39 deletions

14
tests/crashes/101036.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #101036
#![feature(generic_const_exprs)]
const fn t<const N: usize>() -> u8 {
N as u8
}
#[repr(u8)]
enum T<const N: u8 = { T::<0>::A as u8 + T::<0>::B as u8 }>
where
[(); N as usize]:
{
A = t::<N>() as u8, B
}

41
tests/crashes/101557.rs Normal file
View File

@ -0,0 +1,41 @@
//@ known-bug: #101557
#![feature(generic_const_exprs)]
use std::marker::PhantomData;
trait Trait {
const CONST: usize;
}
struct A<T: Trait> {
_marker: PhantomData<T>,
}
impl<const N: usize> Trait for [i8; N] {
const CONST: usize = N;
}
impl<const N: usize> From<usize> for A<[i8; N]> {
fn from(_: usize) -> Self {
todo!()
}
}
impl<T: Trait> From<A<[i8; T::CONST]>> for A<T> {
fn from(_: A<[i8; T::CONST]>) -> Self {
todo!()
}
}
fn f<T: Trait>() -> A<T>
where
[(); T::CONST]:,
{
// Usage of `0` is arbitrary
let a = A::<[i8; T::CONST]>::from(0);
A::<T>::from(a)
}
fn main() {
// Usage of `1` is arbitrary
f::<[i8; 1]>();
}

27
tests/crashes/105275.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #105275
//@ compile-flags: -Copt-level=0
pub fn encode_num<Writer: ExampleWriter>(n: u32, mut writer: Writer) -> Result<(), Writer::Error> {
if n > 15 {
encode_num(n / 16, &mut writer)?;
}
Ok(())
}
pub trait ExampleWriter {
type Error;
}
impl<'a, T: ExampleWriter> ExampleWriter for &'a mut T {
type Error = T::Error;
}
struct Error;
impl ExampleWriter for Error {
type Error = ();
}
fn main() {
encode_num(69, &mut Error).unwrap();
}

View File

@ -1,39 +0,0 @@
//@ known-bug: #105488
pub trait MyFnOnce {
type Output;
fn call_my_fn_once(self) -> Self::Output;
}
pub struct WrapFnOnce<F>(F);
impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for WrapFnOnce<F> {
type Output = D::Output;
fn call_my_fn_once(self) -> Self::Output {
D::call_my_fn_once(self.0())
}
}
impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for F {
type Output = D::Output;
fn call_my_fn_once(self) -> Self::Output {
D::call_my_fn_once(self())
}
}
pub fn my_fn_1() -> impl MyFnOnce {
my_fn_2
}
pub fn my_fn_2() -> impl MyFnOnce {
WrapFnOnce(my_fn_1)
}
fn main() {
let v = my_fn_1();
let _ = v.call_my_fn_once();
}

27
tests/crashes/105937.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #105937
//@ compile-flags: -Copt-level=0
pub fn encode_num<Writer: ExampleWriter>(n: u32, mut writer: Writer) -> Result<(), Writer::Error> {
if n > 15 {
encode_num(n / 16, &mut writer)?;
}
Ok(())
}
pub trait ExampleWriter {
type Error;
}
impl<'a, T: ExampleWriter> ExampleWriter for &'a mut T {
type Error = T::Error;
}
struct Error;
impl ExampleWriter for Error {
type Error = ();
}
fn main() {
encode_num(69, &mut Error).unwrap();
}

12
tests/crashes/106473.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #106473
#![feature(generic_const_exprs)]
const DEFAULT: u32 = 1;
struct V<const U: usize = DEFAULT>
where
[(); U]:;
trait Tr {}
impl Tr for V {}

44
tests/crashes/110534.rs Normal file
View File

@ -0,0 +1,44 @@
//@ known-bug: #110534
//@ edition:2021
use core::cell::Ref;
struct System;
trait IntoSystem {
fn into_system(self) -> System;
}
impl IntoSystem for fn(Ref<'_, u32>) {
fn into_system(self) -> System { System }
}
impl<A> IntoSystem for fn(A)
where
// n.b. No `Ref<'_, u32>` can satisfy this bound
A: 'static + for<'x> MaybeBorrowed<'x, Output = A>,
{
fn into_system(self) -> System { System }
}
//---------------------------------------------------
trait MaybeBorrowed<'a> {
type Output: 'a;
}
// If you comment this out you'll see the compiler chose to look at the
// fn(A) implementation of IntoSystem above
impl<'a, 'b> MaybeBorrowed<'a> for Ref<'b, u32> {
type Output = Ref<'a, u32>;
}
// ---------------------------------------------
fn main() {
fn sys_ref(_age: Ref<u32>) {}
let _sys_c = (sys_ref as fn(_)).into_system();
// properly fails
// let _sys_c = (sys_ref as fn(Ref<'static, u32>)).into_system();
// properly succeeds
// let _sys_c = (sys_ref as fn(Ref<'_, u32>)).into_system();
}

8
tests/crashes/110627.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: #110627
#![feature(non_lifetime_binders)]
fn take(id: impl for<T> Fn(T) -> T) {}
fn main() {
take(|x| x)
}

14
tests/crashes/111419.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #111419
#![allow(incomplete_features)]
#![feature(generic_const_exprs, generic_arg_infer)]
pub trait Example<const X: usize, const Y: usize, const Z: usize = { X + Y }>
where
[(); X + Y]:,
{}
impl<const X: usize, const Y: usize> Example<X, Y> for Value {}
pub struct Value;
fn main() {}

12
tests/crashes/111699.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #111699
#![feature(core_intrinsics)]
use std::intrinsics::offset;
fn main() {
let a = [1u8, 2, 3];
let ptr: *const u8 = a.as_ptr();
unsafe {
assert_eq!(*offset(ptr, 0), 1);
}
}

15
tests/crashes/111709-2.rs Normal file
View File

@ -0,0 +1,15 @@
//@ known-bug: #111709
//@ edition: 2021
use core::arch::asm;
extern "C" fn test<T>() {}
fn uwu() {
unsafe {
asm!(
"/* {0} */",
sym test::<&mut ()>
);
}
}

25
tests/crashes/111709.rs Normal file
View File

@ -0,0 +1,25 @@
//@ known-bug: #111709
//@ edition:2021
use core::arch::asm;
struct TrapFrame;
unsafe extern "C" fn _rust_abi_shim1<A, R>(arg: A, f: fn(A) -> R) -> R {
f(arg)
}
unsafe extern "C" fn _start_trap() {
extern "Rust" {
fn interrupt(tf: &mut TrapFrame);
}
asm!(
"
la a1, {irq}
call {shim}
",
shim = sym crate::_rust_abi_shim1::<&mut TrapFrame, ()>,
irq = sym interrupt,
options(noreturn)
)
}

40
tests/crashes/111883.rs Normal file
View File

@ -0,0 +1,40 @@
//@ known-bug: #111883
#![crate_type = "lib"]
#![feature(arbitrary_self_types, no_core, lang_items)]
#![no_core]
#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}
#[lang = "receiver"]
trait Receiver {}
#[lang = "dispatch_from_dyn"]
trait DispatchFromDyn<T> {}
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
#[lang = "unsize"]
trait Unsize<T: ?Sized> {}
#[lang = "coerce_unsized"]
pub trait CoerceUnsized<T: ?Sized> {}
impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
#[lang = "drop_in_place"]
fn drop_in_place_fn<T>(a: &dyn Trait2<T>) {}
pub trait Trait1 {
fn foo(&self);
}
pub struct Type1;
impl Trait1 for Type1 {
fn foo(&self) {}
}
pub trait Trait2<T> {}
pub fn bar1() {
let a = Type1;
let b = &a as &dyn Trait1;
b.foo();
}

16
tests/crashes/113272.rs Normal file
View File

@ -0,0 +1,16 @@
//@ known-bug: #113272
trait Trait {
type RefTarget;
}
impl Trait for () where Missing: Trait {}
struct Other {
data: <() as Trait>::RefTarget,
}
fn main() {
unsafe {
std::mem::transmute::<Option<()>, Option<&Other>>(None);
}
}

32
tests/crashes/113846.rs Normal file
View File

@ -0,0 +1,32 @@
//@ known-bug: #113846
trait Www {
type W;
}
trait Xxx: Www<W = Self::X> {
type X;
}
trait Yyy: Xxx {}
trait Zzz<'a>: Yyy + Xxx<X = Self::Z> {
type Z;
}
trait Aaa {
type Y: Yyy;
}
trait Bbb: Aaa<Y = Self::B> {
type B: for<'a> Zzz<'a>;
}
impl<T> Bbb for T
where
T: Aaa,
T::Y: for<'a> Zzz<'a>,
{
type B = T::Y;
}
pub fn main() {}

16
tests/crashes/114212-2.rs Normal file
View File

@ -0,0 +1,16 @@
//@ known-bug: #114212
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
const SOME_CONST: usize = 1;
struct UwU<
// have a const generic with a default that's from another const item
// (associated consts work, a const declared in a block here, inline_const, etc)
const N: usize = SOME_CONST,
// use the previous const in a type generic
A = [(); N],
> {
// here to suppress "unused generic" error if the code stops ICEing
_x: core::marker::PhantomData<A>,
}

34
tests/crashes/114212.rs Normal file
View File

@ -0,0 +1,34 @@
//@ known-bug: #114212
#![feature(generic_const_exprs)]
use core::marker::PhantomData;
pub const DEFAULT_MAX_INPUT_LEN: usize = 256;
pub trait FooTrait {}
pub struct Foo<const MAX_INPUT_LEN: usize>;
impl<const MAX_INPUT_LEN: usize> FooTrait for Foo<MAX_INPUT_LEN> {}
pub struct Bar<
const MAX_INPUT_LEN: usize = DEFAULT_MAX_INPUT_LEN,
PB = Foo<MAX_INPUT_LEN>,
>
where
PB: FooTrait,
{
_pb: PhantomData<PB>,
}
impl<const MAX_INPUT_LEN: usize, PB> Bar<MAX_INPUT_LEN, PB>
where
PB: FooTrait,
{
pub fn new() -> Self {
Self {
_pb: PhantomData,
}
}
}

6
tests/crashes/114317.rs Normal file
View File

@ -0,0 +1,6 @@
//@ known-bug: #114317
#![feature(generic_const_exprs)]
struct A<const B: str = 1, C>;
fn main() {}

20
tests/crashes/114456-2.rs Normal file
View File

@ -0,0 +1,20 @@
//@ known-bug: #114456
#![feature(adt_const_params)]
const EMPTY_MATRIX: <Type as Trait>::Matrix = [0; 1];
pub struct Walk<const REMAINING: <Type as Trait>::Matrix> {}
impl Walk<EMPTY_MATRIX> {
pub const fn new() -> Self {
Self {}
}
}
pub enum Type {}
pub trait Trait { type Matrix; }
impl Trait for Type { type Matrix = [usize; 1]; }
fn main() {
let _ = Walk::new();
}

17
tests/crashes/114456.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: #114456
#![feature(adt_const_params, lazy_type_alias)]
pub type Matrix = [usize; 1];
const EMPTY_MATRIX: Matrix = [0; 1];
pub struct Walk<const REMAINING: Matrix> {}
impl Walk<EMPTY_MATRIX> {
pub const fn new() -> Self {
Self {}
}
}
fn main() {
let _ = Walk::new();
}

67
tests/crashes/114484.rs Normal file
View File

@ -0,0 +1,67 @@
//@ known-bug: #114484
use std::marker::PhantomData;
trait MyTrait {
fn virtualize(&self) -> &dyn MyTrait;
}
struct VirtualWrapper<T, const L: u8>(T);
impl<T, const L: u8> VirtualWrapper<T, L> {
pub fn wrap(value: &T) -> &Self {
unsafe { &*(value as *const T as *const Self) }
}
}
impl<T: MyTrait + 'static, const L: u8> MyTrait for VirtualWrapper<T, L> {
fn virtualize(&self) -> &dyn MyTrait {
unsafe { virtualize_my_trait(L, self) }
// unsafe { virtualize_my_trait(L, &self.0) } // <-- this code fixes the problem
}
}
const unsafe fn virtualize_my_trait<T>(level: u8, obj: &T) -> &dyn MyTrait
where
T: MyTrait + 'static,
{
const fn gen_vtable_ptr<T, const L: u8>() -> *const ()
where
T: MyTrait + 'static,
{
let [_, vtable] = unsafe {
std::mem::transmute::<*const dyn MyTrait, [*const (); 2]>(std::ptr::null::<
VirtualWrapper<T, L>,
>())
};
vtable
}
struct Vtable<T>(PhantomData<T>);
impl<T> Vtable<T>
where
T: MyTrait + 'static,
{
const LEVELS: [*const (); 2] = [gen_vtable_ptr::<T, 1>(), gen_vtable_ptr::<T, 2>()];
}
let vtable = Vtable::<T>::LEVELS[(level != 0) as usize];
let data = obj as *const T as *const ();
let ptr: *const dyn MyTrait = std::mem::transmute([data, vtable]);
&*ptr
}
struct SomeData<const N: usize>([u8; N]);
impl<const N: usize> MyTrait for SomeData<N> {
fn virtualize(&self) -> &dyn MyTrait {
VirtualWrapper::<Self, 0>::wrap(self)
}
}
fn main() {
let test = SomeData([0; 256]);
test.virtualize();
}

17
tests/crashes/114663.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: #114663
//@ edition:2021
#![feature(generic_const_exprs)]
use core::fmt::Debug;
struct Inline<T>
where
[u8; ::core::mem::size_of::<T>() + 1]:,
{
_phantom: PhantomData<T>,
}
fn main() {
let dst = Inline::<dyn Debug>::new(0); // BANG!
}

23
tests/crashes/115435.rs Normal file
View File

@ -0,0 +1,23 @@
//@ known-bug: #115435
trait MyTrait {
type Target: ?Sized;
}
impl<A: ?Sized> MyTrait for A {
type Target = A;
}
fn main() {
bug_run::<dyn MyTrait<Target = u8>>();
}
fn bug_run<T: ?Sized>()
where
<T as MyTrait>::Target: Sized,
{
bug::<T>();
}
fn bug<T>() {
std::mem::size_of::<T>();
}

27
tests/crashes/115808.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #115808
#![feature(generic_const_exprs)]
use std::ops::Mul;
pub trait Indices<const N: usize> {
const NUM_ELEMS: usize;
}
pub trait Concat<J> {
type Output;
}
pub struct Tensor<I: Indices<N>, const N: usize>
where
[u8; I::NUM_ELEMS]: Sized, {}
impl<I: Indices<N>, J: Indices<N>, const N: usize> Mul<Tensor<J, N>> for Tensor<I, N>
where
I: Concat<FN>,
<I as Concat<J>>::Output: Indices<N>,
[u8; I::NUM_ELEMS]: Sized,
[u8; J::NUM_ELEMS]: Sized,
[u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
{
type Output = Tensor<<I as Concat<J>>::Output, N>;
}

16
tests/crashes/116308.rs Normal file
View File

@ -0,0 +1,16 @@
//@ known-bug: #116308
#![feature(adt_const_params)]
pub trait Identity {
type Identity;
}
impl<T> Identity for T {
type Identity = Self;
}
pub fn foo<const X: <i32 as Identity>::Identity>() {}
fn main() {
foo::<12>();
}

15
tests/crashes/116519-2.rs Normal file
View File

@ -0,0 +1,15 @@
//@ known-bug: #116519
#![feature(generic_const_exprs)]
trait Ret {
type R;
}
struct Cond<const PRED: bool, U, V>(std::marker::PhantomData<U>, );
struct RobinHashTable<
const MAX_LENGTH: usize,
CellIdx = <Cond<{ }, u16, u32> as Ret>::R,
> {}
impl<CellIdx> HashMapBase<CellIdx> for RobinHashTable<MAX_LENGTH, CellIdx> {}

57
tests/crashes/116519.rs Normal file
View File

@ -0,0 +1,57 @@
//@ known-bug: #116519
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
trait Ret {
type R;
}
struct Cond<const PRED: bool, U, V>(std::marker::PhantomData<U>, std::marker::PhantomData<V>);
impl<U, V> Ret for Cond<true, U, V> {
type R = U;
}
impl<U, V> Ret for Cond<false, U, V> {
type R = V;
}
struct RobinHashTable<
const MAX_LENGTH: usize,
CellIdx = <Cond<{ MAX_LENGTH < 65535 }, u16, u32> as Ret>::R,
> {
_idx: CellIdx,
}
impl<CellIdx> RobinHashTable<MAX_LENGTH, CellIdx> {
fn new() -> Self {
Self {
_idx: CellIdx { MAX_LENGTH },
}
}
}
impl<CellIdx> HashMapBase<CellIdx> {
fn new() -> Self {
Self {
_idx: CellIdx { 0 },
}
}
}
impl<CellIdx> HashMapBase<CellIdx> for RobinHashTable<MAX_LENGTH, CellIdx> {
fn hash<H: Hash + Hasher>(&self,
) -> H {
self._idx.hash()
}
fn eq(&self, other: &Self) -> bool {
self._idx.eq(other._idx)
}
}
impl<CellIdx> HashMapBase<CellIdx> for RobinHashTable<MAX_LENGTH, CellIdx> {
fn hash<H: Hash + Hasher>(&self, other: &Self) -> H {
self._idx.hash(other._idx)
}
fn eq(&self, other: &Self) -> bool {
self._idx.eq(other._idx)
}
}
#[test]
fn test_size_of_robin_hash_table() {
use std::mem::size_of;
println!("{}", size_of::<RobinHashTable<1024>>());
println!("{}", size_of::<RobinHashTable<65536>>());
}

31
tests/crashes/116554.rs Normal file
View File

@ -0,0 +1,31 @@
//@ known-bug: #116554
#![feature(generic_const_exprs)]
const fn t<const N: usize>() -> u8 {
N as u8
}
#[repr(u8)]
enum T<const N: u8 = { T::<0>::A as u8 + T::<0>::B as u8 }>
where
[(); N as usize]:,
T: ?Sized,
{
A,
}
fn main() {
A = t::<N>() as u8,
B,
}

16
tests/crashes/116947.rs Normal file
View File

@ -0,0 +1,16 @@
//@ known-bug: #116947
#![feature(min_specialization)]
trait MySpecTrait {
fn f();
}
impl<'a, T: ?Sized> MySpecTrait for T {
default fn f() {}
}
impl<'a, T: ?Sized> MySpecTrait for &'a T {
fn f() {}
}
fn main() {}

27
tests/crashes/117392-2.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #117392
pub trait BorrowComposite {
type Ref<'a>: 'a;
}
impl BorrowComposite for () {
type Ref<'a> = ();
}
pub trait Component<Args> {
type Output;
}
impl<Args> Component<Args> for () {
type Output = ();
}
pub fn delay<Args: BorrowComposite, Make: for<'a> FnMut(Args::Ref<'a>) -> C, C: Component<Args>>(
make: Make,
) -> impl Component<Args> {
}
pub fn crash() -> impl Component<()> {
delay(|()| delay(|()| ()))
}
pub fn main() {}

47
tests/crashes/117392.rs Normal file
View File

@ -0,0 +1,47 @@
//@ known-bug: #117392
pub trait BorrowComposite {
type Ref<'a>
where
Self: 'a;
}
impl BorrowComposite for () {
type Ref<'a> = ();
}
pub trait Component<Args: BorrowComposite> {
type Output;
}
impl<Args: BorrowComposite> Component<Args> for () {
type Output = ();
}
struct Delay<Make> {
_make: Make,
}
impl<
Args: BorrowComposite,
Make: for<'a> FnMut(Args::Ref<'a>) -> C,
C: Component<Args>,
> Component<Args> for Delay<Make>
{
type Output = C::Output;
}
pub fn delay<
Args: BorrowComposite,
Make: for<'a> FnMut(Args::Ref<'a>) -> C,
C: Component<Args>,
>(
make: Make,
) -> impl Component<Args, Output = C::Output> {
Delay { _make: make }
}
pub fn crash() -> impl Component<(), Output = ()> {
delay(|()| delay(|()| ()))
}
pub fn main() {}

22
tests/crashes/117496.rs Normal file
View File

@ -0,0 +1,22 @@
//@ known-bug: #117496
#![feature(adt_const_params)]
#![feature(generic_const_exprs)]
use core::marker::ConstParamTy;
#[derive(PartialEq, Copy, Clone, Eq, ConstParamTy)]
pub enum Foo {}
impl Foo {
pub const fn size(self) -> usize {
1
}
}
pub struct Bar<const F: Foo, const SIZE: usize = { F.size() }>([u64; SIZE])
where
[u64; SIZE]: Sized;
pub struct Quux<const F: Foo> {}
impl<const F: Foo> Quux<{ F }> {
pub unsafe fn nothing(&self, bar: &mut Bar<{ F }>) {}
}

11
tests/crashes/117629.rs Normal file
View File

@ -0,0 +1,11 @@
//@ known-bug: #117629
//@ edition:2021
#![feature(const_trait_impl)]
#[const_trait]
trait Tr {
async fn ft1() {}
}
fn main() {}

29
tests/crashes/117696-1.rs Normal file
View File

@ -0,0 +1,29 @@
//@ known-bug: #117696
fn main() {
let mut it = (Empty);
rec(&mut it);
}
struct Empty;
impl Iterator for Empty {
type Item = ();
fn next<'a>(&'a mut self) -> core::option::Option<()> {
None
}
}
fn identity<T>(x: T) -> T {
x
}
fn rec<T>(mut it: T)
where
T: Iterator,
{
if () == () {
T::count(it);
} else {
rec(identity(&mut it))
}
}

13
tests/crashes/117696-2.rs Normal file
View File

@ -0,0 +1,13 @@
//@ known-bug: #117696
//@ compile-flags: -Copt-level=0
fn main() {
rec(&mut None::<()>.into_iter());
}
fn rec<T: Iterator>(mut it: T) {
if true {
it.next();
} else {
rec(&mut it);
}
}

8
tests/crashes/117795.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: #117795
const fn f() -> usize {
5
}
fn main() {
let _ = [0; FnMut::call_mut(&mut f, ())];
}

14
tests/crashes/117829-2.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #117829
#![feature(auto_traits)]
trait B {}
auto trait Z<T>
where
T: Z<u16>,
<T as Z<u16>>::W: B,
{
type W;
}
fn main() {}

9
tests/crashes/117829.rs Normal file
View File

@ -0,0 +1,9 @@
//@ known-bug: #117829
auto trait Z<'a, T: ?Sized>
where
T: Z<'a, u16>,
for<'b> <T as Z<'b, u16>>::W: Clone,
{
type W: ?Sized;
}

7
tests/crashes/117942.rs Normal file
View File

@ -0,0 +1,7 @@
//@ known-bug: #117942
struct Foo {
_: union {
#[rustfmt::skip]
f: String
},
}

12
tests/crashes/118038.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #118038
#![feature(non_lifetime_binders)]
fn trivial<A>()
where
for<B> dyn Fn(A, *const A): Fn(A, *const B),
{
}
fn main() {
trivial::<u8>();
}

13
tests/crashes/118320.rs Normal file
View File

@ -0,0 +1,13 @@
//@ known-bug: #118320
#![feature(const_trait_impl, effects, const_closures)]
#[const_trait]
trait Bar {
fn foo(&self);
}
impl Bar for () {}
const FOO: () = {
(const || (()).foo())();
};

8
tests/crashes/118403.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: #118403
#![feature(generic_const_exprs)]
pub struct X<const N: usize> {}
impl<const Z: usize> X<Z> {
pub fn y<'a, U: 'a>(&'a self) -> impl Iterator<Item = impl Iterator<Item = [u8; Z]> + '_> {
(0..1).map(move |_| (0..1).map(move |_| loop {}))
}
}

44
tests/crashes/118603.rs Normal file
View File

@ -0,0 +1,44 @@
//@ known-bug: #118603
//@ compile-flags: -Copt-level=0
// ignore-tidy-linelength
#![feature(generic_const_exprs)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
struct FlatTree;
#[derive(Copy, Clone)]
struct TreeLeaf;
#[derive(Copy, Clone)]
struct TreeNode<V, W>(V, W);
const fn const_concat<const A: usize, const B: usize>(_: [FlatTree; A], _: [FlatTree; B]) -> [FlatTree; A + B] {
[FlatTree; A + B]
}
struct Builder<const N: usize, I> {
ops: [FlatTree; N],
builder: I,
}
fn create_node<const N: usize, const M: usize, A, B>(a: Builder<N, A>, b: Builder<M, B>) -> Builder<{ N + M + 1 }, TreeNode<A, B>> {
Builder {
ops: const_concat(const_concat::<N, M>(a.ops, b.ops), [FlatTree]),
builder: TreeNode(a.builder, b.builder),
}
}
const LEAF: Builder<1, TreeLeaf> = Builder {
ops: [FlatTree],
builder: TreeLeaf,
};
static INTERNAL_SIMPLE_BOOLEAN_TEMPLATES: &[fn()] = &[{
fn eval() {
create_node(LEAF, create_node(LEAF, LEAF));
}
eval
}];
pub fn main() {}

10
tests/crashes/118952-2.rs Normal file
View File

@ -0,0 +1,10 @@
//@ known-bug: #118952
#![feature(generic_const_exprs)]
pub struct TinyVec<T, const N: usize = { () }>
where
[(); () - std::mem::size_of() - std::mem::size_of::<isize>()]:, {}
pub fn main() {
let t = TinyVec::<u8>::new();
}

25
tests/crashes/118952.rs Normal file
View File

@ -0,0 +1,25 @@
//@ known-bug: #118952
#![allow(non_camel_case_types)]
#![feature(generic_const_exprs)]
#![feature(specialization)]
const DEFAULT_SMALL_VEC_INLINE_CAPACITY: usize = std::mem::size_of::<usize>() * 8;
pub const fn tiny_vec_cap<T>() -> usize {
return (DEFAULT_SMALL_VEC_INLINE_CAPACITY - 1) / std::mem::size_of::<T>()
}
pub struct TinyVec<T, const N: usize = {tiny_vec_cap::<T>()}>
where [
();
(N * std::mem::size_of::<T>())
- std::mem::size_of::<std::ptr::NonNull<T>>()
- std::mem::size_of::<isize>()
]: ,
{
data: isize //TinyVecData<T, N>,
}
pub fn main() {
let t = TinyVec::<u8>::new();
}

17
tests/crashes/118987-2.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: #118987
#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
trait Assoc {
type Output;
}
default impl<T: Clone> Assoc for T {
type Output = bool;
}
impl Assoc for u8 {}
trait Foo {}
impl Foo for <u8 as Assoc>::Output {}
impl Foo for <u16 as Assoc>::Output {}

17
tests/crashes/118987.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: #118987
#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
trait Assoc {
type Output;
}
default impl<T: Clone> Assoc for T {
type Output = bool;
}
impl Assoc for u8 {}
trait Foo {}
impl Foo for <u8 as Assoc>::Output {}
impl Foo for <u16 as Assoc>::Output {}

27
tests/crashes/119272.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #119272
#![feature(type_alias_impl_trait)]
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() {}

25
tests/crashes/119299.rs Normal file
View File

@ -0,0 +1,25 @@
//@ known-bug: #119299
#![feature(adt_const_params)]
#![allow(incomplete_features)]
use std::marker::ConstParamTy;
#[derive(Eq, PartialEq)]
struct ConstStrU(*const u8, usize);
impl ConstParamTy for &'static ConstStrU {}
impl ConstStrU {
const fn from_bytes(bytes: &'static [u8]) -> Self {
Self(bytes.as_ptr(), bytes.len())
}
}
const fn chars_s<const S: &'static ConstStrU>() -> [char; 3] {
['a','b','c']
}
fn main() {
const A: &'static ConstStrU = &ConstStrU::from_bytes(b"abc");
chars_s::<A>();
}

47
tests/crashes/119692.rs Normal file
View File

@ -0,0 +1,47 @@
//@ known-bug: #119692
#![allow(incomplete_features)]
#![feature(adt_const_params)]
#![feature(generic_const_exprs)]
use std::ops::Add;
#[derive(PartialEq, Eq, Clone, Debug, core::marker::ConstParamTy)]
pub struct Dimension;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Default)]
pub struct Quantity<S, const D: Dimension>(pub(crate) S);
impl<const D: Dimension, LHS, RHS> Add<Quantity<RHS, D>> for Quantity<LHS, D>
where
LHS: Add<RHS>,
{
type Output = Quantity<<LHS as Add<RHS>>::Output, D>;
fn add(self, rhs: Quantity<RHS, D>) -> Self::Output {
Quantity(self.0 + rhs.0)
}
}
impl<LHS, RHS> Add<RHS> for Quantity<LHS, { Dimension }>
where
LHS: Add<RHS>,
{
type Output = Quantity<<LHS as Add<RHS>>::Output, { Dimension }>;
fn add(self, rhs: RHS) -> Self::Output {
Quantity(self.0 + rhs)
}
}
impl Add<Quantity<f32, { Dimension }>> for f32 {
type Output = Quantity<f32, { Dimension }>;
fn add(self, rhs: Quantity<f32, { Dimension }>) -> Self::Output {
Quantity(self + rhs.0)
}
}
pub fn add<const U: Dimension>(x: Quantity<f32, U>, y: Quantity<f32, U>) -> Quantity<f32, U> {
x + y
}
fn main() {
add(Quantity::<f32, {Dimension}>(1.0), Quantity(2.0));
}

18
tests/crashes/119694.rs Normal file
View File

@ -0,0 +1,18 @@
//@ known-bug: #119694
#![feature(dyn_star)]
trait Trait {
fn foo(self);
}
impl Trait for usize {
fn foo(self) {}
}
fn bar(x: dyn* Trait) {
x.foo();
}
fn main() {
bar(0usize);
}

21
tests/crashes/119701.rs Normal file
View File

@ -0,0 +1,21 @@
//@ known-bug: #119701
#![feature(const_trait_impl, effects, generic_const_exprs)]
fn main() {
let _ = process::<()>([()]);
}
fn process<T: const Trait>() -> [(); T::make(2)] {
input
}
#[const_trait]
trait Trait {
fn make(input: u8) -> usize;
}
impl const Trait for () {
fn make(input: usize) -> usize {
input / 2
}
}

View File

@ -0,0 +1,4 @@
//@ known-bug: #119716
#![feature(non_lifetime_binders)]
trait Trait<T> {}
fn f<T>() -> impl for<T> Trait<impl Trait<T>> {}

4
tests/crashes/119716.rs Normal file
View File

@ -0,0 +1,4 @@
//@ known-bug: #119716
#![feature(non_lifetime_binders)]
trait v0<v1> {}
fn kind :(v3main impl for<v4> v0<'_, v2 = impl v0<v4> + '_>) {}

10
tests/crashes/119717.rs Normal file
View File

@ -0,0 +1,10 @@
//@ known-bug: #119717
#![feature(const_trait_impl, effects)]
use std::ops::{FromResidual, Try};
impl const FromResidual for T {
fn from_residual(t: T) -> _ {
t
}
}

12
tests/crashes/119729.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #119729
#![feature(generic_const_exprs)]
trait Size<const N: usize> {}
impl<T: Sized> Size<{ std::mem::size_of::<T>() }> for T {}
struct A<T: Size<8> + ?Sized> {
x: std::marker::PhantomData<T>,
}
fn foo(x: A<dyn Send>) {}

8
tests/crashes/119783.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: #119783
#![feature(associated_const_equality)]
trait Trait { const F: fn(); }
fn take(_: impl Trait<F = { || {} }>) {}
fn main() {}

15
tests/crashes/119786.rs Normal file
View File

@ -0,0 +1,15 @@
//@ known-bug: #119786
//@ edition:2021
fn enum_upvar() {
type T = impl Copy;
let foo: T = Some((1u32, 2u32));
let x = move || {
match foo {
None => (),
Some(yield) => (),
}
};
}
pub fn main() {}

14
tests/crashes/119824.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #119824
#![feature(generic_const_exprs)]
const fn t<const N: usize>() -> u8 {
N as u8
}
#[repr(u8)]
enum T<const N: u8 = { T::<0>::A as u8 + T::<0>::B as u8 }>
where
[(); N as usize]:
{
A = t::<N>() as u8, B
}

11
tests/crashes/119830.rs Normal file
View File

@ -0,0 +1,11 @@
//@ known-bug: #119830
#![feature(effects)]
#![feature(min_specialization)]
trait Specialize {}
trait Foo {}
impl<T> const Foo for T {}
impl<T> const Foo for T where T: const Specialize {}

14
tests/crashes/119924-6.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #119924
#![feature(const_trait_impl, effects)]
struct S;
#[const_trait]
trait Trait<const N: u32> {}
const fn f<T: Trait<{
struct I<U: ~const Trait<0>>(U); // should've gotten rejected during AST validation
//~^ ICE no host param id for call in const yet no errors reported
0
}>>() {}
pub fn main() {}

View File

@ -0,0 +1,9 @@
//@ known-bug: #120241
#![feature(object_safe_for_dispatch)]
#![feature(unsized_fn_params)]
fn guard(_s: Copy) -> bool {
panic!()
}
fn main() {}

12
tests/crashes/120241.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #120241
#![feature(object_safe_for_dispatch)]
trait B {
fn f(a: A) -> A;
}
trait A {
fn g(b: B) -> B;
}
fn main() {}

12
tests/crashes/120482.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #120482
#![feature(object_safe_for_dispatch)]
trait B {
fn bar(&self, x: &Self);
}
trait A {
fn g(new: B) -> B;
}
fn main() {}

10
tests/crashes/120503.rs Normal file
View File

@ -0,0 +1,10 @@
//@ known-bug: #120503
#![feature(effects)]
trait MyTrait {}
impl MyTrait for i32 {
async const fn bar(&self) {
main8().await;
}
}

13
tests/crashes/120600-2.rs Normal file
View File

@ -0,0 +1,13 @@
//@ known-bug: #120600
#![feature(never_type, never_type_fallback)]
enum E { Bar(!) }
fn f(a: &E, b: &E) {
match (a, b) {
(E::Bar(a), E::Bar(b)) => { *a == *b; }
_ => {}
}
}
pub fn main() {}

11
tests/crashes/120600.rs Normal file
View File

@ -0,0 +1,11 @@
//@ known-bug: #120600
#![feature(never_type)]
#![feature(never_type_fallback)]
#[derive(Ord, Eq, PartialOrd, PartialEq)]
enum E {
Foo,
Bar(!, i32, i32),
}
fn main() {}

22
tests/crashes/120793-2.rs Normal file
View File

@ -0,0 +1,22 @@
//@ known-bug: #120793
// can't use build-fail, because this also fails check-fail, but
// the ICE from #120787 only reproduces on build-fail.
//@ compile-flags: --emit=mir
#![feature(effects)]
trait Dim {
fn dim() -> usize;
}
enum Dim3 {}
impl Dim for Dim3 {
fn dim(x: impl Sized) -> usize {
3
}
}
fn main() {
[0; Dim3::dim()];
}

21
tests/crashes/120793.rs Normal file
View File

@ -0,0 +1,21 @@
//@ known-bug: #120793
#![feature(effects)]
trait Dim {
fn dim() -> usize;
}
enum Dim3 {}
impl Dim for Dim3 {
fn dim(mut x: impl Iterator<Item = &'_ ()>) -> usize {
3
}
}
fn main() {
let array: [usize; Dim3::dim()]
//~^ ERROR E0015
= [0; Dim3::dim()];
//~^ ERROR E0015
}

8
tests/crashes/120873.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: #120873
#[repr(packed)]
struct Dealigned<T>(u8, T);
#[derive(PartialEq)]
#[repr(C)]
struct Dealigned<T>(u8, T);

26
tests/crashes/120911.rs Normal file
View File

@ -0,0 +1,26 @@
//@ known-bug: #120911
trait Container {
type Item<'a>;
}
impl Container for () {
type Item<'a> = ();
}
struct Exchange<C, F> {
_marker: std::marker::PhantomData<(C, F)>,
}
fn exchange<C, F>(_: F) -> Exchange<C, F>
where
C: Container,
for<'a> F: FnMut(&C::Item<'a>),
{
unimplemented!()
}
trait Parallelization<C> {}
impl<C, F> Parallelization<C> for Exchange<C, F> {}
fn unary_frontier<P: Parallelization<()>>(_: P) {}
fn main() {
let exchange = exchange(|_| ());
let _ = || {
unary_frontier(exchange);
};
}

32
tests/crashes/121052.rs Normal file
View File

@ -0,0 +1,32 @@
//@ known-bug: #121052
#![feature(generic_const_exprs, with_negative_coherence)]
use std::ops::Mul;
pub trait Indices<const N: usize> {
const NUM_ELEMS: usize;
}
impl<I: Indices<N>, J: Indices<N>, const N: usize> Mul for Tensor<I, N>
where
I: Concat<J>,
<I as Concat<J>>::Output: Indices<N>,
[u8; I::NUM_ELEMS]: Sized,
[u8; J::NUM_ELEMS]: Sized,
[u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
{
}
pub trait Concat<J> {}
pub struct Tensor<I: Indices<N>, const N: usize> {}
impl<I: Indices<N>, J: Indices<N>, const N: usize> Mul for Tensor<I, N>
where
I: Concat<J>,
<I as Concat<J>>::Output: Indices<N>,
[u8; I::NUM_ELEMS]: Sized,
[u8; J::NUM_ELEMS]: Sized,
[u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
{
}

10
tests/crashes/121097.rs Normal file
View File

@ -0,0 +1,10 @@
//@ known-bug: #121097
#[repr(simd)]
enum Aligned {
Zero = 0,
One = 1,
}
fn tou8(al: Aligned) -> u8 {
al as u8
}

4
tests/crashes/121126.rs Normal file
View File

@ -0,0 +1,4 @@
//@ known-bug: #121126
fn main() {
let _n = 1i64 >> [64][4_294_967_295];
}

20
tests/crashes/121134.rs Normal file
View File

@ -0,0 +1,20 @@
//@ known-bug: #121134
trait Output<'a> {
type Type;
}
struct Wrapper;
impl Wrapper {
fn do_something_wrapper<O, F>(&mut self, do_something_wrapper: F)
where
FnOnce:,
F: for<'a> FnOnce(<F as Output<i32, _>>::Type),
{
}
}
fn main() {
let mut wrapper = Wrapper;
wrapper.do_something_wrapper::<i32, _>(|value| ());
}

12
tests/crashes/121161.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #121161
#![allow(incomplete_features)]
#![feature(unnamed_fields)]
#[derive(Eq)]
#[repr(C)]
struct Bar {
_: union {
a: u8,
},
}

View File

@ -0,0 +1,6 @@
//@ known-bug: #121263
#[repr(C)]
#[derive(Debug)]
struct L {
_: MyI32,
}

9
tests/crashes/121263.rs Normal file
View File

@ -0,0 +1,9 @@
//@ known-bug: #121263
#[repr(C)]
#[repr(C)]
#[derive(Debug)]
struct L {
_: i32,
_: MyI32,
_: BadEnum,
}

6
tests/crashes/121299.rs Normal file
View File

@ -0,0 +1,6 @@
//@ known-bug: #121299
#[derive(Eq)]
struct D {
_: union {
},
}

13
tests/crashes/121411.rs Normal file
View File

@ -0,0 +1,13 @@
//@ known-bug: #121411
#![feature(const_trait_impl, effects)]
#[const_trait]
trait Foo {
fn into_iter(&self) {}
}
impl const Foo for () {
fn into_iter(a: u32, b: u32) {}
}
const _: () = Foo::into_iter(&());

8
tests/crashes/121422.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: #121422
#![feature(non_lifetime_binders)]
trait Trait<T: ?Sized> {}
fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> {
16
}

17
tests/crashes/121429.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: #121429
#![feature(generic_const_exprs)]
pub trait True {}
impl<const N: usize = { const { 3 } }> PartialEq<FixedI8<FRAC_RHS>> for FixedI8<FRAC_LHS> where
If<{}>: True
{
}
#![feature(generic_const_exprs)]
pub trait True {}
impl<const N: usize = { const { 3 } }> PartialEq<FixedI8<FRAC_RHS>> for FixedI8<FRAC_LHS> where
If<{}>: True
{
}

9
tests/crashes/121444.rs Normal file
View File

@ -0,0 +1,9 @@
//@ known-bug: #121444
#[repr(align(536870912))]
pub struct A(i64);
pub extern "C" fn foo(x: A) {}
fn main() {
foo(A(0));
}

20
tests/crashes/121536.rs Normal file
View File

@ -0,0 +1,20 @@
//@ known-bug: #121536
#![feature(effects)]
#[derive(Debug, Clone, Copy)]
pub struct Vec3 {
pub x: f32,
pub y: f32,
pub z: f32,
}
impl std::ops::Add<Vec3> for Vec3 {
type Output = Vec3;
const fn add(self, b: Vec3) -> Self::Output {
Vec3 {
x: self.x + b.x,
y: self.y + b.y,
z: self.z + b.z,
}
}
}

View File

@ -0,0 +1,8 @@
//@ known-bug: #121574
#![feature(generic_const_exprs)]
pub struct DimName<const N: usize> {}
impl<const Z: usize> X<Z> {
pub fn y<'a, U: 'a>(&'a self) -> impl Iterator<Item = impl Iterator<Item = [u8; Z]> + '_> {
"0".as_bytes(move |_| (0..1).map(move |_| loop {}))
}
}

6
tests/crashes/121574.rs Normal file
View File

@ -0,0 +1,6 @@
//@ known-bug: #121574
#![feature(generic_const_exprs)]
impl<const Z: usize> X<Z> {
pub fn y<'a, U: 'a>(&'a self) -> impl Iterator<Item = impl Iterator<Item = [u8; Z]> + '_> {}
}

107
tests/crashes/121575.rs Normal file
View File

@ -0,0 +1,107 @@
//@ known-bug: #121575
// ignore-tidy-linelength
#![feature(generic_const_exprs)]
use std::array;
trait PrimRec<const N: usize, const O: usize> {
fn eval(&self, x: [usize; N]) -> [usize; O];
}
struct Zero;
impl<const N: usize> PrimRec<N, 1> for Zero {
fn eval(&self, _: [usize; N]) -> [usize; 1] {
[0]
}
}
struct Const(usize);
impl<const N: usize> PrimRec<N, 1> for Const {
fn eval(&self, _: [usize; N]) -> [usize; 1] {
[self.0]
}
}
struct S;
impl PrimRec<1, 1> for S {
fn eval(&self, x: [usize; 1]) -> [usize; 1] {
[x[0] + 1]
}
}
struct Proj<const I: usize>;
impl<const N: usize, const I: usize> PrimRec<N, 1> for Proj<I> {
fn eval(&self, x: [usize; N]) -> [usize; 1] {
[x[I]]
}
}
struct Merge<const N: usize, const O1: usize, const O2: usize, A: PrimRec<N, O1>, B: PrimRec<N, O2>>(
A,
B,
);
fn concat<const M: usize, const N: usize>(a: [usize; M], b: [usize; N]) -> [usize; M + N] {
array::from_fn(|i| if i < M { a[i] } else { b[i - M] })
}
impl<const N: usize, const O1: usize, const O2: usize, A: PrimRec<N, O1>, B: PrimRec<N, O2>>
PrimRec<N, { O1 + O2 }> for Merge<N, O1, O2, A, B>
{
fn eval(&self, x: [usize; N]) -> [usize; O1 + O2] {
concat(self.0.eval(x), self.1.eval(x))
}
}
struct Compose<const N: usize, const I: usize, const O: usize, A: PrimRec<N, I>, B: PrimRec<I, O>>(
A,
B,
);
impl<const N: usize, const I: usize, const O: usize, A: PrimRec<N, I>, B: PrimRec<I, O>>
PrimRec<N, O> for Compose<N, I, O, A, B>
{
fn eval(&self, x: [usize; N]) -> [usize; O] {
self.1.eval(self.0.eval(x))
}
}
struct Rec<const N: usize, const O: usize, Base: PrimRec<N, O>, F: PrimRec<{ O + (N + 1) }, O>>(
Base,
F,
);
fn tail<const N: usize>(x: [usize; N + 1]) -> [usize; N] {
array::from_fn(|i| x[i + 1])
}
fn cons<const N: usize>(x: usize, xs: [usize; N]) -> [usize; N + 1] {
array::from_fn(|i| if i == 0 { x } else { xs[i - 1] })
}
impl<const N: usize, const O: usize, Base: PrimRec<N, O>, F: PrimRec<{ O + (N + 1) }, O>>
PrimRec<{ N + 1 }, O> for Rec<N, O, Base, F>
{
fn eval(&self, x: [usize; N + 1]) -> [usize; O] {
match (x[0], tail(x)) {
(0, x) => self.0.eval(x),
(y, x) => {
let xy = cons(y - 1, x);
let input = concat(self.eval(xy), xy);
self.1.eval(input)
}
}
}
}
fn main() {
let one = Compose(Zero, S);
dbg!(one.eval([]));
let add: Rec<1, 1, Proj<0>, Compose<3, 1, 1, Proj<0>, S>> =
Rec(Proj::<0>, Compose(Proj::<0>, S));
dbg!(add.eval([3, 2]));
}

13
tests/crashes/121585-1.rs Normal file
View File

@ -0,0 +1,13 @@
//@ known-bug: #121585
#![feature(generic_const_exprs)]
trait Trait {}
struct HasCastInTraitImpl<const N: usize, const M: u128>;
impl<const O: f64> Trait for HasCastInTraitImpl<O, { O as u128 }> {}
pub fn use_trait_impl() {
fn assert_impl<T: Trait>() {}
assert_impl::<HasCastInTraitImpl<13, 13>>();
}

30
tests/crashes/121585-2.rs Normal file
View File

@ -0,0 +1,30 @@
//@ known-bug: #121585
//@ check-pass
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Trait {}
pub struct EvaluatableU128<const N: u128>;
struct HasCastInTraitImpl<const N: usize, const M: u128>;
impl<const O: f64> Trait for HasCastInTraitImpl<O, { O as u128 }> {}
pub fn use_trait_impl<const N: usize>() where EvaluatableU128<{N as u128}>:, {
fn assert_impl<T: Trait>() {}
assert_impl::<HasCastInTraitImpl<N, { N as u128 }>>();
assert_impl::<HasCastInTraitImpl<N, { N as _ }>>();
assert_impl::<HasCastInTraitImpl<12, { 12 as u128 }>>();
assert_impl::<HasCastInTraitImpl<13, 13>>();
}
pub fn use_trait_impl_2<const N: usize>() where EvaluatableU128<{N as _}>:, {
fn assert_impl<T: Trait>() {}
assert_impl::<HasCastInTraitImpl<N, { N as u128 }>>();
assert_impl::<HasCastInTraitImpl<N, { N as _ }>>();
assert_impl::<HasCastInTraitImpl<12, { 12 as u128 }>>()const NUM: u8 = xyz();
assert_impl::<HasCastInTraitImpl<13, 13>>();
}
fn main() {}

28
tests/crashes/121613-2.rs Normal file
View File

@ -0,0 +1,28 @@
//@ known-bug: #121613
fn main() {
// destructure through a qualified path
let <Foo as A>::Assoc { br } = StructStruct { br: 2 };
//~^ ERROR usage of qualified paths in this context is experimental
let _ = <Foo as A>::Assoc { br: 2 };
//~^ ERROR usage of qualified paths in this context is experimental
let <E>::V(..) = E::V(|a, b| a.cmp(b));
//~^ ERROR usage of qualified paths in this context is experimental
}
struct StructStruct {
br: i8,
}
struct Foo;
trait A {
type Assoc;
}
impl A for Foo {
type Assoc = StructStruct;
}
enum E {
V(u8)
}

24
tests/crashes/121613.rs Normal file
View File

@ -0,0 +1,24 @@
//@ known-bug: #121613
fn main() {
let _ = <Foo as A>::Assoc { br: 2 };
let <E>::V(..) = E::V(|a, b| a.cmp(b));
}
struct StructStruct {
br: i8,
}
struct Foo;
trait A {
type Assoc;
}
impl A for Foo {
type Assoc = StructStruct;
}
enum E {
V(u8),
}

8
tests/crashes/121623.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: #121623
fn main() {
match () {
_ => 'b: {
continue 'b;
}
}
}

10
tests/crashes/121722.rs Normal file
View File

@ -0,0 +1,10 @@
//@ known-bug: #121722
#[repr(C)]
struct Foo {
_: u8,
}
#[repr(C)]
struct D {
_: Foo,
}

11
tests/crashes/121799.rs Normal file
View File

@ -0,0 +1,11 @@
//@ known-bug: #121799
struct S {
_: str
}
fn func(a: S)
{
let _x = a.f;
}
fn main() {}

12
tests/crashes/121816.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #121816
fn f<'a, T>(_: &'static &'a (), x: &'a T) -> &'static T {
x
}
trait W<'a> {
fn g<T>(self, x: &'a T) -> &'static T;
}
impl<'a> W<'a> for &'static () {
fn g<T>(self, x: &'a T) -> &'static T {
f(&self, x)
}
}

20
tests/crashes/121858-2.rs Normal file
View File

@ -0,0 +1,20 @@
//@ known-bug: #121858
#![allow(named_arguments_used_positionally)]
#![feature(generic_const_exprs)]
struct Inner<const N: usize, const M: usize>;
impl<const N: usize, const M: usize> Inner<N, M> where [(); N + M]: {
fn i() -> Self {
Self
}
}
struct Outer<const A: i64, const B: usize>(Inner<A, { B * 2 }>) where [(); A + (B * 2)]:;
impl<const A: usize, const B: usize> Outer<A, B> where [(); A + (B * 2)]: {
fn o() -> Union {
Self(Inner::i())
}
}
fn main() {
Outer::<1, 1>::o();
}

14
tests/crashes/121858.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #121858
#![feature(generic_const_exprs)]
struct Outer<const A: i64, const B: usize>();
impl<const A: usize, const B: usize> Outer<A, B>
where
[(); A + (B * 2)]:,
{
fn o() -> Union {}
}
fn main() {
Outer::<1, 1>::o();
}

20
tests/crashes/121957-1.rs Normal file
View File

@ -0,0 +1,20 @@
//@ known-bug: #121957
#![feature(const_trait_impl, effects)]
#[const_trait]
trait Main {
fn compute<T: ~const Aux>() -> u32;
}
impl const Main for () {
fn compute<'x, 'y, 'z: 'x>() -> u32 {}
}
#[const_trait]
trait Aux {}
impl const Aux for () {}
fn main() {
const _: u32 = <()>::compute::<()>();
}

20
tests/crashes/121957-2.rs Normal file
View File

@ -0,0 +1,20 @@
//@ known-bug: #121957
#![feature(const_trait_impl, effects)]
#[const_trait]
trait Main {
fn compute<T: ~const Aux>() -> u32;
}
impl const Main for () {
fn compute<'x, 'y, 'z: 'x>() -> u32 {}
}
#[const_trait]
trait Aux {}
impl const Aux for () {}
fn main() {
const _: u32 = <()>::compute::<()>();
}

26
tests/crashes/121963.rs Normal file
View File

@ -0,0 +1,26 @@
//@ known-bug: #121963
#![feature(generic_const_exprs)]
use std::marker::PhantomData;
trait Arch {
const CHANNEL_COUNT: usize = 2;
}
struct Channel<const N: usize> {
r: [u8; N],
}
struct Dram<A: Arch, S = Channel<{ A::CHANNEL_COUNT }>> {
a: PhantomData<A>,
s: PhantomData<S>,
}
struct C<A: Arch>
where
Channel<{ A::CHANNEL_COUNT }, u8>: Sized,
{
b: Dram<A>,
// b: Dram<A, Channel<{ A::CHANNEL_COUNT }>>, // When I specified generic here, it worked
}
fn main() {}

Some files were not shown because too many files have changed in this diff Show More