diff --git a/ices/82268.rs b/ices/82268.rs new file mode 100644 index 00000000..a19a7225 --- /dev/null +++ b/ices/82268.rs @@ -0,0 +1,82 @@ +#![feature(const_generics, const_evaluatable_checked)] + +struct True; +struct False; + +trait ConstBool { + type Val; +} +struct TypeBool; + +impl ConstBool for TypeBool { + type Val = True; +} + +impl ConstBool for TypeBool { + type Val = False; +} + +trait Collate { + type Pass; + type Fail; + + fn collate(self) -> (Self::Pass, Self::Fail); +} + +impl Collate for () { + type Pass = (); + type Fail = (); + + fn collate(self) -> ((), ()) { + ((), ()) + } +} + +trait CollateStep { + type Pass; + type Fail; + fn collate_step(x: X, prev: Prev) -> (Self::Pass, Self::Fail); +} + +impl CollateStep for TypeBool { + type Pass = (X, P); + type Fail = F; + + fn collate_step(x: X, (p, f): (P, F)) -> ((X, P), F) { + ((x, p), f) + } +} + +impl CollateStep for TypeBool { + type Pass = P; + type Fail = (X, F); + + fn collate_step(x: X, (p, f): (P, F)) -> (P, (X, F)) { + (p, (x, f)) + } +} + +impl> 1 }>, const MASK: u32> Collate for (H, T) +where + TypeBool<{ 1 == MASK & 1 }>: CollateStep, +{ + type Pass = + as CollateStep>::Pass; + type Fail = + as CollateStep>::Fail; + + fn collate(self) -> (Self::Pass, Self::Fail) { + + as CollateStep> + ::collate_step(self.0, self.1.collate()) + } +} + +fn collate(x:X)->(X::Pass, X::Fail) +where X:Collate { + x.collate() +} + +fn main() { + dbg!(collate::<_,3>((4, ('!',())))); +}