summaryrefslogtreecommitdiffstats
path: root/tests/ui/statics/static-method-in-trait-with-tps-intracrate.rs
blob: cd3ccfee06f09f78c78b27920b6971e9c33814a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// run-pass
#![allow(dead_code)]

trait Deserializer {
    fn read_int(&self) -> isize;
}

trait Deserializable<D:Deserializer> {
    fn deserialize(d: &D) -> Self;
}

impl<D:Deserializer> Deserializable<D> for isize {
    fn deserialize(d: &D) -> isize {
        return d.read_int();
    }
}

struct FromThinAir { dummy: () }

impl Deserializer for FromThinAir {
    fn read_int(&self) -> isize { 22 }
}

pub fn main() {
    let d = FromThinAir { dummy: () };
    let i: isize = Deserializable::deserialize(&d);
    assert_eq!(i, 22);
}