Open
Description
I tried this code:
use cgmath::{Vector3, Point3};
use std::ops::Mul;
#[derive(Debug)]
pub struct Ray<S> {
pub origin: Point3<S>,
pub direction: Vector3<S>,
}
impl <S> Ray<S> {
pub fn new(origin: Point3<S>, direction: Vector3<S>) -> Self {
Self { origin, direction }
}
pub fn at(&self, t: S) -> Self {
let aaa = self.direction * t;
Self { origin: self.origin, direction: aaa }
}
}
I expected to see this happen: Compiler suggests the following bound
where
Vector3<S>: Mul<S, Output = Vector3<S>>
Instead, this happened: Compiler suggests the following bound
where
S: Mul<Output = Vector3<S>>
the above bound doesn't constrain the generic correctly and the compiler will keep requesting you add it despite it already being present.
Meta
The bug also occurs when I use nightly.
rustc --version --verbose
:
rustc 1.50.0 (cb75ad5db 2021-02-10)
binary: rustc
commit-hash: cb75ad5db02783e8b0222fee363c5f63f7e2cf5b
commit-date: 2021-02-10
host: aarch64-apple-darwin
release: 1.50.0