Skip to content

Commit 9c64531

Browse files
committed
tests/crashes: add ICEs from matthiaskrgr/glacier2
1 parent 7c4c79a commit 9c64531

File tree

151 files changed

+2886
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+2886
-0
lines changed

tests/crashes/101036.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ known-bug: #101036
2+
#![feature(generic_const_exprs)]
3+
4+
const fn t<const N: usize>() -> u8 {
5+
N as u8
6+
}
7+
8+
#[repr(u8)]
9+
enum T<const N: u8 = { T::<0>::A as u8 + T::<0>::B as u8 }>
10+
where
11+
[(); N as usize]:
12+
{
13+
A = t::<N>() as u8, B
14+
}

tests/crashes/101557.rs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//@ known-bug: #101557
2+
#![feature(generic_const_exprs)]
3+
use std::marker::PhantomData;
4+
5+
trait Trait {
6+
const CONST: usize;
7+
}
8+
9+
struct A<T: Trait> {
10+
_marker: PhantomData<T>,
11+
}
12+
13+
impl<const N: usize> Trait for [i8; N] {
14+
const CONST: usize = N;
15+
}
16+
17+
impl<const N: usize> From<usize> for A<[i8; N]> {
18+
fn from(_: usize) -> Self {
19+
todo!()
20+
}
21+
}
22+
23+
impl<T: Trait> From<A<[i8; T::CONST]>> for A<T> {
24+
fn from(_: A<[i8; T::CONST]>) -> Self {
25+
todo!()
26+
}
27+
}
28+
29+
fn f<T: Trait>() -> A<T>
30+
where
31+
[(); T::CONST]:,
32+
{
33+
// Usage of `0` is arbitrary
34+
let a = A::<[i8; T::CONST]>::from(0);
35+
A::<T>::from(a)
36+
}
37+
38+
fn main() {
39+
// Usage of `1` is arbitrary
40+
f::<[i8; 1]>();
41+
}

tests/crashes/105275.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//@ known-bug: #105275
2+
//@ compile-flags: -Copt-level=0
3+
4+
pub fn encode_num<Writer: ExampleWriter>(n: u32, mut writer: Writer) -> Result<(), Writer::Error> {
5+
if n > 15 {
6+
encode_num(n / 16, &mut writer)?;
7+
}
8+
Ok(())
9+
}
10+
11+
pub trait ExampleWriter {
12+
type Error;
13+
}
14+
15+
impl<'a, T: ExampleWriter> ExampleWriter for &'a mut T {
16+
type Error = T::Error;
17+
}
18+
19+
struct Error;
20+
21+
impl ExampleWriter for Error {
22+
type Error = ();
23+
}
24+
25+
fn main() {
26+
encode_num(69, &mut Error).unwrap();
27+
}

tests/crashes/105937.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//@ known-bug: #105937
2+
//@ compile-flags: -Copt-level=0
3+
4+
pub fn encode_num<Writer: ExampleWriter>(n: u32, mut writer: Writer) -> Result<(), Writer::Error> {
5+
if n > 15 {
6+
encode_num(n / 16, &mut writer)?;
7+
}
8+
Ok(())
9+
}
10+
11+
pub trait ExampleWriter {
12+
type Error;
13+
}
14+
15+
impl<'a, T: ExampleWriter> ExampleWriter for &'a mut T {
16+
type Error = T::Error;
17+
}
18+
19+
struct Error;
20+
21+
impl ExampleWriter for Error {
22+
type Error = ();
23+
}
24+
25+
fn main() {
26+
encode_num(69, &mut Error).unwrap();
27+
}

tests/crashes/106473.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ known-bug: #106473
2+
#![feature(generic_const_exprs)]
3+
4+
const DEFAULT: u32 = 1;
5+
6+
struct V<const U: usize = DEFAULT>
7+
where
8+
[(); U]:;
9+
10+
trait Tr {}
11+
12+
impl Tr for V {}

tests/crashes/108498.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ known-bug: #108498
2+
//@ compile-flags: -Copt-level=0
3+
4+
#![feature(type_alias_impl_trait)]
5+
6+
type Opaque = impl Sized;
7+
8+
fn get_rpit() -> impl Clone {}
9+
10+
fn query(_: impl FnOnce() -> Opaque) {}
11+
12+
fn test() -> Opaque {
13+
query(get_rpit);
14+
get_rpit()
15+
}
16+
17+
pub fn main() {}

tests/crashes/110534.rs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//@ known-bug: #110534
2+
//@ edition:2021
3+
use core::cell::Ref;
4+
5+
struct System;
6+
7+
trait IntoSystem {
8+
fn into_system(self) -> System;
9+
}
10+
11+
impl IntoSystem for fn(Ref<'_, u32>) {
12+
fn into_system(self) -> System { System }
13+
}
14+
15+
impl<A> IntoSystem for fn(A)
16+
where
17+
// n.b. No `Ref<'_, u32>` can satisfy this bound
18+
A: 'static + for<'x> MaybeBorrowed<'x, Output = A>,
19+
{
20+
fn into_system(self) -> System { System }
21+
}
22+
23+
//---------------------------------------------------
24+
25+
trait MaybeBorrowed<'a> {
26+
type Output: 'a;
27+
}
28+
29+
// If you comment this out you'll see the compiler chose to look at the
30+
// fn(A) implementation of IntoSystem above
31+
impl<'a, 'b> MaybeBorrowed<'a> for Ref<'b, u32> {
32+
type Output = Ref<'a, u32>;
33+
}
34+
35+
// ---------------------------------------------
36+
37+
fn main() {
38+
fn sys_ref(_age: Ref<u32>) {}
39+
let _sys_c = (sys_ref as fn(_)).into_system();
40+
// properly fails
41+
// let _sys_c = (sys_ref as fn(Ref<'static, u32>)).into_system();
42+
// properly succeeds
43+
// let _sys_c = (sys_ref as fn(Ref<'_, u32>)).into_system();
44+
}

tests/crashes/110627.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ known-bug: #110627
2+
#![feature(non_lifetime_binders)]
3+
4+
fn take(id: impl for<T> Fn(T) -> T) {}
5+
6+
fn main() {
7+
take(|x| x)
8+
}

tests/crashes/111419.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ known-bug: #111419
2+
#![allow(incomplete_features)]
3+
#![feature(generic_const_exprs, generic_arg_infer)]
4+
5+
pub trait Example<const X: usize, const Y: usize, const Z: usize = { X + Y }>
6+
where
7+
[(); X + Y]:,
8+
{}
9+
10+
impl<const X: usize, const Y: usize> Example<X, Y> for Value {}
11+
12+
pub struct Value;
13+
14+
fn main() {}

tests/crashes/111699.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ known-bug: #111699
2+
#![feature(core_intrinsics)]
3+
use std::intrinsics::offset;
4+
5+
fn main() {
6+
let a = [1u8, 2, 3];
7+
let ptr: *const u8 = a.as_ptr();
8+
9+
unsafe {
10+
assert_eq!(*offset(ptr, 0), 1);
11+
}
12+
}

tests/crashes/111709-2.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ known-bug: #111709
2+
//@ edition: 2021
3+
4+
use core::arch::asm;
5+
6+
extern "C" fn test<T>() {}
7+
8+
fn uwu() {
9+
unsafe {
10+
asm!(
11+
"/* {0} */",
12+
sym test::<&mut ()>
13+
);
14+
}
15+
}

tests/crashes/111709.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//@ known-bug: #111709
2+
//@ edition:2021
3+
4+
use core::arch::asm;
5+
6+
struct TrapFrame;
7+
8+
unsafe extern "C" fn _rust_abi_shim1<A, R>(arg: A, f: fn(A) -> R) -> R {
9+
f(arg)
10+
}
11+
12+
unsafe extern "C" fn _start_trap() {
13+
extern "Rust" {
14+
fn interrupt(tf: &mut TrapFrame);
15+
}
16+
asm!(
17+
"
18+
la a1, {irq}
19+
call {shim}
20+
",
21+
shim = sym crate::_rust_abi_shim1::<&mut TrapFrame, ()>,
22+
irq = sym interrupt,
23+
options(noreturn)
24+
)
25+
}

tests/crashes/111883.rs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//@ known-bug: #111883
2+
#![crate_type = "lib"]
3+
#![feature(arbitrary_self_types, no_core, lang_items)]
4+
#![no_core]
5+
6+
#[lang = "sized"]
7+
trait Sized {}
8+
#[lang = "copy"]
9+
trait Copy {}
10+
#[lang = "receiver"]
11+
trait Receiver {}
12+
#[lang = "dispatch_from_dyn"]
13+
trait DispatchFromDyn<T> {}
14+
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
15+
#[lang = "unsize"]
16+
trait Unsize<T: ?Sized> {}
17+
#[lang = "coerce_unsized"]
18+
pub trait CoerceUnsized<T: ?Sized> {}
19+
impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
20+
21+
#[lang = "drop_in_place"]
22+
fn drop_in_place_fn<T>(a: &dyn Trait2<T>) {}
23+
24+
pub trait Trait1 {
25+
fn foo(&self);
26+
}
27+
28+
pub struct Type1;
29+
30+
impl Trait1 for Type1 {
31+
fn foo(&self) {}
32+
}
33+
34+
pub trait Trait2<T> {}
35+
36+
pub fn bar1() {
37+
let a = Type1;
38+
let b = &a as &dyn Trait1;
39+
b.foo();
40+
}

tests/crashes/113272.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ known-bug: #113272
2+
trait Trait {
3+
type RefTarget;
4+
}
5+
6+
impl Trait for () where Missing: Trait {}
7+
8+
struct Other {
9+
data: <() as Trait>::RefTarget,
10+
}
11+
12+
fn main() {
13+
unsafe {
14+
std::mem::transmute::<Option<()>, Option<&Other>>(None);
15+
}
16+
}

tests/crashes/113846.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//@ known-bug: #113846
2+
trait Www {
3+
type W;
4+
}
5+
6+
trait Xxx: Www<W = Self::X> {
7+
type X;
8+
}
9+
10+
trait Yyy: Xxx {}
11+
12+
trait Zzz<'a>: Yyy + Xxx<X = Self::Z> {
13+
type Z;
14+
}
15+
16+
trait Aaa {
17+
type Y: Yyy;
18+
}
19+
20+
trait Bbb: Aaa<Y = Self::B> {
21+
type B: for<'a> Zzz<'a>;
22+
}
23+
24+
impl<T> Bbb for T
25+
where
26+
T: Aaa,
27+
T::Y: for<'a> Zzz<'a>,
28+
{
29+
type B = T::Y;
30+
}
31+
32+
pub fn main() {}

tests/crashes/114212-2.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ known-bug: #114212
2+
#![allow(incomplete_features)]
3+
#![feature(generic_const_exprs)]
4+
5+
const SOME_CONST: usize = 1;
6+
7+
struct UwU<
8+
// have a const generic with a default that's from another const item
9+
// (associated consts work, a const declared in a block here, inline_const, etc)
10+
const N: usize = SOME_CONST,
11+
// use the previous const in a type generic
12+
A = [(); N],
13+
> {
14+
// here to suppress "unused generic" error if the code stops ICEing
15+
_x: core::marker::PhantomData<A>,
16+
}

0 commit comments

Comments
 (0)