From 7d826ae43eb88750bd6745d73e100965bad72520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 30 Mar 2024 00:21:25 +0100 Subject: [PATCH] tests/crashes: add ICEs from matthiaskrgr/glacier2 --- tests/crashes/101036.rs | 14 +++++ tests/crashes/101557.rs | 41 ++++++++++++++ tests/crashes/105275.rs | 27 ++++++++++ tests/crashes/105488.rs | 39 -------------- tests/crashes/105937.rs | 27 ++++++++++ tests/crashes/106473.rs | 12 +++++ tests/crashes/110534.rs | 44 +++++++++++++++ tests/crashes/110627.rs | 8 +++ tests/crashes/111419.rs | 14 +++++ tests/crashes/111699.rs | 12 +++++ tests/crashes/111709-2.rs | 15 ++++++ tests/crashes/111709.rs | 25 +++++++++ tests/crashes/111883.rs | 40 ++++++++++++++ tests/crashes/113272.rs | 16 ++++++ tests/crashes/113846.rs | 32 +++++++++++ tests/crashes/114212-2.rs | 16 ++++++ tests/crashes/114212.rs | 34 ++++++++++++ tests/crashes/114317.rs | 6 +++ tests/crashes/114456-2.rs | 20 +++++++ tests/crashes/114456.rs | 17 ++++++ tests/crashes/114484.rs | 67 +++++++++++++++++++++++ tests/crashes/114663.rs | 17 ++++++ tests/crashes/115435.rs | 23 ++++++++ tests/crashes/115808.rs | 27 ++++++++++ tests/crashes/116308.rs | 16 ++++++ tests/crashes/116519-2.rs | 15 ++++++ tests/crashes/116519.rs | 57 ++++++++++++++++++++ tests/crashes/116554.rs | 31 +++++++++++ tests/crashes/116947.rs | 16 ++++++ tests/crashes/117392-2.rs | 27 ++++++++++ tests/crashes/117392.rs | 47 ++++++++++++++++ tests/crashes/117496.rs | 22 ++++++++ tests/crashes/117629.rs | 11 ++++ tests/crashes/117696-1.rs | 29 ++++++++++ tests/crashes/117696-2.rs | 13 +++++ tests/crashes/117795.rs | 8 +++ tests/crashes/117829-2.rs | 14 +++++ tests/crashes/117829.rs | 9 ++++ tests/crashes/117942.rs | 7 +++ tests/crashes/118038.rs | 12 +++++ tests/crashes/118320.rs | 13 +++++ tests/crashes/118403.rs | 8 +++ tests/crashes/118603.rs | 44 +++++++++++++++ tests/crashes/118952-2.rs | 10 ++++ tests/crashes/118952.rs | 25 +++++++++ tests/crashes/118987-2.rs | 17 ++++++ tests/crashes/118987.rs | 17 ++++++ tests/crashes/119272.rs | 27 ++++++++++ tests/crashes/119299.rs | 25 +++++++++ tests/crashes/119692.rs | 47 ++++++++++++++++ tests/crashes/119694.rs | 18 +++++++ tests/crashes/119701.rs | 21 ++++++++ tests/crashes/119716-2.rs | 4 ++ tests/crashes/119716.rs | 4 ++ tests/crashes/119717.rs | 10 ++++ tests/crashes/119729.rs | 12 +++++ tests/crashes/119783.rs | 8 +++ tests/crashes/119786.rs | 15 ++++++ tests/crashes/119824.rs | 14 +++++ tests/crashes/119830.rs | 11 ++++ tests/crashes/119924-6.rs | 14 +++++ tests/crashes/120241-2.rs | 9 ++++ tests/crashes/120241.rs | 12 +++++ tests/crashes/120482.rs | 12 +++++ tests/crashes/120503.rs | 10 ++++ tests/crashes/120600-2.rs | 13 +++++ tests/crashes/120600.rs | 11 ++++ tests/crashes/120793-2.rs | 22 ++++++++ tests/crashes/120793.rs | 21 ++++++++ tests/crashes/120873.rs | 8 +++ tests/crashes/120911.rs | 26 +++++++++ tests/crashes/121052.rs | 32 +++++++++++ tests/crashes/121097.rs | 10 ++++ tests/crashes/121126.rs | 4 ++ tests/crashes/121134.rs | 20 +++++++ tests/crashes/121161.rs | 12 +++++ tests/crashes/121263-2.rs | 6 +++ tests/crashes/121263.rs | 9 ++++ tests/crashes/121299.rs | 6 +++ tests/crashes/121411.rs | 13 +++++ tests/crashes/121422.rs | 8 +++ tests/crashes/121429.rs | 17 ++++++ tests/crashes/121444.rs | 9 ++++ tests/crashes/121536.rs | 20 +++++++ tests/crashes/121574-2.rs | 8 +++ tests/crashes/121574.rs | 6 +++ tests/crashes/121575.rs | 107 +++++++++++++++++++++++++++++++++++++ tests/crashes/121585-1.rs | 13 +++++ tests/crashes/121585-2.rs | 30 +++++++++++ tests/crashes/121613-2.rs | 28 ++++++++++ tests/crashes/121613.rs | 24 +++++++++ tests/crashes/121623.rs | 8 +++ tests/crashes/121722.rs | 10 ++++ tests/crashes/121799.rs | 11 ++++ tests/crashes/121816.rs | 12 +++++ tests/crashes/121858-2.rs | 20 +++++++ tests/crashes/121858.rs | 14 +++++ tests/crashes/121957-1.rs | 20 +++++++ tests/crashes/121957-2.rs | 20 +++++++ tests/crashes/121963.rs | 26 +++++++++ tests/crashes/122044.rs | 38 +++++++++++++ tests/crashes/122529.rs | 8 +++ tests/crashes/122548.rs | 17 ++++++ tests/crashes/122552.rs | 10 ++++ tests/crashes/122587-1.rs | 5 ++ tests/crashes/122638.rs | 12 +++++ tests/crashes/122681.rs | 10 ++++ tests/crashes/122704.rs | 14 +++++ tests/crashes/122710.rs | 24 +++++++++ tests/crashes/122736.rs | 15 ++++++ tests/crashes/122823.rs | 69 ++++++++++++++++++++++++ tests/crashes/122903-1.rs | 8 +++ tests/crashes/122903-2.rs | 9 ++++ tests/crashes/122904-2.rs | 15 ++++++ tests/crashes/122904.rs | 11 ++++ tests/crashes/122908.rs | 4 ++ tests/crashes/122914.rs | 11 ++++ tests/crashes/122989.rs | 8 +++ tests/crashes/123077-1.rs | 9 ++++ tests/crashes/123077-2.rs | 11 ++++ tests/crashes/123134.rs | 39 ++++++++++++++ tests/crashes/123140.rs | 6 +++ tests/crashes/123141-2.rs | 23 ++++++++ tests/crashes/123141.rs | 22 ++++++++ tests/crashes/123153.rs | 17 ++++++ tests/crashes/123154.rs | 12 +++++ tests/crashes/123157.rs | 15 ++++++ tests/crashes/23707.rs | 109 ++++++++++++++++++++++++++++++++++++++ tests/crashes/92004.rs | 70 ++++++++++++++++++++++++ tests/crashes/93182.rs | 29 ++++++++++ tests/crashes/93237.rs | 18 +++++++ tests/crashes/94846.rs | 6 +++ tests/crashes/95134.rs | 27 ++++++++++ 133 files changed, 2620 insertions(+), 39 deletions(-) create mode 100644 tests/crashes/101036.rs create mode 100644 tests/crashes/101557.rs create mode 100644 tests/crashes/105275.rs delete mode 100644 tests/crashes/105488.rs create mode 100644 tests/crashes/105937.rs create mode 100644 tests/crashes/106473.rs create mode 100644 tests/crashes/110534.rs create mode 100644 tests/crashes/110627.rs create mode 100644 tests/crashes/111419.rs create mode 100644 tests/crashes/111699.rs create mode 100644 tests/crashes/111709-2.rs create mode 100644 tests/crashes/111709.rs create mode 100644 tests/crashes/111883.rs create mode 100644 tests/crashes/113272.rs create mode 100644 tests/crashes/113846.rs create mode 100644 tests/crashes/114212-2.rs create mode 100644 tests/crashes/114212.rs create mode 100644 tests/crashes/114317.rs create mode 100644 tests/crashes/114456-2.rs create mode 100644 tests/crashes/114456.rs create mode 100644 tests/crashes/114484.rs create mode 100644 tests/crashes/114663.rs create mode 100644 tests/crashes/115435.rs create mode 100644 tests/crashes/115808.rs create mode 100644 tests/crashes/116308.rs create mode 100644 tests/crashes/116519-2.rs create mode 100644 tests/crashes/116519.rs create mode 100644 tests/crashes/116554.rs create mode 100644 tests/crashes/116947.rs create mode 100644 tests/crashes/117392-2.rs create mode 100644 tests/crashes/117392.rs create mode 100644 tests/crashes/117496.rs create mode 100644 tests/crashes/117629.rs create mode 100644 tests/crashes/117696-1.rs create mode 100644 tests/crashes/117696-2.rs create mode 100644 tests/crashes/117795.rs create mode 100644 tests/crashes/117829-2.rs create mode 100644 tests/crashes/117829.rs create mode 100644 tests/crashes/117942.rs create mode 100644 tests/crashes/118038.rs create mode 100644 tests/crashes/118320.rs create mode 100644 tests/crashes/118403.rs create mode 100644 tests/crashes/118603.rs create mode 100644 tests/crashes/118952-2.rs create mode 100644 tests/crashes/118952.rs create mode 100644 tests/crashes/118987-2.rs create mode 100644 tests/crashes/118987.rs create mode 100644 tests/crashes/119272.rs create mode 100644 tests/crashes/119299.rs create mode 100644 tests/crashes/119692.rs create mode 100644 tests/crashes/119694.rs create mode 100644 tests/crashes/119701.rs create mode 100644 tests/crashes/119716-2.rs create mode 100644 tests/crashes/119716.rs create mode 100644 tests/crashes/119717.rs create mode 100644 tests/crashes/119729.rs create mode 100644 tests/crashes/119783.rs create mode 100644 tests/crashes/119786.rs create mode 100644 tests/crashes/119824.rs create mode 100644 tests/crashes/119830.rs create mode 100644 tests/crashes/119924-6.rs create mode 100644 tests/crashes/120241-2.rs create mode 100644 tests/crashes/120241.rs create mode 100644 tests/crashes/120482.rs create mode 100644 tests/crashes/120503.rs create mode 100644 tests/crashes/120600-2.rs create mode 100644 tests/crashes/120600.rs create mode 100644 tests/crashes/120793-2.rs create mode 100644 tests/crashes/120793.rs create mode 100644 tests/crashes/120873.rs create mode 100644 tests/crashes/120911.rs create mode 100644 tests/crashes/121052.rs create mode 100644 tests/crashes/121097.rs create mode 100644 tests/crashes/121126.rs create mode 100644 tests/crashes/121134.rs create mode 100644 tests/crashes/121161.rs create mode 100644 tests/crashes/121263-2.rs create mode 100644 tests/crashes/121263.rs create mode 100644 tests/crashes/121299.rs create mode 100644 tests/crashes/121411.rs create mode 100644 tests/crashes/121422.rs create mode 100644 tests/crashes/121429.rs create mode 100644 tests/crashes/121444.rs create mode 100644 tests/crashes/121536.rs create mode 100644 tests/crashes/121574-2.rs create mode 100644 tests/crashes/121574.rs create mode 100644 tests/crashes/121575.rs create mode 100644 tests/crashes/121585-1.rs create mode 100644 tests/crashes/121585-2.rs create mode 100644 tests/crashes/121613-2.rs create mode 100644 tests/crashes/121613.rs create mode 100644 tests/crashes/121623.rs create mode 100644 tests/crashes/121722.rs create mode 100644 tests/crashes/121799.rs create mode 100644 tests/crashes/121816.rs create mode 100644 tests/crashes/121858-2.rs create mode 100644 tests/crashes/121858.rs create mode 100644 tests/crashes/121957-1.rs create mode 100644 tests/crashes/121957-2.rs create mode 100644 tests/crashes/121963.rs create mode 100644 tests/crashes/122044.rs create mode 100644 tests/crashes/122529.rs create mode 100644 tests/crashes/122548.rs create mode 100644 tests/crashes/122552.rs create mode 100644 tests/crashes/122587-1.rs create mode 100644 tests/crashes/122638.rs create mode 100644 tests/crashes/122681.rs create mode 100644 tests/crashes/122704.rs create mode 100644 tests/crashes/122710.rs create mode 100644 tests/crashes/122736.rs create mode 100644 tests/crashes/122823.rs create mode 100644 tests/crashes/122903-1.rs create mode 100644 tests/crashes/122903-2.rs create mode 100644 tests/crashes/122904-2.rs create mode 100644 tests/crashes/122904.rs create mode 100644 tests/crashes/122908.rs create mode 100644 tests/crashes/122914.rs create mode 100644 tests/crashes/122989.rs create mode 100644 tests/crashes/123077-1.rs create mode 100644 tests/crashes/123077-2.rs create mode 100644 tests/crashes/123134.rs create mode 100644 tests/crashes/123140.rs create mode 100644 tests/crashes/123141-2.rs create mode 100644 tests/crashes/123141.rs create mode 100644 tests/crashes/123153.rs create mode 100644 tests/crashes/123154.rs create mode 100644 tests/crashes/123157.rs create mode 100644 tests/crashes/23707.rs create mode 100644 tests/crashes/92004.rs create mode 100644 tests/crashes/93182.rs create mode 100644 tests/crashes/93237.rs create mode 100644 tests/crashes/94846.rs create mode 100644 tests/crashes/95134.rs diff --git a/tests/crashes/101036.rs b/tests/crashes/101036.rs new file mode 100644 index 0000000000000..72334985820f8 --- /dev/null +++ b/tests/crashes/101036.rs @@ -0,0 +1,14 @@ +//@ known-bug: #101036 +#![feature(generic_const_exprs)] + +const fn t() -> u8 { + N as u8 +} + +#[repr(u8)] +enum T::A as u8 + T::<0>::B as u8 }> +where + [(); N as usize]: +{ + A = t::() as u8, B +} diff --git a/tests/crashes/101557.rs b/tests/crashes/101557.rs new file mode 100644 index 0000000000000..da32660903e9e --- /dev/null +++ b/tests/crashes/101557.rs @@ -0,0 +1,41 @@ +//@ known-bug: #101557 +#![feature(generic_const_exprs)] +use std::marker::PhantomData; + +trait Trait { + const CONST: usize; +} + +struct A { + _marker: PhantomData, +} + +impl Trait for [i8; N] { + const CONST: usize = N; +} + +impl From for A<[i8; N]> { + fn from(_: usize) -> Self { + todo!() + } +} + +impl From> for A { + fn from(_: A<[i8; T::CONST]>) -> Self { + todo!() + } +} + +fn f() -> A +where + [(); T::CONST]:, +{ + // Usage of `0` is arbitrary + let a = A::<[i8; T::CONST]>::from(0); + A::::from(a) +} + +fn main() { + // Usage of `1` is arbitrary + f::<[i8; 1]>(); +} diff --git a/tests/crashes/105275.rs b/tests/crashes/105275.rs new file mode 100644 index 0000000000000..a97f36d19872c --- /dev/null +++ b/tests/crashes/105275.rs @@ -0,0 +1,27 @@ +//@ known-bug: #105275 +//@ compile-flags: -Copt-level=0 + +pub fn encode_num(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(); +} diff --git a/tests/crashes/105488.rs b/tests/crashes/105488.rs deleted file mode 100644 index 75fe899f173b6..0000000000000 --- a/tests/crashes/105488.rs +++ /dev/null @@ -1,39 +0,0 @@ -//@ known-bug: #105488 - -pub trait MyFnOnce { - type Output; - - fn call_my_fn_once(self) -> Self::Output; -} - -pub struct WrapFnOnce(F); - -impl D, D: MyFnOnce> MyFnOnce for WrapFnOnce { - type Output = D::Output; - - fn call_my_fn_once(self) -> Self::Output { - D::call_my_fn_once(self.0()) - } -} - -impl 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(); -} diff --git a/tests/crashes/105937.rs b/tests/crashes/105937.rs new file mode 100644 index 0000000000000..ffd1a493e46d5 --- /dev/null +++ b/tests/crashes/105937.rs @@ -0,0 +1,27 @@ +//@ known-bug: #105937 +//@ compile-flags: -Copt-level=0 + +pub fn encode_num(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(); +} diff --git a/tests/crashes/106473.rs b/tests/crashes/106473.rs new file mode 100644 index 0000000000000..b0a129cac010a --- /dev/null +++ b/tests/crashes/106473.rs @@ -0,0 +1,12 @@ +//@ known-bug: #106473 +#![feature(generic_const_exprs)] + +const DEFAULT: u32 = 1; + +struct V +where + [(); U]:; + +trait Tr {} + +impl Tr for V {} diff --git a/tests/crashes/110534.rs b/tests/crashes/110534.rs new file mode 100644 index 0000000000000..240ff6c270413 --- /dev/null +++ b/tests/crashes/110534.rs @@ -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 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) {} + 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(); +} diff --git a/tests/crashes/110627.rs b/tests/crashes/110627.rs new file mode 100644 index 0000000000000..752682fa6059e --- /dev/null +++ b/tests/crashes/110627.rs @@ -0,0 +1,8 @@ +//@ known-bug: #110627 +#![feature(non_lifetime_binders)] + +fn take(id: impl for Fn(T) -> T) {} + +fn main() { + take(|x| x) +} diff --git a/tests/crashes/111419.rs b/tests/crashes/111419.rs new file mode 100644 index 0000000000000..3a1a13df1985a --- /dev/null +++ b/tests/crashes/111419.rs @@ -0,0 +1,14 @@ +//@ known-bug: #111419 +#![allow(incomplete_features)] +#![feature(generic_const_exprs, generic_arg_infer)] + +pub trait Example +where + [(); X + Y]:, +{} + +impl Example for Value {} + +pub struct Value; + +fn main() {} diff --git a/tests/crashes/111699.rs b/tests/crashes/111699.rs new file mode 100644 index 0000000000000..b3d12fb4a0bfd --- /dev/null +++ b/tests/crashes/111699.rs @@ -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); + } +} diff --git a/tests/crashes/111709-2.rs b/tests/crashes/111709-2.rs new file mode 100644 index 0000000000000..6c4fb9f28c7de --- /dev/null +++ b/tests/crashes/111709-2.rs @@ -0,0 +1,15 @@ +//@ known-bug: #111709 +//@ edition: 2021 + +use core::arch::asm; + +extern "C" fn test() {} + +fn uwu() { + unsafe { + asm!( + "/* {0} */", + sym test::<&mut ()> + ); + } +} diff --git a/tests/crashes/111709.rs b/tests/crashes/111709.rs new file mode 100644 index 0000000000000..eef375b8924b7 --- /dev/null +++ b/tests/crashes/111709.rs @@ -0,0 +1,25 @@ +//@ known-bug: #111709 +//@ edition:2021 + +use core::arch::asm; + +struct TrapFrame; + +unsafe extern "C" fn _rust_abi_shim1(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) + ) +} diff --git a/tests/crashes/111883.rs b/tests/crashes/111883.rs new file mode 100644 index 0000000000000..fa72b28c22870 --- /dev/null +++ b/tests/crashes/111883.rs @@ -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 {} +impl<'a, T: ?Sized + Unsize, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {} +#[lang = "unsize"] +trait Unsize {} +#[lang = "coerce_unsized"] +pub trait CoerceUnsized {} +impl<'a, 'b: 'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} + +#[lang = "drop_in_place"] +fn drop_in_place_fn(a: &dyn Trait2) {} + +pub trait Trait1 { + fn foo(&self); +} + +pub struct Type1; + +impl Trait1 for Type1 { + fn foo(&self) {} +} + +pub trait Trait2 {} + +pub fn bar1() { + let a = Type1; + let b = &a as &dyn Trait1; + b.foo(); +} diff --git a/tests/crashes/113272.rs b/tests/crashes/113272.rs new file mode 100644 index 0000000000000..d161575c657ec --- /dev/null +++ b/tests/crashes/113272.rs @@ -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<&Other>>(None); + } +} diff --git a/tests/crashes/113846.rs b/tests/crashes/113846.rs new file mode 100644 index 0000000000000..0e5afb4da61b8 --- /dev/null +++ b/tests/crashes/113846.rs @@ -0,0 +1,32 @@ +//@ known-bug: #113846 +trait Www { + type W; +} + +trait Xxx: Www { + type X; +} + +trait Yyy: Xxx {} + +trait Zzz<'a>: Yyy + Xxx { + type Z; +} + +trait Aaa { + type Y: Yyy; +} + +trait Bbb: Aaa { + type B: for<'a> Zzz<'a>; +} + +impl Bbb for T +where + T: Aaa, + T::Y: for<'a> Zzz<'a>, +{ + type B = T::Y; +} + +pub fn main() {} diff --git a/tests/crashes/114212-2.rs b/tests/crashes/114212-2.rs new file mode 100644 index 0000000000000..a430c1b40d37a --- /dev/null +++ b/tests/crashes/114212-2.rs @@ -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, +} diff --git a/tests/crashes/114212.rs b/tests/crashes/114212.rs new file mode 100644 index 0000000000000..8642dbe8e71f2 --- /dev/null +++ b/tests/crashes/114212.rs @@ -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; + +impl FooTrait for Foo {} + +pub struct Bar< + const MAX_INPUT_LEN: usize = DEFAULT_MAX_INPUT_LEN, + PB = Foo, +> +where + PB: FooTrait, +{ + _pb: PhantomData, +} + +impl Bar +where + PB: FooTrait, +{ + pub fn new() -> Self { + Self { + _pb: PhantomData, + } + } +} diff --git a/tests/crashes/114317.rs b/tests/crashes/114317.rs new file mode 100644 index 0000000000000..09fd2beeba8a5 --- /dev/null +++ b/tests/crashes/114317.rs @@ -0,0 +1,6 @@ +//@ known-bug: #114317 +#![feature(generic_const_exprs)] + +struct A; + +fn main() {} diff --git a/tests/crashes/114456-2.rs b/tests/crashes/114456-2.rs new file mode 100644 index 0000000000000..eca27febb968a --- /dev/null +++ b/tests/crashes/114456-2.rs @@ -0,0 +1,20 @@ +//@ known-bug: #114456 +#![feature(adt_const_params)] + +const EMPTY_MATRIX: ::Matrix = [0; 1]; + +pub struct Walk::Matrix> {} + +impl Walk { + 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(); +} diff --git a/tests/crashes/114456.rs b/tests/crashes/114456.rs new file mode 100644 index 0000000000000..e347327e73863 --- /dev/null +++ b/tests/crashes/114456.rs @@ -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 {} + +impl Walk { + pub const fn new() -> Self { + Self {} + } +} + +fn main() { + let _ = Walk::new(); +} diff --git a/tests/crashes/114484.rs b/tests/crashes/114484.rs new file mode 100644 index 0000000000000..9d90c153624cc --- /dev/null +++ b/tests/crashes/114484.rs @@ -0,0 +1,67 @@ +//@ known-bug: #114484 +use std::marker::PhantomData; + +trait MyTrait { + fn virtualize(&self) -> &dyn MyTrait; +} + +struct VirtualWrapper(T); + +impl VirtualWrapper { + pub fn wrap(value: &T) -> &Self { + unsafe { &*(value as *const T as *const Self) } + } +} + +impl MyTrait for VirtualWrapper { + 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(level: u8, obj: &T) -> &dyn MyTrait +where + T: MyTrait + 'static, +{ + const fn gen_vtable_ptr() -> *const () + where + T: MyTrait + 'static, + { + let [_, vtable] = unsafe { + std::mem::transmute::<*const dyn MyTrait, [*const (); 2]>(std::ptr::null::< + VirtualWrapper, + >()) + }; + vtable + } + + struct Vtable(PhantomData); + + impl Vtable + where + T: MyTrait + 'static, + { + const LEVELS: [*const (); 2] = [gen_vtable_ptr::(), gen_vtable_ptr::()]; + } + + let vtable = Vtable::::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([u8; N]); + +impl MyTrait for SomeData { + fn virtualize(&self) -> &dyn MyTrait { + VirtualWrapper::::wrap(self) + } +} + +fn main() { + let test = SomeData([0; 256]); + test.virtualize(); +} diff --git a/tests/crashes/114663.rs b/tests/crashes/114663.rs new file mode 100644 index 0000000000000..406371f12e460 --- /dev/null +++ b/tests/crashes/114663.rs @@ -0,0 +1,17 @@ +//@ known-bug: #114663 +//@ edition:2021 + +#![feature(generic_const_exprs)] + +use core::fmt::Debug; + +struct Inline +where + [u8; ::core::mem::size_of::() + 1]:, +{ + _phantom: PhantomData, +} + +fn main() { + let dst = Inline::::new(0); // BANG! +} diff --git a/tests/crashes/115435.rs b/tests/crashes/115435.rs new file mode 100644 index 0000000000000..c846c95961d7a --- /dev/null +++ b/tests/crashes/115435.rs @@ -0,0 +1,23 @@ +//@ known-bug: #115435 +trait MyTrait { + type Target: ?Sized; +} + +impl MyTrait for A { + type Target = A; +} + +fn main() { + bug_run::>(); +} + +fn bug_run() +where + ::Target: Sized, +{ + bug::(); +} + +fn bug() { + std::mem::size_of::(); +} diff --git a/tests/crashes/115808.rs b/tests/crashes/115808.rs new file mode 100644 index 0000000000000..79196ac9c6544 --- /dev/null +++ b/tests/crashes/115808.rs @@ -0,0 +1,27 @@ +//@ known-bug: #115808 +#![feature(generic_const_exprs)] + +use std::ops::Mul; + +pub trait Indices { + const NUM_ELEMS: usize; +} + +pub trait Concat { + type Output; +} + +pub struct Tensor, const N: usize> +where + [u8; I::NUM_ELEMS]: Sized, {} + +impl, J: Indices, const N: usize> Mul> for Tensor +where + I: Concat, + >::Output: Indices, + [u8; I::NUM_ELEMS]: Sized, + [u8; J::NUM_ELEMS]: Sized, + [u8; >::Output::NUM_ELEMS]: Sized, +{ + type Output = Tensor<>::Output, N>; +} diff --git a/tests/crashes/116308.rs b/tests/crashes/116308.rs new file mode 100644 index 0000000000000..cb96c80d79bdc --- /dev/null +++ b/tests/crashes/116308.rs @@ -0,0 +1,16 @@ +//@ known-bug: #116308 +#![feature(adt_const_params)] + +pub trait Identity { + type Identity; +} + +impl Identity for T { + type Identity = Self; +} + +pub fn foo::Identity>() {} + +fn main() { + foo::<12>(); +} diff --git a/tests/crashes/116519-2.rs b/tests/crashes/116519-2.rs new file mode 100644 index 0000000000000..e1abbbcd4c145 --- /dev/null +++ b/tests/crashes/116519-2.rs @@ -0,0 +1,15 @@ +//@ known-bug: #116519 +#![feature(generic_const_exprs)] + +trait Ret { + type R; +} + +struct Cond(std::marker::PhantomData, ); + +struct RobinHashTable< + const MAX_LENGTH: usize, + CellIdx = as Ret>::R, +> {} + +impl HashMapBase for RobinHashTable {} diff --git a/tests/crashes/116519.rs b/tests/crashes/116519.rs new file mode 100644 index 0000000000000..0824a72be1977 --- /dev/null +++ b/tests/crashes/116519.rs @@ -0,0 +1,57 @@ +//@ known-bug: #116519 +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] +trait Ret { + type R; +} +struct Cond(std::marker::PhantomData, std::marker::PhantomData); +impl Ret for Cond { + type R = U; +} +impl Ret for Cond { + type R = V; +} +struct RobinHashTable< + const MAX_LENGTH: usize, + CellIdx = as Ret>::R, +> { + _idx: CellIdx, +} +impl RobinHashTable { + fn new() -> Self { + Self { + _idx: CellIdx { MAX_LENGTH }, + } + } +} +impl HashMapBase { + fn new() -> Self { + Self { + _idx: CellIdx { 0 }, + } + } +} +impl HashMapBase for RobinHashTable { + fn hash(&self, + + ) -> H { + self._idx.hash() + } + fn eq(&self, other: &Self) -> bool { + self._idx.eq(other._idx) + } +} +impl HashMapBase for RobinHashTable { + fn hash(&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::>()); + println!("{}", size_of::>()); +} diff --git a/tests/crashes/116554.rs b/tests/crashes/116554.rs new file mode 100644 index 0000000000000..b87a478e6f20c --- /dev/null +++ b/tests/crashes/116554.rs @@ -0,0 +1,31 @@ +//@ known-bug: #116554 +#![feature(generic_const_exprs)] + +const fn t() -> u8 { + + N as u8 + +} + +#[repr(u8)] + +enum T::A as u8 + T::<0>::B as u8 }> + +where + + [(); N as usize]:, + + T: ?Sized, + +{ + + A, + +} + +fn main() { + A = t::() as u8, + + B, + +} diff --git a/tests/crashes/116947.rs b/tests/crashes/116947.rs new file mode 100644 index 0000000000000..34f0522369e28 --- /dev/null +++ b/tests/crashes/116947.rs @@ -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() {} diff --git a/tests/crashes/117392-2.rs b/tests/crashes/117392-2.rs new file mode 100644 index 0000000000000..632ce8b9deece --- /dev/null +++ b/tests/crashes/117392-2.rs @@ -0,0 +1,27 @@ +//@ known-bug: #117392 +pub trait BorrowComposite { + type Ref<'a>: 'a; +} + +impl BorrowComposite for () { + type Ref<'a> = (); +} + +pub trait Component { + type Output; +} + +impl Component for () { + type Output = (); +} + +pub fn delay FnMut(Args::Ref<'a>) -> C, C: Component>( + make: Make, +) -> impl Component { +} + +pub fn crash() -> impl Component<()> { + delay(|()| delay(|()| ())) +} + +pub fn main() {} diff --git a/tests/crashes/117392.rs b/tests/crashes/117392.rs new file mode 100644 index 0000000000000..95fdf63f893ec --- /dev/null +++ b/tests/crashes/117392.rs @@ -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 { + type Output; +} + +impl Component for () { + type Output = (); +} + +struct Delay { + _make: Make, +} + +impl< + Args: BorrowComposite, + Make: for<'a> FnMut(Args::Ref<'a>) -> C, + C: Component, + > Component for Delay +{ + type Output = C::Output; +} + +pub fn delay< + Args: BorrowComposite, + Make: for<'a> FnMut(Args::Ref<'a>) -> C, + C: Component, +>( + make: Make, +) -> impl Component { + Delay { _make: make } +} + +pub fn crash() -> impl Component<(), Output = ()> { + delay(|()| delay(|()| ())) +} + +pub fn main() {} diff --git a/tests/crashes/117496.rs b/tests/crashes/117496.rs new file mode 100644 index 0000000000000..1e85646cf8313 --- /dev/null +++ b/tests/crashes/117496.rs @@ -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([u64; SIZE]) +where + [u64; SIZE]: Sized; + +pub struct Quux {} +impl Quux<{ F }> { + pub unsafe fn nothing(&self, bar: &mut Bar<{ F }>) {} +} diff --git a/tests/crashes/117629.rs b/tests/crashes/117629.rs new file mode 100644 index 0000000000000..d8b5f328545da --- /dev/null +++ b/tests/crashes/117629.rs @@ -0,0 +1,11 @@ +//@ known-bug: #117629 +//@ edition:2021 + +#![feature(const_trait_impl)] + +#[const_trait] +trait Tr { + async fn ft1() {} +} + +fn main() {} diff --git a/tests/crashes/117696-1.rs b/tests/crashes/117696-1.rs new file mode 100644 index 0000000000000..dfca39177855d --- /dev/null +++ b/tests/crashes/117696-1.rs @@ -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(x: T) -> T { + x +} + +fn rec(mut it: T) +where + T: Iterator, +{ + if () == () { + T::count(it); + } else { + rec(identity(&mut it)) + } +} diff --git a/tests/crashes/117696-2.rs b/tests/crashes/117696-2.rs new file mode 100644 index 0000000000000..9c2a68d3a915c --- /dev/null +++ b/tests/crashes/117696-2.rs @@ -0,0 +1,13 @@ +//@ known-bug: #117696 +//@ compile-flags: -Copt-level=0 +fn main() { + rec(&mut None::<()>.into_iter()); +} + +fn rec(mut it: T) { + if true { + it.next(); + } else { + rec(&mut it); + } +} diff --git a/tests/crashes/117795.rs b/tests/crashes/117795.rs new file mode 100644 index 0000000000000..3f0dd2f9bf4f9 --- /dev/null +++ b/tests/crashes/117795.rs @@ -0,0 +1,8 @@ +//@ known-bug: #117795 +const fn f() -> usize { + 5 +} + +fn main() { + let _ = [0; FnMut::call_mut(&mut f, ())]; +} diff --git a/tests/crashes/117829-2.rs b/tests/crashes/117829-2.rs new file mode 100644 index 0000000000000..ecfd3148569df --- /dev/null +++ b/tests/crashes/117829-2.rs @@ -0,0 +1,14 @@ +//@ known-bug: #117829 +#![feature(auto_traits)] + +trait B {} + +auto trait Z +where + T: Z, + >::W: B, +{ + type W; +} + +fn main() {} diff --git a/tests/crashes/117829.rs b/tests/crashes/117829.rs new file mode 100644 index 0000000000000..7544b5ec0fceb --- /dev/null +++ b/tests/crashes/117829.rs @@ -0,0 +1,9 @@ +//@ known-bug: #117829 +auto trait Z<'a, T: ?Sized> +where + T: Z<'a, u16>, + + for<'b> >::W: Clone, +{ + type W: ?Sized; +} diff --git a/tests/crashes/117942.rs b/tests/crashes/117942.rs new file mode 100644 index 0000000000000..6fdfc6892506e --- /dev/null +++ b/tests/crashes/117942.rs @@ -0,0 +1,7 @@ +//@ known-bug: #117942 +struct Foo { + _: union { + #[rustfmt::skip] + f: String + }, +} diff --git a/tests/crashes/118038.rs b/tests/crashes/118038.rs new file mode 100644 index 0000000000000..a346e84c78f49 --- /dev/null +++ b/tests/crashes/118038.rs @@ -0,0 +1,12 @@ +//@ known-bug: #118038 +#![feature(non_lifetime_binders)] + +fn trivial() +where + for dyn Fn(A, *const A): Fn(A, *const B), +{ +} + +fn main() { + trivial::(); +} diff --git a/tests/crashes/118320.rs b/tests/crashes/118320.rs new file mode 100644 index 0000000000000..0f47c923e1058 --- /dev/null +++ b/tests/crashes/118320.rs @@ -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())(); +}; diff --git a/tests/crashes/118403.rs b/tests/crashes/118403.rs new file mode 100644 index 0000000000000..21ab15f9ffd0a --- /dev/null +++ b/tests/crashes/118403.rs @@ -0,0 +1,8 @@ +//@ known-bug: #118403 +#![feature(generic_const_exprs)] +pub struct X {} +impl X { + pub fn y<'a, U: 'a>(&'a self) -> impl Iterator + '_> { + (0..1).map(move |_| (0..1).map(move |_| loop {})) + } +} diff --git a/tests/crashes/118603.rs b/tests/crashes/118603.rs new file mode 100644 index 0000000000000..cde2cf3530571 --- /dev/null +++ b/tests/crashes/118603.rs @@ -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); + +const fn const_concat(_: [FlatTree; A], _: [FlatTree; B]) -> [FlatTree; A + B] { + [FlatTree; A + B] +} + +struct Builder { + ops: [FlatTree; N], + builder: I, +} + +fn create_node(a: Builder, b: Builder) -> Builder<{ N + M + 1 }, TreeNode> { + Builder { + ops: const_concat(const_concat::(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() {} diff --git a/tests/crashes/118952-2.rs b/tests/crashes/118952-2.rs new file mode 100644 index 0000000000000..469b1e8e90599 --- /dev/null +++ b/tests/crashes/118952-2.rs @@ -0,0 +1,10 @@ +//@ known-bug: #118952 +#![feature(generic_const_exprs)] + +pub struct TinyVec +where + [(); () - std::mem::size_of() - std::mem::size_of::()]:, {} + +pub fn main() { + let t = TinyVec::::new(); +} diff --git a/tests/crashes/118952.rs b/tests/crashes/118952.rs new file mode 100644 index 0000000000000..cd873703284dd --- /dev/null +++ b/tests/crashes/118952.rs @@ -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::() * 8; + +pub const fn tiny_vec_cap() -> usize { + return (DEFAULT_SMALL_VEC_INLINE_CAPACITY - 1) / std::mem::size_of::() +} + +pub struct TinyVec()}> + where [ + (); + (N * std::mem::size_of::()) + - std::mem::size_of::>() + - std::mem::size_of::() + ]: , +{ + data: isize //TinyVecData, +} + +pub fn main() { + let t = TinyVec::::new(); +} diff --git a/tests/crashes/118987-2.rs b/tests/crashes/118987-2.rs new file mode 100644 index 0000000000000..4382a7bcb6397 --- /dev/null +++ b/tests/crashes/118987-2.rs @@ -0,0 +1,17 @@ +//@ known-bug: #118987 +#![feature(specialization)] //~ WARN the feature `specialization` is incomplete + +trait Assoc { + type Output; +} + +default impl Assoc for T { + type Output = bool; +} + +impl Assoc for u8 {} + +trait Foo {} + +impl Foo for ::Output {} +impl Foo for ::Output {} diff --git a/tests/crashes/118987.rs b/tests/crashes/118987.rs new file mode 100644 index 0000000000000..4382a7bcb6397 --- /dev/null +++ b/tests/crashes/118987.rs @@ -0,0 +1,17 @@ +//@ known-bug: #118987 +#![feature(specialization)] //~ WARN the feature `specialization` is incomplete + +trait Assoc { + type Output; +} + +default impl Assoc for T { + type Output = bool; +} + +impl Assoc for u8 {} + +trait Foo {} + +impl Foo for ::Output {} +impl Foo for ::Output {} diff --git a/tests/crashes/119272.rs b/tests/crashes/119272.rs new file mode 100644 index 0000000000000..02e2cfd09e2f8 --- /dev/null +++ b/tests/crashes/119272.rs @@ -0,0 +1,27 @@ +//@ known-bug: #119272 +#![feature(type_alias_impl_trait)] +mod defining_scope { + use super::*; + pub type Alias = impl Sized; + + pub fn cast(x: Container, T>) -> Container { + x + } +} + +struct Container, U> { + x: >::Assoc, +} + +trait Trait { + type Assoc; +} + +impl Trait for T { + type Assoc = Box; +} +impl Trait for defining_scope::Alias { + type Assoc = usize; +} + +fn main() {} diff --git a/tests/crashes/119299.rs b/tests/crashes/119299.rs new file mode 100644 index 0000000000000..c8c10546d9409 --- /dev/null +++ b/tests/crashes/119299.rs @@ -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() -> [char; 3] { + ['a','b','c'] +} + +fn main() { + const A: &'static ConstStrU = &ConstStrU::from_bytes(b"abc"); + chars_s::(); +} diff --git a/tests/crashes/119692.rs b/tests/crashes/119692.rs new file mode 100644 index 0000000000000..3b7457a7abe93 --- /dev/null +++ b/tests/crashes/119692.rs @@ -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(pub(crate) S); + +impl Add> for Quantity +where + LHS: Add, +{ + type Output = Quantity<>::Output, D>; + fn add(self, rhs: Quantity) -> Self::Output { + Quantity(self.0 + rhs.0) + } +} + +impl Add for Quantity +where + LHS: Add, +{ + type Output = Quantity<>::Output, { Dimension }>; + fn add(self, rhs: RHS) -> Self::Output { + Quantity(self.0 + rhs) + } +} + +impl Add> for f32 { + type Output = Quantity; + fn add(self, rhs: Quantity) -> Self::Output { + Quantity(self + rhs.0) + } +} + +pub fn add(x: Quantity, y: Quantity) -> Quantity { + x + y +} + +fn main() { + add(Quantity::(1.0), Quantity(2.0)); +} diff --git a/tests/crashes/119694.rs b/tests/crashes/119694.rs new file mode 100644 index 0000000000000..f655ea1cd343c --- /dev/null +++ b/tests/crashes/119694.rs @@ -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); +} diff --git a/tests/crashes/119701.rs b/tests/crashes/119701.rs new file mode 100644 index 0000000000000..5f681bb8da88a --- /dev/null +++ b/tests/crashes/119701.rs @@ -0,0 +1,21 @@ +//@ known-bug: #119701 +#![feature(const_trait_impl, effects, generic_const_exprs)] + +fn main() { + let _ = process::<()>([()]); +} + +fn process() -> [(); T::make(2)] { + input +} + +#[const_trait] +trait Trait { + fn make(input: u8) -> usize; +} + +impl const Trait for () { + fn make(input: usize) -> usize { + input / 2 + } +} diff --git a/tests/crashes/119716-2.rs b/tests/crashes/119716-2.rs new file mode 100644 index 0000000000000..9cdc4417f5ba9 --- /dev/null +++ b/tests/crashes/119716-2.rs @@ -0,0 +1,4 @@ +//@ known-bug: #119716 +#![feature(non_lifetime_binders)] +trait Trait {} +fn f() -> impl for Trait> {} diff --git a/tests/crashes/119716.rs b/tests/crashes/119716.rs new file mode 100644 index 0000000000000..d7cba0f51c4e0 --- /dev/null +++ b/tests/crashes/119716.rs @@ -0,0 +1,4 @@ +//@ known-bug: #119716 +#![feature(non_lifetime_binders)] +trait v0 {} +fn kind :(v3main impl for v0<'_, v2 = impl v0 + '_>) {} diff --git a/tests/crashes/119717.rs b/tests/crashes/119717.rs new file mode 100644 index 0000000000000..22746548e02cb --- /dev/null +++ b/tests/crashes/119717.rs @@ -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 + } +} diff --git a/tests/crashes/119729.rs b/tests/crashes/119729.rs new file mode 100644 index 0000000000000..ed07c58e89fdf --- /dev/null +++ b/tests/crashes/119729.rs @@ -0,0 +1,12 @@ +//@ known-bug: #119729 +#![feature(generic_const_exprs)] + +trait Size {} + +impl Size<{ std::mem::size_of::() }> for T {} + +struct A + ?Sized> { + x: std::marker::PhantomData, +} + +fn foo(x: A) {} diff --git a/tests/crashes/119783.rs b/tests/crashes/119783.rs new file mode 100644 index 0000000000000..9a41abe69206e --- /dev/null +++ b/tests/crashes/119783.rs @@ -0,0 +1,8 @@ +//@ known-bug: #119783 +#![feature(associated_const_equality)] + +trait Trait { const F: fn(); } + +fn take(_: impl Trait) {} + +fn main() {} diff --git a/tests/crashes/119786.rs b/tests/crashes/119786.rs new file mode 100644 index 0000000000000..ca79664d8b74c --- /dev/null +++ b/tests/crashes/119786.rs @@ -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() {} diff --git a/tests/crashes/119824.rs b/tests/crashes/119824.rs new file mode 100644 index 0000000000000..d51cd5f49a395 --- /dev/null +++ b/tests/crashes/119824.rs @@ -0,0 +1,14 @@ +//@ known-bug: #119824 +#![feature(generic_const_exprs)] + +const fn t() -> u8 { + N as u8 +} + +#[repr(u8)] +enum T::A as u8 + T::<0>::B as u8 }> +where + [(); N as usize]: +{ + A = t::() as u8, B +} diff --git a/tests/crashes/119830.rs b/tests/crashes/119830.rs new file mode 100644 index 0000000000000..71becc04e1696 --- /dev/null +++ b/tests/crashes/119830.rs @@ -0,0 +1,11 @@ +//@ known-bug: #119830 +#![feature(effects)] +#![feature(min_specialization)] + +trait Specialize {} + +trait Foo {} + +impl const Foo for T {} + +impl const Foo for T where T: const Specialize {} diff --git a/tests/crashes/119924-6.rs b/tests/crashes/119924-6.rs new file mode 100644 index 0000000000000..01c4f43e8fd43 --- /dev/null +++ b/tests/crashes/119924-6.rs @@ -0,0 +1,14 @@ +//@ known-bug: #119924 +#![feature(const_trait_impl, effects)] + +struct S; +#[const_trait] +trait Trait {} + +const fn f>(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() {} diff --git a/tests/crashes/120241-2.rs b/tests/crashes/120241-2.rs new file mode 100644 index 0000000000000..c7044950211f7 --- /dev/null +++ b/tests/crashes/120241-2.rs @@ -0,0 +1,9 @@ +//@ known-bug: #120241 +#![feature(object_safe_for_dispatch)] +#![feature(unsized_fn_params)] + +fn guard(_s: Copy) -> bool { + panic!() +} + +fn main() {} diff --git a/tests/crashes/120241.rs b/tests/crashes/120241.rs new file mode 100644 index 0000000000000..f19fdf1a902ce --- /dev/null +++ b/tests/crashes/120241.rs @@ -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() {} diff --git a/tests/crashes/120482.rs b/tests/crashes/120482.rs new file mode 100644 index 0000000000000..1045aeb19c8fe --- /dev/null +++ b/tests/crashes/120482.rs @@ -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() {} diff --git a/tests/crashes/120503.rs b/tests/crashes/120503.rs new file mode 100644 index 0000000000000..28f1e3dfd94c4 --- /dev/null +++ b/tests/crashes/120503.rs @@ -0,0 +1,10 @@ +//@ known-bug: #120503 +#![feature(effects)] + +trait MyTrait {} + +impl MyTrait for i32 { + async const fn bar(&self) { + main8().await; + } +} diff --git a/tests/crashes/120600-2.rs b/tests/crashes/120600-2.rs new file mode 100644 index 0000000000000..aa1785eea84c4 --- /dev/null +++ b/tests/crashes/120600-2.rs @@ -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() {} diff --git a/tests/crashes/120600.rs b/tests/crashes/120600.rs new file mode 100644 index 0000000000000..1be51a8da1602 --- /dev/null +++ b/tests/crashes/120600.rs @@ -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() {} diff --git a/tests/crashes/120793-2.rs b/tests/crashes/120793-2.rs new file mode 100644 index 0000000000000..0ce5e4df2247c --- /dev/null +++ b/tests/crashes/120793-2.rs @@ -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()]; +} diff --git a/tests/crashes/120793.rs b/tests/crashes/120793.rs new file mode 100644 index 0000000000000..7e9166a50e553 --- /dev/null +++ b/tests/crashes/120793.rs @@ -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) -> usize { + 3 + } +} + +fn main() { + let array: [usize; Dim3::dim()] + //~^ ERROR E0015 + = [0; Dim3::dim()]; + //~^ ERROR E0015 +} diff --git a/tests/crashes/120873.rs b/tests/crashes/120873.rs new file mode 100644 index 0000000000000..45bc0bd457b10 --- /dev/null +++ b/tests/crashes/120873.rs @@ -0,0 +1,8 @@ +//@ known-bug: #120873 +#[repr(packed)] + +struct Dealigned(u8, T); + +#[derive(PartialEq)] +#[repr(C)] +struct Dealigned(u8, T); diff --git a/tests/crashes/120911.rs b/tests/crashes/120911.rs new file mode 100644 index 0000000000000..9bd2bf681420e --- /dev/null +++ b/tests/crashes/120911.rs @@ -0,0 +1,26 @@ +//@ known-bug: #120911 +trait Container { + type Item<'a>; +} +impl Container for () { + type Item<'a> = (); +} +struct Exchange { + _marker: std::marker::PhantomData<(C, F)>, +} +fn exchange(_: F) -> Exchange +where + C: Container, + for<'a> F: FnMut(&C::Item<'a>), +{ + unimplemented!() +} +trait Parallelization {} +impl Parallelization for Exchange {} +fn unary_frontier>(_: P) {} +fn main() { + let exchange = exchange(|_| ()); + let _ = || { + unary_frontier(exchange); + }; +} diff --git a/tests/crashes/121052.rs b/tests/crashes/121052.rs new file mode 100644 index 0000000000000..5d16b06db237d --- /dev/null +++ b/tests/crashes/121052.rs @@ -0,0 +1,32 @@ +//@ known-bug: #121052 +#![feature(generic_const_exprs, with_negative_coherence)] + +use std::ops::Mul; + +pub trait Indices { + const NUM_ELEMS: usize; +} + +impl, J: Indices, const N: usize> Mul for Tensor +where + I: Concat, + >::Output: Indices, + [u8; I::NUM_ELEMS]: Sized, + [u8; J::NUM_ELEMS]: Sized, + [u8; >::Output::NUM_ELEMS]: Sized, +{ +} + +pub trait Concat {} + +pub struct Tensor, const N: usize> {} + +impl, J: Indices, const N: usize> Mul for Tensor +where + I: Concat, + >::Output: Indices, + [u8; I::NUM_ELEMS]: Sized, + [u8; J::NUM_ELEMS]: Sized, + [u8; >::Output::NUM_ELEMS]: Sized, +{ +} diff --git a/tests/crashes/121097.rs b/tests/crashes/121097.rs new file mode 100644 index 0000000000000..65c6028e03e36 --- /dev/null +++ b/tests/crashes/121097.rs @@ -0,0 +1,10 @@ +//@ known-bug: #121097 +#[repr(simd)] +enum Aligned { + Zero = 0, + One = 1, +} + +fn tou8(al: Aligned) -> u8 { + al as u8 +} diff --git a/tests/crashes/121126.rs b/tests/crashes/121126.rs new file mode 100644 index 0000000000000..2ebe91f02ded9 --- /dev/null +++ b/tests/crashes/121126.rs @@ -0,0 +1,4 @@ +//@ known-bug: #121126 +fn main() { + let _n = 1i64 >> [64][4_294_967_295]; +} diff --git a/tests/crashes/121134.rs b/tests/crashes/121134.rs new file mode 100644 index 0000000000000..36397d4ec3c0d --- /dev/null +++ b/tests/crashes/121134.rs @@ -0,0 +1,20 @@ +//@ known-bug: #121134 +trait Output<'a> { + type Type; +} + +struct Wrapper; + +impl Wrapper { + fn do_something_wrapper(&mut self, do_something_wrapper: F) + where + FnOnce:, + F: for<'a> FnOnce(>::Type), + { + } +} + +fn main() { + let mut wrapper = Wrapper; + wrapper.do_something_wrapper::(|value| ()); +} diff --git a/tests/crashes/121161.rs b/tests/crashes/121161.rs new file mode 100644 index 0000000000000..6da6426a86d92 --- /dev/null +++ b/tests/crashes/121161.rs @@ -0,0 +1,12 @@ +//@ known-bug: #121161 +#![allow(incomplete_features)] +#![feature(unnamed_fields)] + + +#[derive(Eq)] +#[repr(C)] +struct Bar { + _: union { + a: u8, + }, +} diff --git a/tests/crashes/121263-2.rs b/tests/crashes/121263-2.rs new file mode 100644 index 0000000000000..2c6327a8808a5 --- /dev/null +++ b/tests/crashes/121263-2.rs @@ -0,0 +1,6 @@ +//@ known-bug: #121263 +#[repr(C)] +#[derive(Debug)] +struct L { + _: MyI32, +} diff --git a/tests/crashes/121263.rs b/tests/crashes/121263.rs new file mode 100644 index 0000000000000..cd7583a7fafce --- /dev/null +++ b/tests/crashes/121263.rs @@ -0,0 +1,9 @@ +//@ known-bug: #121263 +#[repr(C)] +#[repr(C)] +#[derive(Debug)] +struct L { + _: i32, + _: MyI32, + _: BadEnum, +} diff --git a/tests/crashes/121299.rs b/tests/crashes/121299.rs new file mode 100644 index 0000000000000..be5e0c0df573e --- /dev/null +++ b/tests/crashes/121299.rs @@ -0,0 +1,6 @@ +//@ known-bug: #121299 +#[derive(Eq)] +struct D { + _: union { + }, +} diff --git a/tests/crashes/121411.rs b/tests/crashes/121411.rs new file mode 100644 index 0000000000000..ef7b16579dd58 --- /dev/null +++ b/tests/crashes/121411.rs @@ -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(&()); diff --git a/tests/crashes/121422.rs b/tests/crashes/121422.rs new file mode 100644 index 0000000000000..5d7ef6e8ce991 --- /dev/null +++ b/tests/crashes/121422.rs @@ -0,0 +1,8 @@ +//@ known-bug: #121422 +#![feature(non_lifetime_binders)] + +trait Trait {} + +fn produce() -> impl for Trait<(), Assoc = impl Trait> { + 16 +} diff --git a/tests/crashes/121429.rs b/tests/crashes/121429.rs new file mode 100644 index 0000000000000..09bd343e0ba99 --- /dev/null +++ b/tests/crashes/121429.rs @@ -0,0 +1,17 @@ +//@ known-bug: #121429 +#![feature(generic_const_exprs)] + +pub trait True {} + +impl PartialEq> for FixedI8 where + If<{}>: True +{ +} +#![feature(generic_const_exprs)] + +pub trait True {} + +impl PartialEq> for FixedI8 where + If<{}>: True +{ +} diff --git a/tests/crashes/121444.rs b/tests/crashes/121444.rs new file mode 100644 index 0000000000000..5a4289203ddb0 --- /dev/null +++ b/tests/crashes/121444.rs @@ -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)); +} diff --git a/tests/crashes/121536.rs b/tests/crashes/121536.rs new file mode 100644 index 0000000000000..000e7cb15eb2f --- /dev/null +++ b/tests/crashes/121536.rs @@ -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 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, + } + } +} diff --git a/tests/crashes/121574-2.rs b/tests/crashes/121574-2.rs new file mode 100644 index 0000000000000..a08f3f063974b --- /dev/null +++ b/tests/crashes/121574-2.rs @@ -0,0 +1,8 @@ +//@ known-bug: #121574 +#![feature(generic_const_exprs)] +pub struct DimName {} +impl X { + pub fn y<'a, U: 'a>(&'a self) -> impl Iterator + '_> { + "0".as_bytes(move |_| (0..1).map(move |_| loop {})) + } +} diff --git a/tests/crashes/121574.rs b/tests/crashes/121574.rs new file mode 100644 index 0000000000000..53eec829c5f38 --- /dev/null +++ b/tests/crashes/121574.rs @@ -0,0 +1,6 @@ +//@ known-bug: #121574 +#![feature(generic_const_exprs)] + +impl X { + pub fn y<'a, U: 'a>(&'a self) -> impl Iterator + '_> {} +} diff --git a/tests/crashes/121575.rs b/tests/crashes/121575.rs new file mode 100644 index 0000000000000..f0ce26c6f9564 --- /dev/null +++ b/tests/crashes/121575.rs @@ -0,0 +1,107 @@ +//@ known-bug: #121575 +// ignore-tidy-linelength +#![feature(generic_const_exprs)] + +use std::array; + +trait PrimRec { + fn eval(&self, x: [usize; N]) -> [usize; O]; +} + +struct Zero; + +impl PrimRec for Zero { + fn eval(&self, _: [usize; N]) -> [usize; 1] { + [0] + } +} + +struct Const(usize); + +impl PrimRec 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; + +impl PrimRec for Proj { + fn eval(&self, x: [usize; N]) -> [usize; 1] { + [x[I]] + } +} + +struct Merge, B: PrimRec>( + A, + B, +); + +fn concat(a: [usize; M], b: [usize; N]) -> [usize; M + N] { + array::from_fn(|i| if i < M { a[i] } else { b[i - M] }) +} + +impl, B: PrimRec> + PrimRec for Merge +{ + fn eval(&self, x: [usize; N]) -> [usize; O1 + O2] { + concat(self.0.eval(x), self.1.eval(x)) + } +} + +struct Compose, B: PrimRec>( + A, + B, +); + +impl, B: PrimRec> + PrimRec for Compose +{ + fn eval(&self, x: [usize; N]) -> [usize; O] { + self.1.eval(self.0.eval(x)) + } +} + +struct Rec, F: PrimRec<{ O + (N + 1) }, O>>( + Base, + F, +); + +fn tail(x: [usize; N + 1]) -> [usize; N] { + array::from_fn(|i| x[i + 1]) +} + +fn cons(x: usize, xs: [usize; N]) -> [usize; N + 1] { + array::from_fn(|i| if i == 0 { x } else { xs[i - 1] }) +} + +impl, F: PrimRec<{ O + (N + 1) }, O>> + PrimRec<{ N + 1 }, O> for Rec +{ + 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])); +} diff --git a/tests/crashes/121585-1.rs b/tests/crashes/121585-1.rs new file mode 100644 index 0000000000000..2a4638efcabdd --- /dev/null +++ b/tests/crashes/121585-1.rs @@ -0,0 +1,13 @@ +//@ known-bug: #121585 +#![feature(generic_const_exprs)] + +trait Trait {} + +struct HasCastInTraitImpl; +impl Trait for HasCastInTraitImpl {} + +pub fn use_trait_impl() { + fn assert_impl() {} + + assert_impl::>(); +} diff --git a/tests/crashes/121585-2.rs b/tests/crashes/121585-2.rs new file mode 100644 index 0000000000000..99cc8f7919559 --- /dev/null +++ b/tests/crashes/121585-2.rs @@ -0,0 +1,30 @@ +//@ known-bug: #121585 +//@ check-pass +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +trait Trait {} +pub struct EvaluatableU128; + +struct HasCastInTraitImpl; +impl Trait for HasCastInTraitImpl {} + +pub fn use_trait_impl() where EvaluatableU128<{N as u128}>:, { + fn assert_impl() {} + + assert_impl::>(); + assert_impl::>(); + assert_impl::>(); + assert_impl::>(); +} +pub fn use_trait_impl_2() where EvaluatableU128<{N as _}>:, { + fn assert_impl() {} + + assert_impl::>(); + assert_impl::>(); + assert_impl::>()const NUM: u8 = xyz(); + assert_impl::>(); +} + + +fn main() {} diff --git a/tests/crashes/121613-2.rs b/tests/crashes/121613-2.rs new file mode 100644 index 0000000000000..ddc4f37c96a2f --- /dev/null +++ b/tests/crashes/121613-2.rs @@ -0,0 +1,28 @@ +//@ known-bug: #121613 +fn main() { + // destructure through a qualified path + let ::Assoc { br } = StructStruct { br: 2 }; + //~^ ERROR usage of qualified paths in this context is experimental + let _ = ::Assoc { br: 2 }; + //~^ ERROR usage of qualified paths in this context is experimental + let ::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) +} diff --git a/tests/crashes/121613.rs b/tests/crashes/121613.rs new file mode 100644 index 0000000000000..ec9ba82a68c5f --- /dev/null +++ b/tests/crashes/121613.rs @@ -0,0 +1,24 @@ +//@ known-bug: #121613 +fn main() { + let _ = ::Assoc { br: 2 }; + + let ::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), +} diff --git a/tests/crashes/121623.rs b/tests/crashes/121623.rs new file mode 100644 index 0000000000000..3c01a7f452ca7 --- /dev/null +++ b/tests/crashes/121623.rs @@ -0,0 +1,8 @@ +//@ known-bug: #121623 +fn main() { + match () { + _ => 'b: { + continue 'b; + } + } +} diff --git a/tests/crashes/121722.rs b/tests/crashes/121722.rs new file mode 100644 index 0000000000000..d1b8c447bf727 --- /dev/null +++ b/tests/crashes/121722.rs @@ -0,0 +1,10 @@ +//@ known-bug: #121722 +#[repr(C)] +struct Foo { + _: u8, +} + +#[repr(C)] +struct D { + _: Foo, +} diff --git a/tests/crashes/121799.rs b/tests/crashes/121799.rs new file mode 100644 index 0000000000000..6035c9d9b150d --- /dev/null +++ b/tests/crashes/121799.rs @@ -0,0 +1,11 @@ +//@ known-bug: #121799 +struct S { + _: str +} + +fn func(a: S) +{ + let _x = a.f; +} + +fn main() {} diff --git a/tests/crashes/121816.rs b/tests/crashes/121816.rs new file mode 100644 index 0000000000000..a5569ea19d3ea --- /dev/null +++ b/tests/crashes/121816.rs @@ -0,0 +1,12 @@ +//@ known-bug: #121816 +fn f<'a, T>(_: &'static &'a (), x: &'a T) -> &'static T { + x +} +trait W<'a> { + fn g(self, x: &'a T) -> &'static T; +} +impl<'a> W<'a> for &'static () { + fn g(self, x: &'a T) -> &'static T { + f(&self, x) + } +} diff --git a/tests/crashes/121858-2.rs b/tests/crashes/121858-2.rs new file mode 100644 index 0000000000000..cb80c081cffa3 --- /dev/null +++ b/tests/crashes/121858-2.rs @@ -0,0 +1,20 @@ +//@ known-bug: #121858 +#![allow(named_arguments_used_positionally)] +#![feature(generic_const_exprs)] +struct Inner; +impl Inner where [(); N + M]: { + fn i() -> Self { + Self + } +} + +struct Outer(Inner) where [(); A + (B * 2)]:; +impl Outer where [(); A + (B * 2)]: { + fn o() -> Union { + Self(Inner::i()) + } +} + +fn main() { + Outer::<1, 1>::o(); +} diff --git a/tests/crashes/121858.rs b/tests/crashes/121858.rs new file mode 100644 index 0000000000000..7d5bae37f846b --- /dev/null +++ b/tests/crashes/121858.rs @@ -0,0 +1,14 @@ +//@ known-bug: #121858 +#![feature(generic_const_exprs)] + +struct Outer(); +impl Outer +where + [(); A + (B * 2)]:, +{ + fn o() -> Union {} +} + +fn main() { + Outer::<1, 1>::o(); +} diff --git a/tests/crashes/121957-1.rs b/tests/crashes/121957-1.rs new file mode 100644 index 0000000000000..74b4649cc9d95 --- /dev/null +++ b/tests/crashes/121957-1.rs @@ -0,0 +1,20 @@ +//@ known-bug: #121957 +#![feature(const_trait_impl, effects)] + +#[const_trait] +trait Main { + fn compute() -> 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::<()>(); +} diff --git a/tests/crashes/121957-2.rs b/tests/crashes/121957-2.rs new file mode 100644 index 0000000000000..74b4649cc9d95 --- /dev/null +++ b/tests/crashes/121957-2.rs @@ -0,0 +1,20 @@ +//@ known-bug: #121957 +#![feature(const_trait_impl, effects)] + +#[const_trait] +trait Main { + fn compute() -> 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::<()>(); +} diff --git a/tests/crashes/121963.rs b/tests/crashes/121963.rs new file mode 100644 index 0000000000000..c2ee8716f53a5 --- /dev/null +++ b/tests/crashes/121963.rs @@ -0,0 +1,26 @@ +//@ known-bug: #121963 +#![feature(generic_const_exprs)] +use std::marker::PhantomData; + +trait Arch { + const CHANNEL_COUNT: usize = 2; +} + +struct Channel { + r: [u8; N], +} + +struct Dram> { + a: PhantomData, + s: PhantomData, +} + +struct C +where + Channel<{ A::CHANNEL_COUNT }, u8>: Sized, +{ + b: Dram, + // b: Dram>, // When I specified generic here, it worked +} + +fn main() {} diff --git a/tests/crashes/122044.rs b/tests/crashes/122044.rs new file mode 100644 index 0000000000000..4c1d0de5719e8 --- /dev/null +++ b/tests/crashes/122044.rs @@ -0,0 +1,38 @@ +//@ known-bug: #122044 +use std::hint::black_box; + +trait Func { + type Ret: Id; +} + +trait Id { + type Assoc; +} +impl Id for u32 {} +impl Id for u32 {} + +impl R, R: Id> Func for F { + type Ret = R; +} + +fn bar() -> impl Copy + Id { + 0u32 +} + +struct Foo { + _func: T, + value: Option<<::Ret as Id>::Assoc>, +} + +fn main() { + let mut fn_def = black_box(Foo { + _func: bar, + value: None, + }); + let fn_ptr = black_box(Foo { + _func: bar as fn() -> _, + value: None, + }); + + fn_def.value = fn_ptr.value; +} diff --git a/tests/crashes/122529.rs b/tests/crashes/122529.rs new file mode 100644 index 0000000000000..87d393a453243 --- /dev/null +++ b/tests/crashes/122529.rs @@ -0,0 +1,8 @@ +//@ known-bug: #122529 +pub trait Archive { + type Archived; +} + +impl<'a> Archive for <&'a [u8] as Archive>::Archived { + type Archived = (); +} diff --git a/tests/crashes/122548.rs b/tests/crashes/122548.rs new file mode 100644 index 0000000000000..232ce5d441313 --- /dev/null +++ b/tests/crashes/122548.rs @@ -0,0 +1,17 @@ +//@ known-bug: #122548 +#![feature(const_mut_refs)] +#![feature(const_refs_to_static)] + +use std::cell::UnsafeCell; + +struct Meh { + x: &'static UnsafeCell, +} + +const MUH: Meh = Meh { + x: &mut *(&READONLY as *const _ as *mut _), +}; + +static READONLY: i32 = 0; + +pub fn main() {} diff --git a/tests/crashes/122552.rs b/tests/crashes/122552.rs new file mode 100644 index 0000000000000..29566941e22b2 --- /dev/null +++ b/tests/crashes/122552.rs @@ -0,0 +1,10 @@ +//@ known-bug: #122552 +//@ edition:2021 + +trait X { + fn line_stream<'a, Repr>() -> Self::LineStreamFut<{ async {} }, Repr>; +} + +struct Y; + +pub fn main() {} diff --git a/tests/crashes/122587-1.rs b/tests/crashes/122587-1.rs new file mode 100644 index 0000000000000..ea0e843a10cea --- /dev/null +++ b/tests/crashes/122587-1.rs @@ -0,0 +1,5 @@ +//@ known-bug: #122587 +const b: f16 = 0.0f16; +pub fn main() { + let b = 0.0f16; +} diff --git a/tests/crashes/122638.rs b/tests/crashes/122638.rs new file mode 100644 index 0000000000000..af0fc5bbd5031 --- /dev/null +++ b/tests/crashes/122638.rs @@ -0,0 +1,12 @@ +//@ known-bug: #122638 +#![feature(min_specialization)] + +impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, { N }> { + fn next(&mut self) -> Option {} +} + +struct ConstChunksExact<'a, T: '_, const assert: usize> {} + +impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { + type Item = &'a [T; N]; +} diff --git a/tests/crashes/122681.rs b/tests/crashes/122681.rs new file mode 100644 index 0000000000000..7dae276950e1d --- /dev/null +++ b/tests/crashes/122681.rs @@ -0,0 +1,10 @@ +//@ known-bug: #122681 +#[rustc_layout_scalar_valid_range_start(1)] +struct UnitStruct; + +#[derive(Default)] +enum SomeEnum { + #[default] + Unit, + Tuple(UnitStruct), +} diff --git a/tests/crashes/122704.rs b/tests/crashes/122704.rs new file mode 100644 index 0000000000000..d6c07be831885 --- /dev/null +++ b/tests/crashes/122704.rs @@ -0,0 +1,14 @@ +//@ known-bug: #122704 +use std::any::Any; + +pub struct Foo { + bar: Box Fn(&'a usize) -> Box>, +} + +impl Foo { + pub fn ack(&mut self, f: impl for<'a> Fn(&'a usize) -> Box) { + self.bar = Box::new(|baz| Box::new(f(baz))); + } +} + +fn main() {} diff --git a/tests/crashes/122710.rs b/tests/crashes/122710.rs new file mode 100644 index 0000000000000..16911fd522f8e --- /dev/null +++ b/tests/crashes/122710.rs @@ -0,0 +1,24 @@ +//@ known-bug: #122710 +use std::marker::PhantomData; + +pub trait BarTrait { + fn bar(self, _: T); +} + +impl BarTrait for F { + fn bar(self, _: T) { } +} + +impl MyTrait<'a>> BarTrait for () { + fn bar(self, _: T) { } +} + +pub trait MyTrait<'a> { } + +impl<'a> MyTrait<'a> for PhantomData<&'a ()> { } + +fn foo() { + ().bar(PhantomData); +} + +pub fn main() {} diff --git a/tests/crashes/122736.rs b/tests/crashes/122736.rs new file mode 100644 index 0000000000000..83b60444c2f4d --- /dev/null +++ b/tests/crashes/122736.rs @@ -0,0 +1,15 @@ +//@ known-bug: #122736 +fn main_ref() { + let array = [(); { + let mut x = &0; + let mut n = 0; + while n < 5 { + x = &0; + } + 0 + }]; + + let mut ptrs: Vec<*const [u8]> = vec![&array[0..0], &array[0..1], &array, &array[1..]]; +} + +fn main() {} diff --git a/tests/crashes/122823.rs b/tests/crashes/122823.rs new file mode 100644 index 0000000000000..ec22b331ad929 --- /dev/null +++ b/tests/crashes/122823.rs @@ -0,0 +1,69 @@ +//@ known-bug: #122823 +//@ compile-flags: -Copt-level=0 +// ignore-tidy-linelength + +use std::vec::Vec; +use std::iter::Peekable; + +pub fn main() { + let packet = decode(vec![1,0,1,0]); +} + +pub fn decode(bitstream: Vec) -> Packet { + let mut bitstream_itr = bitstream.into_iter().peekable(); + return match decode_packet(&mut bitstream_itr) { + Some(p) => p, + None => panic!("expected outer packet"), + } +} + +pub fn decode_packets>(itr: &mut Peekable) -> Vec { + let mut res = Vec::new(); + loop { + match decode_packet(itr) { + Some(p) => { res.push(p); }, + None => break + } + } + + return res; +} + +pub fn decode_packet>(itr: &mut Peekable) -> Option { + // get version digits + let version = extend_number(0, itr, 3)?; + let type_id = extend_number(0, itr, 3)?; + return operator_packet(version, type_id, itr); +} + +pub fn operator_packet>(version: u64, type_id: u64, itr: &mut Peekable) -> Option { + let p = OperatorPacket { + version: version, + type_id: type_id, + packets: decode_packets(&mut itr.take(0).peekable()), + }; + + return Some(Packet::Operator(p)); +} + +pub fn extend_number>(num: u64, itr: &mut Peekable, take: u64) -> Option { + let mut value = num; + for _ in 0..take { + value *= 2; + value += itr.next()?; + } + + return Some(value); +} + +#[derive(Debug)] +pub enum Packet { + Operator(OperatorPacket), +} + +#[derive(Debug)] +pub struct OperatorPacket { + version: u64, + type_id: u64, + packets: Vec +} diff --git a/tests/crashes/122903-1.rs b/tests/crashes/122903-1.rs new file mode 100644 index 0000000000000..9323c435851e6 --- /dev/null +++ b/tests/crashes/122903-1.rs @@ -0,0 +1,8 @@ +//@ known-bug: #122903 +impl Struct { + async fn box_box_ref_Struct( + self: Box>)>>, + ) -> &u32 { + f + } +} diff --git a/tests/crashes/122903-2.rs b/tests/crashes/122903-2.rs new file mode 100644 index 0000000000000..0d5d93014c187 --- /dev/null +++ b/tests/crashes/122903-2.rs @@ -0,0 +1,9 @@ +//@ known-bug: #122903 + +impl Struct { + async fn box_box_ref_Struct( + self: Box>)>> + ) -> &u32 { + f + } +} diff --git a/tests/crashes/122904-2.rs b/tests/crashes/122904-2.rs new file mode 100644 index 0000000000000..85ed91c2fa486 --- /dev/null +++ b/tests/crashes/122904-2.rs @@ -0,0 +1,15 @@ +//@ known-bug: #122904 +trait T {} + +type Alias<'a> = impl T; + +struct S; +impl<'a> T for &'a S {} + +fn with_positive(fun: impl Fn(Alias<'_>)) { + with_positive(|&n| ()); +} + +fn main(Alias<'_>) { + with_positive(|&a| ()); +} diff --git a/tests/crashes/122904.rs b/tests/crashes/122904.rs new file mode 100644 index 0000000000000..8b8bb35d56c1e --- /dev/null +++ b/tests/crashes/122904.rs @@ -0,0 +1,11 @@ +//@ known-bug: #122904 +trait T {} + +type Alias<'a> = impl T; + +struct S; +impl<'a> T for &'a S {} + +fn with_positive(fun: impl Fn(Alias<'_>)) { + with_positive(|&n| ()); +} diff --git a/tests/crashes/122908.rs b/tests/crashes/122908.rs new file mode 100644 index 0000000000000..c9da1bc187918 --- /dev/null +++ b/tests/crashes/122908.rs @@ -0,0 +1,4 @@ +//@ known-bug: #122908 +trait Trait { + async fn handle(slf: &F) {} +} diff --git a/tests/crashes/122914.rs b/tests/crashes/122914.rs new file mode 100644 index 0000000000000..63a84bc8099bc --- /dev/null +++ b/tests/crashes/122914.rs @@ -0,0 +1,11 @@ +//@ known-bug: #122914 +use std::future::Future; +use std::pin::Pin; + +impl<'a, F> Poll { + fn project<'_>(self: Pin<&'pin mut Future>) -> Projection<'pin, 'a, F> { + me.local_set.with(|| { + let _ = self.poll(cx); + }) + } +} diff --git a/tests/crashes/122989.rs b/tests/crashes/122989.rs new file mode 100644 index 0000000000000..70ad7d3b65c9b --- /dev/null +++ b/tests/crashes/122989.rs @@ -0,0 +1,8 @@ +//@ known-bug: #122989 +trait Traitor = 1, const N: N<2> = N> { + fn N(&N) -> N<2> { + M + } +} + +trait N = 12> {} diff --git a/tests/crashes/123077-1.rs b/tests/crashes/123077-1.rs new file mode 100644 index 0000000000000..76e81f730f959 --- /dev/null +++ b/tests/crashes/123077-1.rs @@ -0,0 +1,9 @@ +//@ known-bug: #123077 +use std::arch::x86_64::{__m128, _mm_blend_ps}; + +pub fn sse41_blend_noinline( ) -> __m128 { + let f = { |x, y| unsafe { + _mm_blend_ps(x, y, { |x, y| unsafe }) + }}; + f(x, y) +} diff --git a/tests/crashes/123077-2.rs b/tests/crashes/123077-2.rs new file mode 100644 index 0000000000000..d425625dfd9ad --- /dev/null +++ b/tests/crashes/123077-2.rs @@ -0,0 +1,11 @@ +//@ known-bug: #123077 +use std::arch::x86_64::{__m128, _mm_blend_ps}; + +pub fn sse41_blend_noinline( ) -> __m128 { + let f = { |x, y| unsafe { + _mm_blend_ps(x, y, { |x, y| unsafe }) + }}; + f(x, y) +} + +pub fn main() {} diff --git a/tests/crashes/123134.rs b/tests/crashes/123134.rs new file mode 100644 index 0000000000000..61c043db763f5 --- /dev/null +++ b/tests/crashes/123134.rs @@ -0,0 +1,39 @@ +//@ known-bug: #123134 +trait Api: Sized { + type Device: ?Sized; +} + +struct OpenDevice +where + A::Device: Sized, +{ + device: A::Device, + queue: (), +} + +trait Adapter { + type A: Api; + + fn open() -> OpenDevice + where + ::Device: Sized; +} + +struct ApiS; + +impl Api for ApiS { + type Device = [u8]; +} + +impl Adapter for T { + type A = ApiS; + + fn open() -> OpenDevice + where + ::Device: Sized, + { + unreachable!() + } +} + +pub fn main() {} diff --git a/tests/crashes/123140.rs b/tests/crashes/123140.rs new file mode 100644 index 0000000000000..89e55baad98f1 --- /dev/null +++ b/tests/crashes/123140.rs @@ -0,0 +1,6 @@ +//@ known-bug: #123140 +trait Project { + const SELF: Self; +} + +fn take1(_: Project) {} diff --git a/tests/crashes/123141-2.rs b/tests/crashes/123141-2.rs new file mode 100644 index 0000000000000..74f961c2a3377 --- /dev/null +++ b/tests/crashes/123141-2.rs @@ -0,0 +1,23 @@ +//@ known-bug: #123141 + +trait ConstChunksExactTrait { + fn const_chunks_exact(&self) -> ConstChunksExact<'_, T, {N}>; +} + +impl ConstChunksExactTrait for [T] {} + +struct ConstChunksExact<'a, T: 'a, const N: usize> {} + +impl <'a, T: , const N: usize> Iterator for ConstChunksExact<'a, T, {rem}> { + type Item = &'a [T; N]; +} + +fn main() { + let slice = &[1i32, 2, 3, 4, 5, 6, 7, 7, 9, 1i32]; + + let mut iter = [[1, 2, 3], [4, 5, 6], [7, 8 ,9]].iter(); + + for a in slice.const_chunks_exact::<3>() { + assert_eq!(a, iter.next().unwrap()); + } +} diff --git a/tests/crashes/123141.rs b/tests/crashes/123141.rs new file mode 100644 index 0000000000000..99dfee7670ef9 --- /dev/null +++ b/tests/crashes/123141.rs @@ -0,0 +1,22 @@ +//@ known-bug: #123141 +trait ConstChunksExactTrait { + fn const_chunks_exact(&self) -> ConstChunksExact<'_, T, { N }>; +} + +impl ConstChunksExactTrait for [T] {} + +struct ConstChunksExact<'a, T: 'a, const N: usize> {} + +impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, { rem }> { + type Item = &'a [T; N]; +} + +fn main() { + let slice = &[1i32, 2, 3, 4, 5, 6, 7, 7, 9, 1i32]; + + let mut iter = [[1, 2, 3], [4, 5, 6], [7, 8, 9]].iter(); + + for a in slice.const_chunks_exact::<3>() { + assert_eq!(a, iter.next().unwrap()); + } +} diff --git a/tests/crashes/123153.rs b/tests/crashes/123153.rs new file mode 100644 index 0000000000000..d2c32ecd73e74 --- /dev/null +++ b/tests/crashes/123153.rs @@ -0,0 +1,17 @@ +//@ known-bug: #123153 +pub struct wl_interface { + pub version: str, +} + +pub struct Interface { + pub other_interfaces: &'static [&'static Interface], + pub c_ptr: Option<&'static wl_interface>, +} + +pub static mut wl_callback_interface: wl_interface = wl_interface { version: 0 }; + +pub static WL_CALLBACK_INTERFACE: Interface = + Interface { other_interfaces: &[], c_ptr: Some(unsafe { &wl_callback_interface }) }; + + +fn main() {} diff --git a/tests/crashes/123154.rs b/tests/crashes/123154.rs new file mode 100644 index 0000000000000..510ae8adf350d --- /dev/null +++ b/tests/crashes/123154.rs @@ -0,0 +1,12 @@ +//@ known-bug: #123154 +struct AA { + pub data: [&usize] +} + +impl AA { + const fn new() -> Self { } +} + +static AA = AA::new(); + +fn main() { } diff --git a/tests/crashes/123157.rs b/tests/crashes/123157.rs new file mode 100644 index 0000000000000..0c0721d02ec51 --- /dev/null +++ b/tests/crashes/123157.rs @@ -0,0 +1,15 @@ +//@ known-bug: #123157 +#![feature(type_alias_impl_trait)] + +#[derive(Copy, Clone)] +struct Foo((u32, u32)); + +fn main() { + type T = impl Copy; + let foo: T = Foo((1u32, 2u32)); + let x = move || { + let x = move || { + let Foo((a, b)) = foo; + }; + }; +} diff --git a/tests/crashes/23707.rs b/tests/crashes/23707.rs new file mode 100644 index 0000000000000..c8c373c31e24d --- /dev/null +++ b/tests/crashes/23707.rs @@ -0,0 +1,109 @@ +//@ known-bug: #23707 +//@ compile-flags: -Copt-level=0 --edition=2021 + +#![recursion_limit="2048"] + +use std::marker::PhantomData; +use std::fmt; +use std::fmt::Debug; + +pub struct Z( () ); +pub struct S (PhantomData); + + +pub trait Nat { + fn sing() -> Self; + fn get(&self) -> usize; +} + +impl Nat for Z { + fn sing() -> Z { Z( () ) } + #[inline(always)] + fn get(&self) -> usize { + 0 + } +} + +impl Nat for S { + fn sing() -> S { S::( PhantomData:: ) } + #[inline(always)] + fn get(&self) -> usize { + let prd : T = Nat::sing(); + 1 + prd.get() + } +} + +pub type N0 = Z; +pub type N1 = S; +pub type N2 = S; +pub type N3 = S; +pub type N4 = S; +pub type N5 = S; + + +pub struct Node(usize,PhantomData); + +impl Node { + pub fn push(&self, c : usize) -> Node> { + let Node(i,_) = *self; + Node(10*i+c, PhantomData::>) + } +} + +impl Node> { + pub fn pop(&self) -> (Node,usize) { + let Node(i,_) = *self; + (Node(i/10, PhantomData::), i-10*(i/10)) + } +} + +impl Debug for Node { + fn fmt(&self, f : &mut fmt::Formatter) -> fmt::Result { + let s : D = Nat::sing(); + write!(f, "Node<{}>: i= {}", + s.get(), self.0) + } +} +pub trait Step { + fn step(&self, usize) -> Self; +} + +impl Step for Node { + #[inline(always)] + fn step(&self, n : usize) -> Node { + println!("base case"); + Node(n,PhantomData::) + } +} + +impl Step for Node> + where Node : Step { + #[inline(always)] + fn step(&self, n : usize) -> Node> { + println!("rec"); + let (par,c) = self.pop(); + let cnew = c+n; + par.step(c).push(cnew) + } + +} + +fn tst(ref p : &Node, c : usize) -> usize + where Node : Step { + let Node(i,_) = p.step(c); + i +} + + + +fn main() { + let nd : Node = Node(555,PhantomData::); + + // overflow...core::marker::Size + let Node(g,_) = tst(nd,1); + + // ok + //let Node(g,_) = nd.step(1); + + println!("{:?}", g); +} diff --git a/tests/crashes/92004.rs b/tests/crashes/92004.rs new file mode 100644 index 0000000000000..bc2ca2a7ba389 --- /dev/null +++ b/tests/crashes/92004.rs @@ -0,0 +1,70 @@ +//@ known-bug: #102310 +//@ compile-flags: -Copt-level=0 +//@ edition:2021 +// ignore-tidy-linelength + +use std::vec::Vec; +use std::iter::Peekable; + +pub fn main() { + let packet = decode(vec![1,0,1,0]); +} + +pub fn decode(bitstream: Vec) -> Packet { + let mut bitstream_itr = bitstream.into_iter().peekable(); + return match decode_packet(&mut bitstream_itr) { + Some(p) => p, + None => panic!("expected outer packet"), + } +} + +pub fn decode_packets>(itr: &mut Peekable) -> Vec { + let mut res = Vec::new(); + loop { + match decode_packet(itr) { + Some(p) => { res.push(p); }, + None => break + } + } + + return res; +} + +pub fn decode_packet>(itr: &mut Peekable) -> Option { + // get version digits + let version = extend_number(0, itr, 3)?; + let type_id = extend_number(0, itr, 3)?; + return operator_packet(version, type_id, itr); +} + +pub fn operator_packet>(version: u64, type_id: u64, itr: &mut Peekable) -> Option { + let p = OperatorPacket { + version: version, + type_id: type_id, + packets: decode_packets(&mut itr.take(0).peekable()), + }; + + return Some(Packet::Operator(p)); +} + +pub fn extend_number>(num: u64, itr: &mut Peekable, take: u64) -> Option { + let mut value = num; + for _ in 0..take { + value *= 2; + value += itr.next()?; + } + + return Some(value); +} + +#[derive(Debug)] +pub enum Packet { + Operator(OperatorPacket), +} + +#[derive(Debug)] +pub struct OperatorPacket { + version: u64, + type_id: u64, + packets: Vec +} diff --git a/tests/crashes/93182.rs b/tests/crashes/93182.rs new file mode 100644 index 0000000000000..f2e77c03533fa --- /dev/null +++ b/tests/crashes/93182.rs @@ -0,0 +1,29 @@ +//@ known-bug: #93182 +#![feature(generic_const_exprs)] + +// this causes an ICE!!! +pub const CONST: usize = 64; +pub trait Tr: Foo> {} + +// no ICE +// pub trait Digest: FromH<[u8; S]> {} + +struct St (); + +struct A ([u8; S]); + +pub trait Foo { + fn foo(_: T); +} + +impl Foo> for St { + fn foo(_: A) { + todo!() + } +} + +pub trait FooBar { + type Tr: Tr; +} + +pub fn main() {} diff --git a/tests/crashes/93237.rs b/tests/crashes/93237.rs new file mode 100644 index 0000000000000..c903e79a2e300 --- /dev/null +++ b/tests/crashes/93237.rs @@ -0,0 +1,18 @@ +//@ known-bug: #93237 +trait Trait { + type Assoc; +} +impl Trait for () { + type Assoc = (); +} + +macro_rules! m { + ([#$($t:tt)*] [$($open:tt)*] [$($close:tt)*]) => { + m!{[$($t)*][$($open)*$($open)*][$($close)*$($close)*]} + }; + ([] [$($open:tt)*] [$($close:tt)*]) => { + fn _f() -> $($open)*()$($close)* {} + }; +} + +m! {[###########][impl Trait]} diff --git a/tests/crashes/94846.rs b/tests/crashes/94846.rs new file mode 100644 index 0000000000000..9a3b26621d988 --- /dev/null +++ b/tests/crashes/94846.rs @@ -0,0 +1,6 @@ +//@ known-bug: #94846 +#![feature(generic_const_exprs)] + +struct S() where S<{}>:; + +pub fn main() {} diff --git a/tests/crashes/95134.rs b/tests/crashes/95134.rs new file mode 100644 index 0000000000000..bcd88b1076fd9 --- /dev/null +++ b/tests/crashes/95134.rs @@ -0,0 +1,27 @@ +//@ known-bug: #95134 +//@ compile-flags: -Copt-level=0 + +pub fn encode_num(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 EmptyWriter; + +impl ExampleWriter for EmptyWriter { + type Error = (); +} + +fn main() { + encode_num(69, &mut EmptyWriter).unwrap(); +}