Skip to content

Commit 7d826ae

Browse files
committed
tests/crashes: add ICEs from matthiaskrgr/glacier2
1 parent 98dd566 commit 7d826ae

Some content is hidden

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

133 files changed

+2620
-39
lines changed

tests/crashes/101036.rs

Lines changed: 14 additions & 0 deletions
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

Lines changed: 41 additions & 0 deletions
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

Lines changed: 27 additions & 0 deletions
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/105488.rs

Lines changed: 0 additions & 39 deletions
This file was deleted.

tests/crashes/105937.rs

Lines changed: 27 additions & 0 deletions
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

Lines changed: 12 additions & 0 deletions
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/110534.rs

Lines changed: 44 additions & 0 deletions
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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 14 additions & 0 deletions
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

Lines changed: 12 additions & 0 deletions
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+
}

0 commit comments

Comments
 (0)