Debian Codegraph @

gcc/testsuite/rust/compile/mutability_checks1.rs

raw
1 pub fn test() {
2 let a;
3 a = 1;
4 a = 2 + 1;
5 // { dg-error "assignment of read-only variable" "" { target *-*-* } .-1 }
6
7 struct Foo(i32);
8 let a = Foo(1);
9 a.0 = 2;
10 // { dg-error "assignment of read-only variable" "" { target *-*-* } .-1 }
11
12 let a = [1, 2, 3, 4];
13 a[0] = 1 + 2;
14 // { dg-error "assignment of read-only variable" "" { target *-*-* } .-1 }
15 }