File tree 2 files changed +11
-1
lines changed
rustc_transmute/src/layout
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -742,11 +742,21 @@ impl Align {
742
742
1 << self . pow2
743
743
}
744
744
745
+ #[ inline]
746
+ pub fn bytes_usize ( self ) -> usize {
747
+ self . bytes ( ) . try_into ( ) . unwrap ( )
748
+ }
749
+
745
750
#[ inline]
746
751
pub fn bits ( self ) -> u64 {
747
752
self . bytes ( ) * 8
748
753
}
749
754
755
+ #[ inline]
756
+ pub fn bits_usize ( self ) -> usize {
757
+ self . bits ( ) . try_into ( ) . unwrap ( )
758
+ }
759
+
750
760
/// Computes the best alignment possible for the given offset
751
761
/// (the largest power of two that the offset is a multiple of).
752
762
///
Original file line number Diff line number Diff line change @@ -266,7 +266,7 @@ pub(crate) mod rustc {
266
266
267
267
ty:: Ref ( lifetime, ty, mutability) => {
268
268
let ty_and_layout = cx. layout_of ( * ty) ?;
269
- let align = ty_and_layout. align . abi . bytes ( ) as usize ;
269
+ let align = ty_and_layout. align . abi . bytes_usize ( ) ;
270
270
let size = ty_and_layout. size . bytes_usize ( ) ;
271
271
Ok ( Tree :: Ref ( Ref {
272
272
lifetime : * lifetime,
You can’t perform that action at this time.
0 commit comments