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

Add 5 more ICEs #259

Merged
merged 8 commits into from
Jan 15, 2020
47 changes: 47 additions & 0 deletions ices/44861.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# https://github.com/rust-lang/rust/issues/44861
# Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=bdd59503a0dc2d33c60a949fc7c57633
# You need to select `build` instead of `run`.
rustc --crate-type lib - << END
JohnTitor marked this conversation as resolved.
Show resolved Hide resolved

#![feature(specialization)]
#![feature(unsize, coerce_unsized)]

use std::ops::CoerceUnsized;
use std::marker::Unsize;

pub struct SmartassPtr<A: Smartass+?Sized>(A::Data);

pub trait Smartass {
type Data;
type Data2: CoerceUnsized<*const [u8]>;
}

pub trait MaybeObjectSafe {}

impl MaybeObjectSafe for () {}

impl<T> Smartass for T {
type Data = <Self as Smartass>::Data2;
default type Data2 = ();
}

impl Smartass for () {
type Data2 = *const [u8; 1];
}

impl Smartass for MaybeObjectSafe {
type Data = *const [u8];
type Data2 = *const [u8; 0];
}

impl<U: Smartass+?Sized, T: Smartass+?Sized> CoerceUnsized<SmartassPtr<T>> for SmartassPtr<U>
where <U as Smartass>::Data: std::ops::CoerceUnsized<<T as Smartass>::Data>
{}

pub fn conv(s: SmartassPtr<()>) -> SmartassPtr<MaybeObjectSafe> {
s
}

END
12 changes: 12 additions & 0 deletions ices/67945-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// original reproducer by DutchGhost
use std::marker::PhantomData;

use std::mem::{self, MaybeUninit};

struct Bug<S> {
A: [(); {
let x: S = MaybeUninit::uninit();
let b = &*(&x as *const _ as *const S);
0
}],
}
7 changes: 7 additions & 0 deletions ices/67945-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// reduced version by Centril
enum Bug<S> {
Var = {
let x: S = 0;
0
},
}
9 changes: 9 additions & 0 deletions ices/67945-3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Note: Centril asked in the issue to
// include all variants in a regression test.

// even more reduced version by Centril
#![feature(type_ascription)]

enum Bug<S> {
Var = 0: S,
}
11 changes: 11 additions & 0 deletions ices/67945-4.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// reproducer by nikomatsakis
use std::marker::PhantomData;

use std::mem::{self, MaybeUninit};

struct Bug<S> {
A: [(); {
let x: Option<Box<S>> = None;
0
}],
}
9 changes: 9 additions & 0 deletions ices/67981.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![feature(unsized_locals)]

fn main() {
let f: fn([u8]) = |_| {};

let slice: Box<[u8]> = Box::new([1; 8]);

f(*slice);
}
17 changes: 17 additions & 0 deletions ices/68013.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// https://github.com/rust-lang/rust/issues/68013
// Reduced from [https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=0f18f9d5d6071f9a10586e87e5dfd0b0]

#![feature(coerce_unsized)]

// These imports are also needed to get the ICE.
use std::rc::Rc;
use std::cell::Cell;
use std::ops::Deref;
use std::ops::CoerceUnsized;

#[derive(Clone)]
struct Redirectable<'a, T: ?Sized> {
data: Rc<Cell<&'a T>>
}

impl<U, T: CoerceUnsized<U>> CoerceUnsized<Redirectable<'_, U>> for Redirectable<'_, T> {}
12 changes: 12 additions & 0 deletions ices/68025.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// https://github.com/rust-lang/rust/issues/68025
// simplified by Centril
fn foo<F, G>(_: G, _: Box<F>)
where
F: Fn(),
G: Fn(Box<F>),
{
}

fn main() {
foo(|f| (*f)(), Box::new(|| {}));
}