Closed
Description
use std::ops::Mul;
struct BoxedValue<T: Mul> {
value: T
}
impl<T: Mul<Output=T>> Mul for BoxedValue<T> {
type Output = Self;
fn mul(self, rhs: Self) -> Self {
BoxedValue{value: self.value*rhs.value}
}
}
fn width<T: Mul>(value: T) -> BoxedValue<T> {
BoxedValue{value}
}
fn height<T: Mul>(value: T) -> BoxedValue<T> {
BoxedValue{value}
}
fn foo(s1: f64, s2: f64) -> BoxedValue<f64> {
(width(s1) * height(s1)) + (width(s2) * height(s2))
}
fn main() {
}
When compiled produces error which only highlights whole expression - offending operator is not marked in any way.
Newest gcc is capable of much nicer diagnostics in similar situation: https://developers.redhat.com/blog/2019/03/08/usability-improvements-in-gcc-9/ - similar diagnostics should be added to rustc.