]> git.lizzy.rs Git - rust.git/blob - src/test/ui/self/explicit-self-generic.rs
Rollup merge of #101388 - compiler-errors:issue-101376, r=fee1-dead
[rust.git] / src / test / ui / self / explicit-self-generic.rs
1 // run-pass
2 #![allow(dead_code)]
3
4 #[derive(Copy, Clone)]
5 struct LM { resize_at: usize, size: usize }
6
7 enum HashMap<K,V> {
8     HashMap_(LM, Vec<(K,V)>)
9 }
10
11 fn linear_map<K,V>() -> HashMap<K,V> {
12     HashMap::HashMap_(LM{
13         resize_at: 32,
14         size: 0}, Vec::new())
15 }
16
17 impl<K,V> HashMap<K,V> {
18     pub fn len(&mut self) -> usize {
19         match *self {
20             HashMap::HashMap_(ref l, _) => l.size
21         }
22     }
23 }
24
25 pub fn main() {
26     let mut m: Box<_> = Box::new(linear_map::<(),()>());
27     assert_eq!(m.len(), 0);
28 }