From 195f1d77bd6bdd8988d5cbd107cb0c4cfa4694cc Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 29 Oct 2013 10:34:11 -0400 Subject: [PATCH] Rename and modernize region enum names --- src/librustc/metadata/tydecode.rs | 20 +-- src/librustc/metadata/tyencode.rs | 22 +-- src/librustc/middle/astencode.rs | 22 +-- .../middle/borrowck/gather_loans/lifetime.rs | 18 +-- .../middle/borrowck/gather_loans/mod.rs | 20 +-- src/librustc/middle/kind.rs | 6 +- src/librustc/middle/region.rs | 10 +- src/librustc/middle/resolve_lifetime.rs | 4 +- src/librustc/middle/subst.rs | 4 +- src/librustc/middle/trans/_match.rs | 4 +- src/librustc/middle/trans/consts.rs | 6 +- src/librustc/middle/trans/datum.rs | 2 +- src/librustc/middle/trans/expr.rs | 2 +- src/librustc/middle/trans/glue.rs | 2 +- src/librustc/middle/trans/reflect.rs | 2 +- src/librustc/middle/ty.rs | 74 ++++----- src/librustc/middle/typeck/astconv.rs | 28 ++-- src/librustc/middle/typeck/check/mod.rs | 26 ++-- src/librustc/middle/typeck/check/regionck.rs | 20 +-- .../middle/typeck/check/regionmanip.rs | 8 +- src/librustc/middle/typeck/check/vtable.rs | 2 +- src/librustc/middle/typeck/collect.rs | 6 +- src/librustc/middle/typeck/infer/glb.rs | 6 +- src/librustc/middle/typeck/infer/lattice.rs | 6 +- src/librustc/middle/typeck/infer/lub.rs | 4 +- src/librustc/middle/typeck/infer/mod.rs | 16 +- .../typeck/infer/region_inference/mod.rs | 140 +++++++++--------- src/librustc/middle/typeck/infer/resolve.rs | 6 +- src/librustc/middle/typeck/infer/sub.rs | 2 +- src/librustc/middle/typeck/infer/test.rs | 12 +- src/librustc/middle/typeck/mod.rs | 10 +- src/librustc/middle/typeck/rscope.rs | 6 +- src/librustc/middle/typeck/variance.rs | 10 +- src/librustc/util/ppaux.rs | 94 ++++++------ src/libsyntax/ast.rs | 4 +- 35 files changed, 316 insertions(+), 308 deletions(-) diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 6e06cef55ee..18447e6cbc8 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -228,22 +228,22 @@ fn parse_region_substs(st: &mut PState, conv: conv_did) -> ty::RegionSubsts { } } -fn parse_bound_region(st: &mut PState, conv: conv_did) -> ty::bound_region { +fn parse_bound_region(st: &mut PState, conv: conv_did) -> ty::BoundRegion { match next(st) { 'a' => { let id = parse_uint(st); assert_eq!(next(st), '|'); - ty::br_anon(id) + ty::BrAnon(id) } '[' => { let def = parse_def(st, RegionParameter, |x,y| conv(x,y)); let ident = st.tcx.sess.ident_of(parse_str(st, ']')); - ty::br_named(def, ident) + ty::BrNamed(def, ident) } 'f' => { let id = parse_uint(st); assert_eq!(next(st), '|'); - ty::br_fresh(id) + ty::BrFresh(id) } _ => fail!("parse_bound_region: bad input") } @@ -257,7 +257,7 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region { assert_eq!(next(st), '|'); let br = parse_bound_region(st, |x,y| conv(x,y)); assert_eq!(next(st), ']'); - ty::re_fn_bound(id, br) + ty::ReLateBound(id, br) } 'B' => { assert_eq!(next(st), '['); @@ -266,7 +266,7 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region { let index = parse_uint(st); assert_eq!(next(st), '|'); let nm = st.tcx.sess.ident_of(parse_str(st, ']')); - ty::re_type_bound(node_id, index, nm) + ty::ReEarlyBound(node_id, index, nm) } 'f' => { assert_eq!(next(st), '['); @@ -274,19 +274,19 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region { assert_eq!(next(st), '|'); let br = parse_bound_region(st, |x,y| conv(x,y)); assert_eq!(next(st), ']'); - ty::re_free(ty::FreeRegion {scope_id: id, + ty::ReFree(ty::FreeRegion {scope_id: id, bound_region: br}) } 's' => { let id = parse_uint(st) as int; assert_eq!(next(st), '|'); - ty::re_scope(id) + ty::ReScope(id) } 't' => { - ty::re_static + ty::ReStatic } 'e' => { - ty::re_static + ty::ReStatic } _ => fail!("parse_region: bad input") } diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index af28162dbfd..d304db0935a 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -155,49 +155,49 @@ fn enc_region_substs(w: @mut MemWriter, cx: @ctxt, substs: &ty::RegionSubsts) { fn enc_region(w: @mut MemWriter, cx: @ctxt, r: ty::Region) { match r { - ty::re_fn_bound(id, br) => { + ty::ReLateBound(id, br) => { mywrite!(w, "b[{}|", id); enc_bound_region(w, cx, br); mywrite!(w, "]"); } - ty::re_type_bound(node_id, index, ident) => { + ty::ReEarlyBound(node_id, index, ident) => { mywrite!(w, "B[{}|{}|{}]", node_id, index, cx.tcx.sess.str_of(ident)); } - ty::re_free(ref fr) => { + ty::ReFree(ref fr) => { mywrite!(w, "f[{}|", fr.scope_id); enc_bound_region(w, cx, fr.bound_region); mywrite!(w, "]"); } - ty::re_scope(nid) => { + ty::ReScope(nid) => { mywrite!(w, "s{}|", nid); } - ty::re_static => { + ty::ReStatic => { mywrite!(w, "t"); } - ty::re_empty => { + ty::ReEmpty => { mywrite!(w, "e"); } - ty::re_infer(_) => { + ty::ReInfer(_) => { // these should not crop up after typeck cx.diag.handler().bug("Cannot encode region variables"); } } } -fn enc_bound_region(w: @mut MemWriter, cx: @ctxt, br: ty::bound_region) { +fn enc_bound_region(w: @mut MemWriter, cx: @ctxt, br: ty::BoundRegion) { match br { - ty::br_anon(idx) => { + ty::BrAnon(idx) => { mywrite!(w, "a{}|", idx); } - ty::br_named(d, s) => { + ty::BrNamed(d, s) => { mywrite!(w, "[{}|{}]", (cx.ds)(d), cx.tcx.sess.str_of(s)); } - ty::br_fresh(id) => { + ty::BrFresh(id) => { mywrite!(w, "f{}|", id); } } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index e60b9382be4..09c0951b9e3 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -476,27 +476,27 @@ fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::AutoRef { impl tr for ty::Region { fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::Region { match *self { - ty::re_fn_bound(id, br) => ty::re_fn_bound(xcx.tr_id(id), + ty::ReLateBound(id, br) => ty::ReLateBound(xcx.tr_id(id), br.tr(xcx)), - ty::re_type_bound(id, index, ident) => ty::re_type_bound(xcx.tr_id(id), + ty::ReEarlyBound(id, index, ident) => ty::ReEarlyBound(xcx.tr_id(id), index, ident), - ty::re_scope(id) => ty::re_scope(xcx.tr_id(id)), - ty::re_empty | ty::re_static | ty::re_infer(*) => *self, - ty::re_free(ref fr) => { - ty::re_free(ty::FreeRegion {scope_id: xcx.tr_id(fr.scope_id), + ty::ReScope(id) => ty::ReScope(xcx.tr_id(id)), + ty::ReEmpty | ty::ReStatic | ty::ReInfer(*) => *self, + ty::ReFree(ref fr) => { + ty::ReFree(ty::FreeRegion {scope_id: xcx.tr_id(fr.scope_id), bound_region: fr.bound_region.tr(xcx)}) } } } } -impl tr for ty::bound_region { - fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::bound_region { +impl tr for ty::BoundRegion { + fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::BoundRegion { match *self { - ty::br_anon(_) | - ty::br_fresh(_) => *self, - ty::br_named(id, ident) => ty::br_named(xcx.tr_def_id(id), + ty::BrAnon(_) | + ty::BrFresh(_) => *self, + ty::BrNamed(id, ident) => ty::BrNamed(xcx.tr_def_id(id), ident), } } diff --git a/src/librustc/middle/borrowck/gather_loans/lifetime.rs b/src/librustc/middle/borrowck/gather_loans/lifetime.rs index a0c6fdc3225..a5f1709058c 100644 --- a/src/librustc/middle/borrowck/gather_loans/lifetime.rs +++ b/src/librustc/middle/borrowck/gather_loans/lifetime.rs @@ -199,7 +199,7 @@ fn check_root(&self, // Make sure that the loan does not exceed the maximum time // that we can root the value, dynamically. - let root_region = ty::re_scope(self.root_scope_id); + let root_region = ty::ReScope(self.root_scope_id); if !self.bccx.is_subregion_of(self.loan_region, root_region) { self.report_error( err_out_of_root_scope(root_region, self.loan_region)); @@ -208,9 +208,9 @@ fn check_root(&self, // Extract the scope id that indicates how long the rooting is required let root_scope = match self.loan_region { - ty::re_scope(id) => id, + ty::ReScope(id) => id, _ => { - // the check above should fail for anything is not re_scope + // the check above should fail for anything is not ReScope self.bccx.tcx.sess.span_bug( cmt_base.span, format!("Cannot issue root for scope region: {:?}", @@ -260,12 +260,12 @@ fn check_root(&self, note_and_explain_region( self.bccx.tcx, "managed value only needs to be frozen for ", - ty::re_scope(root_scope), + ty::ReScope(root_scope), "..."); note_and_explain_region( self.bccx.tcx, "...but due to Issue #6248, it will be frozen for ", - ty::re_scope(cleanup_scope), + ty::ReScope(cleanup_scope), ""); } @@ -324,13 +324,13 @@ fn scope(&self, cmt: mc::cmt) -> ty::Region { match cmt.cat { mc::cat_rvalue(cleanup_scope_id) => { - ty::re_scope(cleanup_scope_id) + ty::ReScope(cleanup_scope_id) } mc::cat_copied_upvar(_) => { - ty::re_scope(self.item_scope_id) + ty::ReScope(self.item_scope_id) } mc::cat_static_item => { - ty::re_static + ty::ReStatic } mc::cat_local(local_id) | mc::cat_arg(local_id) | @@ -338,7 +338,7 @@ fn scope(&self, cmt: mc::cmt) -> ty::Region { self.bccx.tcx.region_maps.encl_region(local_id) } mc::cat_deref(_, _, mc::unsafe_ptr(*)) => { - ty::re_static + ty::ReStatic } mc::cat_deref(_, _, mc::region_ptr(_, r)) => { r diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc/middle/borrowck/gather_loans/mod.rs index 729da749ec6..56c34178522 100644 --- a/src/librustc/middle/borrowck/gather_loans/mod.rs +++ b/src/librustc/middle/borrowck/gather_loans/mod.rs @@ -277,7 +277,7 @@ fn gather_loans_in_expr(this: &mut GatherLoanCtxt, // Currently these do not use adjustments, so we have to // hardcode this check here (note that the receiver DOES use // adjustments). - let scope_r = ty::re_scope(ex.id); + let scope_r = ty::ReScope(ex.id); let arg_cmt = this.bccx.cat_expr(arg); this.guarantee_valid(arg.id, arg.span, @@ -441,7 +441,7 @@ pub fn guarantee_valid(&mut self, // a loan for the empty region can never be dereferenced, so // it is always safe - if loan_region == ty::re_empty { + if loan_region == ty::ReEmpty { return; } @@ -470,10 +470,10 @@ pub fn guarantee_valid(&mut self, restrictions::SafeIf(loan_path, restrictions) => { let loan_scope = match loan_region { - ty::re_scope(id) => id, - ty::re_free(ref fr) => fr.scope_id, + ty::ReScope(id) => id, + ty::ReFree(ref fr) => fr.scope_id, - ty::re_static => { + ty::ReStatic => { // If we get here, an error must have been // reported in // `lifetime::guarantee_lifetime()`, because @@ -485,10 +485,10 @@ pub fn guarantee_valid(&mut self, return; } - ty::re_empty | - ty::re_fn_bound(*) | - ty::re_type_bound(*) | - ty::re_infer(*) => { + ty::ReEmpty | + ty::ReLateBound(*) | + ty::ReEarlyBound(*) | + ty::ReInfer(*) => { self.tcx().sess.span_bug( cmt.span, format!("Invalid borrow lifetime: {:?}", loan_region)); @@ -715,7 +715,7 @@ fn gather_pat(&mut self, let cmt_discr = match arm_match_ids { None => cmt, Some((arm_id, match_id)) => { - let arm_scope = ty::re_scope(arm_id); + let arm_scope = ty::ReScope(arm_id); if self.bccx.is_subregion_of(scope_r, arm_scope) { self.bccx.cat_discr(cmt, match_id) } else { diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 99f2d7a8700..a570160ce95 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -545,7 +545,7 @@ pub fn check_cast_for_escaping_regions( // Check, based on the region associated with the trait, whether it can // possibly escape the enclosing fn item (note that all type parameters // must have been declared on the enclosing fn item). - if target_regions.iter().any(|r| is_re_scope(*r)) { + if target_regions.iter().any(|r| is_ReScope(*r)) { return; /* case (1) */ } @@ -584,9 +584,9 @@ pub fn check_cast_for_escaping_regions( } }); - fn is_re_scope(r: ty::Region) -> bool { + fn is_ReScope(r: ty::Region) -> bool { match r { - ty::re_scope(*) => true, + ty::ReScope(*) => true, _ => false } } diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 80103aa4106..32ac6ff5492 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -137,7 +137,7 @@ pub fn cleanup_scope(&self, expr_id: ast::NodeId) -> ast::NodeId { pub fn encl_region(&self, id: ast::NodeId) -> ty::Region { //! Returns the narrowest scope region that encloses `id`, if any. - ty::re_scope(self.encl_scope(id)) + ty::ReScope(self.encl_scope(id)) } pub fn scopes_intersect(&self, scope1: ast::NodeId, scope2: ast::NodeId) @@ -227,19 +227,19 @@ pub fn is_subregion_of(&self, sub_region == super_region || { match (sub_region, super_region) { - (_, ty::re_static) => { + (_, ty::ReStatic) => { true } - (ty::re_scope(sub_scope), ty::re_scope(super_scope)) => { + (ty::ReScope(sub_scope), ty::ReScope(super_scope)) => { self.is_subscope_of(sub_scope, super_scope) } - (ty::re_scope(sub_scope), ty::re_free(ref fr)) => { + (ty::ReScope(sub_scope), ty::ReFree(ref fr)) => { self.is_subscope_of(sub_scope, fr.scope_id) } - (ty::re_free(sub_fr), ty::re_free(super_fr)) => { + (ty::ReFree(sub_fr), ty::ReFree(super_fr)) => { self.sub_free_region(sub_fr, super_fr) } diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 98260be9902..b21720f2e30 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -176,7 +176,7 @@ fn resolve_lifetime_ref(&self, ItemScope(lifetimes) => { match search_lifetimes(lifetimes, lifetime_ref) { Some((index, decl_id)) => { - let def = ast::DefTypeBoundRegion(index, decl_id); + let def = ast::DefEarlyBoundRegion(index, decl_id); self.insert_lifetime(lifetime_ref, def); return; } @@ -189,7 +189,7 @@ fn resolve_lifetime_ref(&self, FnScope(id, lifetimes, s) => { match search_lifetimes(lifetimes, lifetime_ref) { Some((_index, decl_id)) => { - let def = ast::DefFnBoundRegion(id, depth, decl_id); + let def = ast::DefLateBoundRegion(id, depth, decl_id); self.insert_lifetime(lifetime_ref, def); return; } diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index 7654a46ec36..c9abf71e2b6 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -193,9 +193,9 @@ fn subst(&self, _tcx: ty::ctxt, substs: &ty::substs) -> ty::Region { // the specialized routine // `middle::typeck::check::regionmanip::replace_bound_regions_in_fn_sig()`. match self { - &ty::re_type_bound(_, i, _) => { + &ty::ReEarlyBound(_, i, _) => { match substs.regions { - ty::ErasedRegions => ty::re_static, + ty::ErasedRegions => ty::ReStatic, ty::NonerasedRegions(ref regions) => *regions.get(i), } } diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 9bafea6d861..9dddf96e34d 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1048,7 +1048,7 @@ fn extract_vec_elems(bcx: @mut Block, let slice_len = Sub(bcx, len, slice_len_offset); let slice_ty = ty::mk_evec(bcx.tcx(), ty::mt {ty: vt.unit_ty, mutbl: ast::MutImmutable}, - ty::vstore_slice(ty::re_static) + ty::vstore_slice(ty::ReStatic) ); let scratch = scratch_datum(bcx, slice_ty, "", false); Store(bcx, slice_begin, @@ -1697,7 +1697,7 @@ fn compile_submatch_continue(mut bcx: @mut Block, let t = node_id_type(bcx, pat_id); let Result {bcx: after_cx, val: matches} = { do with_scope_result(bcx, None, - "compare_scope") |bcx| { + "compaReScope") |bcx| { match trans_opt(bcx, opt) { single_result( Result {bcx, val}) => { diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 9f497afb121..06fe4717f58 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -181,7 +181,7 @@ pub fn const_expr(cx: @mut CrateContext, e: &ast::Expr) -> (ValueRef, bool) { let adjustment = cx.tcx.adjustments.find_copy(&e.id); match adjustment { None => { } - Some(@ty::AutoAddEnv(ty::re_static, ast::BorrowedSigil)) => { + Some(@ty::AutoAddEnv(ty::ReStatic, ast::BorrowedSigil)) => { llconst = C_struct([llconst, C_null(Type::opaque_box(cx).ptr_to())], false) } Some(@ty::AutoAddEnv(ref r, ref s)) => { @@ -211,11 +211,11 @@ pub fn const_expr(cx: @mut CrateContext, e: &ast::Expr) -> (ValueRef, bool) { }; match *autoref { ty::AutoUnsafe(m) | - ty::AutoPtr(ty::re_static, m) => { + ty::AutoPtr(ty::ReStatic, m) => { assert!(m != ast::MutMutable); llconst = llptr; } - ty::AutoBorrowVec(ty::re_static, m) => { + ty::AutoBorrowVec(ty::ReStatic, m) => { assert!(m != ast::MutMutable); assert_eq!(abi::slice_elt_base, 0); assert_eq!(abi::slice_elt_len, 1); diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 1efa7f763d8..01cf1022750 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -588,7 +588,7 @@ pub fn to_rptr(&self, bcx: @mut Block) -> Datum { // result (which will be by-value). Note that it is not // significant *which* region we pick here. let llval = self.to_ref_llval(bcx); - let rptr_ty = ty::mk_imm_rptr(bcx.tcx(), ty::re_static, + let rptr_ty = ty::mk_imm_rptr(bcx.tcx(), ty::ReStatic, self.ty); Datum {val: llval, ty: rptr_ty, mode: ByValue} } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index f291f088dec..ddf9354ad38 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -271,7 +271,7 @@ fn auto_slice(bcx: @mut Block, // real one, but it will have the same runtime representation let slice_ty = ty::mk_evec(tcx, ty::mt { ty: unit_ty, mutbl: ast::MutImmutable }, - ty::vstore_slice(ty::re_static)); + ty::vstore_slice(ty::ReStatic)); let scratch = scratch_datum(bcx, slice_ty, "__adjust", false); diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index f461120e4c3..0993d3322f1 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -339,7 +339,7 @@ pub fn make_visit_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block { do with_scope(bcx, None, "visitor cleanup") |bcx| { let mut bcx = bcx; let (visitor_trait, object_ty) = match ty::visitor_object_ty(bcx.tcx(), - ty::re_static) { + ty::ReStatic) { Ok(pair) => pair, Err(s) => { bcx.tcx().sess.fatal(s); diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 2f4fcfed20b..0781f724d48 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -59,7 +59,7 @@ pub fn c_slice(&mut self, s: @str) -> ValueRef { // We're careful to not use first class aggregates here because that // will kick us off fast isel. (Issue #4352.) let bcx = self.bcx; - let str_vstore = ty::vstore_slice(ty::re_static); + let str_vstore = ty::vstore_slice(ty::ReStatic); let str_ty = ty::mk_estr(bcx.tcx(), str_vstore); let scratch = scratch_datum(bcx, str_ty, "", false); let len = C_uint(bcx.ccx(), s.len()); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index a2959170584..390c651ea79 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -470,43 +470,45 @@ pub struct param_ty { /// Representation of regions: #[deriving(Clone, Eq, IterBytes, Encodable, Decodable, ToStr)] pub enum Region { - // Region bound in a type declaration (type/enum/struct/trait), - // which will be substituted when an instance of the type is accessed - re_type_bound(/* param id */ ast::NodeId, /*index*/ uint, ast::Ident), + // Region bound in a type or fn declaration which will be + // substituted 'early' -- that is, at the same time when type + // parameters are substituted. + ReEarlyBound(/* param id */ ast::NodeId, /*index*/ uint, ast::Ident), - // Region bound in a fn scope, which will be substituted when the - // fn is called. - re_fn_bound(/* binder_id */ ast::NodeId, bound_region), + // Region bound in a function scope, which will be substituted when the + // function is called. The first argument must be the `binder_id` of + // some enclosing function signature. + ReLateBound(/* binder_id */ ast::NodeId, BoundRegion), /// When checking a function body, the types of all arguments and so forth /// that refer to bound region parameters are modified to refer to free /// region parameters. - re_free(FreeRegion), + ReFree(FreeRegion), /// A concrete region naming some expression within the current function. - re_scope(NodeId), + ReScope(NodeId), /// Static data that has an "infinite" lifetime. Top in the region lattice. - re_static, + ReStatic, /// A region variable. Should not exist after typeck. - re_infer(InferRegion), + ReInfer(InferRegion), /// Empty lifetime is for data that is never accessed. - /// Bottom in the region lattice. We treat re_empty somewhat + /// Bottom in the region lattice. We treat ReEmpty somewhat /// specially; at least right now, we do not generate instances of /// it during the GLB computations, but rather /// generate an error instead. This is to improve error messages. - /// The only way to get an instance of re_empty is to have a region + /// The only way to get an instance of ReEmpty is to have a region /// variable with no constraints. - re_empty, + ReEmpty, } impl Region { pub fn is_bound(&self) -> bool { match self { - &ty::re_type_bound(*) => true, - &ty::re_fn_bound(*) => true, + &ty::ReEarlyBound(*) => true, + &ty::ReLateBound(*) => true, _ => false } } @@ -515,28 +517,28 @@ pub fn is_bound(&self) -> bool { #[deriving(Clone, Eq, TotalOrd, TotalEq, IterBytes, Encodable, Decodable, ToStr)] pub struct FreeRegion { scope_id: NodeId, - bound_region: bound_region + bound_region: BoundRegion } #[deriving(Clone, Eq, TotalEq, TotalOrd, IterBytes, Encodable, Decodable, ToStr)] -pub enum bound_region { +pub enum BoundRegion { /// An anonymous region parameter for a given fn (&T) - br_anon(uint), + BrAnon(uint), /// Named region parameters for functions (a in &'a T) /// /// The def-id is needed to distinguish free regions in /// the event of shadowing. - br_named(ast::DefId, ast::Ident), + BrNamed(ast::DefId, ast::Ident), /// Fresh bound identifiers created during GLB computations. - br_fresh(uint), + BrFresh(uint), } /** * Represents the values to use when substituting lifetime parameters. * If the value is `ErasedRegions`, then this subst is occurring during - * trans, and all region parameters will be replaced with `ty::re_static`. */ + * trans, and all region parameters will be replaced with `ty::ReStatic`. */ #[deriving(Clone, Eq, IterBytes)] pub enum RegionSubsts { ErasedRegions, @@ -701,8 +703,8 @@ pub enum type_err { terr_regions_does_not_outlive(Region, Region), terr_regions_not_same(Region, Region), terr_regions_no_overlap(Region, Region), - terr_regions_insufficiently_polymorphic(bound_region, Region), - terr_regions_overly_polymorphic(bound_region, Region), + terr_regions_insufficiently_polymorphic(BoundRegion, Region), + terr_regions_overly_polymorphic(BoundRegion, Region), terr_vstores_differ(terr_vstore_kind, expected_found), terr_trait_stores_differ(terr_vstore_kind, expected_found), terr_in_field(@type_err, ast::Ident), @@ -778,7 +780,7 @@ pub enum InferTy { #[deriving(Clone, Encodable, Decodable, IterBytes, ToStr)] pub enum InferRegion { ReVar(RegionVid), - ReSkolemized(uint, bound_region) + ReSkolemized(uint, BoundRegion) } impl cmp::Eq for InferRegion { @@ -1043,7 +1045,7 @@ pub fn mk_t(cx: ctxt, st: sty) -> t { fn rflags(r: Region) -> uint { (has_regions as uint) | { match r { - ty::re_infer(_) => needs_infer as uint, + ty::ReInfer(_) => needs_infer as uint, _ => 0u } } @@ -2148,7 +2150,7 @@ fn borrowed_contents(region: ty::Region, ast::MutMutable => TC::ReachesMutable | TC::OwnsAffine, ast::MutImmutable => TC::None, }; - b | (TC::ReachesBorrowed).when(region != ty::re_static) + b | (TC::ReachesBorrowed).when(region != ty::ReStatic) } fn closure_contents(cx: ctxt, cty: &ClosureTy) -> TypeContents { @@ -4220,12 +4222,12 @@ fn fold_ty(&mut self, t: ty::t) -> ty::t { fn fold_vstore(&mut self, vstore: vstore) -> vstore { match vstore { vstore_fixed(*) | vstore_uniq | vstore_box => vstore, - vstore_slice(_) => vstore_slice(re_static) + vstore_slice(_) => vstore_slice(ReStatic) } } fn fold_region(&mut self, _: ty::Region) -> ty::Region { - ty::re_static + ty::ReStatic } fn fold_substs(&mut self, @@ -4564,10 +4566,16 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: @str) -> u64 { let mut hash = SipState::new(0, 0); let region = |_hash: &mut SipState, r: Region| { match r { - re_static => {} - - re_empty | re_bound(*) | re_free(*) | re_scope(*) | re_infer(*) => + ReStatic => {} + + ReEmpty | + ReEarlyBound(*) | + ReLateBound(*) | + ReFree(*) | + ReStatic(*) | + ReInfer(*) => { tcx.sess.bug("non-static region found when hashing a type") + } } }; let vstore = |hash: &mut SipState, v: vstore| { @@ -4751,9 +4759,9 @@ pub fn construct_parameter_environment( // map bound 'a => free 'a let region_params = item_region_params.iter(). - map(|r| ty::re_free(ty::FreeRegion { + map(|r| ty::ReFree(ty::FreeRegion { scope_id: free_id, - bound_region: ty::br_named(r.def_id, r.ident)})). + bound_region: ty::BrNamed(r.def_id, r.ident)})). collect(); let free_substs = substs { diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 0c0abaa5d76..5040c19158e 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -87,23 +87,23 @@ pub fn ast_region_to_region( } Some(&ast::DefStaticRegion) => { - ty::re_static + ty::ReStatic } - Some(&ast::DefFnBoundRegion(binder_id, _, id)) => { - ty::re_fn_bound(binder_id, ty::br_named(ast_util::local_def(id), - lifetime.ident)) + Some(&ast::DefLateBoundRegion(binder_id, _, id)) => { + ty::ReLateBound(binder_id, ty::BrNamed(ast_util::local_def(id), + lifetime.ident)) } - Some(&ast::DefTypeBoundRegion(index, id)) => { - ty::re_type_bound(id, index, lifetime.ident) + Some(&ast::DefEarlyBoundRegion(index, id)) => { + ty::ReEarlyBound(id, index, lifetime.ident) } Some(&ast::DefFreeRegion(scope_id, id)) => { - ty::re_free(ty::FreeRegion { + ty::ReFree(ty::FreeRegion { scope_id: scope_id, - bound_region: ty::br_named(ast_util::local_def(id), - lifetime.ident) + bound_region: ty::BrNamed(ast_util::local_def(id), + lifetime.ident) }) } }; @@ -133,7 +133,7 @@ pub fn opt_ast_region_to_region( debug!("optional region in illegal location"); this.tcx().sess.span_err( default_span, "missing lifetime specifier"); - ty::re_static + ty::ReStatic } Some(rs) => { @@ -190,7 +190,7 @@ fn ast_path_substs( match anon_regions { Some(v) => opt_vec::from(v), None => opt_vec::from(vec::from_fn(expected_num_region_params, - |_| ty::re_static)) // hokey + |_| ty::ReStatic)) // hokey } }; @@ -431,7 +431,7 @@ fn check_path_args(tcx: ty::ctxt, let bounds = conv_builtin_bounds(this.tcx(), &f.bounds, match f.sigil { // Use corresponding trait store to figure out default bounds // if none were specified. - ast::BorrowedSigil => ty::RegionTraitStore(ty::re_empty), // dummy region + ast::BorrowedSigil => ty::RegionTraitStore(ty::ReEmpty), // dummy region ast::OwnedSigil => ty::UniqTraitStore, ast::ManagedSigil => ty::BoxTraitStore, }); @@ -713,7 +713,7 @@ pub fn ty_of_closure( ast::OwnedSigil | ast::ManagedSigil => { // @fn(), ~fn() default to static as the bound // on their upvars: - ty::re_static + ty::ReStatic } ast::BorrowedSigil => { // &fn() defaults as normal for an omitted lifetime: @@ -803,7 +803,7 @@ fn conv_builtin_bounds(tcx: ty::ctxt, ast_bounds: &Option { + (&None, ty::RegionTraitStore(ty::ReStatic)) => { let mut set = ty::EmptyBuiltinBounds(); set.add(ty::BoundStatic); set } // &'r Trait is sugar for &'r Trait:. diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index cf362384f3a..ebe3c828262 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -438,7 +438,7 @@ pub fn check_fn(ccx: @mut CrateCtxt, let (_, opt_self_ty, fn_sig) = replace_bound_regions_in_fn_sig( tcx, opt_self_ty, fn_sig, - |br| ty::re_free(ty::FreeRegion {scope_id: body.id, + |br| ty::ReFree(ty::FreeRegion {scope_id: body.id, bound_region: br})); let opt_self_info = opt_self_info.map( @@ -931,9 +931,9 @@ pub fn compare_impl_method(tcx: ty::ctxt, collect(); let dummy_impl_regions: OptVec = impl_generics.region_param_defs.iter(). - map(|l| ty::re_free(ty::FreeRegion { + map(|l| ty::ReFree(ty::FreeRegion { scope_id: impl_m_body_id, - bound_region: ty::br_named(l.def_id, l.ident)})). + bound_region: ty::BrNamed(l.def_id, l.ident)})). collect(); let dummy_substs = ty::substs { tps: vec::append(dummy_impl_tps, dummy_method_tps), @@ -1090,7 +1090,7 @@ pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> ty::t { } pub fn block_region(&self) -> ty::Region { - ty::re_scope(self.region_lb) + ty::ReScope(self.region_lb) } #[inline] @@ -1357,10 +1357,10 @@ pub fn check_lit(fcx: @mut FnCtxt, lit: @ast::lit) -> ty::t { let tcx = fcx.ccx.tcx; match lit.node { - ast::lit_str(*) => ty::mk_estr(tcx, ty::vstore_slice(ty::re_static)), + ast::lit_str(*) => ty::mk_estr(tcx, ty::vstore_slice(ty::ReStatic)), ast::lit_binary(*) => { ty::mk_evec(tcx, ty::mt{ ty: ty::mk_u8(), mutbl: ast::MutImmutable }, - ty::vstore_slice(ty::re_static)) + ty::vstore_slice(ty::ReStatic)) } ast::lit_char(_) => ty::mk_char(), ast::lit_int(_, t) => ty::mk_mach_int(t), @@ -3925,19 +3925,19 @@ fn param(ccx: @mut CrateCtxt, n: uint) -> ty::t { //We only care about the operation here match split[1] { "cxchg" => (0, ~[ty::mk_mut_rptr(tcx, - ty::re_fn_bound(it.id, ty::br_anon(0)), + ty::ReLateBound(it.id, ty::BrAnon(0)), ty::mk_int()), ty::mk_int(), ty::mk_int() ], ty::mk_int()), "load" => (0, ~[ - ty::mk_imm_rptr(tcx, ty::re_fn_bound(it.id, ty::br_anon(0)), ty::mk_int()) + ty::mk_imm_rptr(tcx, ty::ReLateBound(it.id, ty::BrAnon(0)), ty::mk_int()) ], ty::mk_int()), "store" => (0, ~[ - ty::mk_mut_rptr(tcx, ty::re_fn_bound(it.id, ty::br_anon(0)), ty::mk_int()), + ty::mk_mut_rptr(tcx, ty::ReLateBound(it.id, ty::BrAnon(0)), ty::mk_int()), ty::mk_int() ], ty::mk_nil()), @@ -3945,7 +3945,7 @@ fn param(ccx: @mut CrateCtxt, n: uint) -> ty::t { "xchg" | "xadd" | "xsub" | "and" | "nand" | "or" | "xor" | "max" | "min" | "umax" | "umin" => { (0, ~[ty::mk_mut_rptr(tcx, - ty::re_fn_bound(it.id, ty::br_anon(0)), + ty::ReLateBound(it.id, ty::BrAnon(0)), ty::mk_int()), ty::mk_int() ], ty::mk_int()) } "fence" => { @@ -3971,7 +3971,7 @@ fn param(ccx: @mut CrateCtxt, n: uint) -> ty::t { "move_val" | "move_val_init" => { (1u, ~[ - ty::mk_mut_rptr(tcx, ty::re_fn_bound(it.id, ty::br_anon(0)), param(ccx, 0)), + ty::mk_mut_rptr(tcx, ty::ReLateBound(it.id, ty::BrAnon(0)), param(ccx, 0)), param(ccx, 0u) ], ty::mk_nil()) @@ -3983,7 +3983,7 @@ fn param(ccx: @mut CrateCtxt, n: uint) -> ty::t { "atomic_xchg_rel" | "atomic_xadd_rel" | "atomic_xsub_rel" => { (0, ~[ - ty::mk_mut_rptr(tcx, ty::re_fn_bound(it.id, ty::br_anon(0)), ty::mk_int()), + ty::mk_mut_rptr(tcx, ty::ReLateBound(it.id, ty::BrAnon(0)), ty::mk_int()), ty::mk_int() ], ty::mk_int()) @@ -4006,7 +4006,7 @@ fn param(ccx: @mut CrateCtxt, n: uint) -> ty::t { Ok(t) => t, Err(s) => { tcx.sess.span_fatal(it.span, s); } }; - let region = ty::re_fn_bound(it.id, ty::br_anon(0)); + let region = ty::ReLateBound(it.id, ty::BrAnon(0)); let visitor_object_ty = match ty::visitor_object_ty(tcx, region) { Ok((_, vot)) => vot, Err(s) => { tcx.sess.span_fatal(it.span, s); } diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index cd94e040ac3..b21d36777c2 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -29,7 +29,7 @@ use middle::freevars::get_freevars; -use middle::ty::{re_scope}; +use middle::ty::{ReScope}; use middle::ty; use middle::typeck::check::FnCtxt; use middle::typeck::check::regionmanip::relate_nested_regions; @@ -64,7 +64,7 @@ fn encl_region_of_def(fcx: @mut FnCtxt, def: ast::Def) -> ty::Region { DefUpvar(_, subdef, closure_id, body_id) => { match ty::ty_closure_sigil(fcx.node_ty(closure_id)) { BorrowedSigil => encl_region_of_def(fcx, *subdef), - ManagedSigil | OwnedSigil => re_scope(body_id) + ManagedSigil | OwnedSigil => ReScope(body_id) } } _ => { @@ -317,7 +317,7 @@ fn visit_expr(rcx: &mut Rcx, expr: @ast::Expr) { // // FIXME(#6268) remove to support nested method calls constrain_regions_in_type_of_node( - rcx, expr.id, ty::re_scope(expr.id), + rcx, expr.id, ty::ReScope(expr.id), infer::AutoBorrow(expr.span)); } } @@ -416,7 +416,7 @@ fn visit_expr(rcx: &mut Rcx, expr: @ast::Expr) { // // FIXME(#6268) nested method calls requires that this rule change let ty0 = rcx.resolve_node_type(expr.id); - constrain_regions_in_type(rcx, ty::re_scope(expr.id), + constrain_regions_in_type(rcx, ty::ReScope(expr.id), infer::AddrOf(expr.span), ty0); visit::walk_expr(rcx, expr, ()); } @@ -474,7 +474,7 @@ fn check_expr_fn_block(rcx: &mut Rcx, // (since otherwise that would require // infinite stack). constrain_free_variables(rcx, region, expr); - let repeating_scope = ty::re_scope(rcx.repeating_scope); + let repeating_scope = ty::ReScope(rcx.repeating_scope); rcx.fcx.mk_subr(true, infer::InfStackClosure(expr.span), region, repeating_scope); } @@ -500,7 +500,7 @@ fn constrain_callee(rcx: &mut Rcx, call_expr: @ast::Expr, callee_expr: @ast::Expr) { - let call_region = ty::re_scope(call_expr.id); + let call_region = ty::ReScope(call_expr.id); let callee_ty = rcx.resolve_node_type(callee_id); match ty::get(callee_ty).sty { @@ -555,7 +555,7 @@ fn constrain_call(rcx: &mut Rcx, // // FIXME(#6268) to support nested method calls, should be callee_id let callee_scope = call_expr.id; - let callee_region = ty::re_scope(callee_scope); + let callee_region = ty::ReScope(callee_scope); for &arg_expr in arg_exprs.iter() { debug!("Argument"); @@ -604,7 +604,7 @@ fn constrain_derefs(rcx: &mut Rcx, * the deref expr. */ let tcx = rcx.fcx.tcx(); - let r_deref_expr = ty::re_scope(deref_expr.id); + let r_deref_expr = ty::ReScope(deref_expr.id); for i in range(0u, derefs) { debug!("constrain_derefs(deref_expr=?, derefd_ty={}, derefs={:?}/{:?}", rcx.fcx.infcx().ty_to_str(derefd_ty), @@ -650,7 +650,7 @@ fn constrain_index(rcx: &mut Rcx, debug!("constrain_index(index_expr=?, indexed_ty={}", rcx.fcx.infcx().ty_to_str(indexed_ty)); - let r_index_expr = ty::re_scope(index_expr.id); + let r_index_expr = ty::ReScope(index_expr.id); match ty::get(indexed_ty).sty { ty::ty_estr(ty::vstore_slice(r_ptr)) | ty::ty_evec(_, ty::vstore_slice(r_ptr)) => { @@ -912,7 +912,7 @@ pub fn for_by_ref(rcx: &mut Rcx, let expr_cat = categorize(rcx, expr); debug!("guarantor::for_by_ref(expr={:?}, callee_scope={:?}) category={:?}", expr.id, callee_scope, expr_cat); - let minimum_lifetime = ty::re_scope(callee_scope); + let minimum_lifetime = ty::ReScope(callee_scope); for guarantor in expr_cat.guarantor.iter() { mk_subregion_due_to_derefence(rcx, expr.span, minimum_lifetime, *guarantor); diff --git a/src/librustc/middle/typeck/check/regionmanip.rs b/src/librustc/middle/typeck/check/regionmanip.rs index ea7b2faf273..a73aa46fbec 100644 --- a/src/librustc/middle/typeck/check/regionmanip.rs +++ b/src/librustc/middle/typeck/check/regionmanip.rs @@ -23,8 +23,8 @@ pub fn replace_bound_regions_in_fn_sig( tcx: ty::ctxt, opt_self_ty: Option, fn_sig: &ty::FnSig, - mapf: &fn(ty::bound_region) -> ty::Region) - -> (HashMap, Option, ty::FnSig) + mapf: &fn(ty::BoundRegion) -> ty::Region) + -> (HashMap, Option, ty::FnSig) { debug!("replace_bound_regions_in_fn_sig(self_ty={}, fn_sig={})", opt_self_ty.repr(tcx), @@ -35,7 +35,7 @@ pub fn replace_bound_regions_in_fn_sig( let mut f = ty_fold::RegionFolder::regions(tcx, |r| { debug!("region r={}", r.to_str()); match r { - ty::re_fn_bound(s, br) if s == fn_sig.binder_id => { + ty::ReLateBound(s, br) if s == fn_sig.binder_id => { *map.find_or_insert_with(br, |_| mapf(br)) } _ => r @@ -175,7 +175,7 @@ pub fn relate_free_regions( debug!("relate_free_regions(t={})", ppaux::ty_to_str(tcx, t)); relate_nested_regions(tcx, None, t, |a, b| { match (&a, &b) { - (&ty::re_free(free_a), &ty::re_free(free_b)) => { + (&ty::ReFree(free_a), &ty::ReFree(free_b)) => { tcx.region_maps.relate_free_regions(free_a, free_b); } _ => {} diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index ae76c9ed6dd..996157df2e2 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -480,7 +480,7 @@ fn fixup_substs(vcx: &VtableContext, // use a dummy type just to package up the substs that need fixing up let t = ty::mk_trait(tcx, id, substs, - ty::RegionTraitStore(ty::re_static), + ty::RegionTraitStore(ty::ReStatic), ast::MutImmutable, ty::EmptyBuiltinBounds()); do fixup_ty(vcx, location_info, t, is_early).map |t_f| { diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 7cf004be5e2..e55005d62e9 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -282,8 +282,8 @@ fn make_static_method_ty(ccx: &CrateCtxt, // Convert the regions 'a, 'b, 'c defined on the trait into // bound regions on the fn. let rps_from_trait = trait_ty_generics.region_param_defs.iter().map(|d| { - ty::re_fn_bound(m.fty.sig.binder_id, - ty::br_named(d.def_id, d.ident)) + ty::ReLateBound(m.fty.sig.binder_id, + ty::BrNamed(d.def_id, d.ident)) }).collect(); // build up the substitution from @@ -964,7 +964,7 @@ pub fn mk_item_substs(ccx: &CrateCtxt, let regions: OptVec = ty_generics.region_param_defs.iter().enumerate().map( - |(i, l)| ty::re_type_bound(l.def_id.node, i, l.ident)).collect(); + |(i, l)| ty::ReEarlyBound(l.def_id.node, i, l.ident)).collect(); substs {regions: ty::NonerasedRegions(regions), self_ty: self_ty, diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index 78e0bd17eca..9febef1c7c3 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -161,7 +161,7 @@ fn generalize_region(this: &Glb, snapshot: uint, new_vars: &[RegionVid], new_binder_id: NodeId, - a_map: &HashMap, + a_map: &HashMap, a_vars: &[RegionVid], b_vars: &[RegionVid], r0: ty::Region) -> ty::Region { @@ -228,13 +228,13 @@ fn generalize_region(this: &Glb, } fn rev_lookup(this: &Glb, - a_map: &HashMap, + a_map: &HashMap, new_binder_id: NodeId, r: ty::Region) -> ty::Region { for (a_br, a_r) in a_map.iter() { if *a_r == r { - return ty::re_fn_bound(new_binder_id, *a_br); + return ty::ReLateBound(new_binder_id, *a_br); } } this.infcx.tcx.sess.span_bug( diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index 9aaa4be1181..04bf5fda725 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -522,10 +522,10 @@ pub fn lattice_var_and_t(this: &T, - map: &HashMap) + map: &HashMap) -> ~[RegionVid] { map.iter().map(|(_, r)| match *r { - ty::re_infer(ty::ReVar(r)) => { r } + ty::ReInfer(ty::ReVar(r)) => { r } r => { this.infcx().tcx.sess.span_bug( this.trace().origin.span(), @@ -536,7 +536,7 @@ pub fn var_ids(this: &T, pub fn is_var_in_set(new_vars: &[RegionVid], r: ty::Region) -> bool { match r { - ty::re_infer(ty::ReVar(ref v)) => new_vars.iter().any(|x| x == v), + ty::ReInfer(ty::ReVar(ref v)) => new_vars.iter().any(|x| x == v), _ => false } } diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index ad649f379b5..b826310df7b 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -149,7 +149,7 @@ fn generalize_region(this: &Lub, snapshot: uint, new_vars: &[RegionVid], new_scope: NodeId, - a_map: &HashMap, + a_map: &HashMap, r0: ty::Region) -> ty::Region { // Regions that pre-dated the LUB computation stay as they are. @@ -182,7 +182,7 @@ fn generalize_region(this: &Lub, debug!("generalize_region(r0={:?}): \ replacing with {:?}, tainted={:?}", r0, *a_br, tainted); - return ty::re_fn_bound(new_scope, *a_br); + return ty::ReLateBound(new_scope, *a_br); } } diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index 121b32f4145..eafc7e262f1 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -216,11 +216,11 @@ pub enum RegionVariableOrigin { // Region variables created for bound regions // in a function or method that is called - BoundRegionInFnCall(Span, ty::bound_region), + BoundRegionInFnCall(Span, ty::BoundRegion), // Region variables created for bound regions // when doing subtyping/lub/glb computations - BoundRegionInFnType(Span, ty::bound_region), + BoundRegionInFnType(Span, ty::BoundRegion), BoundRegionInTypeOrImpl(Span), @@ -638,7 +638,7 @@ pub fn next_float_var(&mut self) -> ty::t { } pub fn next_region_var(&mut self, origin: RegionVariableOrigin) -> ty::Region { - ty::re_infer(ty::ReVar(self.region_vars.new_region_var(origin))) + ty::ReInfer(ty::ReVar(self.region_vars.new_region_var(origin))) } pub fn next_region_vars(&mut self, @@ -798,7 +798,7 @@ pub fn replace_bound_regions_with_fresh_regions(&mut self, trace: TypeTrace, fsig: &ty::FnSig) -> (ty::FnSig, - HashMap) { let (map, _, fn_sig) = replace_bound_regions_in_fn_sig(self.tcx, None, fsig, |br| { @@ -933,13 +933,13 @@ fn repr(&self, tcx: ty::ctxt) -> ~str { AddrOfSlice(a) => format!("AddrOfSlice({})", a.repr(tcx)), Autoref(a) => format!("Autoref({})", a.repr(tcx)), Coercion(a) => format!("Coercion({})", a.repr(tcx)), - BoundRegionInFnCall(a, b) => format!("BoundRegionInFnCall({},{})", + BoundRegionInFnCall(a, b) => format!("bound_regionInFnCall({},{})", a.repr(tcx), b.repr(tcx)), - BoundRegionInFnType(a, b) => format!("BoundRegionInFnType({},{})", + BoundRegionInFnType(a, b) => format!("bound_regionInFnType({},{})", a.repr(tcx), b.repr(tcx)), - BoundRegionInTypeOrImpl(a) => format!("BoundRegionInTypeOrImpl({})", + BoundRegionInTypeOrImpl(a) => format!("bound_regionInTypeOrImpl({})", a.repr(tcx)), - BoundRegionInCoherence => format!("BoundRegionInCoherence"), + BoundRegionInCoherence => format!("bound_regionInCoherence"), } } } diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index effd34da0de..e613aa4ba28 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -13,9 +13,9 @@ use middle::ty; use middle::ty::{FreeRegion, Region, RegionVid}; -use middle::ty::{re_empty, re_static, re_infer, re_free, re_type_bound, - re_fn_bound}; -use middle::ty::{re_scope, ReVar, ReSkolemized, br_fresh}; +use middle::ty::{ReEmpty, ReStatic, ReInfer, ReFree, ReEarlyBound, + ReLateBound}; +use middle::ty::{ReScope, ReVar, ReSkolemized, BrFresh}; use middle::typeck::infer::cres; use middle::typeck::infer::{RegionVariableOrigin, SubregionOrigin}; use middle::typeck::infer; @@ -187,10 +187,10 @@ pub fn new_region_var(&mut self, origin: RegionVariableOrigin) -> RegionVid { return vid; } - pub fn new_skolemized(&mut self, br: ty::bound_region) -> Region { + pub fn new_skolemized(&mut self, br: ty::BoundRegion) -> Region { let sc = self.skolemization_count; self.skolemization_count += 1; - re_infer(ReSkolemized(sc, br)) + ReInfer(ReSkolemized(sc, br)) } pub fn new_bound(&mut self, binder_id: ast::NodeId) -> Region { @@ -219,7 +219,7 @@ pub fn new_bound(&mut self, binder_id: ast::NodeId) -> Region { self.tcx.sess.bug("Rollover in RegionInference new_bound()"); } - re_fn_bound(binder_id, br_fresh(sc)) + ReLateBound(binder_id, BrFresh(sc)) } pub fn add_constraint(&mut self, @@ -246,23 +246,23 @@ pub fn make_subregion(&mut self, debug!("RegionVarBindings: make_subregion({:?}, {:?})", sub, sup); match (sub, sup) { - (re_type_bound(*), _) | - (re_fn_bound(*), _) | - (_, re_type_bound(*)) | - (_, re_fn_bound(*)) => { + (ReEarlyBound(*), _) | + (ReLateBound(*), _) | + (_, ReEarlyBound(*)) | + (_, ReLateBound(*)) => { self.tcx.sess.span_bug( origin.span(), format!("Cannot relate bound region: {} <= {}", sub.repr(self.tcx), sup.repr(self.tcx))); } - (re_infer(ReVar(sub_id)), re_infer(ReVar(sup_id))) => { + (ReInfer(ReVar(sub_id)), ReInfer(ReVar(sup_id))) => { self.add_constraint(ConstrainVarSubVar(sub_id, sup_id), origin); } - (r, re_infer(ReVar(sup_id))) => { + (r, ReInfer(ReVar(sup_id))) => { self.add_constraint(ConstrainRegSubVar(r, sup_id), origin); } - (re_infer(ReVar(sub_id)), r) => { + (ReInfer(ReVar(sub_id)), r) => { self.add_constraint(ConstrainVarSubReg(sub_id, r), origin); } _ => { @@ -281,8 +281,8 @@ pub fn lub_regions(&mut self, debug!("RegionVarBindings: lub_regions({:?}, {:?})", a, b); match (a, b) { - (re_static, _) | (_, re_static) => { - re_static // nothing lives longer than static + (ReStatic, _) | (_, ReStatic) => { + ReStatic // nothing lives longer than static } _ => { @@ -304,7 +304,7 @@ pub fn glb_regions(&mut self, debug!("RegionVarBindings: glb_regions({:?}, {:?})", a, b); match (a, b) { - (re_static, r) | (r, re_static) => { + (ReStatic, r) | (r, ReStatic) => { // static lives longer than everything else r } @@ -333,13 +333,13 @@ pub fn resolve_var(&mut self, rid: RegionVid) -> ty::Region { Value(r) => r, NoValue => { - // No constraints, return ty::re_empty - re_empty + // No constraints, return ty::ReEmpty + ReEmpty } ErrorValue => { // An error that has previously been reported. - re_static + ReStatic } } } @@ -366,7 +366,7 @@ pub fn combine_vars(&mut self, let vars = TwoRegions { a: a, b: b }; match self.combine_map(t).find(&vars) { Some(&c) => { - return re_infer(ReVar(c)); + return ReInfer(ReVar(c)); } None => {} } @@ -375,10 +375,10 @@ pub fn combine_vars(&mut self, if self.in_snapshot() { self.undo_log.push(AddCombination(t, vars)); } - relate(self, a, re_infer(ReVar(c))); - relate(self, b, re_infer(ReVar(c))); + relate(self, a, ReInfer(ReVar(c))); + relate(self, b, ReInfer(ReVar(c))); debug!("combine_vars() c={:?}", c); - re_infer(ReVar(c)) + ReInfer(ReVar(c)) } pub fn vars_created_since_snapshot(&mut self, snapshot: uint) @@ -421,14 +421,14 @@ pub fn tainted(&mut self, snapshot: uint, r0: Region) -> ~[Region] { // nb: can't use uint::range() here as we move result_set let regs = match self.undo_log[undo_index] { AddConstraint(ConstrainVarSubVar(ref a, ref b)) => { - Some((re_infer(ReVar(*a)), - re_infer(ReVar(*b)))) + Some((ReInfer(ReVar(*a)), + ReInfer(ReVar(*b)))) } AddConstraint(ConstrainRegSubVar(ref a, ref b)) => { - Some((*a, re_infer(ReVar(*b)))) + Some((*a, ReInfer(ReVar(*b)))) } AddConstraint(ConstrainVarSubReg(ref a, ref b)) => { - Some((re_infer(ReVar(*a)), *b)) + Some((ReInfer(ReVar(*a)), *b)) } AddConstraint(ConstrainRegSubReg(a, b)) => { Some((a, b)) @@ -495,33 +495,33 @@ fn is_subregion_of(&self, sub: Region, sup: Region) -> bool { fn lub_concrete_regions(&self, a: Region, b: Region) -> Region { match (a, b) { - (re_fn_bound(*), _) | - (_, re_fn_bound(*)) | - (re_type_bound(*), _) | - (_, re_type_bound(*)) => { + (ReLateBound(*), _) | + (_, ReLateBound(*)) | + (ReEarlyBound(*), _) | + (_, ReEarlyBound(*)) => { self.tcx.sess.bug( format!("Cannot relate bound region: LUB({}, {})", a.repr(self.tcx), b.repr(self.tcx))); } - (re_static, _) | (_, re_static) => { - re_static // nothing lives longer than static + (ReStatic, _) | (_, ReStatic) => { + ReStatic // nothing lives longer than static } - (re_empty, r) | (r, re_empty) => { + (ReEmpty, r) | (r, ReEmpty) => { r // everything lives longer than empty } - (re_infer(ReVar(v_id)), _) | (_, re_infer(ReVar(v_id))) => { + (ReInfer(ReVar(v_id)), _) | (_, ReInfer(ReVar(v_id))) => { self.tcx.sess.span_bug( self.var_origins[v_id.to_uint()].span(), format!("lub_concrete_regions invoked with \ non-concrete regions: {:?}, {:?}", a, b)); } - (f @ re_free(ref fr), re_scope(s_id)) | - (re_scope(s_id), f @ re_free(ref fr)) => { + (f @ ReFree(ref fr), ReScope(s_id)) | + (ReScope(s_id), f @ ReFree(ref fr)) => { // A "free" region can be interpreted as "some region // at least as big as the block fr.scope_id". So, we can // reasonably compare free regions and scopes: @@ -534,30 +534,30 @@ fn lub_concrete_regions(&self, a: Region, b: Region) -> Region { // otherwise, we don't know what the free region is, // so we must conservatively say the LUB is static: - _ => re_static + _ => ReStatic } } - (re_scope(a_id), re_scope(b_id)) => { + (ReScope(a_id), ReScope(b_id)) => { // The region corresponding to an outer block is a // subtype of the region corresponding to an inner // block. let rm = self.tcx.region_maps; match rm.nearest_common_ancestor(a_id, b_id) { - Some(r_id) => re_scope(r_id), - _ => re_static + Some(r_id) => ReScope(r_id), + _ => ReStatic } } - (re_free(ref a_fr), re_free(ref b_fr)) => { + (ReFree(ref a_fr), ReFree(ref b_fr)) => { self.lub_free_regions(a_fr, b_fr) } // For these types, we cannot define any additional // relationship: - (re_infer(ReSkolemized(*)), _) | - (_, re_infer(ReSkolemized(*))) => { - if a == b {a} else {re_static} + (ReInfer(ReSkolemized(*)), _) | + (_, ReInfer(ReSkolemized(*))) => { + if a == b {a} else {ReStatic} } } } @@ -575,7 +575,7 @@ fn lub_free_regions(&self, return match a.cmp(b) { Less => helper(self, a, b), Greater => helper(self, b, a), - Equal => ty::re_free(*a) + Equal => ty::ReFree(*a) }; fn helper(this: &RegionVarBindings, @@ -584,11 +584,11 @@ fn helper(this: &RegionVarBindings, { let rm = this.tcx.region_maps; if rm.sub_free_region(*a, *b) { - ty::re_free(*b) + ty::ReFree(*b) } else if rm.sub_free_region(*b, *a) { - ty::re_free(*a) + ty::ReFree(*a) } else { - ty::re_static + ty::ReStatic } } } @@ -599,36 +599,36 @@ fn glb_concrete_regions(&self, -> cres { debug!("glb_concrete_regions({:?}, {:?})", a, b); match (a, b) { - (re_fn_bound(*), _) | - (_, re_fn_bound(*)) | - (re_type_bound(*), _) | - (_, re_type_bound(*)) => { + (ReLateBound(*), _) | + (_, ReLateBound(*)) | + (ReEarlyBound(*), _) | + (_, ReEarlyBound(*)) => { self.tcx.sess.bug( format!("Cannot relate bound region: GLB({}, {})", a.repr(self.tcx), b.repr(self.tcx))); } - (re_static, r) | (r, re_static) => { + (ReStatic, r) | (r, ReStatic) => { // static lives longer than everything else Ok(r) } - (re_empty, _) | (_, re_empty) => { + (ReEmpty, _) | (_, ReEmpty) => { // nothing lives shorter than everything else - Ok(re_empty) + Ok(ReEmpty) } - (re_infer(ReVar(v_id)), _) | - (_, re_infer(ReVar(v_id))) => { + (ReInfer(ReVar(v_id)), _) | + (_, ReInfer(ReVar(v_id))) => { self.tcx.sess.span_bug( self.var_origins[v_id.to_uint()].span(), format!("glb_concrete_regions invoked with \ non-concrete regions: {:?}, {:?}", a, b)); } - (re_free(ref fr), s @ re_scope(s_id)) | - (s @ re_scope(s_id), re_free(ref fr)) => { + (ReFree(ref fr), s @ ReScope(s_id)) | + (s @ ReScope(s_id), ReFree(ref fr)) => { // Free region is something "at least as big as // `fr.scope_id`." If we find that the scope `fr.scope_id` is bigger // than the scope `s_id`, then we can say that the GLB @@ -641,18 +641,18 @@ fn glb_concrete_regions(&self, } } - (re_scope(a_id), re_scope(b_id)) => { + (ReScope(a_id), ReScope(b_id)) => { self.intersect_scopes(a, b, a_id, b_id) } - (re_free(ref a_fr), re_free(ref b_fr)) => { + (ReFree(ref a_fr), ReFree(ref b_fr)) => { self.glb_free_regions(a_fr, b_fr) } // For these types, we cannot define any additional // relationship: - (re_infer(ReSkolemized(*)), _) | - (_, re_infer(ReSkolemized(*))) => { + (ReInfer(ReSkolemized(*)), _) | + (_, ReInfer(ReSkolemized(*))) => { if a == b { Ok(a) } else { @@ -675,7 +675,7 @@ fn glb_free_regions(&self, return match a.cmp(b) { Less => helper(self, a, b), Greater => helper(self, b, a), - Equal => Ok(ty::re_free(*a)) + Equal => Ok(ty::ReFree(*a)) }; fn helper(this: &RegionVarBindings, @@ -684,11 +684,11 @@ fn helper(this: &RegionVarBindings, { let rm = this.tcx.region_maps; if rm.sub_free_region(*a, *b) { - Ok(ty::re_free(*a)) + Ok(ty::ReFree(*a)) } else if rm.sub_free_region(*b, *a) { - Ok(ty::re_free(*b)) + Ok(ty::ReFree(*b)) } else { - this.intersect_scopes(ty::re_free(*a), ty::re_free(*b), + this.intersect_scopes(ty::ReFree(*a), ty::ReFree(*b), a.scope_id, b.scope_id) } } @@ -715,8 +715,8 @@ fn intersect_scopes(&self, scope_a, scope_b, region_a, region_b); let rm = self.tcx.region_maps; match rm.nearest_common_ancestor(scope_a, scope_b) { - Some(r_id) if scope_a == r_id => Ok(re_scope(scope_b)), - Some(r_id) if scope_b == r_id => Ok(re_scope(scope_a)), + Some(r_id) if scope_a == r_id => Ok(ReScope(scope_b)), + Some(r_id) if scope_b == r_id => Ok(ReScope(scope_a)), _ => Err(ty::terr_regions_no_overlap(region_a, region_b)) } } diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs index 84f3d9c6937..168d8a57c7f 100644 --- a/src/librustc/middle/typeck/infer/resolve.rs +++ b/src/librustc/middle/typeck/infer/resolve.rs @@ -192,21 +192,21 @@ pub fn resolve_type(&mut self, typ: ty::t) -> ty::t { pub fn resolve_region(&mut self, orig: ty::Region) -> ty::Region { debug!("Resolve_region({})", orig.inf_str(self.infcx)); match orig { - ty::re_infer(ty::ReVar(rid)) => self.resolve_region_var(rid), + ty::ReInfer(ty::ReVar(rid)) => self.resolve_region_var(rid), _ => orig } } pub fn resolve_region_var(&mut self, rid: RegionVid) -> ty::Region { if !self.should(resolve_rvar) { - return ty::re_infer(ty::ReVar(rid)); + return ty::ReInfer(ty::ReVar(rid)); } self.infcx.region_vars.resolve_var(rid) } pub fn assert_not_rvar(&mut self, rid: RegionVid, r: ty::Region) { match r { - ty::re_infer(ty::ReVar(rid2)) => { + ty::ReInfer(ty::ReVar(rid2)) => { self.err = Some(region_var_bound_by_region_var(rid, rid2)); } _ => { } diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index 802d635a3f0..117b100005a 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -192,7 +192,7 @@ fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres { // Each skolemized should only be relatable to itself // or new variables: match *tainted_region { - ty::re_infer(ty::ReVar(ref vid)) => { + ty::ReInfer(ty::ReVar(ref vid)) => { if new_vars.iter().any(|x| x == vid) { continue; } } _ => { diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs index d7a00ebf0e9..7c56594d267 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc/middle/typeck/infer/test.rs @@ -188,7 +188,7 @@ pub fn t_fn(&self, input_tys: &[ty::t], output_ty: ty::t) -> ty::t { meta: FnMeta {purity: ast::impure_fn, proto: ast::ProtoBare, onceness: ast::Many, - region: ty::re_static, + region: ty::ReStatic, bounds: @~[]}, sig: FnSig { inputs: inputs, @@ -203,22 +203,22 @@ pub fn t_int(&self) -> ty::t { } pub fn t_rptr_bound(&self, id: uint) -> ty::t { - ty::mk_imm_rptr(self.tcx, ty::re_bound(ty::br_anon(id)), self.t_int()) + ty::mk_imm_rptr(self.tcx, ty::re_bound(ty::BrAnon(id)), self.t_int()) } pub fn t_rptr_scope(&self, id: ast::node_id) -> ty::t { - ty::mk_imm_rptr(self.tcx, ty::re_scope(id), self.t_int()) + ty::mk_imm_rptr(self.tcx, ty::ReScope(id), self.t_int()) } pub fn t_rptr_free(&self, nid: ast::node_id, id: uint) -> ty::t { ty::mk_imm_rptr(self.tcx, - ty::re_free(ty::FreeRegion {scope_id: nid, - bound_region: ty::br_anon(id)}), + ty::ReFree(ty::FreeRegion {scope_id: nid, + bound_region: ty::BrAnon(id)}), self.t_int()) } pub fn t_rptr_static(&self) -> ty::t { - ty::mk_imm_rptr(self.tcx, ty::re_static, self.t_int()) + ty::mk_imm_rptr(self.tcx, ty::ReStatic, self.t_int()) } pub fn lub() -> Lub { Lub(self.infcx.combine_fields(true, dummy_sp())) } diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index ed6c810e52c..63ddc9addc5 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -317,19 +317,19 @@ pub fn require_same_types( // a list of mapping from in-scope-region-names ("isr") to the // corresponding ty::Region -pub type isr_alist = @List<(ty::bound_region, ty::Region)>; +pub type isr_alist = @List<(ty::BoundRegion, ty::Region)>; trait get_and_find_region { - fn get(&self, br: ty::bound_region) -> ty::Region; - fn find(&self, br: ty::bound_region) -> Option; + fn get(&self, br: ty::BoundRegion) -> ty::Region; + fn find(&self, br: ty::BoundRegion) -> Option; } impl get_and_find_region for isr_alist { - fn get(&self, br: ty::bound_region) -> ty::Region { + fn get(&self, br: ty::BoundRegion) -> ty::Region { self.find(br).unwrap() } - fn find(&self, br: ty::bound_region) -> Option { + fn find(&self, br: ty::BoundRegion) -> Option { let mut ret = None; do list::each(*self) |isr| { let (isr_br, isr_r) = *isr; diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index 2c48eb04ee6..3d095d1e8a5 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -56,8 +56,8 @@ fn anon_regions(&self, -> Option<~[ty::Region]> { let idx = *self.anon_bindings; *self.anon_bindings += count; - Some(vec::from_fn(count, |i| ty::re_fn_bound(self.binder_id, - ty::br_anon(idx + i)))) + Some(vec::from_fn(count, |i| ty::ReLateBound(self.binder_id, + ty::BrAnon(idx + i)))) } } @@ -65,5 +65,5 @@ pub fn bound_type_regions(defs: &[ty::RegionParameterDef]) -> OptVec { assert!(defs.iter().all(|def| def.def_id.crate == ast::LOCAL_CRATE)); defs.iter().enumerate().map( - |(i, def)| ty::re_type_bound(def.def_id.node, i, def.ident)).collect() + |(i, def)| ty::ReEarlyBound(def.def_id.node, i, def.ident)).collect() } diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs index adb05d252e6..4e8f0a9468c 100644 --- a/src/librustc/middle/typeck/variance.rs +++ b/src/librustc/middle/typeck/variance.rs @@ -613,20 +613,20 @@ fn add_constraints_from_region(&mut self, region: ty::Region, variance: VarianceTermPtr<'self>) { match region { - ty::re_type_bound(param_id, _, _) => { + ty::ReEarlyBound(param_id, _, _) => { let index = self.inferred_index(param_id); self.add_constraint(index, variance); } - ty::re_static => { } + ty::ReStatic => { } - ty::re_fn_bound(*) => { + ty::ReLateBound(*) => { // We do not infer variance for region parameters on // methods or in fn types. } - ty::re_free(*) | ty::re_scope(*) | ty::re_infer(*) | - ty::re_empty => { + ty::ReFree(*) | ty::ReScope(*) | ty::ReInfer(*) | + ty::ReEmpty => { // We don't expect to see anything but 'static or bound // regions when visiting member types or method types. self.tcx().sess.bug(format!("Unexpected region encountered in \ diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 89dc71b3af6..c5d7db465e6 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -11,11 +11,11 @@ use metadata::encoder; use middle::ty::{ReSkolemized, ReVar}; -use middle::ty::{bound_region, br_anon, br_named}; -use middle::ty::{br_fresh, ctxt, field}; +use middle::ty::{BoundRegion, BrAnon, BrNamed}; +use middle::ty::{BrFresh, ctxt, field}; use middle::ty::{mt, t, param_ty}; -use middle::ty::{re_free, re_scope, re_infer, re_static, Region, - re_empty}; +use middle::ty::{ReFree, ReScope, ReInfer, ReStatic, Region, + ReEmpty}; use middle::ty::{ty_bool, ty_char, ty_bot, ty_box, ty_struct, ty_enum}; use middle::ty::{ty_err, ty_estr, ty_evec, ty_float, ty_bare_fn, ty_closure}; use middle::ty::{ty_nil, ty_opaque_box, ty_opaque_closure_ptr, ty_param}; @@ -71,7 +71,7 @@ pub fn explain_region(cx: ctxt, region: ty::Region) -> ~str { pub fn explain_region_and_span(cx: ctxt, region: ty::Region) -> (~str, Option) { return match region { - re_scope(node_id) => { + ReScope(node_id) => { match cx.items.find(&node_id) { Some(&ast_map::node_block(ref blk)) => { explain_span(cx, "block", blk.span) @@ -104,11 +104,11 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region) } } - re_free(ref fr) => { + ReFree(ref fr) => { let prefix = match fr.bound_region { - br_anon(idx) => format!("the anonymous lifetime \\#{} defined on", + BrAnon(idx) => format!("the anonymous lifetime \\#{} defined on", idx + 1), - br_fresh(_) => format!("an anonymous lifetime defined on"), + BrFresh(_) => format!("an anonymous lifetime defined on"), _ => format!("the lifetime {} as defined on", bound_region_ptr_to_str(cx, fr.bound_region)) }; @@ -130,13 +130,13 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region) } } - re_static => { (~"the static lifetime", None) } + ReStatic => { (~"the static lifetime", None) } - re_empty => { (~"the empty lifetime", None) } + ReEmpty => { (~"the empty lifetime", None) } // I believe these cases should not occur (except when debugging, // perhaps) - ty::re_infer(_) | ty::re_type_bound(*) | ty::re_fn_bound(*) => { + ty::ReInfer(_) | ty::ReEarlyBound(*) | ty::ReLateBound(*) => { (format!("lifetime {:?}", region), None) } }; @@ -150,13 +150,13 @@ fn explain_span(cx: ctxt, heading: &str, span: Span) } } -pub fn bound_region_ptr_to_str(cx: ctxt, br: bound_region) -> ~str { +pub fn bound_region_ptr_to_str(cx: ctxt, br: BoundRegion) -> ~str { bound_region_to_str(cx, "&", true, br) } pub fn bound_region_to_str(cx: ctxt, prefix: &str, space: bool, - br: bound_region) -> ~str { + br: BoundRegion) -> ~str { let space_str = if space { " " } else { "" }; if cx.sess.verbose() { @@ -164,14 +164,14 @@ pub fn bound_region_to_str(cx: ctxt, } match br { - br_named(_, ident) => format!("{}'{}{}", prefix, + BrNamed(_, ident) => format!("{}'{}{}", prefix, cx.sess.str_of(ident), space_str), - br_anon(_) => prefix.to_str(), - br_fresh(_) => prefix.to_str(), + BrAnon(_) => prefix.to_str(), + BrFresh(_) => prefix.to_str(), } } -pub fn re_scope_id_to_str(cx: ctxt, node_id: ast::NodeId) -> ~str { +pub fn ReScope_id_to_str(cx: ctxt, node_id: ast::NodeId) -> ~str { match cx.items.find(&node_id) { Some(&ast_map::node_block(ref blk)) => { format!("", @@ -204,7 +204,7 @@ pub fn re_scope_id_to_str(cx: ctxt, node_id: ast::NodeId) -> ~str { format!("", node_id) } _ => { cx.sess.bug( - format!("re_scope refers to {}", + format!("ReScope refers to {}", ast_map::node_id_to_str(cx.items, node_id, token::get_ident_interner()))) } } @@ -229,16 +229,16 @@ pub fn region_to_str(cx: ctxt, prefix: &str, space: bool, region: Region) -> ~st // to fit that into a short string. Hence the recommendation to use // `explain_region()` or `note_and_explain_region()`. match region { - ty::re_scope(_) => prefix.to_str(), - ty::re_type_bound(_, _, ident) => cx.sess.str_of(ident).to_owned(), - ty::re_fn_bound(_, br) => bound_region_to_str(cx, prefix, space, br), - ty::re_free(ref fr) => bound_region_to_str(cx, prefix, space, fr.bound_region), - ty::re_infer(ReSkolemized(_, br)) => { + ty::ReScope(_) => prefix.to_str(), + ty::ReEarlyBound(_, _, ident) => cx.sess.str_of(ident).to_owned(), + ty::ReLateBound(_, br) => bound_region_to_str(cx, prefix, space, br), + ty::ReFree(ref fr) => bound_region_to_str(cx, prefix, space, fr.bound_region), + ty::ReInfer(ReSkolemized(_, br)) => { bound_region_to_str(cx, prefix, space, br) } - ty::re_infer(ReVar(_)) => prefix.to_str(), - ty::re_static => format!("{}'static{}", prefix, space_str), - ty::re_empty => format!("{}'{}", prefix, space_str) + ty::ReInfer(ReVar(_)) => prefix.to_str(), + ty::ReStatic => format!("{}'static{}", prefix, space_str), + ty::ReEmpty => format!("{}'{}", prefix, space_str) } } @@ -356,8 +356,8 @@ fn closure_to_str(cx: ctxt, cty: &ty::ClosureTy) -> ~str { }; match (cty.sigil, cty.region) { - (ast::ManagedSigil, ty::re_static) | - (ast::OwnedSigil, ty::re_static) => {} + (ast::ManagedSigil, ty::ReStatic) | + (ast::OwnedSigil, ty::ReStatic) => {} (_, region) => { s.push_str(region_to_str(cx, "", true, region)); @@ -689,14 +689,14 @@ fn repr(&self, tcx: ctxt) -> ~str { } } -impl Repr for ty::bound_region { +impl Repr for ty::BoundRegion { fn repr(&self, tcx: ctxt) -> ~str { match *self { - ty::br_anon(id) => format!("br_anon({})", id), - ty::br_named(id, ident) => format!("br_named({}, {})", + ty::BrAnon(id) => format!("BrAnon({})", id), + ty::BrNamed(id, ident) => format!("BrNamed({}, {})", id.repr(tcx), ident.repr(tcx)), - ty::br_fresh(id) => format!("br_fresh({})", id), + ty::BrFresh(id) => format!("BrFresh({})", id), } } } @@ -704,41 +704,41 @@ fn repr(&self, tcx: ctxt) -> ~str { impl Repr for ty::Region { fn repr(&self, tcx: ctxt) -> ~str { match *self { - ty::re_type_bound(id, index, ident) => { - format!("re_type_bound({}, {}, {})", + ty::ReEarlyBound(id, index, ident) => { + format!("ReEarlyBound({}, {}, {})", id, index, ident.repr(tcx)) } - ty::re_fn_bound(binder_id, ref bound_region) => { - format!("re_fn_bound({}, {})", + ty::ReLateBound(binder_id, ref bound_region) => { + format!("ReLateBound({}, {})", binder_id, bound_region.repr(tcx)) } - ty::re_free(ref fr) => { - format!("re_free({}, {})", + ty::ReFree(ref fr) => { + format!("ReFree({}, {})", fr.scope_id, fr.bound_region.repr(tcx)) } - ty::re_scope(id) => { - format!("re_scope({})", id) + ty::ReScope(id) => { + format!("ReScope({})", id) } - ty::re_static => { - format!("re_static") + ty::ReStatic => { + format!("ReStatic") } - ty::re_infer(ReVar(ref vid)) => { - format!("re_infer({})", vid.id) + ty::ReInfer(ReVar(ref vid)) => { + format!("ReInfer({})", vid.id) } - ty::re_infer(ReSkolemized(id, ref bound_region)) => { + ty::ReInfer(ReSkolemized(id, ref bound_region)) => { format!("re_skolemized({}, {})", id, bound_region.repr(tcx)) } - ty::re_empty => { - format!("re_empty") + ty::ReEmpty => { + format!("ReEmpty") } } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 6245c61dfa1..df9ab083bf2 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -254,8 +254,8 @@ pub enum Def { #[deriving(Clone, Eq, IterBytes, Encodable, Decodable, ToStr)] pub enum DefRegion { DefStaticRegion, - DefTypeBoundRegion(/* index */ uint, /* lifetime decl */ NodeId), - DefFnBoundRegion(/* binder_id */ NodeId, /* depth */ uint, /* lifetime decl */ NodeId), + DefEarlyBoundRegion(/* index */ uint, /* lifetime decl */ NodeId), + DefLateBoundRegion(/* binder_id */ NodeId, /* depth */ uint, /* lifetime decl */ NodeId), DefFreeRegion(/* block scope */ NodeId, /* lifetime decl */ NodeId), } -- GitLab