summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts/issue-79137-monomorphic.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/consts/issue-79137-monomorphic.rs')
-rw-r--r--tests/ui/consts/issue-79137-monomorphic.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/ui/consts/issue-79137-monomorphic.rs b/tests/ui/consts/issue-79137-monomorphic.rs
new file mode 100644
index 000000000..58e0c387f
--- /dev/null
+++ b/tests/ui/consts/issue-79137-monomorphic.rs
@@ -0,0 +1,19 @@
+// check-pass
+
+// Verify that variant count intrinsic can still evaluate for types like `Option<T>`.
+
+#![feature(variant_count)]
+
+pub struct GetVariantCount<T>(T);
+
+impl<T> GetVariantCount<T> {
+ pub const VALUE: usize = std::mem::variant_count::<T>();
+}
+
+const fn check_variant_count<T>() -> bool {
+ matches!(GetVariantCount::<Option<T>>::VALUE, GetVariantCount::<Option<()>>::VALUE)
+}
+
+fn main() {
+ assert!(check_variant_count::<()>());
+}