We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Align::from_bytes
1 parent 2a71115 commit 99fd9cbCopy full SHA for 99fd9cb
compiler/rustc_abi/src/lib.rs
@@ -665,15 +665,12 @@ impl Align {
665
format!("`{}` is too large", align)
666
}
667
668
- let mut bytes = align;
669
- let mut pow2: u8 = 0;
670
- while (bytes & 1) == 0 {
671
- pow2 += 1;
672
- bytes >>= 1;
673
- }
674
- if bytes != 1 {
+ let tz = align.trailing_zeros();
+ if align != (1 << tz) {
675
return Err(not_power_of_2(align));
676
+
+ let pow2 = tz as u8;
677
if pow2 > Self::MAX.pow2 {
678
return Err(too_large(align));
679
0 commit comments