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

Add some ICEs #652

Merged
merged 9 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ices/80351.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
fn main() {
enqueue::<(), _>(|_result| {});
}

trait Query<'a> {
type Result: 'a;
fn execute() -> Self::Result;
}

impl<'a> Query<'a> for () {
type Result = ();
fn execute() -> () {
()
}
}

fn enqueue<Q: for<'q> Query<'q>, F: 'static + for<'r> FnOnce(<Q as Query<'r>>::Result)>(f: F) {
let _: Box<dyn FnOnce()> = Box::new(move || f(Q::execute()));
}
9 changes: 9 additions & 0 deletions ices/81199.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
union PtrRepr<T: ?Sized> {
const_ptr: *const T,
mut_ptr: *mut T,
components: <T as Pointee>::Metadata
}

pub trait Pointee {
type Metadata;
}
31 changes: 31 additions & 0 deletions ices/81786.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

cat > out.rs <<'EOF'
#![feature(auto_traits, negative_impls)]

auto trait AutoTrait {}

pub struct Struct<K, V> {
k: K,
v: V
}

impl<T> !AutoTrait for *const T {}

impl<K, V> AutoTrait for Struct<K, V>
where
K: AutoTrait,
V: AutoTrait,
{
}

impl AutoTrait for Struct<usize, *const usize> {}

pub struct Wrap<'a> {
inner: &'a Struct<usize, *const usize>,
}

fn main() {}
EOF

rustdoc out.rs --output-format json
74 changes: 74 additions & 0 deletions ices/81809.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
use std::ops::Index;

pub trait Indexable {
type Index;
}
struct Foo;
struct Bar;
impl Indexable for Foo { type Index = u8; }
impl Indexable for Bar { type Index = u16; }

pub trait Indexer<T: Indexable>: Index<T::Index, Output=T> {}

struct Store;

impl Index<u8> for Store {
type Output = Foo;
fn index(&self, _: u8) -> &Foo { panic!() }
}
impl Index<u16> for Store {
type Output = Bar;
fn index(&self, _: u16) -> &Bar { panic!() }
}
impl Indexer<Foo> for Store { }
impl Indexer<Bar> for Store { }

// implies StoreIndex: Index<u8, Output=Foo> + Index<u16, Output=Bar>
trait StoreIndex: Indexer<Foo> + Indexer<Bar> {}

impl StoreIndex for Store {}

struct Collection {
stores: Vec<Store>,
}

trait StoreCollection {
fn get_store(&self, _: usize) -> Option<&dyn StoreIndex>;
}

impl StoreCollection for Collection {
// Fails to compile:
// expected:
// Option<&dyn StoreIndex<Output = Bar, Output = Foo>
// found:
// Option<&Store>
/*
fn get_store(&self, i: usize) -> Option<&dyn StoreIndex> {
self.stores.get(i)
}
*/

// ICE
fn get_store(&self, i: usize) -> Option<&dyn StoreIndex> {
if let Some(s) = self.stores.get(i) {
Some(s as &dyn StoreIndex)
} else {
None
}
}

// However, if the above is removed in favor of Indexing
// type checking succeeds and the type of `&self.stores[i]`
// is properly inferred
/*
fn get_store(&self, i: usize) -> Option<&dyn StoreIndex> {
if i < self.stores.len() {
Some(&self.stores[i])
} else {
None
}
}
*/
}

fn main() {}
10 changes: 10 additions & 0 deletions ices/81899.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const _CONST: &[u8] = &f(&[], |_| {});

const fn f<F>(_: &[u8], _: F) -> &[u8]
where
F: FnMut(&u8),
{
panic!()
}

fn main() {}
1 change: 1 addition & 0 deletions ices/81924.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#![a = {enum b {