From 71128e75b083c9e5915d4fe1aa99f3abeee8f043 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sat, 21 Apr 2012 10:26:51 -0700 Subject: [PATCH] moderate comment, remove some dead regions code --- src/rustc/middle/typeck.rs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index 7e270649274..64d3c4f869b 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -2646,13 +2646,13 @@ impl methods for lookup { tps: self_substs.tps + m_substs}; self.fcx.write_ty_substs(self.node_id, fty, all_substs); - // FIXME--this treatment of self and regions seems wrong. As a rule - // of thumb, one ought to substitute all type parameters at once, and - // we are not doing so here. The danger you open up has to do with - // the possibility that one of the substs in `all_substs` maps to a - // self type. Right now I think this is impossible but it may not be - // forever, and it's just sloppy to substitute in multiple steps. - // Probably the self parameter ought to be part of the all_substs. + // n.b. This treatment of self is risky but ok. As a rule of thumb, + // one ought to substitute all type parameters at once, and we are not + // doing so here. The danger you open up has to do with the + // possibility that one of the substs in `all_substs` maps to a self + // type. However, right now I think it is safe because the types in + // `all_substs` may not refer to self. This may not stay true + // forever, though. if has_self && !option::is_none(self_ty_sub) { let fty = self.fcx.node_ty(self.node_id); @@ -2662,13 +2662,6 @@ impl methods for lookup { self.fcx.write_ty(self.node_id, fty); } - if ty::type_has_regions(ty::ty_fn_ret(fty)) { - let fty = self.fcx.node_ty(self.node_id); - let self_region = region_of(self.fcx, self.expr); - let fty = replace_self_region(self.tcx(), self_region, fty); - self.fcx.write_ty(self.node_id, fty); - } - ret origin; } }