forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add regression test for rust-lang#79495
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|