]> git.proxmox.com Git - rustc.git/blob - src/test/ui/const-generics/invalid-enum.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / src / test / ui / const-generics / invalid-enum.rs
1 #![feature(const_generics)]
2 #![allow(incomplete_features)]
3
4 #[derive(PartialEq, Eq)]
5 enum CompileFlag {
6 A,
7 B,
8 }
9
10 pub fn test_1<const CF: CompileFlag>() {}
11 pub fn test_2<T, const CF: CompileFlag>(x: T) {}
12 pub struct Example<const CF: CompileFlag, T=u32>{
13 x: T,
14 }
15
16 impl<const CF: CompileFlag, T> Example<CF, T> {
17 const ASSOC_FLAG: CompileFlag = CompileFlag::A;
18 }
19
20 pub fn main() {
21 test_1::<CompileFlag::A>();
22 //~^ ERROR: expected type, found variant
23 //~| ERROR: unresolved item provided when a constant was expected
24
25 test_2::<_, CompileFlag::A>(0);
26 //~^ ERROR: expected type, found variant
27 //~| ERROR: unresolved item provided when a constant was expected
28
29 let _: Example<CompileFlag::A, _> = Example { x: 0 };
30 //~^ ERROR: expected type, found variant
31 //~| ERROR: unresolved item provided when a constant was expected
32
33 let _: Example<Example::ASSOC_FLAG, _> = Example { x: 0 };
34 //~^ ERROR: type provided when a constant was expected
35 }