about summary refs log tree commit diff
path: root/src/test/codegen/stack-alloc-string-slice.rs
diff options
context:
space:
mode:
authorBjörn Steinbrink <bsteinbr@gmail.com>2014-10-22 21:23:26 +0200
committerBjörn Steinbrink <bsteinbr@gmail.com>2014-10-23 11:43:48 +0200
commit70fe20a69827a2b1abfef338c83f9ec9be7c9376 (patch)
treeda6b32606de5474d4c2d6f40566a28c9729a3854 /src/test/codegen/stack-alloc-string-slice.rs
parent2130f2221600f03129df95f3611444468806b237 (diff)
downloadrust-70fe20a69827a2b1abfef338c83f9ec9be7c9376.tar.gz
rust-70fe20a69827a2b1abfef338c83f9ec9be7c9376.zip
Fix codegen breaking aliasing rules for functions with sret results
This reverts commit a0ec902e239b2219edf1a18b036dd32c18d3be42 "Avoid
unnecessary temporary on assignments".

Leaving out the temporary for the functions return value can lead to a
situation that conflicts with rust's aliasing rules.

Given this:

````rust
fn func(f: &mut Foo) -> Foo { /* ... */ }

fn bar() {
    let mut foo = Foo { /* ... */ };

    foo = func(&mut foo);
}
````

We effectively get two mutable references to the same variable `foo` at
the same time. One for the parameter `f`, and one for the hidden
out-pointer. So we can't just `trans_into` the destination directly, but
must use `trans` to get a new temporary slot from which the result can
be copied.
Diffstat (limited to 'src/test/codegen/stack-alloc-string-slice.rs')
0 files changed, 0 insertions, 0 deletions