Skip to content

Commit

Permalink
test discriminant of enum with uninhabited variant
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Mar 8, 2020
1 parent 22f2385 commit 6bbb9b8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/ui/consts/const_discriminant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,21 @@ const TEST_A: Discriminant<Test> = discriminant(&Test::A(5));
const TEST_A_OTHER: Discriminant<Test> = discriminant(&Test::A(17));
const TEST_B: Discriminant<Test> = discriminant(&Test::B);

enum Void {}

enum SingleVariant {
V,
Never(Void),
}

const TEST_V: Discriminant<SingleVariant> = discriminant(&SingleVariant::V);

fn main() {
assert_eq!(TEST_A, TEST_A_OTHER);
assert_eq!(TEST_A, discriminant(identity(&Test::A(17))));
assert_eq!(TEST_B, discriminant(identity(&Test::B)));
assert_ne!(TEST_A, TEST_B);
assert_ne!(TEST_B, discriminant(identity(&Test::C { a: 42, b: 7 })));

assert_eq!(TEST_V, discriminant(identity(&SingleVariant::V)));
}

0 comments on commit 6bbb9b8

Please sign in to comment.