@@ -24,7 +24,10 @@ macro_rules! impl_nonzero_fmt {
24
24
25
25
macro_rules! nonzero_integer {
26
26
(
27
- #[ $stability: meta] #[ $const_new_unchecked_stability: meta] $Ty: ident( $Int: ty) ;
27
+ Self = $Ty: ident,
28
+ Primitive = $signedness: ident $Int: ident,
29
+ feature = $feature: literal,
30
+ original_stabilization = $since: literal,
28
31
) => {
29
32
/// An integer that is known not to equal zero.
30
33
///
@@ -56,7 +59,7 @@ macro_rules! nonzero_integer {
56
59
/// ```
57
60
///
58
61
/// [null pointer optimization]: crate::option#representation
59
- #[ $stability ]
62
+ #[ stable ( feature = $feature , since = $since ) ]
60
63
#[ derive( Copy , Clone , Eq , PartialEq , Ord , PartialOrd , Hash ) ]
61
64
#[ repr( transparent) ]
62
65
#[ rustc_layout_scalar_valid_range_start( 1 ) ]
@@ -71,8 +74,8 @@ macro_rules! nonzero_integer {
71
74
/// # Safety
72
75
///
73
76
/// The value must not be zero.
74
- #[ $stability ]
75
- #[ $const_new_unchecked_stability ]
77
+ #[ stable ( feature = $feature , since = $since ) ]
78
+ #[ rustc_const_stable ( feature = $feature , since = $since ) ]
76
79
#[ must_use]
77
80
#[ inline]
78
81
pub const unsafe fn new_unchecked( n: $Int) -> Self {
@@ -87,7 +90,7 @@ macro_rules! nonzero_integer {
87
90
}
88
91
89
92
/// Creates a non-zero if the given value is not zero.
90
- #[ $stability ]
93
+ #[ stable ( feature = $feature , since = $since ) ]
91
94
#[ rustc_const_stable( feature = "const_nonzero_int_methods" , since = "1.47.0" ) ]
92
95
#[ must_use]
93
96
#[ inline]
@@ -101,7 +104,7 @@ macro_rules! nonzero_integer {
101
104
}
102
105
103
106
/// Returns the value as a primitive type.
104
- #[ $stability ]
107
+ #[ stable ( feature = $feature , since = $since ) ]
105
108
#[ inline]
106
109
#[ rustc_const_stable( feature = "const_nonzero_get" , since = "1.34.0" ) ]
107
110
pub const fn get( self ) -> $Int {
@@ -119,7 +122,6 @@ macro_rules! nonzero_integer {
119
122
}
120
123
self . 0
121
124
}
122
-
123
125
}
124
126
125
127
#[ stable( feature = "from_nonzero" , since = "1.31.0" ) ]
@@ -185,7 +187,8 @@ macro_rules! nonzero_integer {
185
187
}
186
188
187
189
impl_nonzero_fmt! {
188
- #[ $stability] ( Debug , Display , Binary , Octal , LowerHex , UpperHex ) for $Ty
190
+ #[ stable( feature = $feature, since = $since) ]
191
+ ( Debug , Display , Binary , Octal , LowerHex , UpperHex ) for $Ty
189
192
}
190
193
} ;
191
194
}
@@ -1383,49 +1386,85 @@ nonzero_bits! {
1383
1386
}
1384
1387
1385
1388
nonzero_integer ! {
1386
- #[ stable( feature = "nonzero" , since = "1.28.0" ) ] #[ rustc_const_stable( feature = "nonzero" , since = "1.28.0" ) ] NonZeroU8 ( u8 ) ;
1389
+ Self = NonZeroU8 ,
1390
+ Primitive = unsigned u8 ,
1391
+ feature = "nonzero" ,
1392
+ original_stabilization = "1.28.0" ,
1387
1393
}
1388
1394
1389
1395
nonzero_integer ! {
1390
- #[ stable( feature = "nonzero" , since = "1.28.0" ) ] #[ rustc_const_stable( feature = "nonzero" , since = "1.28.0" ) ] NonZeroU16 ( u16 ) ;
1396
+ Self = NonZeroU16 ,
1397
+ Primitive = unsigned u16 ,
1398
+ feature = "nonzero" ,
1399
+ original_stabilization = "1.28.0" ,
1391
1400
}
1392
1401
1393
1402
nonzero_integer ! {
1394
- #[ stable( feature = "nonzero" , since = "1.28.0" ) ] #[ rustc_const_stable( feature = "nonzero" , since = "1.28.0" ) ] NonZeroU32 ( u32 ) ;
1403
+ Self = NonZeroU32 ,
1404
+ Primitive = unsigned u32 ,
1405
+ feature = "nonzero" ,
1406
+ original_stabilization = "1.28.0" ,
1395
1407
}
1396
1408
1397
1409
nonzero_integer ! {
1398
- #[ stable( feature = "nonzero" , since = "1.28.0" ) ] #[ rustc_const_stable( feature = "nonzero" , since = "1.28.0" ) ] NonZeroU64 ( u64 ) ;
1410
+ Self = NonZeroU64 ,
1411
+ Primitive = unsigned u64 ,
1412
+ feature = "nonzero" ,
1413
+ original_stabilization = "1.28.0" ,
1399
1414
}
1400
1415
1401
1416
nonzero_integer ! {
1402
- #[ stable( feature = "nonzero" , since = "1.28.0" ) ] #[ rustc_const_stable( feature = "nonzero" , since = "1.28.0" ) ] NonZeroU128 ( u128 ) ;
1417
+ Self = NonZeroU128 ,
1418
+ Primitive = unsigned u128 ,
1419
+ feature = "nonzero" ,
1420
+ original_stabilization = "1.28.0" ,
1403
1421
}
1404
1422
1405
1423
nonzero_integer ! {
1406
- #[ stable( feature = "nonzero" , since = "1.28.0" ) ] #[ rustc_const_stable( feature = "nonzero" , since = "1.28.0" ) ] NonZeroUsize ( usize ) ;
1424
+ Self = NonZeroUsize ,
1425
+ Primitive = unsigned usize ,
1426
+ feature = "nonzero" ,
1427
+ original_stabilization = "1.28.0" ,
1407
1428
}
1408
1429
1409
1430
nonzero_integer ! {
1410
- #[ stable( feature = "signed_nonzero" , since = "1.34.0" ) ] #[ rustc_const_stable( feature = "signed_nonzero" , since = "1.34.0" ) ] NonZeroI8 ( i8 ) ;
1431
+ Self = NonZeroI8 ,
1432
+ Primitive = signed i8 ,
1433
+ feature = "signed_nonzero" ,
1434
+ original_stabilization = "1.34.0" ,
1411
1435
}
1412
1436
1413
1437
nonzero_integer ! {
1414
- #[ stable( feature = "signed_nonzero" , since = "1.34.0" ) ] #[ rustc_const_stable( feature = "signed_nonzero" , since = "1.34.0" ) ] NonZeroI16 ( i16 ) ;
1438
+ Self = NonZeroI16 ,
1439
+ Primitive = signed i16 ,
1440
+ feature = "signed_nonzero" ,
1441
+ original_stabilization = "1.34.0" ,
1415
1442
}
1416
1443
1417
1444
nonzero_integer ! {
1418
- #[ stable( feature = "signed_nonzero" , since = "1.34.0" ) ] #[ rustc_const_stable( feature = "signed_nonzero" , since = "1.34.0" ) ] NonZeroI32 ( i32 ) ;
1445
+ Self = NonZeroI32 ,
1446
+ Primitive = signed i32 ,
1447
+ feature = "signed_nonzero" ,
1448
+ original_stabilization = "1.34.0" ,
1419
1449
}
1420
1450
1421
1451
nonzero_integer ! {
1422
- #[ stable( feature = "signed_nonzero" , since = "1.34.0" ) ] #[ rustc_const_stable( feature = "signed_nonzero" , since = "1.34.0" ) ] NonZeroI64 ( i64 ) ;
1452
+ Self = NonZeroI64 ,
1453
+ Primitive = signed i64 ,
1454
+ feature = "signed_nonzero" ,
1455
+ original_stabilization = "1.34.0" ,
1423
1456
}
1424
1457
1425
1458
nonzero_integer ! {
1426
- #[ stable( feature = "signed_nonzero" , since = "1.34.0" ) ] #[ rustc_const_stable( feature = "signed_nonzero" , since = "1.34.0" ) ] NonZeroI128 ( i128 ) ;
1459
+ Self = NonZeroI128 ,
1460
+ Primitive = signed i128 ,
1461
+ feature = "signed_nonzero" ,
1462
+ original_stabilization = "1.34.0" ,
1427
1463
}
1428
1464
1429
1465
nonzero_integer ! {
1430
- #[ stable( feature = "signed_nonzero" , since = "1.34.0" ) ] #[ rustc_const_stable( feature = "signed_nonzero" , since = "1.34.0" ) ] NonZeroIsize ( isize ) ;
1466
+ Self = NonZeroIsize ,
1467
+ Primitive = signed isize ,
1468
+ feature = "signed_nonzero" ,
1469
+ original_stabilization = "1.34.0" ,
1431
1470
}
0 commit comments