aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile/mutability_checks1.rs
blob: 4affae0305343219faaa40e354fd45268623ca44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
pub fn test() {
    let a;
    a = 1;
    a = 2 + 1;
    // { dg-error "assignment of read-only variable" "" { target *-*-* } .-1 }

    struct Foo(i32);
    let a = Foo(1);
    a.0 = 2;
    // { dg-error "assignment of read-only variable" "" { target *-*-* } .-1 }

    let a = [1, 2, 3, 4];
    a[0] = 1 + 2;
    // { dg-error "assignment of read-only variable" "" { target *-*-* } .-1 }
}