@@ -168,16 +168,28 @@ impl Alignment {
168168 #[ unstable( feature = "ptr_alignment_type" , issue = "102070" ) ]
169169 #[ inline]
170170 pub const fn as_usize ( self ) -> usize {
171- // Going through `as_nonzero ` helps this be more clearly the inverse of
171+ // Going through `as_nonzero_usize ` helps this be more clearly the inverse of
172172 // `new_unchecked`, letting MIR optimizations fold it away.
173173
174- self . as_nonzero ( ) . get ( )
174+ self . as_nonzero_usize ( ) . get ( )
175175 }
176176
177177 /// Returns the alignment as a <code>[NonZero]<[usize]></code>.
178178 #[ unstable( feature = "ptr_alignment_type" , issue = "102070" ) ]
179+ #[ deprecated(
180+ since = "CURRENT_RUSTC_VERSION" ,
181+ note = "renamed to `as_nonzero_usize`" ,
182+ suggestion = "as_nonzero_usize"
183+ ) ]
179184 #[ inline]
180185 pub const fn as_nonzero ( self ) -> NonZero < usize > {
186+ self . as_nonzero_usize ( )
187+ }
188+
189+ /// Returns the alignment as a <code>[NonZero]<[usize]></code>.
190+ #[ unstable( feature = "ptr_alignment_type" , issue = "102070" ) ]
191+ #[ inline]
192+ pub const fn as_nonzero_usize ( self ) -> NonZero < usize > {
181193 // This transmutes directly to avoid the UbCheck in `NonZero::new_unchecked`
182194 // since there's no way for the user to trip that check anyway -- the
183195 // validity invariant of the type would have to have been broken earlier --
@@ -203,7 +215,7 @@ impl Alignment {
203215 #[ unstable( feature = "ptr_alignment_type" , issue = "102070" ) ]
204216 #[ inline]
205217 pub const fn log2 ( self ) -> u32 {
206- self . as_nonzero ( ) . trailing_zeros ( )
218+ self . as_nonzero_usize ( ) . trailing_zeros ( )
207219 }
208220
209221 /// Returns a bit mask that can be used to match this alignment.
@@ -246,7 +258,7 @@ impl Alignment {
246258#[ unstable( feature = "ptr_alignment_type" , issue = "102070" ) ]
247259impl fmt:: Debug for Alignment {
248260 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
249- write ! ( f, "{:?} (1 << {:?})" , self . as_nonzero ( ) , self . log2( ) )
261+ write ! ( f, "{:?} (1 << {:?})" , self . as_nonzero_usize ( ) , self . log2( ) )
250262 }
251263}
252264
@@ -277,7 +289,7 @@ impl const TryFrom<usize> for Alignment {
277289impl const From < Alignment > for NonZero < usize > {
278290 #[ inline]
279291 fn from ( align : Alignment ) -> NonZero < usize > {
280- align. as_nonzero ( )
292+ align. as_nonzero_usize ( )
281293 }
282294}
283295
@@ -294,7 +306,7 @@ impl const From<Alignment> for usize {
294306impl cmp:: Ord for Alignment {
295307 #[ inline]
296308 fn cmp ( & self , other : & Self ) -> cmp:: Ordering {
297- self . as_nonzero ( ) . cmp ( & other. as_nonzero ( ) )
309+ self . as_nonzero_usize ( ) . cmp ( & other. as_nonzero_usize ( ) )
298310 }
299311}
300312
@@ -310,7 +322,7 @@ impl cmp::PartialOrd for Alignment {
310322impl hash:: Hash for Alignment {
311323 #[ inline]
312324 fn hash < H : hash:: Hasher > ( & self , state : & mut H ) {
313- self . as_nonzero ( ) . hash ( state)
325+ self . as_nonzero_usize ( ) . hash ( state)
314326 }
315327}
316328
0 commit comments