File tree 2 files changed +29
-0
lines changed 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( arbitrary_enum_discriminant, core_intrinsics) ]
2
+
3
+ extern crate core;
4
+ use core:: intrinsics:: discriminant_value;
5
+
6
+ #[ repr( usize ) ]
7
+ enum MyWeirdOption < T > {
8
+ None = 0 ,
9
+ Some ( T ) = std:: mem:: size_of :: < T > ( ) ,
10
+ //~^ ERROR generic parameters may not be used in const operations
11
+ }
12
+
13
+ fn main ( ) {
14
+ assert_eq ! ( discriminant_value( & MyWeirdOption :: <u8 >:: None ) , 0 ) ;
15
+ assert_eq ! ( discriminant_value( & MyWeirdOption :: Some ( 0u8 ) ) , 1 ) ;
16
+ }
Original file line number Diff line number Diff line change
1
+ error: generic parameters may not be used in const operations
2
+ --> $DIR/issue-79495.rs:9:35
3
+ |
4
+ LL | Some(T) = std::mem::size_of::<T>(),
5
+ | ^ cannot perform const operation using `T`
6
+ |
7
+ = note: type parameters may not be used in const expressions
8
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
9
+
10
+ error: Compilation failed, aborting rustdoc
11
+
12
+ error: aborting due to 2 previous errors
13
+
You can’t perform that action at this time.
0 commit comments