@@ -108,24 +108,28 @@ fn repr_with_values() {
108
108
assert_eq ! ( 2 , unsafe { * <* const _>:: from( & Test :: C ) . cast:: <u8 >( ) } ) ;
109
109
}
110
110
111
- #[ test]
112
- fn repr_with_discriminants_values ( ) {
113
- #[ repr( u8 ) ]
114
- enum Test {
115
- A ( u8 ) = 3 ,
116
- B ,
117
- C ,
118
- }
119
-
120
- #[ cfg( feature = "nightly" ) ]
121
- {
122
- assert_eq ! ( 3_u8 , discriminant_value( & Test :: A ( 0 ) ) ) ;
123
- assert_eq ! ( 4_u8 , discriminant_value( & Test :: B ) ) ;
124
- assert_eq ! ( 5_u8 , discriminant_value( & Test :: C ) ) ;
111
+ #[ rustversion:: since( 1.66 ) ]
112
+ mod repr_with_discriminants_values {
113
+ #[ test]
114
+ fn test ( ) {
115
+ #[ repr( u8 ) ]
116
+ enum Test {
117
+ A ( u8 ) = 3 ,
118
+ B ,
119
+ C ,
120
+ }
121
+
122
+ #[ cfg( feature = "nightly" ) ]
123
+ {
124
+ use std:: intrinsics:: discriminant_value;
125
+ assert_eq ! ( 3_u8 , discriminant_value( & Test :: A ( 0 ) ) ) ;
126
+ assert_eq ! ( 4_u8 , discriminant_value( & Test :: B ) ) ;
127
+ assert_eq ! ( 5_u8 , discriminant_value( & Test :: C ) ) ;
128
+ }
129
+ assert_eq ! ( 3 , unsafe { * <* const _>:: from( & Test :: A ( 0 ) ) . cast:: <u8 >( ) } ) ;
130
+ assert_eq ! ( 4 , unsafe { * <* const _>:: from( & Test :: B ) . cast:: <u8 >( ) } ) ;
131
+ assert_eq ! ( 5 , unsafe { * <* const _>:: from( & Test :: C ) . cast:: <u8 >( ) } ) ;
125
132
}
126
- assert_eq ! ( 3 , unsafe { * <* const _>:: from( & Test :: A ( 0 ) ) . cast:: <u8 >( ) } ) ;
127
- assert_eq ! ( 4 , unsafe { * <* const _>:: from( & Test :: B ) . cast:: <u8 >( ) } ) ;
128
- assert_eq ! ( 5 , unsafe { * <* const _>:: from( & Test :: C ) . cast:: <u8 >( ) } ) ;
129
133
}
130
134
131
135
#[ test]
@@ -148,22 +152,26 @@ fn repr_with_repr_c_with_values() {
148
152
assert_eq ! ( 2 , unsafe { * <* const _>:: from( & Test :: C ) . cast:: <u8 >( ) } ) ;
149
153
}
150
154
151
- #[ test]
152
- fn repr_with_repr_c_with_values_discriminants ( ) {
153
- #[ repr( C , u8 ) ]
154
- enum Test {
155
- A ( u8 ) = 3 ,
156
- B ,
157
- C ,
158
- }
159
-
160
- #[ cfg( feature = "nightly" ) ]
161
- {
162
- assert_eq ! ( 3_u8 , discriminant_value( & Test :: A ( 0 ) ) ) ;
163
- assert_eq ! ( 4_u8 , discriminant_value( & Test :: B ) ) ;
164
- assert_eq ! ( 5_u8 , discriminant_value( & Test :: C ) ) ;
155
+ #[ rustversion:: since( 1.66 ) ]
156
+ mod repr_with_repr_c_with_values_discriminants {
157
+ #[ test]
158
+ fn test ( ) {
159
+ #[ repr( C , u8 ) ]
160
+ enum Test {
161
+ A ( u8 ) = 3 ,
162
+ B ,
163
+ C ,
164
+ }
165
+
166
+ #[ cfg( feature = "nightly" ) ]
167
+ {
168
+ use std:: intrinsics:: discriminant_value;
169
+ assert_eq ! ( 3_u8 , discriminant_value( & Test :: A ( 0 ) ) ) ;
170
+ assert_eq ! ( 4_u8 , discriminant_value( & Test :: B ) ) ;
171
+ assert_eq ! ( 5_u8 , discriminant_value( & Test :: C ) ) ;
172
+ }
173
+ assert_eq ! ( 3 , unsafe { * <* const _>:: from( & Test :: A ( 0 ) ) . cast:: <u8 >( ) } ) ;
174
+ assert_eq ! ( 4 , unsafe { * <* const _>:: from( & Test :: B ) . cast:: <u8 >( ) } ) ;
175
+ assert_eq ! ( 5 , unsafe { * <* const _>:: from( & Test :: C ) . cast:: <u8 >( ) } ) ;
165
176
}
166
- assert_eq ! ( 3 , unsafe { * <* const _>:: from( & Test :: A ( 0 ) ) . cast:: <u8 >( ) } ) ;
167
- assert_eq ! ( 4 , unsafe { * <* const _>:: from( & Test :: B ) . cast:: <u8 >( ) } ) ;
168
- assert_eq ! ( 5 , unsafe { * <* const _>:: from( & Test :: C ) . cast:: <u8 >( ) } ) ;
169
177
}
0 commit comments