]> git.lizzy.rs Git - rust.git/commit
During method resolution, only reborrow if we are not doing an auto-ref.
authorNiko Matsakis <niko@alum.mit.edu>
Sat, 6 Dec 2014 19:55:38 +0000 (11:55 -0800)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 11 Dec 2014 00:45:19 +0000 (19:45 -0500)
commit31e46ac0a95d58fa95dcd154a0f8a56089e2f5b9
tree871e5cdbc82e0ce8e4abb0d3a7671cff67b532bb
parentca98fefd04b2a0ccd784f96538c824c49210a418
During method resolution, only reborrow if we are not doing an auto-ref.
The current behavior leads to adjustments like `&&*` being applied
instead of just `&` (when the unmodified receiver is a `&T` or an `&mut
T`). This causes both safety errors and unexpected behavior. The safety
errors result from regionck not being prepared for auto-ref-ref-like
adjustments; this is worth fixing on its own, but I think the best way
to do it is to modify regionck to use expr-use-visitor (and fix
expr-use-visitor as well, which I don't think properly invokes `borrow`
for each level of auto-ref), and for now it's simpler to just not
produce the adjustment in question. (I have a separate patch porting
regionck to use exprusevisitor for a different bug, so that is coming.)
src/librustc_typeck/check/method/mod.rs
src/librustc_typeck/check/method/probe.rs
src/test/compile-fail/borrowck-return-variable-on-stack-via-clone.rs [new file with mode: 0644]
src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs [new file with mode: 0644]