Skip to content

Commit 11c1ed2

Browse files
committed
---
yaml --- r: 12878 b: refs/heads/master c: 44c100c h: refs/heads/master v: v3
1 parent 8172fe8 commit 11c1ed2

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
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: da204e1d733ad1dbe794b7d9f5ce2badab7f8993
2+
refs/heads/master: 44c100c28df866041633a8338b7935d061afd9bb
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/middle/borrowck.rs

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import std::list::{list, cons, nil};
1111
import result::{result, ok, err, extensions};
1212
import syntax::print::pprust;
1313
import util::common::indenter;
14+
import ast_util::op_expr_callee_id;
1415

1516
export check_crate, root_map, mutbl_map;
1617

@@ -301,7 +302,7 @@ impl methods for gather_loan_ctxt {
301302
_ {
302303
self.bccx.span_err(
303304
cmt.span,
304-
#fmt["Cannot guarantee the stability \
305+
#fmt["cannot guarantee the stability \
305306
of this expression for the entirety of \
306307
its lifetime, %s",
307308
region_to_str(self.tcx(), scope_r)]);
@@ -989,21 +990,30 @@ impl categorize_methods for borrowck_ctxt {
989990
}
990991
}
991992

992-
fn cat_expr(expr: @ast::expr) -> cmt {
993-
let tcx = self.tcx;
994-
let expr_ty = tcx.ty(expr);
993+
fn cat_method_ref(expr: @ast::expr, expr_ty: ty::t) -> cmt {
994+
@{id:expr.id, span:expr.span,
995+
cat:cat_special(sk_method), lp:none,
996+
mutbl:m_imm, ty:expr_ty}
997+
}
995998

999+
fn cat_rvalue(expr: @ast::expr, expr_ty: ty::t) -> cmt {
1000+
@{id:expr.id, span:expr.span,
1001+
cat:cat_rvalue, lp:none,
1002+
mutbl:m_imm, ty:expr_ty}
1003+
}
1004+
1005+
fn cat_expr(expr: @ast::expr) -> cmt {
9961006
#debug["cat_expr: id=%d expr=%s",
9971007
expr.id, pprust::expr_to_str(expr)];
9981008

999-
if self.method_map.contains_key(expr.id) {
1000-
ret @{id:expr.id, span:expr.span,
1001-
cat:cat_special(sk_method), lp:none,
1002-
mutbl:m_imm, ty:expr_ty};
1003-
}
1004-
1009+
let tcx = self.tcx;
1010+
let expr_ty = tcx.ty(expr);
10051011
alt expr.node {
10061012
ast::expr_unary(ast::deref, e_base) {
1013+
if self.method_map.contains_key(expr.id) {
1014+
ret self.cat_rvalue(expr, expr_ty);
1015+
}
1016+
10071017
let base_cmt = self.cat_expr(e_base);
10081018
alt self.cat_deref(expr, base_cmt, 0u, true) {
10091019
some(cmt) { ret cmt; }
@@ -1017,11 +1027,19 @@ impl categorize_methods for borrowck_ctxt {
10171027
}
10181028

10191029
ast::expr_field(base, f_name, _) {
1030+
if self.method_map.contains_key(expr.id) {
1031+
ret self.cat_method_ref(expr, expr_ty);
1032+
}
1033+
10201034
let base_cmt = self.cat_autoderef(base);
10211035
self.cat_field(expr, base_cmt, f_name)
10221036
}
10231037

10241038
ast::expr_index(base, _) {
1039+
if self.method_map.contains_key(expr.id) {
1040+
ret self.cat_rvalue(expr, expr_ty);
1041+
}
1042+
10251043
self.cat_index(expr, base)
10261044
}
10271045

@@ -1042,9 +1060,7 @@ impl categorize_methods for borrowck_ctxt {
10421060
ast::expr_block(*) | ast::expr_loop(*) | ast::expr_alt(*) |
10431061
ast::expr_lit(*) | ast::expr_break | ast::expr_mac(*) |
10441062
ast::expr_cont | ast::expr_rec(*) {
1045-
@{id:expr.id, span:expr.span,
1046-
cat:cat_rvalue, lp:none,
1047-
mutbl:m_imm, ty:expr_ty}
1063+
ret self.cat_rvalue(expr, expr_ty);
10481064
}
10491065
}
10501066
}

0 commit comments

Comments
 (0)