Closed
Description
This code produces some disturbing results:
struct A<'self> {
a: &'self [~str],
b: Option<&'self [~str]>,
}
fn main() {
let b = Some(&[~"foo"]);
let a = A {
a: [~"test"],
b: b,
};
assert_eq!(a.b.get_ref()[0].as_slice(), "foo");
}
$ rust run bar.rs
warning: no debug symbols in executable (-arch x86_64)
task <unnamed> failed at 'assertion failed: `(left == right) && (right == left)` (left: `"test"`, right: `"foo"`)', bar.rs:12
Somehow the string ~"foo"
is getting overwritten with ~"test"
...