Closed
Description
Given the following code: here
fn rot<T : std::ops::Shl<Output = T>>(x:&T, k:u32) -> T {
let bit_count = std::mem::size_of::<T>() << 3;
(x << k as T) | (x >> (bit_count - k as T))
}
The current output is:
error[E0369]: no implementation for `&T << T`
--> src\lib.rs:10:8
|
10 | (x << k as T) | (x >> (bit_count - k as T))
| - ^^ ------ T
| |
| &T
|
help: consider further restricting this bound
|
8 | fn rot<T : std::ops::Shl<Output = T> + std::ops::Shl<Output = T>>(x:&T, k:u32) -> T {
| +++++++++++++++++++++++++++
The code is incorrect and shouldn't compile, but the suggestion is to duplicate a trait restriction that is already present in the function and can be repeated n-times, e.g. with T: std::ops::Shl<Output = T> + std::ops::Shl<Output = T>
it will suggest T: std::ops::Shl<Output = T> + std::ops::Shl<Output = T>+ std::ops::Shl<Output = T>
. This appears to indicate that the traits are not being checked correctly for suggestions, suggesting trait restrictions that are already present. The same output occurs in the nightly build.