Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit 34d8e43

Browse files
Julian-WollersbergerJohnTitor
authored andcommitted
Add 5 more ICEs (#259)
1 parent 41b704b commit 34d8e43

File tree

8 files changed

+120
-0
lines changed

8 files changed

+120
-0
lines changed

ices/44861.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// https://github.com/rust-lang/rust/issues/44861
2+
// Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=bdd59503a0dc2d33c60a949fc7c57633
3+
// You need to select `build` instead of `run`.
4+
5+
#![crate_type = "lib"]
6+
#![feature(specialization)]
7+
#![feature(unsize, coerce_unsized)]
8+
9+
use std::ops::CoerceUnsized;
10+
use std::marker::Unsize;
11+
12+
pub struct SmartassPtr<A: Smartass+?Sized>(A::Data);
13+
14+
pub trait Smartass {
15+
type Data;
16+
type Data2: CoerceUnsized<*const [u8]>;
17+
}
18+
19+
pub trait MaybeObjectSafe {}
20+
21+
impl MaybeObjectSafe for () {}
22+
23+
impl<T> Smartass for T {
24+
type Data = <Self as Smartass>::Data2;
25+
default type Data2 = ();
26+
}
27+
28+
impl Smartass for () {
29+
type Data2 = *const [u8; 1];
30+
}
31+
32+
impl Smartass for MaybeObjectSafe {
33+
type Data = *const [u8];
34+
type Data2 = *const [u8; 0];
35+
}
36+
37+
impl<U: Smartass+?Sized, T: Smartass+?Sized> CoerceUnsized<SmartassPtr<T>> for SmartassPtr<U>
38+
where <U as Smartass>::Data: std::ops::CoerceUnsized<<T as Smartass>::Data>
39+
{}
40+
41+
pub fn conv(s: SmartassPtr<()>) -> SmartassPtr<MaybeObjectSafe> {
42+
s
43+
}

ices/67945-1.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// original reproducer by DutchGhost
2+
use std::marker::PhantomData;
3+
4+
use std::mem::{self, MaybeUninit};
5+
6+
struct Bug<S> {
7+
A: [(); {
8+
let x: S = MaybeUninit::uninit();
9+
let b = &*(&x as *const _ as *const S);
10+
0
11+
}],
12+
}

ices/67945-2.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// reduced version by Centril
2+
enum Bug<S> {
3+
Var = {
4+
let x: S = 0;
5+
0
6+
},
7+
}

ices/67945-3.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Note: Centril asked in the issue to
2+
// include all variants in a regression test.
3+
4+
// even more reduced version by Centril
5+
#![feature(type_ascription)]
6+
7+
enum Bug<S> {
8+
Var = 0: S,
9+
}

ices/67945-4.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// reproducer by nikomatsakis
2+
use std::marker::PhantomData;
3+
4+
use std::mem::{self, MaybeUninit};
5+
6+
struct Bug<S> {
7+
A: [(); {
8+
let x: Option<Box<S>> = None;
9+
0
10+
}],
11+
}

ices/67981.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(unsized_locals)]
2+
3+
fn main() {
4+
let f: fn([u8]) = |_| {};
5+
6+
let slice: Box<[u8]> = Box::new([1; 8]);
7+
8+
f(*slice);
9+
}

ices/68013.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// https://github.com/rust-lang/rust/issues/68013
2+
// Reduced from [https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=0f18f9d5d6071f9a10586e87e5dfd0b0]
3+
4+
#![feature(coerce_unsized)]
5+
6+
// These imports are also needed to get the ICE.
7+
use std::rc::Rc;
8+
use std::cell::Cell;
9+
use std::ops::Deref;
10+
use std::ops::CoerceUnsized;
11+
12+
#[derive(Clone)]
13+
struct Redirectable<'a, T: ?Sized> {
14+
data: Rc<Cell<&'a T>>
15+
}
16+
17+
impl<U, T: CoerceUnsized<U>> CoerceUnsized<Redirectable<'_, U>> for Redirectable<'_, T> {}

ices/68025.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// https://github.com/rust-lang/rust/issues/68025
2+
// simplified by Centril
3+
fn foo<F, G>(_: G, _: Box<F>)
4+
where
5+
F: Fn(),
6+
G: Fn(Box<F>),
7+
{
8+
}
9+
10+
fn main() {
11+
foo(|f| (*f)(), Box::new(|| {}));
12+
}

0 commit comments

Comments
 (0)