Skip to content

Commit 3f7ce5c

Browse files
committed
---
yaml --- r: 11983 b: refs/heads/master c: bf13fb7 h: refs/heads/master i: 11981: 3e1eb43 11979: 09e911b 11975: 5a5c065 11967: aec07de v: v3
1 parent 1376faf commit 3f7ce5c

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
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: b12588a197bcba39a170d78ff02a2b4f8f73ae3d
2+
refs/heads/master: bf13fb7921bae57bcb153f7842afa2959aaf47a1
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/middle/typeck.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,18 @@ fn fixup_self_in_method_ty(cx: ty::ctxt, mty: ty::t, m_substs: [ty::t],
835835
} else { mty }
836836
}
837837

838+
// Mangles an iface method ty to instantiate its `self` region.
839+
fn fixup_self_region_in_method_ty(fcx: @fn_ctxt, mty: ty::t,
840+
self_expr: @ast::expr) -> ty::t {
841+
let self_region = region_of(fcx, self_expr);
842+
ty::fold_ty(fcx.ccx.tcx, ty::fm_rptr({|r|
843+
alt r {
844+
ty::re_self(_) { self_region }
845+
_ { r }
846+
}
847+
}), mty)
848+
}
849+
838850
// Item collection - a pair of bootstrap passes:
839851
//
840852
// (1) Collect the IDs of all type items (typedefs) and store them in a table.
@@ -1811,6 +1823,11 @@ fn lookup_method(fcx: @fn_ctxt, expr: @ast::expr, node_id: ast::node_id,
18111823
tcx, fty, substs, option::get(self_sub));
18121824
write_ty(tcx, node_id, fty);
18131825
}
1826+
if ty::type_has_rptrs(ty::ty_fn_ret(fty)) {
1827+
let fty = ty::node_id_to_type(tcx, node_id);
1828+
fty = fixup_self_region_in_method_ty(fcx, fty, expr);
1829+
write_ty(tcx, node_id, fty);
1830+
}
18141831
some(origin)
18151832
}
18161833
none { none }
@@ -1982,9 +1999,13 @@ fn region_of(fcx: @fn_ctxt, expr: @ast::expr) -> ty::region {
19821999
}
19832000
}
19842001
}
1985-
ast::expr_field(base, _, _) | ast::expr_index(base, _) {
1986-
fcx.ccx.tcx.sess.span_unimpl(expr.span, "regions of field or " +
1987-
"index operations");
2002+
ast::expr_field(base, _, _) {
2003+
// FIXME: Insert borrowing!
2004+
ret region_of(fcx, base);
2005+
}
2006+
ast::expr_index(base, _) {
2007+
fcx.ccx.tcx.sess.span_unimpl(expr.span,
2008+
"regions of index operations");
19882009
}
19892010
ast::expr_unary(ast::deref, base) {
19902011
let expr_ty = ty::expr_ty(fcx.ccx.tcx, base);

0 commit comments

Comments
 (0)