// revisions: default miropt // check-pass //[miropt]compile-flags: -Z mir-opt-level=3 // -^ This flag is for #96395 as a regression test. mod convenience_operators { use crate::{Op, Relation}; use std::ops::AddAssign; use std::ops::Mul; impl Relation { pub fn map D2 + 'static, D2: 'static>( self, f: F, ) -> Relation> { self.map_dr(move |x, r| (f(x), r)) } } impl> Relation { pub fn semijoin, R2, R3: AddAssign>( self, other: Relation, ) -> Relation> where C::R: Mul, { 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 { _left: LC, _right: RC, } impl< LC: Op, RC: Op, K: 'static, LD: 'static, LR: AddAssign + Mul, RD: 'static, RR: AddAssign, OR: AddAssign, > Op for Join { type D = (K, LD, RD); type R = OR; } impl> Relation { pub fn join, D2: 'static, OR: AddAssign>( self, other: Relation, ) -> Relation> where C::R: Mul, { Relation { inner: Join { _left: self.inner, _right: other.inner, }, } } } } mod map { use super::Op; use crate::core::Relation; use std::ops::AddAssign; struct Map { _inner: C, _op: MF, } impl< D1, R1, D2: 'static, R2: AddAssign, C: Op, MF: Fn(D1, R1) -> (D2, R2), > Op for Map { type D = D2; type R = R2; } impl Relation { pub fn map_dr (D2, R2), D2: 'static, R2: AddAssign>( self, f: F, ) -> Relation> { Relation { inner: Map { _inner: self.inner, _op: f, }, } } } } use std::ops::AddAssign; pub trait Op { type D: 'static; type R: AddAssign; } } pub use self::operator::Op; #[derive(Clone)] pub struct Relation { inner: C, } } use self::core::Op; pub use self::core::Relation; fn main() {}