]> git.lizzy.rs Git - rust.git/commit
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)
commit04906061d8ec787757d27a94894d8674485e76e3
tree8044ea395ce3a1c5815c313001a8fd91b33c406f
parentcaf6095fcfed3f57688fc64308e151ae35638c81
parent2f86c1605c3a82d0c82c36f1dc84441237a9f5c1
Rollup merge of #30761 - nagisa:mir-fix-destination, r=michaelwoerister

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