@@ -1466,6 +1466,17 @@ fn instantiate_self_regions(pcx: pat_ctxt, args: [ty::t]) -> [ty::t] {
1466
1466
} )
1467
1467
}
1468
1468
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
+
1469
1480
fn check_pat_variant ( pcx : pat_ctxt , pat : @ast:: pat , path : @ast:: path ,
1470
1481
subpats : [ @ast:: pat ] , expected : ty:: t ) {
1471
1482
// Typecheck the path.
@@ -1877,7 +1888,12 @@ fn lookup_method_inner(fcx: @fn_ctxt, expr: @ast::expr,
1877
1888
let { n_tps, ty: self_ty } = impl_self_ty ( tcx, did) ;
1878
1889
let { vars, ty: self_ty } = if n_tps > 0 u {
1879
1890
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
+
1881
1897
alt unify:: unify ( fcx, ty, self_ty) {
1882
1898
result:: ok ( _) {
1883
1899
if option:: is_some ( result) {
0 commit comments