diff --git a/tests/kani/Intrinsics/Compiler/variant_count.rs b/tests/kani/Intrinsics/Compiler/variant_count.rs new file mode 100644 index 000000000000..3a7c330aefe7 --- /dev/null +++ b/tests/kani/Intrinsics/Compiler/variant_count.rs @@ -0,0 +1,16 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 OR MIT +// kani-verify-fail + +// Check that `variant_count` is not supported. +// This test can be replaced with `variant_count_fixme.rs` once the intrinsic is +// supported and works as expected. + +#![feature(variant_count)] +use std::mem; + +enum Void {} + +fn main() { + let _ = mem::variant_count::(); +} diff --git a/tests/kani/Intrinsics/Compiler/variant_count_fixme.rs b/tests/kani/Intrinsics/Compiler/variant_count_fixme.rs new file mode 100644 index 000000000000..37a14dc967b1 --- /dev/null +++ b/tests/kani/Intrinsics/Compiler/variant_count_fixme.rs @@ -0,0 +1,21 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 OR MIT + +// Check that `variant_count` is supported and returns the expected result. + +#![feature(variant_count)] +use std::mem; + +enum Void {} +enum MyError { + Error1, + Error2, + Error3, +} + +fn main() { + assert!(mem::variant_count::() == 0); + assert!(mem::variant_count::() == 3); + assert!(mem::variant_count::>() == 2); + assert!(mem::variant_count::>() == 2); +}