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

Commit f9ee27d

Browse files
authored
Merge pull request #655 from fanninpm/add-ices-2021-02-15
Add some ICEs
2 parents cff2d2a + da245df commit f9ee27d

File tree

6 files changed

+222
-0
lines changed

6 files changed

+222
-0
lines changed

ices/77647.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
cat > out.rs <<'EOF'
4+
#![feature(const_generics, const_evaluatable_checked)]
5+
#![allow(incomplete_features)]
6+
struct A<T, const N: core::num::NonZeroUsize>([T; N.get()]) where [T; N.get()]: Sized;
7+
EOF
8+
9+
rustdoc out.rs --output-format json

ices/82034.sh

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
rustc --test -C incremental=foo - <<'EOF'
4+
#![feature(const_generics)]
5+
#![feature(const_evaluatable_checked)]
6+
#![allow(incomplete_features)]
7+
pub trait IsTrue {}
8+
pub trait IsFalse {}
9+
10+
pub struct Assert<const CHECK: bool> {}
11+
12+
impl IsTrue for Assert<true> {}
13+
impl IsFalse for Assert<false> {}
14+
15+
pub struct SliceConstWriter<'a, const N: usize> {
16+
ptr: &'a mut [u8]
17+
}
18+
impl<'a, const N: usize> SliceConstWriter<'a, {N}> {
19+
pub fn from_slice(vec: &'a mut [u8]) -> Self {
20+
Self {
21+
ptr: vec
22+
}
23+
}
24+
25+
pub fn convert<const NN: usize>(mut self) -> SliceConstWriter<'a, {NN}> {
26+
SliceConstWriter {
27+
ptr: self.ptr
28+
}
29+
}
30+
}
31+
32+
impl<'a, const N: usize> SliceConstWriter<'a, {N}> where Assert::<{N >= 2}>: IsTrue {
33+
// broken
34+
pub fn write_u8(mut self) -> SliceConstWriter<'a, {N-2}> {
35+
self.convert()
36+
}
37+
38+
//working
39+
// pub fn write_u8(mut self) -> SliceConstWriter<'a, {N-2}> {
40+
// SliceConstWriter {
41+
// ptr: self.ptr
42+
// }
43+
// }
44+
}
45+
46+
47+
#[cfg(test)]
48+
mod tests {
49+
use crate::SliceConstWriter;
50+
51+
#[test]
52+
fn it_works() {
53+
let mut buff = [0u8; 128];
54+
let mut a = SliceConstWriter::<10>::from_slice(&mut buff);
55+
56+
let mut a = a.write_u8().write_u8().write_u8().write_u8().write_u8();
57+
}
58+
}
59+
EOF

ices/82079.rs

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#![crate_type = "lib"]
2+
3+
mod convenience_operators {
4+
use crate::{Op, Relation};
5+
use std::ops::AddAssign;
6+
use std::ops::Mul;
7+
8+
impl<C: Op> Relation<C> {
9+
pub fn map<F: Fn(C::D) -> D2 + 'static, D2: 'static>(
10+
self,
11+
f: F,
12+
) -> Relation<impl Op<D = D2, R = C::R>> {
13+
self.map_dr(move |x, r| (f(x), r))
14+
}
15+
}
16+
17+
impl<K: 'static, V: 'static, C: Op<D = (K, V)>> Relation<C> {
18+
pub fn semijoin<C2: Op<D = K, R = R2>, R2, R3: AddAssign<R3>>(
19+
self,
20+
other: Relation<C2>,
21+
) -> Relation<impl Op<D = C::D, R = R3>>
22+
where
23+
C::R: Mul<R2, Output = R3>,
24+
{
25+
self.join(other.map(|x| (x, ()))).map(|(k, x, ())| (k, x))
26+
}
27+
}
28+
}
29+
30+
mod core {
31+
mod operator {
32+
mod join {
33+
use super::Op;
34+
use crate::core::Relation;
35+
use std::ops::{AddAssign, Mul};
36+
struct Join<LC, RC> {
37+
_left: LC,
38+
_right: RC,
39+
}
40+
impl<
41+
LC: Op<D = (K, LD), R = LR>,
42+
RC: Op<D = (K, RD), R = RR>,
43+
K: 'static,
44+
LD: 'static,
45+
LR: AddAssign<LR> + Mul<RR, Output = OR>,
46+
RD: 'static,
47+
RR: AddAssign<RR>,
48+
OR: AddAssign<OR>,
49+
> Op for Join<LC, RC>
50+
{
51+
type D = (K, LD, RD);
52+
type R = OR;
53+
}
54+
impl<K: 'static, D: 'static, C: Op<D = (K, D)>> Relation<C> {
55+
pub fn join<C2: Op<D = (K, D2)>, D2: 'static, OR: AddAssign<OR>>(
56+
self,
57+
other: Relation<C2>,
58+
) -> Relation<impl Op<D = (K, D, D2), R = OR>>
59+
where
60+
C::R: Mul<C2::R, Output = OR>,
61+
{
62+
Relation {
63+
inner: Join {
64+
_left: self.inner,
65+
_right: other.inner,
66+
},
67+
}
68+
}
69+
}
70+
}
71+
mod map {
72+
use super::Op;
73+
use crate::core::Relation;
74+
use std::ops::AddAssign;
75+
struct Map<C, MF> {
76+
_inner: C,
77+
_op: MF,
78+
}
79+
impl<
80+
D1,
81+
R1,
82+
D2: 'static,
83+
R2: AddAssign<R2>,
84+
C: Op<D = D1, R = R1>,
85+
MF: Fn(D1, R1) -> (D2, R2),
86+
> Op for Map<C, MF>
87+
{
88+
type D = D2;
89+
type R = R2;
90+
}
91+
impl<C: Op> Relation<C> {
92+
pub fn map_dr<F: Fn(C::D, C::R) -> (D2, R2), D2: 'static, R2: AddAssign<R2>>(
93+
self,
94+
f: F,
95+
) -> Relation<impl Op<D = D2, R = R2>> {
96+
Relation {
97+
inner: Map {
98+
_inner: self.inner,
99+
_op: f,
100+
},
101+
}
102+
}
103+
}
104+
}
105+
use std::ops::AddAssign;
106+
pub trait Op {
107+
type D: 'static;
108+
type R: AddAssign<Self::R>;
109+
}
110+
}
111+
pub use self::operator::Op;
112+
#[derive(Clone)]
113+
pub struct Relation<C> {
114+
inner: C,
115+
}
116+
}
117+
118+
use self::core::Op;
119+
pub use self::core::Relation;

ices/82126.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use std::sync::Mutex;
2+
3+
struct MarketMultiplier {}
4+
5+
impl MarketMultiplier {
6+
fn buy(&mut self) -> &mut usize {
7+
todo!()
8+
}
9+
}
10+
11+
async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_> {
12+
LockedMarket(generator.lock().unwrap().buy())
13+
}
14+
15+
struct LockedMarket<T>(T);
16+
17+
fn main() {}

ices/82139.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
trait Trait {
2+
type Associated;
3+
fn func() -> Self::Associated;
4+
}
5+
6+
trait Bound {}
7+
pub struct Struct;
8+
9+
impl Trait for Struct {
10+
type Associated = impl Bound;
11+
12+
fn func() -> Self::Associated {
13+
Some(42).map(|_| j)
14+
}
15+
}

ices/82156.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
super();
3+
}

0 commit comments

Comments
 (0)