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

Commit

Permalink
Merge pull request #327 from JohnTitor/add-ices
Browse files Browse the repository at this point in the history
Add 5 ICEs
  • Loading branch information
Alexendoo authored Apr 11, 2020
2 parents 9d1a836 + 46a8d6e commit d84f478
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ices/70746.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
pub trait Trait1 {
type C;
}

struct T1;
impl Trait1 for T1 {
type C = usize;
}
pub trait Callback<T: Trait1>: FnMut(<T as Trait1>::C) {}
impl<T: Trait1, F: FnMut(<T as Trait1>::C)> Callback<T> for F {}

pub struct State<T: Trait1> {
callback: Option<Box<dyn Callback<T>>>,
}
impl<T: Trait1> State<T> {
fn new() -> Self {
Self { callback: None }
}
fn test_cb(&mut self, d: <T as Trait1>::C) {
(self.callback.as_mut().unwrap())(d)
}
}

fn main() {
let mut s = State::<T1>::new();
s.test_cb(1);
}
38 changes: 38 additions & 0 deletions ices/70877.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#![allow(incomplete_features)]
#![feature(type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]

type FooArg<'a> = &'a dyn ToString;
type FooRet = impl std::fmt::Debug;

type FooItem = Box<dyn Fn(FooArg) -> FooRet>;
type Foo = impl Iterator<Item = FooItem>;

#[repr(C)]
struct Bar(u8);

impl Iterator for Bar {
type Item = FooItem;

fn next(&mut self) -> Option<Self::Item> {
Some(Box::new(quux))
}
}

fn quux(st: FooArg) -> FooRet {
Some(st.to_string())
}

fn ham() -> Foo {
Bar(1)
}

fn oof() -> impl std::fmt::Debug {
let mut bar = ham();
let func = bar.next().unwrap();
return func(&"oof");
}

fn main() {
println!("{:?}", oof());
}
5 changes: 5 additions & 0 deletions ices/70934.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
struct S;

fn main() {
&([S][0],);
}
6 changes: 6 additions & 0 deletions ices/70971.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#![allow(incomplete_features)]
#![feature(impl_trait_in_bindings)]

fn main() {
let ref _x: impl Sized = 5;
}
16 changes: 16 additions & 0 deletions ices/70972.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use std::sync::atomic::{AtomicPtr, Ordering};

const P: &dyn T = &S as &dyn T;
static mut LOGGER: AtomicPtr<&dyn T> = AtomicPtr::new(&mut P);

pub trait T {}
struct S;
impl T for S {}

pub fn f() {
match *LOGGER.load(Ordering::SeqCst) {
P | _ => {}
}
}

fn main() {}

0 comments on commit d84f478

Please sign in to comment.