@@ -182,8 +182,7 @@ macro_rules! cpubits {
182182 ) => {
183183 $crate:: cpubits! {
184184 // `cfg` selector for 64-bit target overrides
185- // Implicitly `cfg(any(...))`
186- #[ cfg( enable_64bit(
185+ #[ cfg( enable_64_bit = any(
187186 // ARMv7
188187 all( target_arch = "arm" , not( target_feature = "thumb-mode" ) ) ,
189188 // WASM
@@ -198,7 +197,7 @@ macro_rules! cpubits {
198197 // Same API as immediately above, but with a pseudo-attribute we use to pass the `cfg` overrides
199198 // for `target_pointer_width` that promote a 32-bit target into a 64-bit one.
200199 (
201- #[ cfg( enable_64bit ( $( $enable_64bit: tt) + ) ) ]
200+ #[ cfg( enable_64_bit = $( $enable_64bit: tt) + ) ]
202201 16 => { $( $tokens16: tt ) * }
203202 32 => { $( $tokens32: tt ) * }
204203 64 => { $( $tokens64: tt ) * }
@@ -212,14 +211,14 @@ macro_rules! cpubits {
212211 (
213212 ( all(
214213 target_pointer_width = "32" ,
215- not( any ( $( $enable_64bit ) +) )
214+ not( $( $enable_64bit ) +)
216215 ) )
217216 ( $( $tokens32 ) * )
218217 ) ,
219218 (
220219 ( any(
221220 target_pointer_width = "64" ,
222- any ( $( $enable_64bit ) +)
221+ $( $enable_64bit ) +
223222 ) )
224223 ( $( $tokens64 ) * )
225224 ) ,
@@ -291,20 +290,6 @@ pub const CPUBITS: u32 = {
291290mod tests {
292291 use super :: CPUBITS ;
293292
294- /// Return an integer that maps to `target_pointer_width`.
295- #[ allow( dead_code) ]
296- fn detect_pointer_width ( ) -> u32 {
297- if cfg ! ( target_pointer_width = "16" ) {
298- 16
299- } else if cfg ! ( target_pointer_width = "32" ) {
300- 32
301- } else if cfg ! ( target_pointer_width = "64" ) {
302- 64
303- } else {
304- unreachable ! ( "rustc only support 16, 32, and 64-bit pointer widths" )
305- }
306- }
307-
308293 /// Return the expected number of bits for the target.
309294 fn expected_bits ( ) -> u32 {
310295 // Duplicated 64-bit override predicates need to go here
@@ -316,7 +301,7 @@ mod tests {
316301 ) ) {
317302 64
318303 } else {
319- detect_pointer_width ( )
304+ usize :: BITS
320305 }
321306 }
322307
@@ -339,18 +324,19 @@ mod tests {
339324 assert_eq ! ( CPUBITS , 64 ) ;
340325 }
341326
327+ /// Test for the `16 | 32` syntax.
342328 #[ test]
343329 fn cpubits_16_or_32_vs_64 ( ) {
344- fn bits32or64 ( ) -> u32 {
330+ const BITS : u32 = {
345331 cpubits ! {
346332 16 | 32 => { 32 }
347333 64 => { 64 }
348334 }
349- }
335+ } ;
350336
351337 match expected_bits ( ) {
352- 16 | 32 => assert_eq ! ( 32 , bits32or64 ( ) ) ,
353- 64 => assert_eq ! ( 64 , bits32or64 ( ) ) ,
338+ 16 | 32 => assert_eq ! ( 32 , BITS ) ,
339+ 64 => assert_eq ! ( 64 , BITS ) ,
354340 bits => unreachable ! ( "#{bits}-bits should be one of: 16, 32, 64" ) ,
355341 }
356342 }
0 commit comments