]> git.proxmox.com Git - rustc.git/blob - tests/ui/consts/const-eval/issue-50706.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / consts / const-eval / issue-50706.rs
1 // check-pass
2
3 pub struct Stats;
4
5 #[derive(PartialEq, Eq)]
6 pub struct StatVariant {
7 pub id: u8,
8 _priv: (),
9 }
10
11 #[derive(PartialEq, Eq)]
12 pub struct Stat {
13 pub variant: StatVariant,
14 pub index: usize,
15 _priv: (),
16 }
17
18 impl Stats {
19 pub const TEST: StatVariant = StatVariant{id: 0, _priv: (),};
20 #[allow(non_upper_case_globals)]
21 pub const A: Stat = Stat{
22 variant: Self::TEST,
23 index: 0,
24 _priv: (),};
25 }
26
27 impl Stat {
28 pub fn from_index(variant: StatVariant, index: usize) -> Option<Stat> {
29 let stat = Stat{variant, index, _priv: (),};
30 match stat {
31 Stats::A => Some(Stats::A),
32 _ => None,
33 }
34 }
35 }
36
37 fn main() {}