Skip to content

Commit 195f1d7

Browse files
committed
Rename and modernize region enum names
1 parent 5e54a73 commit 195f1d7

35 files changed

+316
-308
lines changed

src/librustc/metadata/tydecode.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,22 +228,22 @@ fn parse_region_substs(st: &mut PState, conv: conv_did) -> ty::RegionSubsts {
228228
}
229229
}
230230

231-
fn parse_bound_region(st: &mut PState, conv: conv_did) -> ty::bound_region {
231+
fn parse_bound_region(st: &mut PState, conv: conv_did) -> ty::BoundRegion {
232232
match next(st) {
233233
'a' => {
234234
let id = parse_uint(st);
235235
assert_eq!(next(st), '|');
236-
ty::br_anon(id)
236+
ty::BrAnon(id)
237237
}
238238
'[' => {
239239
let def = parse_def(st, RegionParameter, |x,y| conv(x,y));
240240
let ident = st.tcx.sess.ident_of(parse_str(st, ']'));
241-
ty::br_named(def, ident)
241+
ty::BrNamed(def, ident)
242242
}
243243
'f' => {
244244
let id = parse_uint(st);
245245
assert_eq!(next(st), '|');
246-
ty::br_fresh(id)
246+
ty::BrFresh(id)
247247
}
248248
_ => fail!("parse_bound_region: bad input")
249249
}
@@ -257,7 +257,7 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
257257
assert_eq!(next(st), '|');
258258
let br = parse_bound_region(st, |x,y| conv(x,y));
259259
assert_eq!(next(st), ']');
260-
ty::re_fn_bound(id, br)
260+
ty::ReLateBound(id, br)
261261
}
262262
'B' => {
263263
assert_eq!(next(st), '[');
@@ -266,27 +266,27 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
266266
let index = parse_uint(st);
267267
assert_eq!(next(st), '|');
268268
let nm = st.tcx.sess.ident_of(parse_str(st, ']'));
269-
ty::re_type_bound(node_id, index, nm)
269+
ty::ReEarlyBound(node_id, index, nm)
270270
}
271271
'f' => {
272272
assert_eq!(next(st), '[');
273273
let id = parse_uint(st) as int;
274274
assert_eq!(next(st), '|');
275275
let br = parse_bound_region(st, |x,y| conv(x,y));
276276
assert_eq!(next(st), ']');
277-
ty::re_free(ty::FreeRegion {scope_id: id,
277+
ty::ReFree(ty::FreeRegion {scope_id: id,
278278
bound_region: br})
279279
}
280280
's' => {
281281
let id = parse_uint(st) as int;
282282
assert_eq!(next(st), '|');
283-
ty::re_scope(id)
283+
ty::ReScope(id)
284284
}
285285
't' => {
286-
ty::re_static
286+
ty::ReStatic
287287
}
288288
'e' => {
289-
ty::re_static
289+
ty::ReStatic
290290
}
291291
_ => fail!("parse_region: bad input")
292292
}

src/librustc/metadata/tyencode.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,49 +155,49 @@ fn enc_region_substs(w: @mut MemWriter, cx: @ctxt, substs: &ty::RegionSubsts) {
155155

156156
fn enc_region(w: @mut MemWriter, cx: @ctxt, r: ty::Region) {
157157
match r {
158-
ty::re_fn_bound(id, br) => {
158+
ty::ReLateBound(id, br) => {
159159
mywrite!(w, "b[{}|", id);
160160
enc_bound_region(w, cx, br);
161161
mywrite!(w, "]");
162162
}
163-
ty::re_type_bound(node_id, index, ident) => {
163+
ty::ReEarlyBound(node_id, index, ident) => {
164164
mywrite!(w, "B[{}|{}|{}]",
165165
node_id,
166166
index,
167167
cx.tcx.sess.str_of(ident));
168168
}
169-
ty::re_free(ref fr) => {
169+
ty::ReFree(ref fr) => {
170170
mywrite!(w, "f[{}|", fr.scope_id);
171171
enc_bound_region(w, cx, fr.bound_region);
172172
mywrite!(w, "]");
173173
}
174-
ty::re_scope(nid) => {
174+
ty::ReScope(nid) => {
175175
mywrite!(w, "s{}|", nid);
176176
}
177-
ty::re_static => {
177+
ty::ReStatic => {
178178
mywrite!(w, "t");
179179
}
180-
ty::re_empty => {
180+
ty::ReEmpty => {
181181
mywrite!(w, "e");
182182
}
183-
ty::re_infer(_) => {
183+
ty::ReInfer(_) => {
184184
// these should not crop up after typeck
185185
cx.diag.handler().bug("Cannot encode region variables");
186186
}
187187
}
188188
}
189189

190-
fn enc_bound_region(w: @mut MemWriter, cx: @ctxt, br: ty::bound_region) {
190+
fn enc_bound_region(w: @mut MemWriter, cx: @ctxt, br: ty::BoundRegion) {
191191
match br {
192-
ty::br_anon(idx) => {
192+
ty::BrAnon(idx) => {
193193
mywrite!(w, "a{}|", idx);
194194
}
195-
ty::br_named(d, s) => {
195+
ty::BrNamed(d, s) => {
196196
mywrite!(w, "[{}|{}]",
197197
(cx.ds)(d),
198198
cx.tcx.sess.str_of(s));
199199
}
200-
ty::br_fresh(id) => {
200+
ty::BrFresh(id) => {
201201
mywrite!(w, "f{}|", id);
202202
}
203203
}

src/librustc/middle/astencode.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -476,27 +476,27 @@ impl tr for ty::AutoRef {
476476
impl tr for ty::Region {
477477
fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::Region {
478478
match *self {
479-
ty::re_fn_bound(id, br) => ty::re_fn_bound(xcx.tr_id(id),
479+
ty::ReLateBound(id, br) => ty::ReLateBound(xcx.tr_id(id),
480480
br.tr(xcx)),
481-
ty::re_type_bound(id, index, ident) => ty::re_type_bound(xcx.tr_id(id),
481+
ty::ReEarlyBound(id, index, ident) => ty::ReEarlyBound(xcx.tr_id(id),
482482
index,
483483
ident),
484-
ty::re_scope(id) => ty::re_scope(xcx.tr_id(id)),
485-
ty::re_empty | ty::re_static | ty::re_infer(*) => *self,
486-
ty::re_free(ref fr) => {
487-
ty::re_free(ty::FreeRegion {scope_id: xcx.tr_id(fr.scope_id),
484+
ty::ReScope(id) => ty::ReScope(xcx.tr_id(id)),
485+
ty::ReEmpty | ty::ReStatic | ty::ReInfer(*) => *self,
486+
ty::ReFree(ref fr) => {
487+
ty::ReFree(ty::FreeRegion {scope_id: xcx.tr_id(fr.scope_id),
488488
bound_region: fr.bound_region.tr(xcx)})
489489
}
490490
}
491491
}
492492
}
493493

494-
impl tr for ty::bound_region {
495-
fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::bound_region {
494+
impl tr for ty::BoundRegion {
495+
fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::BoundRegion {
496496
match *self {
497-
ty::br_anon(_) |
498-
ty::br_fresh(_) => *self,
499-
ty::br_named(id, ident) => ty::br_named(xcx.tr_def_id(id),
497+
ty::BrAnon(_) |
498+
ty::BrFresh(_) => *self,
499+
ty::BrNamed(id, ident) => ty::BrNamed(xcx.tr_def_id(id),
500500
ident),
501501
}
502502
}

src/librustc/middle/borrowck/gather_loans/lifetime.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl<'self> GuaranteeLifetimeContext<'self> {
199199

200200
// Make sure that the loan does not exceed the maximum time
201201
// that we can root the value, dynamically.
202-
let root_region = ty::re_scope(self.root_scope_id);
202+
let root_region = ty::ReScope(self.root_scope_id);
203203
if !self.bccx.is_subregion_of(self.loan_region, root_region) {
204204
self.report_error(
205205
err_out_of_root_scope(root_region, self.loan_region));
@@ -208,9 +208,9 @@ impl<'self> GuaranteeLifetimeContext<'self> {
208208

209209
// Extract the scope id that indicates how long the rooting is required
210210
let root_scope = match self.loan_region {
211-
ty::re_scope(id) => id,
211+
ty::ReScope(id) => id,
212212
_ => {
213-
// the check above should fail for anything is not re_scope
213+
// the check above should fail for anything is not ReScope
214214
self.bccx.tcx.sess.span_bug(
215215
cmt_base.span,
216216
format!("Cannot issue root for scope region: {:?}",
@@ -260,12 +260,12 @@ impl<'self> GuaranteeLifetimeContext<'self> {
260260
note_and_explain_region(
261261
self.bccx.tcx,
262262
"managed value only needs to be frozen for ",
263-
ty::re_scope(root_scope),
263+
ty::ReScope(root_scope),
264264
"...");
265265
note_and_explain_region(
266266
self.bccx.tcx,
267267
"...but due to Issue #6248, it will be frozen for ",
268-
ty::re_scope(cleanup_scope),
268+
ty::ReScope(cleanup_scope),
269269
"");
270270
}
271271

@@ -324,21 +324,21 @@ impl<'self> GuaranteeLifetimeContext<'self> {
324324

325325
match cmt.cat {
326326
mc::cat_rvalue(cleanup_scope_id) => {
327-
ty::re_scope(cleanup_scope_id)
327+
ty::ReScope(cleanup_scope_id)
328328
}
329329
mc::cat_copied_upvar(_) => {
330-
ty::re_scope(self.item_scope_id)
330+
ty::ReScope(self.item_scope_id)
331331
}
332332
mc::cat_static_item => {
333-
ty::re_static
333+
ty::ReStatic
334334
}
335335
mc::cat_local(local_id) |
336336
mc::cat_arg(local_id) |
337337
mc::cat_self(local_id) => {
338338
self.bccx.tcx.region_maps.encl_region(local_id)
339339
}
340340
mc::cat_deref(_, _, mc::unsafe_ptr(*)) => {
341-
ty::re_static
341+
ty::ReStatic
342342
}
343343
mc::cat_deref(_, _, mc::region_ptr(_, r)) => {
344344
r

src/librustc/middle/borrowck/gather_loans/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ fn gather_loans_in_expr(this: &mut GatherLoanCtxt,
277277
// Currently these do not use adjustments, so we have to
278278
// hardcode this check here (note that the receiver DOES use
279279
// adjustments).
280-
let scope_r = ty::re_scope(ex.id);
280+
let scope_r = ty::ReScope(ex.id);
281281
let arg_cmt = this.bccx.cat_expr(arg);
282282
this.guarantee_valid(arg.id,
283283
arg.span,
@@ -441,7 +441,7 @@ impl<'self> GatherLoanCtxt<'self> {
441441

442442
// a loan for the empty region can never be dereferenced, so
443443
// it is always safe
444-
if loan_region == ty::re_empty {
444+
if loan_region == ty::ReEmpty {
445445
return;
446446
}
447447

@@ -470,10 +470,10 @@ impl<'self> GatherLoanCtxt<'self> {
470470

471471
restrictions::SafeIf(loan_path, restrictions) => {
472472
let loan_scope = match loan_region {
473-
ty::re_scope(id) => id,
474-
ty::re_free(ref fr) => fr.scope_id,
473+
ty::ReScope(id) => id,
474+
ty::ReFree(ref fr) => fr.scope_id,
475475

476-
ty::re_static => {
476+
ty::ReStatic => {
477477
// If we get here, an error must have been
478478
// reported in
479479
// `lifetime::guarantee_lifetime()`, because
@@ -485,10 +485,10 @@ impl<'self> GatherLoanCtxt<'self> {
485485
return;
486486
}
487487

488-
ty::re_empty |
489-
ty::re_fn_bound(*) |
490-
ty::re_type_bound(*) |
491-
ty::re_infer(*) => {
488+
ty::ReEmpty |
489+
ty::ReLateBound(*) |
490+
ty::ReEarlyBound(*) |
491+
ty::ReInfer(*) => {
492492
self.tcx().sess.span_bug(
493493
cmt.span,
494494
format!("Invalid borrow lifetime: {:?}", loan_region));
@@ -715,7 +715,7 @@ impl<'self> GatherLoanCtxt<'self> {
715715
let cmt_discr = match arm_match_ids {
716716
None => cmt,
717717
Some((arm_id, match_id)) => {
718-
let arm_scope = ty::re_scope(arm_id);
718+
let arm_scope = ty::ReScope(arm_id);
719719
if self.bccx.is_subregion_of(scope_r, arm_scope) {
720720
self.bccx.cat_discr(cmt, match_id)
721721
} else {

src/librustc/middle/kind.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ pub fn check_cast_for_escaping_regions(
545545
// Check, based on the region associated with the trait, whether it can
546546
// possibly escape the enclosing fn item (note that all type parameters
547547
// must have been declared on the enclosing fn item).
548-
if target_regions.iter().any(|r| is_re_scope(*r)) {
548+
if target_regions.iter().any(|r| is_ReScope(*r)) {
549549
return; /* case (1) */
550550
}
551551

@@ -584,9 +584,9 @@ pub fn check_cast_for_escaping_regions(
584584
}
585585
});
586586

587-
fn is_re_scope(r: ty::Region) -> bool {
587+
fn is_ReScope(r: ty::Region) -> bool {
588588
match r {
589-
ty::re_scope(*) => true,
589+
ty::ReScope(*) => true,
590590
_ => false
591591
}
592592
}

src/librustc/middle/region.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl RegionMaps {
137137
pub fn encl_region(&self, id: ast::NodeId) -> ty::Region {
138138
//! Returns the narrowest scope region that encloses `id`, if any.
139139
140-
ty::re_scope(self.encl_scope(id))
140+
ty::ReScope(self.encl_scope(id))
141141
}
142142

143143
pub fn scopes_intersect(&self, scope1: ast::NodeId, scope2: ast::NodeId)
@@ -227,19 +227,19 @@ impl RegionMaps {
227227

228228
sub_region == super_region || {
229229
match (sub_region, super_region) {
230-
(_, ty::re_static) => {
230+
(_, ty::ReStatic) => {
231231
true
232232
}
233233

234-
(ty::re_scope(sub_scope), ty::re_scope(super_scope)) => {
234+
(ty::ReScope(sub_scope), ty::ReScope(super_scope)) => {
235235
self.is_subscope_of(sub_scope, super_scope)
236236
}
237237

238-
(ty::re_scope(sub_scope), ty::re_free(ref fr)) => {
238+
(ty::ReScope(sub_scope), ty::ReFree(ref fr)) => {
239239
self.is_subscope_of(sub_scope, fr.scope_id)
240240
}
241241

242-
(ty::re_free(sub_fr), ty::re_free(super_fr)) => {
242+
(ty::ReFree(sub_fr), ty::ReFree(super_fr)) => {
243243
self.sub_free_region(sub_fr, super_fr)
244244
}
245245

src/librustc/middle/resolve_lifetime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl LifetimeContext {
176176
ItemScope(lifetimes) => {
177177
match search_lifetimes(lifetimes, lifetime_ref) {
178178
Some((index, decl_id)) => {
179-
let def = ast::DefTypeBoundRegion(index, decl_id);
179+
let def = ast::DefEarlyBoundRegion(index, decl_id);
180180
self.insert_lifetime(lifetime_ref, def);
181181
return;
182182
}
@@ -189,7 +189,7 @@ impl LifetimeContext {
189189
FnScope(id, lifetimes, s) => {
190190
match search_lifetimes(lifetimes, lifetime_ref) {
191191
Some((_index, decl_id)) => {
192-
let def = ast::DefFnBoundRegion(id, depth, decl_id);
192+
let def = ast::DefLateBoundRegion(id, depth, decl_id);
193193
self.insert_lifetime(lifetime_ref, def);
194194
return;
195195
}

src/librustc/middle/subst.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ impl Subst for ty::Region {
193193
// the specialized routine
194194
// `middle::typeck::check::regionmanip::replace_bound_regions_in_fn_sig()`.
195195
match self {
196-
&ty::re_type_bound(_, i, _) => {
196+
&ty::ReEarlyBound(_, i, _) => {
197197
match substs.regions {
198-
ty::ErasedRegions => ty::re_static,
198+
ty::ErasedRegions => ty::ReStatic,
199199
ty::NonerasedRegions(ref regions) => *regions.get(i),
200200
}
201201
}

src/librustc/middle/trans/_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ fn extract_vec_elems(bcx: @mut Block,
10481048
let slice_len = Sub(bcx, len, slice_len_offset);
10491049
let slice_ty = ty::mk_evec(bcx.tcx(),
10501050
ty::mt {ty: vt.unit_ty, mutbl: ast::MutImmutable},
1051-
ty::vstore_slice(ty::re_static)
1051+
ty::vstore_slice(ty::ReStatic)
10521052
);
10531053
let scratch = scratch_datum(bcx, slice_ty, "", false);
10541054
Store(bcx, slice_begin,
@@ -1697,7 +1697,7 @@ fn compile_submatch_continue(mut bcx: @mut Block,
16971697
let t = node_id_type(bcx, pat_id);
16981698
let Result {bcx: after_cx, val: matches} = {
16991699
do with_scope_result(bcx, None,
1700-
"compare_scope") |bcx| {
1700+
"compaReScope") |bcx| {
17011701
match trans_opt(bcx, opt) {
17021702
single_result(
17031703
Result {bcx, val}) => {

0 commit comments

Comments
 (0)