about summary refs log tree commit diff
path: root/src/test/compile-fail/tps-invariant-class.rs
blob: a3ecbec5b11246e43da41e550def822b12eca7f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class box_impl<T> {
    let mut f: T;

    new(f: T) {
        self.f = f;
    }
}

fn set_box_impl<T>(b: box_impl<@const T>, v: @const T) {
    b.f = v;
}

fn main() {
    let b = box_impl::<@int>(@3);
    set_box_impl(b, @mut 5);
    //~^ ERROR values differ in mutability

    // No error when type of parameter actually IS @const int
    let b = box_impl::<@const int>(@3);
    set_box_impl(b, @mut 5);
}