summary refs log tree commit diff
path: root/src/test/compile-fail/regions-trait-2.rs
blob: 712512e5037021e4e7d29755eba201a54fb4de3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
type ctxt = { v: uint };

trait get_ctxt {
    fn get_ctxt() -> &self/ctxt;
}

type has_ctxt = { c: &ctxt };

impl has_ctxt: get_ctxt {
    fn get_ctxt() -> &self/ctxt { self.c }
}

fn make_gc() -> get_ctxt  {
    let ctxt = { v: 22u };
    let hc = { c: &ctxt }; //~ ERROR illegal borrow
    return hc as get_ctxt;
}

fn main() {
    make_gc().get_ctxt().v;
}