Skip to content

Commit b33b30b

Browse files
committed
---
yaml --- r: 23677 b: refs/heads/master c: b808cfb h: refs/heads/master i: 23675: e46ad6c v: v3
1 parent 76f5e77 commit b33b30b

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 49c9ac175f07505f2113feaca3546d4b8b44dfa8
2+
refs/heads/master: b808cfbb74a6d9ee01d22a1754f8ddfe3022b1e5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/rustc/middle/trans/base.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3151,6 +3151,9 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr,
31513151
// routine consults this table and performs these adaptations. It returns a
31523152
// new location for the borrowed result as well as a new type for the argument
31533153
// that reflects the borrowed value and not the original.
3154+
//
3155+
// NB: "e" has already been translated; do not translate it again. If you do,
3156+
// this will cause problems with autoderef and method receivers (bug #3357).
31543157
fn adapt_borrowed_value(lv: lval_result,
31553158
e: @ast::expr,
31563159
e_ty: ty::t) -> {lv: lval_result,
@@ -3200,7 +3203,7 @@ fn adapt_borrowed_value(lv: lval_result,
32003203

32013204
_ => {
32023205
// Just take a reference. This is basically like trans_addr_of.
3203-
let mut {bcx, val, kind} = trans_temp_lval(bcx, e);
3206+
let mut {bcx, val, kind} = lv;
32043207
let is_immediate = ty::type_is_immediate(e_ty);
32053208
if (kind == lv_temporary && is_immediate) || kind == lv_owned_imm {
32063209
val = do_spill(bcx, val, e_ty);

trunk/src/rustc/middle/typeck/check/method.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ struct lookup {
183183
match ty::deref(self.tcx(), self.self_ty, false) {
184184
None => break,
185185
Some(mt) => {
186+
debug!("(checking method) ... autodereffing");
186187
self.self_ty = mt.ty;
187188
self.derefs += 1u;
188189
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
struct Foo {
2+
x: int;
3+
}
4+
5+
impl Foo {
6+
fn f(&self) {}
7+
}
8+
9+
fn g(x: &mut Foo) {
10+
x.f();
11+
}
12+
13+
fn main() {
14+
}
15+

0 commit comments

Comments
 (0)