//@ known-bug: #119692 //@ compile-flags: -Copt-level=0 #![allow(incomplete_features)] #![feature(adt_const_params)] #![feature(generic_const_exprs)] use std::ops::Add; #[derive(PartialEq, Eq, Clone, Debug, core::marker::ConstParamTy)] pub struct Dimension; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Default)] pub struct Quantity(pub(crate) S); impl Add> for Quantity where LHS: Add, { type Output = Quantity<>::Output, D>; fn add(self, rhs: Quantity) -> Self::Output { Quantity(self.0 + rhs.0) } } impl Add for Quantity where LHS: Add, { type Output = Quantity<>::Output, { Dimension }>; fn add(self, rhs: RHS) -> Self::Output { Quantity(self.0 + rhs) } } impl Add> for f32 { type Output = Quantity; fn add(self, rhs: Quantity) -> Self::Output { Quantity(self + rhs.0) } } pub fn add(x: Quantity, y: Quantity) -> Quantity { x + y } fn main() { add(Quantity::(1.0), Quantity(2.0)); }