@@ -6,6 +6,7 @@ use crate::hash::{Hash, Hasher};
6
6
use crate :: intrinsics;
7
7
use crate :: marker:: StructuralPartialEq ;
8
8
use crate :: ops:: { BitOr , BitOrAssign , Div , Neg , Rem } ;
9
+ use crate :: panic:: { RefUnwindSafe , UnwindSafe } ;
9
10
use crate :: ptr;
10
11
use crate :: str:: FromStr ;
11
12
@@ -129,6 +130,25 @@ impl_nonzero_fmt!(Octal);
129
130
impl_nonzero_fmt ! ( LowerHex ) ;
130
131
impl_nonzero_fmt ! ( UpperHex ) ;
131
132
133
+ macro_rules! impl_nonzero_auto_trait {
134
+ ( unsafe $Trait: ident) => {
135
+ #[ stable( feature = "nonzero" , since = "1.28.0" ) ]
136
+ unsafe impl <T > $Trait for NonZero <T > where T : ZeroablePrimitive + $Trait { }
137
+ } ;
138
+ ( $Trait: ident) => {
139
+ #[ stable( feature = "nonzero" , since = "1.28.0" ) ]
140
+ impl <T > $Trait for NonZero <T > where T : ZeroablePrimitive + $Trait { }
141
+ } ;
142
+ }
143
+
144
+ // Implement auto-traits manually based on `T` to avoid docs exposing
145
+ // the `ZeroablePrimitive::NonZeroInner` implementation detail.
146
+ impl_nonzero_auto_trait ! ( RefUnwindSafe ) ;
147
+ impl_nonzero_auto_trait ! ( unsafe Send ) ;
148
+ impl_nonzero_auto_trait ! ( unsafe Sync ) ;
149
+ impl_nonzero_auto_trait ! ( Unpin ) ;
150
+ impl_nonzero_auto_trait ! ( UnwindSafe ) ;
151
+
132
152
#[ stable( feature = "nonzero" , since = "1.28.0" ) ]
133
153
impl < T > Clone for NonZero < T >
134
154
where
0 commit comments