Skip to content

Commit b543f43

Browse files
committed
---
yaml --- r: 11849 b: refs/heads/master c: 383a801 h: refs/heads/master i: 11847: ae65af1 v: v3
1 parent 37eec54 commit b543f43

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-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: a3d2882ffd694caeb274e53c8b8bb4ca03c493b3
2+
refs/heads/master: 383a80199351c6b9f9f4834242231c8586fb2ab6
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: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,6 +1466,17 @@ fn instantiate_self_regions(pcx: pat_ctxt, args: [ty::t]) -> [ty::t] {
14661466
})
14671467
}
14681468

1469+
// Replaces all region variables in the given type with "inferred regions".
1470+
// This is used during method lookup to allow typeclass implementations to
1471+
// refer to inferred regions.
1472+
fn universally_quantify_regions(tcx: ty::ctxt, ty: ty::t) -> ty::t {
1473+
if ty::type_has_rptrs(ty) {
1474+
ty::fold_ty(tcx, ty::fm_rptr({|_r| ty::re_inferred}), ty)
1475+
} else {
1476+
ty
1477+
}
1478+
}
1479+
14691480
fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
14701481
subpats: [@ast::pat], expected: ty::t) {
14711482
// Typecheck the path.
@@ -1877,7 +1888,12 @@ fn lookup_method_inner(fcx: @fn_ctxt, expr: @ast::expr,
18771888
let {n_tps, ty: self_ty} = impl_self_ty(tcx, did);
18781889
let {vars, ty: self_ty} = if n_tps > 0u {
18791890
bind_params(fcx, self_ty, n_tps)
1880-
} else { {vars: [], ty: self_ty} };
1891+
} else {
1892+
{vars: [], ty: self_ty}
1893+
};
1894+
1895+
let ty = universally_quantify_regions(tcx, ty);
1896+
18811897
alt unify::unify(fcx, ty, self_ty) {
18821898
result::ok(_) {
18831899
if option::is_some(result) {

0 commit comments

Comments
 (0)