Skip to content

Commit

Permalink
add regression test for rust-lang#79495
Browse files Browse the repository at this point in the history
  • Loading branch information
TaKO8Ki committed Jun 28, 2022
1 parent 8c7d9f6 commit 4795388
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/test/rustdoc-ui/issue-79495.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#![feature(arbitrary_enum_discriminant, core_intrinsics)]

extern crate core;
use core::intrinsics::discriminant_value;

#[repr(usize)]
enum MyWeirdOption<T> {
None = 0,
Some(T) = std::mem::size_of::<T>(),
//~^ ERROR generic parameters may not be used in const operations
}

fn main() {
assert_eq!(discriminant_value(&MyWeirdOption::<u8>::None), 0);
assert_eq!(discriminant_value(&MyWeirdOption::Some(0u8)), 1);
}
13 changes: 13 additions & 0 deletions src/test/rustdoc-ui/issue-79495.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error: generic parameters may not be used in const operations
--> $DIR/issue-79495.rs:9:35
|
LL | Some(T) = std::mem::size_of::<T>(),
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions

error: Compilation failed, aborting rustdoc

error: aborting due to 2 previous errors

0 comments on commit 4795388

Please sign in to comment.