Wrapping<_> implements ShX<usize> but wrapping_shX takes u32
This is mostly just slightly confusing.
impl ShX for Wrapping<_> (the code refers to #23545, I'm not sure how this is related).
This is mostly just slightly confusing.
impl ShX for Wrapping<_>(the code refers to #23545, I'm not sure how this is related).Martin Nordholts at 2023-11-18 09:06:57
The same way
Shr/Shlare implemented for all primitive integrals with all primitive integral types for RHS,Shr/Shlshould be implemented ∀Wrapping<T>, where T: primitive with all primitive integral types for RHS.Simonas Kazlauskas at 2016-07-14 15:19:51
Does anyone know why this is? It was added by @aturon, and it seems it was intended to be implemented for more types: https://github.com/rust-lang/rust/pull/23549#r26862139. I suspect that this is a side-effect of #23545 since it causes inference regressions, but I'm uncertain (and that seems odd, since I'd expect most/all uses of shifting operations to have the types fairly well defined explicitly...).
Mark Rousskov at 2017-05-06 18:58:49
I ran into this problem when working on #50465; it appears that neither
Wrapping(1u32) >> 2norWrapping(1u32) >> Wrapping(2)work today without type ascription.IMHO, it makes the most sense to get rid of the
Shr<usize>andShl<usize>impls and useWrappingon both sides, but that would be a breaking change. I assume that there's no way to deprecate trait impls either…Ideally, we'd want to implement all of the necessary impls for
Wrapping >> WrappingandWrapping << Wrapping, using all combinations of integer types like the non-wrapping versions, then somehow deprecate the current, lonelyusizeimpl. Ideally, we could outright remove it, but I doubt that'd happen any time soon.Clar Fon at 2018-05-07 21:03:13
Triage: I believe this issue can be closed after the disabled impls here have been enabled, which is requires #23545 to be fixed first. Please correct me if that is wrong.
Martin Nordholts at 2023-11-18 09:10:10