Closed
Description
trying to compile:
fn main() {
let bar = ["aaaaaa", "bbbbbb", "cccccc"];
let mut foo: [str];
for b in bar { foo += [b]; }
}
fails with:
un.rs:9:8: 9:11 error: unsatisfied precondition constraint (for example, init(foo id=10 - arising from un.rs:6:12: 6:22)) for expression:
foo
precondition:
init(foo id=10 - arising from un.rs:6:12: 6:22)
prestate:
!init(main! id=101 - arising from un.rs:1:0: 1:0), !init(main id=100 - arising from un.rs:1:0: 1:0), init(bar id=2 - arising from un.rs:4:8: 4:44), !init(foo id=10 - arising from un.rs:6:12: 6:22), init(b id=17 - arising from un.rs:8:8: 8:9)
un.rs:9 foo += [b];
^~~
The fixed code below (note line 3) compiles correctly:
fn main() {
let bar = ["aaaaaa", "bbbbbb", "cccccc"];
let mut foo: [str] = [];
for b in bar { foo += [b]; }
}
Metadata
Metadata
Assignees
Labels
No labels