]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/issue-79137-toogeneric.rs
Rollup merge of #107004 - compiler-errors:new-solver-new-candidates-2, r=lcnr
[rust.git] / tests / ui / consts / issue-79137-toogeneric.rs
1 // Test that `variant_count` only gets evaluated once the type is concrete enough.
2
3 #![feature(variant_count)]
4
5 pub struct GetVariantCount<T>(T);
6
7 impl<T> GetVariantCount<T> {
8     pub const VALUE: usize = std::mem::variant_count::<T>();
9 }
10
11 const fn check_variant_count<T>() -> bool {
12     matches!(GetVariantCount::<T>::VALUE, GetVariantCount::<T>::VALUE)
13     //~^ ERROR constant pattern depends on a generic parameter
14     //~| ERROR constant pattern depends on a generic parameter
15 }
16
17 fn main() {
18     assert!(check_variant_count::<Option<()>>());
19 }