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 #655 from fanninpm/add-ices-2021-02-15
Browse files Browse the repository at this point in the history
Add some ICEs
  • Loading branch information
Alexendoo committed Feb 16, 2021
2 parents cff2d2a + da245df commit f9ee27d
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ices/77647.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

cat > out.rs <<'EOF'
#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]
struct A<T, const N: core::num::NonZeroUsize>([T; N.get()]) where [T; N.get()]: Sized;
EOF

rustdoc out.rs --output-format json
59 changes: 59 additions & 0 deletions ices/82034.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

rustc --test -C incremental=foo - <<'EOF'
#![feature(const_generics)]
#![feature(const_evaluatable_checked)]
#![allow(incomplete_features)]
pub trait IsTrue {}
pub trait IsFalse {}
pub struct Assert<const CHECK: bool> {}
impl IsTrue for Assert<true> {}
impl IsFalse for Assert<false> {}
pub struct SliceConstWriter<'a, const N: usize> {
ptr: &'a mut [u8]
}
impl<'a, const N: usize> SliceConstWriter<'a, {N}> {
pub fn from_slice(vec: &'a mut [u8]) -> Self {
Self {
ptr: vec
}
}
pub fn convert<const NN: usize>(mut self) -> SliceConstWriter<'a, {NN}> {
SliceConstWriter {
ptr: self.ptr
}
}
}
impl<'a, const N: usize> SliceConstWriter<'a, {N}> where Assert::<{N >= 2}>: IsTrue {
// broken
pub fn write_u8(mut self) -> SliceConstWriter<'a, {N-2}> {
self.convert()
}
//working
// pub fn write_u8(mut self) -> SliceConstWriter<'a, {N-2}> {
// SliceConstWriter {
// ptr: self.ptr
// }
// }
}
#[cfg(test)]
mod tests {
use crate::SliceConstWriter;
#[test]
fn it_works() {
let mut buff = [0u8; 128];
let mut a = SliceConstWriter::<10>::from_slice(&mut buff);
let mut a = a.write_u8().write_u8().write_u8().write_u8().write_u8();
}
}
EOF
119 changes: 119 additions & 0 deletions ices/82079.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#![crate_type = "lib"]

mod convenience_operators {
use crate::{Op, Relation};
use std::ops::AddAssign;
use std::ops::Mul;

impl<C: Op> Relation<C> {
pub fn map<F: Fn(C::D) -> D2 + 'static, D2: 'static>(
self,
f: F,
) -> Relation<impl Op<D = D2, R = C::R>> {
self.map_dr(move |x, r| (f(x), r))
}
}

impl<K: 'static, V: 'static, C: Op<D = (K, V)>> Relation<C> {
pub fn semijoin<C2: Op<D = K, R = R2>, R2, R3: AddAssign<R3>>(
self,
other: Relation<C2>,
) -> Relation<impl Op<D = C::D, R = R3>>
where
C::R: Mul<R2, Output = R3>,
{
self.join(other.map(|x| (x, ()))).map(|(k, x, ())| (k, x))
}
}
}

mod core {
mod operator {
mod join {
use super::Op;
use crate::core::Relation;
use std::ops::{AddAssign, Mul};
struct Join<LC, RC> {
_left: LC,
_right: RC,
}
impl<
LC: Op<D = (K, LD), R = LR>,
RC: Op<D = (K, RD), R = RR>,
K: 'static,
LD: 'static,
LR: AddAssign<LR> + Mul<RR, Output = OR>,
RD: 'static,
RR: AddAssign<RR>,
OR: AddAssign<OR>,
> Op for Join<LC, RC>
{
type D = (K, LD, RD);
type R = OR;
}
impl<K: 'static, D: 'static, C: Op<D = (K, D)>> Relation<C> {
pub fn join<C2: Op<D = (K, D2)>, D2: 'static, OR: AddAssign<OR>>(
self,
other: Relation<C2>,
) -> Relation<impl Op<D = (K, D, D2), R = OR>>
where
C::R: Mul<C2::R, Output = OR>,
{
Relation {
inner: Join {
_left: self.inner,
_right: other.inner,
},
}
}
}
}
mod map {
use super::Op;
use crate::core::Relation;
use std::ops::AddAssign;
struct Map<C, MF> {
_inner: C,
_op: MF,
}
impl<
D1,
R1,
D2: 'static,
R2: AddAssign<R2>,
C: Op<D = D1, R = R1>,
MF: Fn(D1, R1) -> (D2, R2),
> Op for Map<C, MF>
{
type D = D2;
type R = R2;
}
impl<C: Op> Relation<C> {
pub fn map_dr<F: Fn(C::D, C::R) -> (D2, R2), D2: 'static, R2: AddAssign<R2>>(
self,
f: F,
) -> Relation<impl Op<D = D2, R = R2>> {
Relation {
inner: Map {
_inner: self.inner,
_op: f,
},
}
}
}
}
use std::ops::AddAssign;
pub trait Op {
type D: 'static;
type R: AddAssign<Self::R>;
}
}
pub use self::operator::Op;
#[derive(Clone)]
pub struct Relation<C> {
inner: C,
}
}

use self::core::Op;
pub use self::core::Relation;
17 changes: 17 additions & 0 deletions ices/82126.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::sync::Mutex;

struct MarketMultiplier {}

impl MarketMultiplier {
fn buy(&mut self) -> &mut usize {
todo!()
}
}

async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_> {
LockedMarket(generator.lock().unwrap().buy())
}

struct LockedMarket<T>(T);

fn main() {}
15 changes: 15 additions & 0 deletions ices/82139.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
trait Trait {
type Associated;
fn func() -> Self::Associated;
}

trait Bound {}
pub struct Struct;

impl Trait for Struct {
type Associated = impl Bound;

fn func() -> Self::Associated {
Some(42).map(|_| j)
}
}
3 changes: 3 additions & 0 deletions ices/82156.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
super();
}

0 comments on commit f9ee27d

Please sign in to comment.