Skip to content

Commit 7586232

Browse files
committed
Rename tail to rest
1 parent b126c74 commit 7586232

File tree

11 files changed

+74
-74
lines changed

11 files changed

+74
-74
lines changed

src/librustc/middle/borrowck/gather_loans.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -592,17 +592,17 @@ impl GatherLoanCtxt {
592592
}
593593
}
594594

595-
ast::pat_vec(_, Some(tail_pat)) => {
596-
// The `tail_pat` here creates a slice into the
595+
ast::pat_vec(_, Some(rest_pat)) => {
596+
// The `rest_pat` here creates a slice into the
597597
// original vector. This is effectively a borrow of
598598
// the elements of the vector being matched.
599599

600-
let tail_ty = self.tcx().ty(tail_pat);
601-
let (tail_mutbl, tail_r) =
602-
self.vec_slice_info(tail_pat, tail_ty);
600+
let rest_ty = self.tcx().ty(rest_pat);
601+
let (rest_mutbl, rest_r) =
602+
self.vec_slice_info(rest_pat, rest_ty);
603603
let mcx = self.bccx.mc_ctxt();
604-
let cmt_index = mcx.cat_index(tail_pat, cmt);
605-
self.guarantee_valid(cmt_index, tail_mutbl, tail_r);
604+
let cmt_index = mcx.cat_index(rest_pat, cmt);
605+
self.guarantee_valid(cmt_index, rest_mutbl, rest_r);
606606
}
607607

608608
_ => {}
@@ -612,7 +612,7 @@ impl GatherLoanCtxt {
612612

613613
fn vec_slice_info(@mut self,
614614
pat: @ast::pat,
615-
tail_ty: ty::t) -> (ast::mutability, ty::Region) {
615+
rest_ty: ty::t) -> (ast::mutability, ty::Region) {
616616
/*!
617617
*
618618
* In a pattern like [a, b, ..c], normally `c` has slice type,
@@ -621,9 +621,9 @@ impl GatherLoanCtxt {
621621
* to recurse through rptrs.
622622
*/
623623

624-
match ty::get(tail_ty).sty {
625-
ty::ty_evec(tail_mt, ty::vstore_slice(tail_r)) => {
626-
(tail_mt.mutbl, tail_r)
624+
match ty::get(rest_ty).sty {
625+
ty::ty_evec(rest_mt, ty::vstore_slice(rest_r)) => {
626+
(rest_mt.mutbl, rest_r)
627627
}
628628

629629
ty::ty_rptr(_, ref mt) => {
@@ -633,7 +633,7 @@ impl GatherLoanCtxt {
633633
_ => {
634634
self.tcx().sess.span_bug(
635635
pat.span,
636-
fmt!("Type of tail pattern is not a slice"));
636+
fmt!("Type of rest pattern is not a slice"));
637637
}
638638
}
639639
}

src/librustc/middle/check_match.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ pub fn pat_ctor_id(cx: @MatchCheckCtxt, p: @pat) -> Option<ctor> {
315315
pat_region(*) => {
316316
Some(single)
317317
}
318-
pat_vec(elems, tail) => {
319-
match tail {
318+
pat_vec(elems, rest) => {
319+
match rest {
320320
Some(_) => None,
321321
None => Some(vec(elems.len()))
322322
}
@@ -386,47 +386,47 @@ pub fn missing_ctor(cx: @MatchCheckCtxt,
386386
}
387387
ty::ty_unboxed_vec(*) | ty::ty_evec(*) => {
388388
389-
// Find the lengths and tails of all vector patterns.
389+
// Find the lengths and rests of all vector patterns.
390390
let vec_pat_lens = do m.filter_mapped |r| {
391391
match r[0].node {
392-
pat_vec(ref elems, ref tail) => {
393-
Some((elems.len(), tail.is_some()))
392+
pat_vec(ref elems, ref rest) => {
393+
Some((elems.len(), rest.is_some()))
394394
}
395395
_ => None
396396
}
397397
};
398398
399399
// Sort them by length such that for patterns of the same length,
400-
// those with a destructured tail come first.
400+
// those with a destructured rest come first.
401401
let mut sorted_vec_lens = sort::merge_sort(vec_pat_lens,
402-
|&(len1, tail1), &(len2, tail2)| {
402+
|&(len1, rest1), &(len2, rest2)| {
403403
if len1 == len2 {
404-
tail1 > tail2
404+
rest1 > rest2
405405
} else {
406406
len1 <= len2
407407
}
408408
}
409409
);
410410
vec::dedup(&mut sorted_vec_lens);
411411
412-
let mut found_tail = false;
412+
let mut found_rest = false;
413413
let mut next = 0;
414414
let mut missing = None;
415-
for sorted_vec_lens.each |&(length, tail)| {
415+
for sorted_vec_lens.each |&(length, rest)| {
416416
if length != next {
417417
missing = Some(next);
418418
break;
419419
}
420-
if tail {
421-
found_tail = true;
420+
if rest {
421+
found_rest = true;
422422
break;
423423
}
424424
next += 1;
425425
}
426426
427427
// We found patterns of all lengths within <0, next), yet there was no
428-
// pattern with a tail - therefore, we report vec(next) as missing.
429-
if !found_tail {
428+
// pattern with a rest - therefore, we report vec(next) as missing.
429+
if !found_rest {
430430
missing = Some(next);
431431
}
432432
match missing {
@@ -613,11 +613,11 @@ pub fn specialize(cx: @MatchCheckCtxt,
613613
compare_const_vals(c_hi, v_hi) <= 0;
614614
if match_ { Some(vec::tail(r)) } else { None }
615615
}
616-
pat_vec(elems, tail) => {
616+
pat_vec(elems, rest) => {
617617
match ctor_id {
618618
vec(_) => {
619619
let num_elements = elems.len();
620-
if num_elements < arity && tail.is_some() {
620+
if num_elements < arity && rest.is_some() {
621621
Some(vec::append(
622622
vec::append(elems, vec::from_elem(
623623
arity - num_elements, wild()

src/librustc/middle/mem_categorization.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -882,16 +882,16 @@ pub impl &mem_categorization_ctxt {
882882
self.cat_pattern(subcmt, subpat, op);
883883
}
884884

885-
ast::pat_vec(ref pats, opt_tail_pat) => {
885+
ast::pat_vec(ref pats, opt_rest_pat) => {
886886
for pats.each |pat| {
887887
let elt_cmt = self.cat_index(*pat, cmt);
888888
self.cat_pattern(elt_cmt, *pat, op);
889889
}
890890

891-
for opt_tail_pat.each |tail_pat| {
892-
let tail_ty = self.tcx.ty(*tail_pat);
893-
let tail_cmt = self.cat_rvalue(*tail_pat, tail_ty);
894-
self.cat_pattern(tail_cmt, *tail_pat, op);
891+
for opt_rest_pat.each |rest_pat| {
892+
let rest_ty = self.tcx.ty(*rest_pat);
893+
let rest_cmt = self.cat_rvalue(*rest_pat, rest_ty);
894+
self.cat_pattern(rest_cmt, *rest_pat, op);
895895
}
896896
}
897897

src/librustc/middle/trans/_match.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,11 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
564564
None
565565
}
566566
}
567-
ast::pat_vec(elems, tail) => {
568-
match tail {
567+
ast::pat_vec(elems, rest) => {
568+
match rest {
569569
Some(_) => {
570570
if opt_eq(tcx, &vec_len_ge(elems.len()), opt) {
571-
Some(vec::append_one(elems, tail.get()))
571+
Some(vec::append_one(elems, rest.get()))
572572
} else {
573573
None
574574
}
@@ -805,8 +805,8 @@ pub fn get_options(ccx: @crate_ctxt, m: &[@Match], col: uint) -> ~[Opt] {
805805
ast::pat_range(l1, l2) => {
806806
add_to_set(ccx.tcx, &found, range(l1, l2));
807807
}
808-
ast::pat_vec(elems, tail) => {
809-
let opt = match tail {
808+
ast::pat_vec(elems, rest) => {
809+
let opt = match rest {
810810
None => vec_len_eq(elems.len()),
811811
Some(_) => vec_len_ge(elems.len())
812812
};
@@ -853,7 +853,7 @@ pub fn extract_variant_args(bcx: block,
853853
pub fn extract_vec_elems(bcx: block,
854854
pat_id: ast::node_id,
855855
elem_count: uint,
856-
tail: bool,
856+
rest: bool,
857857
val: ValueRef)
858858
-> {vals: ~[ValueRef], bcx: block} {
859859
let _icx = bcx.insn_ctxt("match::extract_vec_elems");
@@ -864,21 +864,21 @@ pub fn extract_vec_elems(bcx: block,
864864
let mut elems = do vec::from_fn(elem_count) |i| {
865865
GEPi(bcx, base, ~[i])
866866
};
867-
if tail {
868-
let tail_offset = Mul(bcx, vt.llunit_size,
867+
if rest {
868+
let rest_offset = Mul(bcx, vt.llunit_size,
869869
C_int(bcx.ccx(), elem_count as int)
870870
);
871-
let tail_begin = tvec::pointer_add(bcx, base, tail_offset);
872-
let tail_len = Sub(bcx, len, tail_offset);
873-
let tail_ty = ty::mk_evec(bcx.tcx(),
871+
let rest_begin = tvec::pointer_add(bcx, base, rest_offset);
872+
let rest_len = Sub(bcx, len, rest_offset);
873+
let rest_ty = ty::mk_evec(bcx.tcx(),
874874
ty::mt {ty: vt.unit_ty, mutbl: ast::m_imm},
875875
ty::vstore_slice(ty::re_static)
876876
);
877-
let scratch = scratch_datum(bcx, tail_ty, false);
878-
Store(bcx, tail_begin,
877+
let scratch = scratch_datum(bcx, rest_ty, false);
878+
Store(bcx, rest_begin,
879879
GEPi(bcx, scratch.val, [0u, abi::slice_elt_base])
880880
);
881-
Store(bcx, tail_len,
881+
Store(bcx, rest_len,
882882
GEPi(bcx, scratch.val, [0u, abi::slice_elt_len])
883883
);
884884
elems.push(scratch.val);
@@ -1524,11 +1524,11 @@ pub fn compile_submatch(bcx: block,
15241524
opt_cx = args.bcx;
15251525
}
15261526
vec_len_eq(n) | vec_len_ge(n) => {
1527-
let tail = match *opt {
1527+
let rest = match *opt {
15281528
vec_len_ge(_) => true,
15291529
_ => false
15301530
};
1531-
let args = extract_vec_elems(opt_cx, pat_id, n, tail, val);
1531+
let args = extract_vec_elems(opt_cx, pat_id, n, rest, val);
15321532
size = args.vals.len();
15331533
unpacked = /*bad*/copy args.vals;
15341534
opt_cx = args.bcx;

src/librustc/middle/typeck/check/_match.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
536536
}
537537
}
538538
}
539-
ast::pat_vec(elts, tail) => {
539+
ast::pat_vec(elts, rest) => {
540540
let default_region_var =
541541
fcx.infcx().next_region_var_with_lb(
542542
pat.span, pcx.block_region
@@ -570,13 +570,13 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
570570
}
571571
fcx.write_ty(pat.id, expected);
572572

573-
match tail {
574-
Some(tail_pat) => {
573+
match rest {
574+
Some(rest_pat) => {
575575
let slice_ty = ty::mk_evec(tcx,
576576
ty::mt {ty: elt_type.ty, mutbl: elt_type.mutbl},
577577
ty::vstore_slice(region_var)
578578
);
579-
check_pat(pcx, tail_pat, slice_ty);
579+
check_pat(pcx, rest_pat, slice_ty);
580580
}
581581
None => ()
582582
}

src/librustc/middle/typeck/check/regionck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ pub mod guarantor {
882882
}
883883
ast::pat_lit(*) => {}
884884
ast::pat_range(*) => {}
885-
ast::pat_vec(ref ps, ref opt_tail_pat) => {
885+
ast::pat_vec(ref ps, ref opt_rest_pat) => {
886886
let vec_ty = rcx.resolve_node_type(pat.id);
887887
if !ty::type_contains_err(vec_ty) {
888888
let vstore = ty::ty_vstore(vec_ty);
@@ -894,7 +894,7 @@ pub mod guarantor {
894894

895895
link_ref_bindings_in_pats(rcx, ps, guarantor1);
896896

897-
for opt_tail_pat.each |p| {
897+
for opt_rest_pat.each |p| {
898898
link_ref_bindings_in_pat(rcx, *p, guarantor);
899899
}
900900
}

src/libsyntax/ast_util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,12 +552,12 @@ pub fn walk_pat(pat: @pat, it: fn(@pat)) {
552552
pat_box(s) | pat_uniq(s) | pat_region(s) => {
553553
walk_pat(s, it)
554554
}
555-
pat_vec(elts, tail) => {
555+
pat_vec(elts, rest) => {
556556
for elts.each |p| {
557557
walk_pat(*p, it)
558558
}
559-
do option::iter(&tail) |tail| {
560-
walk_pat(*tail, it)
559+
do option::iter(&rest) |rest| {
560+
walk_pat(*rest, it)
561561
}
562562
}
563563
pat_wild | pat_lit(_) | pat_range(_, _) | pat_ident(_, _, _) |

src/libsyntax/fold.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ pub fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
376376
pat_range(e1, e2) => {
377377
pat_range(fld.fold_expr(e1), fld.fold_expr(e2))
378378
},
379-
pat_vec(elts, tail) => pat_vec(
379+
pat_vec(elts, rest) => pat_vec(
380380
vec::map(elts, |x| fld.fold_pat(*x)),
381-
option::map(&tail, |tail| fld.fold_pat(*tail))
381+
option::map(&rest, |rest| fld.fold_pat(*rest))
382382
)
383383
};
384384
}

src/libsyntax/parse/parser.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,35 +1885,35 @@ pub impl Parser {
18851885
18861886
fn parse_pat_vec_elements(refutable: bool) -> (~[@pat], Option<@pat>) {
18871887
let mut elements = ~[];
1888-
let mut tail = None;
1888+
let mut rest = None;
18891889
let mut first = true;
18901890
18911891
while self.token != token::RBRACKET {
18921892
if first { first = false; }
18931893
else { self.expect(token::COMMA); }
18941894
1895-
let mut is_tail = false;
1895+
let mut is_rest = false;
18961896
if self.token == token::DOTDOT {
18971897
self.bump();
1898-
is_tail = true;
1898+
is_rest = true;
18991899
}
19001900
19011901
let subpat = self.parse_pat(refutable);
1902-
if is_tail {
1902+
if is_rest {
19031903
match subpat {
19041904
@ast::pat { node: pat_wild, _ } => (),
19051905
@ast::pat { node: pat_ident(_, _, _), _ } => (),
19061906
@ast::pat { span, _ } => self.span_fatal(
19071907
span, ~"expected an identifier or `_`"
19081908
)
19091909
}
1910-
tail = Some(subpat);
1910+
rest = Some(subpat);
19111911
break;
19121912
}
19131913

19141914
elements.push(subpat);
19151915
}
1916-
return (elements, tail);
1916+
return (elements, rest);
19171917
}
19181918

19191919
fn parse_pat_fields(refutable: bool) -> (~[ast::field_pat], bool) {
@@ -2066,10 +2066,10 @@ pub impl Parser {
20662066
}
20672067
token::LBRACKET => {
20682068
self.bump();
2069-
let (elements, tail) = self.parse_pat_vec_elements(refutable);
2069+
let (elements, rest) = self.parse_pat_vec_elements(refutable);
20702070
hi = self.span.hi;
20712071
self.expect(token::RBRACKET);
2072-
pat = ast::pat_vec(elements, tail);
2072+
pat = ast::pat_vec(elements, rest);
20732073
}
20742074
copy tok => {
20752075
if !is_ident_or_path(tok)

src/libsyntax/print/pprust.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,13 +1653,13 @@ pub fn print_pat(s: @ps, &&pat: @ast::pat, refutable: bool) {
16531653
word(s.s, ~"..");
16541654
print_expr(s, end);
16551655
}
1656-
ast::pat_vec(elts, tail) => {
1656+
ast::pat_vec(elts, rest) => {
16571657
word(s.s, ~"[");
16581658
commasep(s, inconsistent, elts, |s, p| print_pat(s, p, refutable));
1659-
do option::iter(&tail) |tail| {
1659+
do option::iter(&rest) |rest| {
16601660
if vec::len(elts) != 0u { word_space(s, ~","); }
16611661
word(s.s, ~"..");
1662-
print_pat(s, *tail, refutable);
1662+
print_pat(s, *rest, refutable);
16631663
}
16641664
word(s.s, ~"]");
16651665
}

0 commit comments

Comments
 (0)