]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #103456 - scottmcm:fix-unchecked-shifts, r=scottmcm
authorManish Goregaokar <manishsmail@gmail.com>
Fri, 18 Nov 2022 22:48:17 +0000 (17:48 -0500)
committerGitHub <noreply@github.com>
Fri, 18 Nov 2022 22:48:17 +0000 (17:48 -0500)
`unchecked_{shl|shr}` should use `u32` as the RHS

The other shift methods, such as https://doc.rust-lang.org/nightly/std/primitive.u64.html#method.checked_shr and https://doc.rust-lang.org/nightly/std/primitive.i16.html#method.wrapping_shl, use `u32` for the shift amount.  That's consistent with other things, like `count_ones`, which also always use `u32` for a bit count, regardless of the size of the type.

This PR changes `unchecked_shl` and `unchecked_shr` to also use `u32` for the shift amount (rather than Self).

cc #85122, the `unchecked_math` tracking issue

1  2 
library/core/src/lib.rs
library/core/src/num/int_macros.rs
library/core/src/num/uint_macros.rs

Simple merge
Simple merge
Simple merge