Skip to content

Commit 48178e0

Browse files
committed
---
yaml --- r: 14844 b: refs/heads/try c: 1ed768b h: refs/heads/master v: v3
1 parent 0080504 commit 48178e0

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 1600be2c3b1054e2fce59778e2f85d7fa582657f
5+
refs/heads/try: 1ed768bc3b32f45626b1fb1c3dca83d4936bf33f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustc/middle/typeck.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,8 +1933,8 @@ fn lookup_field_ty(cx: ty::ctxt, items:[@ast::class_item],
19331933

19341934
/*
19351935
* Returns the region that the value named by the given expression lives in.
1936-
* If the expression is not an lvalue, reports an error and returns the block
1937-
* region.
1936+
* The expression must have been typechecked. If the expression is not an
1937+
* lvalue, returns the block region.
19381938
*
19391939
* Note that borrowing is not detected here, because we would have to
19401940
* immediately structurally resolve too many types otherwise. Thus the
@@ -1958,10 +1958,20 @@ fn region_of(fcx: @fn_ctxt, expr: @ast::expr) -> ty::region {
19581958
}
19591959
}
19601960
}
1961-
ast::expr_field(base, _, _) | ast::expr_index(base, _) |
1962-
ast::expr_unary(ast::deref, base) {
1963-
fcx.ccx.tcx.sess.span_unimpl(expr.span, "regions of field, " +
1964-
"index, or deref operations");
1961+
ast::expr_field(base, _, _) | ast::expr_index(base, _) {
1962+
fcx.ccx.tcx.sess.span_unimpl(expr.span, "regions of field or " +
1963+
"index operations");
1964+
}
1965+
ast::expr_unary(ast::deref, base) {
1966+
let expr_ty = ty::expr_ty(fcx.ccx.tcx, base);
1967+
let expr_ty = structurally_resolved_type(fcx, expr.span, expr_ty);
1968+
alt ty::get(expr_ty).struct {
1969+
ty::ty_rptr(region, _) { region }
1970+
ty::ty_box(_) | ty::ty_uniq(_) {
1971+
fcx.ccx.tcx.sess.span_unimpl(expr.span, "borrowing");
1972+
}
1973+
_ { ret region_of(fcx, base); }
1974+
}
19651975
}
19661976
_ {
19671977
let blk_id = fcx.ccx.tcx.region_map.rvalue_to_block.get(expr.id);

0 commit comments

Comments
 (0)