]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #30761 - nagisa:mir-fix-destination, r=michaelwoerister
authorSimonas Kazlauskas <github@kazlauskas.me>
Mon, 11 Jan 2016 19:17:52 +0000 (21:17 +0200)
committerSimonas Kazlauskas <github@kazlauskas.me>
Mon, 11 Jan 2016 19:17:52 +0000 (21:17 +0200)
Previously it was returning a clone, mostly for the two reasons:

* Cloning Lvalue is very cheap most of the time (i.e. when Lvalue is not a Projection);
* There’s users who want &mut lvalue and there’s users who want &lvalue. Returning a value allows
  to make either one easier when pattern matching (i.e. Some(ref dest) or Some(ref mut dest)).

However, I’m now convinced this is an invalid approach. Namely the users which want a mutable
reference may modify the Lvalue in-place, but the changes won’t be reflected in the final MIR,
since the Lvalue modified is merely a clone.

Instead, we have two accessors `destination` and `destination_mut` which return a reference to the
destination in desired mode.

r? @nikomatsakis


Trivial merge