File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
rustc_transmute/src/layout Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -742,11 +742,21 @@ impl Align {
742742 1 << self . pow2
743743 }
744744
745+ #[ inline]
746+ pub fn bytes_usize ( self ) -> usize {
747+ self . bytes ( ) . try_into ( ) . unwrap ( )
748+ }
749+
745750 #[ inline]
746751 pub fn bits ( self ) -> u64 {
747752 self . bytes ( ) * 8
748753 }
749754
755+ #[ inline]
756+ pub fn bits_usize ( self ) -> usize {
757+ self . bits ( ) . try_into ( ) . unwrap ( )
758+ }
759+
750760 /// Computes the best alignment possible for the given offset
751761 /// (the largest power of two that the offset is a multiple of).
752762 ///
Original file line number Diff line number Diff line change @@ -266,7 +266,7 @@ pub(crate) mod rustc {
266266
267267 ty:: Ref ( lifetime, ty, mutability) => {
268268 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 ( ) ;
270270 let size = ty_and_layout. size . bytes_usize ( ) ;
271271 Ok ( Tree :: Ref ( Ref {
272272 lifetime : * lifetime,
You can’t perform that action at this time.
0 commit comments