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

Commit d594e0a

Browse files
authored
Add some ICEs (#652)
1 parent b156372 commit d594e0a

File tree

6 files changed

+144
-0
lines changed

6 files changed

+144
-0
lines changed

ices/80351.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
fn main() {
2+
enqueue::<(), _>(|_result| {});
3+
}
4+
5+
trait Query<'a> {
6+
type Result: 'a;
7+
fn execute() -> Self::Result;
8+
}
9+
10+
impl<'a> Query<'a> for () {
11+
type Result = ();
12+
fn execute() -> () {
13+
()
14+
}
15+
}
16+
17+
fn enqueue<Q: for<'q> Query<'q>, F: 'static + for<'r> FnOnce(<Q as Query<'r>>::Result)>(f: F) {
18+
let _: Box<dyn FnOnce()> = Box::new(move || f(Q::execute()));
19+
}

ices/81199.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
union PtrRepr<T: ?Sized> {
2+
const_ptr: *const T,
3+
mut_ptr: *mut T,
4+
components: <T as Pointee>::Metadata
5+
}
6+
7+
pub trait Pointee {
8+
type Metadata;
9+
}

ices/81786.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
cat > out.rs <<'EOF'
4+
#![feature(auto_traits, negative_impls)]
5+
6+
auto trait AutoTrait {}
7+
8+
pub struct Struct<K, V> {
9+
k: K,
10+
v: V
11+
}
12+
13+
impl<T> !AutoTrait for *const T {}
14+
15+
impl<K, V> AutoTrait for Struct<K, V>
16+
where
17+
K: AutoTrait,
18+
V: AutoTrait,
19+
{
20+
}
21+
22+
impl AutoTrait for Struct<usize, *const usize> {}
23+
24+
pub struct Wrap<'a> {
25+
inner: &'a Struct<usize, *const usize>,
26+
}
27+
28+
fn main() {}
29+
EOF
30+
31+
rustdoc out.rs --output-format json

ices/81809.rs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
use std::ops::Index;
2+
3+
pub trait Indexable {
4+
type Index;
5+
}
6+
struct Foo;
7+
struct Bar;
8+
impl Indexable for Foo { type Index = u8; }
9+
impl Indexable for Bar { type Index = u16; }
10+
11+
pub trait Indexer<T: Indexable>: Index<T::Index, Output=T> {}
12+
13+
struct Store;
14+
15+
impl Index<u8> for Store {
16+
type Output = Foo;
17+
fn index(&self, _: u8) -> &Foo { panic!() }
18+
}
19+
impl Index<u16> for Store {
20+
type Output = Bar;
21+
fn index(&self, _: u16) -> &Bar { panic!() }
22+
}
23+
impl Indexer<Foo> for Store { }
24+
impl Indexer<Bar> for Store { }
25+
26+
// implies StoreIndex: Index<u8, Output=Foo> + Index<u16, Output=Bar>
27+
trait StoreIndex: Indexer<Foo> + Indexer<Bar> {}
28+
29+
impl StoreIndex for Store {}
30+
31+
struct Collection {
32+
stores: Vec<Store>,
33+
}
34+
35+
trait StoreCollection {
36+
fn get_store(&self, _: usize) -> Option<&dyn StoreIndex>;
37+
}
38+
39+
impl StoreCollection for Collection {
40+
// Fails to compile:
41+
// expected:
42+
// Option<&dyn StoreIndex<Output = Bar, Output = Foo>
43+
// found:
44+
// Option<&Store>
45+
/*
46+
fn get_store(&self, i: usize) -> Option<&dyn StoreIndex> {
47+
self.stores.get(i)
48+
}
49+
*/
50+
51+
// ICE
52+
fn get_store(&self, i: usize) -> Option<&dyn StoreIndex> {
53+
if let Some(s) = self.stores.get(i) {
54+
Some(s as &dyn StoreIndex)
55+
} else {
56+
None
57+
}
58+
}
59+
60+
// However, if the above is removed in favor of Indexing
61+
// type checking succeeds and the type of `&self.stores[i]`
62+
// is properly inferred
63+
/*
64+
fn get_store(&self, i: usize) -> Option<&dyn StoreIndex> {
65+
if i < self.stores.len() {
66+
Some(&self.stores[i])
67+
} else {
68+
None
69+
}
70+
}
71+
*/
72+
}
73+
74+
fn main() {}

ices/81899.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const _CONST: &[u8] = &f(&[], |_| {});
2+
3+
const fn f<F>(_: &[u8], _: F) -> &[u8]
4+
where
5+
F: FnMut(&u8),
6+
{
7+
panic!()
8+
}
9+
10+
fn main() {}

ices/81924.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#![a = {enum b {

0 commit comments

Comments
 (0)