Skip to content

Commit 7c48e53

Browse files
eddybalexcrichton
authored andcommitted
syntax: remove obsolete mutability from ExprVec and ExprRepeat.
1 parent b236f45 commit 7c48e53

File tree

19 files changed

+54
-67
lines changed

19 files changed

+54
-67
lines changed

src/librustc/front/test.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -404,21 +404,17 @@ fn is_test_crate(krate: &ast::Crate) -> bool {
404404
}
405405

406406
fn mk_test_descs(cx: &TestCtxt) -> @ast::Expr {
407-
let mut descs = Vec::new();
408407
debug!("building test vector from {} tests", cx.testfns.borrow().len());
409-
for test in cx.testfns.borrow().iter() {
410-
descs.push(mk_test_desc_and_fn_rec(cx, test));
411-
}
412-
413-
let inner_expr = @ast::Expr {
414-
id: ast::DUMMY_NODE_ID,
415-
node: ast::ExprVec(descs, ast::MutImmutable),
416-
span: DUMMY_SP,
417-
};
418408

419409
@ast::Expr {
420410
id: ast::DUMMY_NODE_ID,
421-
node: ast::ExprVstore(inner_expr, ast::ExprVstoreSlice),
411+
node: ast::ExprVstore(@ast::Expr {
412+
id: ast::DUMMY_NODE_ID,
413+
node: ast::ExprVec(cx.testfns.borrow().iter().map(|test| {
414+
mk_test_desc_and_fn_rec(cx, test)
415+
}).collect()),
416+
span: DUMMY_SP,
417+
}, ast::ExprVstoreSlice),
422418
span: DUMMY_SP,
423419
}
424420
}

src/librustc/middle/cfg/construct.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ impl<'a> CFGBuilder<'a> {
347347
self.add_node(expr.id, [])
348348
}
349349

350-
ast::ExprVec(ref elems, _) => {
350+
ast::ExprVec(ref elems) => {
351351
self.straightline(expr, pred, elems.as_slice())
352352
}
353353

@@ -379,7 +379,7 @@ impl<'a> CFGBuilder<'a> {
379379
self.straightline(expr, base_exit, field_exprs.as_slice())
380380
}
381381

382-
ast::ExprRepeat(elem, count, _) => {
382+
ast::ExprRepeat(elem, count) => {
383383
self.straightline(expr, pred, [elem, count])
384384
}
385385

src/librustc/middle/check_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr, is_const: bool) {
157157
}
158158
ExprVstore(_, ExprVstoreMutSlice) |
159159
ExprVstore(_, ExprVstoreSlice) |
160-
ExprVec(_, MutImmutable) |
160+
ExprVec(_) |
161161
ExprAddrOf(MutImmutable, _) |
162162
ExprParen(..) |
163163
ExprField(..) |

src/librustc/middle/const_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl<'a> ConstEvalVisitor<'a> {
213213
join(self.classify(a), self.classify(b)),
214214

215215
ast::ExprTup(ref es) |
216-
ast::ExprVec(ref es, ast::MutImmutable) =>
216+
ast::ExprVec(ref es) =>
217217
join_all(es.iter().map(|e| self.classify(*e))),
218218

219219
ast::ExprVstore(e, vstore) => {

src/librustc/middle/dataflow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,11 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> {
538538
self.walk_expr(l, in_out, loop_scopes);
539539
}
540540

541-
ast::ExprVec(ref exprs, _) => {
541+
ast::ExprVec(ref exprs) => {
542542
self.walk_exprs(exprs.as_slice(), in_out, loop_scopes)
543543
}
544544

545-
ast::ExprRepeat(l, r, _) => {
545+
ast::ExprRepeat(l, r) => {
546546
self.walk_expr(l, in_out, loop_scopes);
547547
self.walk_expr(r, in_out, loop_scopes);
548548
}

src/librustc/middle/kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ pub fn check_expr(cx: &mut Context, e: &Expr) {
309309
let target_ty = ty::expr_ty(cx.tcx, e);
310310
check_trait_cast(cx, source_ty, target_ty, source.span);
311311
}
312-
ExprRepeat(element, count_expr, _) => {
312+
ExprRepeat(element, count_expr) => {
313313
let count = ty::eval_repeat_count(cx.tcx, count_expr);
314314
if count > 1 {
315315
let element_ty = ty::expr_ty(cx.tcx, element);

src/librustc/middle/liveness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,11 +1109,11 @@ impl<'a> Liveness<'a> {
11091109
self.propagate_through_expr(expr, succ)
11101110
}
11111111

1112-
ExprVec(ref exprs, _) => {
1112+
ExprVec(ref exprs) => {
11131113
self.propagate_through_exprs(exprs.as_slice(), succ)
11141114
}
11151115

1116-
ExprRepeat(element, count, _) => {
1116+
ExprRepeat(element, count) => {
11171117
let succ = self.propagate_through_expr(count, succ);
11181118
self.propagate_through_expr(element, succ)
11191119
}

src/librustc/middle/moves.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ impl<'a> VisitContext<'a> {
473473
self.use_expr(base, expr_mode);
474474
}
475475

476-
ExprVec(ref exprs, _) => {
476+
ExprVec(ref exprs) => {
477477
self.consume_exprs(exprs.as_slice());
478478
}
479479

@@ -539,7 +539,7 @@ impl<'a> VisitContext<'a> {
539539
// }
540540
}
541541

542-
ExprRepeat(base, count, _) => {
542+
ExprRepeat(base, count) => {
543543
self.consume_expr(base);
544544
self.consume_expr(count);
545545
}

src/librustc/middle/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor,
724724
visitor.region_maps.record_rvalue_scope(subexpr.id, blk_id);
725725
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id);
726726
}
727-
ast::ExprVec(ref subexprs, _) |
727+
ast::ExprVec(ref subexprs) |
728728
ast::ExprTup(ref subexprs) => {
729729
for &subexpr in subexprs.iter() {
730730
record_rvalue_scope_if_borrow_expr(

src/librustc/middle/trans/consts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
557557
inlineable.iter().fold(true, |a, &b| a && b))
558558
})
559559
}
560-
ast::ExprVec(ref es, ast::MutImmutable) => {
560+
ast::ExprVec(ref es) => {
561561
let (v, _, inlineable) = const_vec(cx,
562562
e,
563563
es.as_slice(),
@@ -573,7 +573,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
573573
_ => { cx.sess().span_bug(e.span, "bad const-slice lit") }
574574
}
575575
}
576-
ast::ExprVec(ref es, ast::MutImmutable) => {
576+
ast::ExprVec(ref es) => {
577577
let (cv, llunitty, _) = const_vec(cx,
578578
e,
579579
es.as_slice(),
@@ -592,7 +592,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
592592
_ => cx.sess().span_bug(e.span, "bad const-slice expr")
593593
}
594594
}
595-
ast::ExprRepeat(elem, count, _) => {
595+
ast::ExprRepeat(elem, count) => {
596596
let vec_ty = ty::expr_ty(cx.tcx(), e);
597597
let unit_ty = ty::sequence_element_type(cx.tcx(), vec_ty);
598598
let llunitty = type_of::type_of(cx, unit_ty);

src/librustc/middle/trans/debuginfo.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,15 +2619,15 @@ fn populate_scope_map(cx: &CrateContext,
26192619
walk_expr(cx, rhs, scope_stack, scope_map);
26202620
}
26212621

2622-
ast::ExprVec(ref init_expressions, _) |
2623-
ast::ExprTup(ref init_expressions) => {
2622+
ast::ExprVec(ref init_expressions) |
2623+
ast::ExprTup(ref init_expressions) => {
26242624
for ie in init_expressions.iter() {
26252625
walk_expr(cx, *ie, scope_stack, scope_map);
26262626
}
26272627
}
26282628

2629-
ast::ExprAssign(sub_exp1, sub_exp2) |
2630-
ast::ExprRepeat(sub_exp1, sub_exp2, _) => {
2629+
ast::ExprAssign(sub_exp1, sub_exp2) |
2630+
ast::ExprRepeat(sub_exp1, sub_exp2) => {
26312631
walk_expr(cx, sub_exp1, scope_stack, scope_map);
26322632
walk_expr(cx, sub_exp2, scope_stack, scope_map);
26332633
}

src/librustc/middle/trans/tvec.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ pub fn write_content<'a>(
392392
}
393393
}
394394
}
395-
ast::ExprVec(ref elements, _) => {
395+
ast::ExprVec(ref elements) => {
396396
match dest {
397397
Ignore => {
398398
for element in elements.iter() {
@@ -418,7 +418,7 @@ pub fn write_content<'a>(
418418
}
419419
return bcx;
420420
}
421-
ast::ExprRepeat(element, count_expr, _) => {
421+
ast::ExprRepeat(element, count_expr) => {
422422
match dest {
423423
Ignore => {
424424
return expr::trans_into(bcx, element, Ignore);
@@ -486,8 +486,8 @@ pub fn elements_required(bcx: &Block, content_expr: &ast::Expr) -> uint {
486486
}
487487
}
488488
},
489-
ast::ExprVec(ref es, _) => es.len(),
490-
ast::ExprRepeat(_, count_expr, _) => {
489+
ast::ExprVec(ref es) => es.len(),
490+
ast::ExprRepeat(_, count_expr) => {
491491
ty::eval_repeat_count(bcx.tcx(), count_expr)
492492
}
493493
_ => bcx.tcx().sess.span_bug(content_expr.span,

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2482,13 +2482,13 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
24822482
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
24832483
ty::mk_str(tcx, tt)
24842484
}
2485-
ast::ExprVec(ref args, mutbl) => {
2485+
ast::ExprVec(ref args) => {
24862486
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
24872487
let mut any_error = false;
24882488
let mut any_bot = false;
24892489
let mutability = match vst {
24902490
ast::ExprVstoreMutSlice => ast::MutMutable,
2491-
_ => mutbl,
2491+
_ => ast::MutImmutable,
24922492
};
24932493
let t: ty::t = fcx.infcx().next_ty_var();
24942494
for e in args.iter() {
@@ -2509,13 +2509,13 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
25092509
ty::mk_vec(tcx, ty::mt {ty: t, mutbl: mutability}, tt)
25102510
}
25112511
}
2512-
ast::ExprRepeat(element, count_expr, mutbl) => {
2512+
ast::ExprRepeat(element, count_expr) => {
25132513
check_expr_with_hint(fcx, count_expr, ty::mk_uint());
25142514
let _ = ty::eval_repeat_count(fcx, count_expr);
25152515
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
25162516
let mutability = match vst {
25172517
ast::ExprVstoreMutSlice => ast::MutMutable,
2518-
_ => mutbl,
2518+
_ => ast::MutImmutable,
25192519
};
25202520
let t: ty::t = fcx.infcx().next_ty_var();
25212521
check_expr_has_type(fcx, element, t);
@@ -3017,16 +3017,16 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
30173017
fcx.write_ty(id, t_1);
30183018
}
30193019
}
3020-
ast::ExprVec(ref args, mutbl) => {
3020+
ast::ExprVec(ref args) => {
30213021
let t: ty::t = fcx.infcx().next_ty_var();
30223022
for e in args.iter() {
30233023
check_expr_has_type(fcx, *e, t);
30243024
}
3025-
let typ = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: mutbl},
3025+
let typ = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: ast::MutImmutable},
30263026
ty::vstore_fixed(args.len()));
30273027
fcx.write_ty(id, typ);
30283028
}
3029-
ast::ExprRepeat(element, count_expr, mutbl) => {
3029+
ast::ExprRepeat(element, count_expr) => {
30303030
check_expr_with_hint(fcx, count_expr, ty::mk_uint());
30313031
let count = ty::eval_repeat_count(fcx, count_expr);
30323032
let t: ty::t = fcx.infcx().next_ty_var();
@@ -3039,7 +3039,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
30393039
fcx.write_bot(id);
30403040
}
30413041
else {
3042-
let t = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: mutbl},
3042+
let t = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: ast::MutImmutable},
30433043
ty::vstore_fixed(count));
30443044
fcx.write_ty(id, t);
30453045
}
@@ -3864,7 +3864,7 @@ pub fn ast_expr_vstore_to_vstore(fcx: &FnCtxt,
38643864
// string literals and *empty slices* live in static memory
38653865
ty::vstore_slice(ty::ReStatic)
38663866
}
3867-
ast::ExprVec(ref elements, _) if elements.len() == 0 => {
3867+
ast::ExprVec(ref elements) if elements.len() == 0 => {
38683868
// string literals and *empty slices* live in static memory
38693869
ty::vstore_slice(ty::ReStatic)
38703870
}

src/libsyntax/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ pub enum Expr_ {
493493
ExprVstore(@Expr, ExprVstore),
494494
// First expr is the place; second expr is the value.
495495
ExprBox(@Expr, @Expr),
496-
ExprVec(Vec<@Expr>, Mutability),
496+
ExprVec(Vec<@Expr>),
497497
ExprCall(@Expr, Vec<@Expr>),
498498
ExprMethodCall(Ident, Vec<P<Ty>>, Vec<@Expr>),
499499
ExprTup(Vec<@Expr>),
@@ -536,7 +536,7 @@ pub enum Expr_ {
536536
ExprStruct(Path, Vec<Field> , Option<@Expr> /* base */),
537537

538538
// A vector literal constructed from one repeated element.
539-
ExprRepeat(@Expr /* element */, @Expr /* count */, Mutability),
539+
ExprRepeat(@Expr /* element */, @Expr /* count */),
540540

541541
// No-op: used solely so we can pretty-print faithfully
542542
ExprParen(@Expr)

src/libsyntax/ext/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
579579
self.expr(sp, ast::ExprVstore(expr, vst))
580580
}
581581
fn expr_vec(&self, sp: Span, exprs: Vec<@ast::Expr> ) -> @ast::Expr {
582-
self.expr(sp, ast::ExprVec(exprs, ast::MutImmutable))
582+
self.expr(sp, ast::ExprVec(exprs))
583583
}
584584
fn expr_vec_ng(&self, sp: Span) -> @ast::Expr {
585585
self.expr_call_global(sp,

src/libsyntax/fold.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,11 +740,11 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr {
740740
ExprBox(p, e) => {
741741
ExprBox(folder.fold_expr(p), folder.fold_expr(e))
742742
}
743-
ExprVec(ref exprs, mutt) => {
744-
ExprVec(exprs.iter().map(|&x| folder.fold_expr(x)).collect(), mutt)
743+
ExprVec(ref exprs) => {
744+
ExprVec(exprs.iter().map(|&x| folder.fold_expr(x)).collect())
745745
}
746-
ExprRepeat(expr, count, mutt) => {
747-
ExprRepeat(folder.fold_expr(expr), folder.fold_expr(count), mutt)
746+
ExprRepeat(expr, count) => {
747+
ExprRepeat(folder.fold_expr(expr), folder.fold_expr(count))
748748
}
749749
ExprTup(ref elts) => ExprTup(elts.iter().map(|x| folder.fold_expr(*x)).collect()),
750750
ExprCall(f, ref args) => {

src/libsyntax/parse/parser.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,12 +1819,11 @@ impl<'a> Parser<'a> {
18191819
return self.parse_block_expr(lo, UnsafeBlock(ast::UserProvided));
18201820
} else if self.token == token::LBRACKET {
18211821
self.bump();
1822-
let mutbl = MutImmutable;
18231822

18241823
if self.token == token::RBRACKET {
18251824
// Empty vector.
18261825
self.bump();
1827-
ex = ExprVec(Vec::new(), mutbl);
1826+
ex = ExprVec(Vec::new());
18281827
} else {
18291828
// Nonempty vector.
18301829
let first_expr = self.parse_expr();
@@ -1835,7 +1834,7 @@ impl<'a> Parser<'a> {
18351834
self.bump();
18361835
let count = self.parse_expr();
18371836
self.expect(&token::RBRACKET);
1838-
ex = ExprRepeat(first_expr, count, mutbl);
1837+
ex = ExprRepeat(first_expr, count);
18391838
} else if self.token == token::COMMA {
18401839
// Vector with two or more elements.
18411840
self.bump();
@@ -1846,11 +1845,11 @@ impl<'a> Parser<'a> {
18461845
);
18471846
let mut exprs = vec!(first_expr);
18481847
exprs.push_all_move(remaining_exprs);
1849-
ex = ExprVec(exprs, mutbl);
1848+
ex = ExprVec(exprs);
18501849
} else {
18511850
// Vector with one element.
18521851
self.expect(&token::RBRACKET);
1853-
ex = ExprVec(vec!(first_expr), mutbl);
1852+
ex = ExprVec(vec!(first_expr));
18541853
}
18551854
}
18561855
hi = self.last_span.hi;

src/libsyntax/print/pprust.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,25 +1110,17 @@ impl<'a> State<'a> {
11101110
try!(self.word_space(")"));
11111111
try!(self.print_expr(e));
11121112
}
1113-
ast::ExprVec(ref exprs, mutbl) => {
1113+
ast::ExprVec(ref exprs) => {
11141114
try!(self.ibox(indent_unit));
11151115
try!(word(&mut self.s, "["));
1116-
if mutbl == ast::MutMutable {
1117-
try!(word(&mut self.s, "mut"));
1118-
if exprs.len() > 0u { try!(self.nbsp()); }
1119-
}
11201116
try!(self.commasep_exprs(Inconsistent, exprs.as_slice()));
11211117
try!(word(&mut self.s, "]"));
11221118
try!(self.end());
11231119
}
11241120

1125-
ast::ExprRepeat(element, count, mutbl) => {
1121+
ast::ExprRepeat(element, count) => {
11261122
try!(self.ibox(indent_unit));
11271123
try!(word(&mut self.s, "["));
1128-
if mutbl == ast::MutMutable {
1129-
try!(word(&mut self.s, "mut"));
1130-
try!(self.nbsp());
1131-
}
11321124
try!(self.print_expr(element));
11331125
try!(word(&mut self.s, ","));
11341126
try!(word(&mut self.s, ".."));

src/libsyntax/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,10 +635,10 @@ pub fn walk_expr<E: Clone, V: Visitor<E>>(visitor: &mut V, expression: &Expr, en
635635
visitor.visit_expr(place, env.clone());
636636
visitor.visit_expr(subexpression, env.clone())
637637
}
638-
ExprVec(ref subexpressions, _) => {
638+
ExprVec(ref subexpressions) => {
639639
walk_exprs(visitor, subexpressions.as_slice(), env.clone())
640640
}
641-
ExprRepeat(element, count, _) => {
641+
ExprRepeat(element, count) => {
642642
visitor.visit_expr(element, env.clone());
643643
visitor.visit_expr(count, env.clone())
644644
}

0 commit comments

Comments
 (0)