syntax: remove obsolete mutability from ExprVec and ExprRepeat.
This commit is contained in:
parent
b236f45e35
commit
7c48e53c1e
@ -404,21 +404,17 @@ fn is_test_crate(krate: &ast::Crate) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn mk_test_descs(cx: &TestCtxt) -> @ast::Expr {
|
fn mk_test_descs(cx: &TestCtxt) -> @ast::Expr {
|
||||||
let mut descs = Vec::new();
|
|
||||||
debug!("building test vector from {} tests", cx.testfns.borrow().len());
|
debug!("building test vector from {} tests", cx.testfns.borrow().len());
|
||||||
for test in cx.testfns.borrow().iter() {
|
|
||||||
descs.push(mk_test_desc_and_fn_rec(cx, test));
|
|
||||||
}
|
|
||||||
|
|
||||||
let inner_expr = @ast::Expr {
|
|
||||||
id: ast::DUMMY_NODE_ID,
|
|
||||||
node: ast::ExprVec(descs, ast::MutImmutable),
|
|
||||||
span: DUMMY_SP,
|
|
||||||
};
|
|
||||||
|
|
||||||
@ast::Expr {
|
@ast::Expr {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
node: ast::ExprVstore(inner_expr, ast::ExprVstoreSlice),
|
node: ast::ExprVstore(@ast::Expr {
|
||||||
|
id: ast::DUMMY_NODE_ID,
|
||||||
|
node: ast::ExprVec(cx.testfns.borrow().iter().map(|test| {
|
||||||
|
mk_test_desc_and_fn_rec(cx, test)
|
||||||
|
}).collect()),
|
||||||
|
span: DUMMY_SP,
|
||||||
|
}, ast::ExprVstoreSlice),
|
||||||
span: DUMMY_SP,
|
span: DUMMY_SP,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ impl<'a> CFGBuilder<'a> {
|
|||||||
self.add_node(expr.id, [])
|
self.add_node(expr.id, [])
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::ExprVec(ref elems, _) => {
|
ast::ExprVec(ref elems) => {
|
||||||
self.straightline(expr, pred, elems.as_slice())
|
self.straightline(expr, pred, elems.as_slice())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,7 +379,7 @@ impl<'a> CFGBuilder<'a> {
|
|||||||
self.straightline(expr, base_exit, field_exprs.as_slice())
|
self.straightline(expr, base_exit, field_exprs.as_slice())
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::ExprRepeat(elem, count, _) => {
|
ast::ExprRepeat(elem, count) => {
|
||||||
self.straightline(expr, pred, [elem, count])
|
self.straightline(expr, pred, [elem, count])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr, is_const: bool) {
|
|||||||
}
|
}
|
||||||
ExprVstore(_, ExprVstoreMutSlice) |
|
ExprVstore(_, ExprVstoreMutSlice) |
|
||||||
ExprVstore(_, ExprVstoreSlice) |
|
ExprVstore(_, ExprVstoreSlice) |
|
||||||
ExprVec(_, MutImmutable) |
|
ExprVec(_) |
|
||||||
ExprAddrOf(MutImmutable, _) |
|
ExprAddrOf(MutImmutable, _) |
|
||||||
ExprParen(..) |
|
ExprParen(..) |
|
||||||
ExprField(..) |
|
ExprField(..) |
|
||||||
|
@ -213,7 +213,7 @@ impl<'a> ConstEvalVisitor<'a> {
|
|||||||
join(self.classify(a), self.classify(b)),
|
join(self.classify(a), self.classify(b)),
|
||||||
|
|
||||||
ast::ExprTup(ref es) |
|
ast::ExprTup(ref es) |
|
||||||
ast::ExprVec(ref es, ast::MutImmutable) =>
|
ast::ExprVec(ref es) =>
|
||||||
join_all(es.iter().map(|e| self.classify(*e))),
|
join_all(es.iter().map(|e| self.classify(*e))),
|
||||||
|
|
||||||
ast::ExprVstore(e, vstore) => {
|
ast::ExprVstore(e, vstore) => {
|
||||||
|
@ -538,11 +538,11 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> {
|
|||||||
self.walk_expr(l, in_out, loop_scopes);
|
self.walk_expr(l, in_out, loop_scopes);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::ExprVec(ref exprs, _) => {
|
ast::ExprVec(ref exprs) => {
|
||||||
self.walk_exprs(exprs.as_slice(), in_out, loop_scopes)
|
self.walk_exprs(exprs.as_slice(), in_out, loop_scopes)
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::ExprRepeat(l, r, _) => {
|
ast::ExprRepeat(l, r) => {
|
||||||
self.walk_expr(l, in_out, loop_scopes);
|
self.walk_expr(l, in_out, loop_scopes);
|
||||||
self.walk_expr(r, in_out, loop_scopes);
|
self.walk_expr(r, in_out, loop_scopes);
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ pub fn check_expr(cx: &mut Context, e: &Expr) {
|
|||||||
let target_ty = ty::expr_ty(cx.tcx, e);
|
let target_ty = ty::expr_ty(cx.tcx, e);
|
||||||
check_trait_cast(cx, source_ty, target_ty, source.span);
|
check_trait_cast(cx, source_ty, target_ty, source.span);
|
||||||
}
|
}
|
||||||
ExprRepeat(element, count_expr, _) => {
|
ExprRepeat(element, count_expr) => {
|
||||||
let count = ty::eval_repeat_count(cx.tcx, count_expr);
|
let count = ty::eval_repeat_count(cx.tcx, count_expr);
|
||||||
if count > 1 {
|
if count > 1 {
|
||||||
let element_ty = ty::expr_ty(cx.tcx, element);
|
let element_ty = ty::expr_ty(cx.tcx, element);
|
||||||
|
@ -1109,11 +1109,11 @@ impl<'a> Liveness<'a> {
|
|||||||
self.propagate_through_expr(expr, succ)
|
self.propagate_through_expr(expr, succ)
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprVec(ref exprs, _) => {
|
ExprVec(ref exprs) => {
|
||||||
self.propagate_through_exprs(exprs.as_slice(), succ)
|
self.propagate_through_exprs(exprs.as_slice(), succ)
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprRepeat(element, count, _) => {
|
ExprRepeat(element, count) => {
|
||||||
let succ = self.propagate_through_expr(count, succ);
|
let succ = self.propagate_through_expr(count, succ);
|
||||||
self.propagate_through_expr(element, succ)
|
self.propagate_through_expr(element, succ)
|
||||||
}
|
}
|
||||||
|
@ -473,7 +473,7 @@ impl<'a> VisitContext<'a> {
|
|||||||
self.use_expr(base, expr_mode);
|
self.use_expr(base, expr_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprVec(ref exprs, _) => {
|
ExprVec(ref exprs) => {
|
||||||
self.consume_exprs(exprs.as_slice());
|
self.consume_exprs(exprs.as_slice());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,7 +539,7 @@ impl<'a> VisitContext<'a> {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprRepeat(base, count, _) => {
|
ExprRepeat(base, count) => {
|
||||||
self.consume_expr(base);
|
self.consume_expr(base);
|
||||||
self.consume_expr(count);
|
self.consume_expr(count);
|
||||||
}
|
}
|
||||||
|
@ -724,7 +724,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor,
|
|||||||
visitor.region_maps.record_rvalue_scope(subexpr.id, blk_id);
|
visitor.region_maps.record_rvalue_scope(subexpr.id, blk_id);
|
||||||
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id);
|
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id);
|
||||||
}
|
}
|
||||||
ast::ExprVec(ref subexprs, _) |
|
ast::ExprVec(ref subexprs) |
|
||||||
ast::ExprTup(ref subexprs) => {
|
ast::ExprTup(ref subexprs) => {
|
||||||
for &subexpr in subexprs.iter() {
|
for &subexpr in subexprs.iter() {
|
||||||
record_rvalue_scope_if_borrow_expr(
|
record_rvalue_scope_if_borrow_expr(
|
||||||
|
@ -557,7 +557,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
|
|||||||
inlineable.iter().fold(true, |a, &b| a && b))
|
inlineable.iter().fold(true, |a, &b| a && b))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
ast::ExprVec(ref es, ast::MutImmutable) => {
|
ast::ExprVec(ref es) => {
|
||||||
let (v, _, inlineable) = const_vec(cx,
|
let (v, _, inlineable) = const_vec(cx,
|
||||||
e,
|
e,
|
||||||
es.as_slice(),
|
es.as_slice(),
|
||||||
@ -573,7 +573,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
|
|||||||
_ => { cx.sess().span_bug(e.span, "bad const-slice lit") }
|
_ => { cx.sess().span_bug(e.span, "bad const-slice lit") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::ExprVec(ref es, ast::MutImmutable) => {
|
ast::ExprVec(ref es) => {
|
||||||
let (cv, llunitty, _) = const_vec(cx,
|
let (cv, llunitty, _) = const_vec(cx,
|
||||||
e,
|
e,
|
||||||
es.as_slice(),
|
es.as_slice(),
|
||||||
@ -592,7 +592,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
|
|||||||
_ => cx.sess().span_bug(e.span, "bad const-slice expr")
|
_ => cx.sess().span_bug(e.span, "bad const-slice expr")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::ExprRepeat(elem, count, _) => {
|
ast::ExprRepeat(elem, count) => {
|
||||||
let vec_ty = ty::expr_ty(cx.tcx(), e);
|
let vec_ty = ty::expr_ty(cx.tcx(), e);
|
||||||
let unit_ty = ty::sequence_element_type(cx.tcx(), vec_ty);
|
let unit_ty = ty::sequence_element_type(cx.tcx(), vec_ty);
|
||||||
let llunitty = type_of::type_of(cx, unit_ty);
|
let llunitty = type_of::type_of(cx, unit_ty);
|
||||||
|
@ -2619,15 +2619,15 @@ fn populate_scope_map(cx: &CrateContext,
|
|||||||
walk_expr(cx, rhs, scope_stack, scope_map);
|
walk_expr(cx, rhs, scope_stack, scope_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::ExprVec(ref init_expressions, _) |
|
ast::ExprVec(ref init_expressions) |
|
||||||
ast::ExprTup(ref init_expressions) => {
|
ast::ExprTup(ref init_expressions) => {
|
||||||
for ie in init_expressions.iter() {
|
for ie in init_expressions.iter() {
|
||||||
walk_expr(cx, *ie, scope_stack, scope_map);
|
walk_expr(cx, *ie, scope_stack, scope_map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::ExprAssign(sub_exp1, sub_exp2) |
|
ast::ExprAssign(sub_exp1, sub_exp2) |
|
||||||
ast::ExprRepeat(sub_exp1, sub_exp2, _) => {
|
ast::ExprRepeat(sub_exp1, sub_exp2) => {
|
||||||
walk_expr(cx, sub_exp1, scope_stack, scope_map);
|
walk_expr(cx, sub_exp1, scope_stack, scope_map);
|
||||||
walk_expr(cx, sub_exp2, scope_stack, scope_map);
|
walk_expr(cx, sub_exp2, scope_stack, scope_map);
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ pub fn write_content<'a>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::ExprVec(ref elements, _) => {
|
ast::ExprVec(ref elements) => {
|
||||||
match dest {
|
match dest {
|
||||||
Ignore => {
|
Ignore => {
|
||||||
for element in elements.iter() {
|
for element in elements.iter() {
|
||||||
@ -418,7 +418,7 @@ pub fn write_content<'a>(
|
|||||||
}
|
}
|
||||||
return bcx;
|
return bcx;
|
||||||
}
|
}
|
||||||
ast::ExprRepeat(element, count_expr, _) => {
|
ast::ExprRepeat(element, count_expr) => {
|
||||||
match dest {
|
match dest {
|
||||||
Ignore => {
|
Ignore => {
|
||||||
return expr::trans_into(bcx, element, Ignore);
|
return expr::trans_into(bcx, element, Ignore);
|
||||||
@ -486,8 +486,8 @@ pub fn elements_required(bcx: &Block, content_expr: &ast::Expr) -> uint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ast::ExprVec(ref es, _) => es.len(),
|
ast::ExprVec(ref es) => es.len(),
|
||||||
ast::ExprRepeat(_, count_expr, _) => {
|
ast::ExprRepeat(_, count_expr) => {
|
||||||
ty::eval_repeat_count(bcx.tcx(), count_expr)
|
ty::eval_repeat_count(bcx.tcx(), count_expr)
|
||||||
}
|
}
|
||||||
_ => bcx.tcx().sess.span_bug(content_expr.span,
|
_ => bcx.tcx().sess.span_bug(content_expr.span,
|
||||||
|
@ -2482,13 +2482,13 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
|||||||
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
|
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
|
||||||
ty::mk_str(tcx, tt)
|
ty::mk_str(tcx, tt)
|
||||||
}
|
}
|
||||||
ast::ExprVec(ref args, mutbl) => {
|
ast::ExprVec(ref args) => {
|
||||||
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
|
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
|
||||||
let mut any_error = false;
|
let mut any_error = false;
|
||||||
let mut any_bot = false;
|
let mut any_bot = false;
|
||||||
let mutability = match vst {
|
let mutability = match vst {
|
||||||
ast::ExprVstoreMutSlice => ast::MutMutable,
|
ast::ExprVstoreMutSlice => ast::MutMutable,
|
||||||
_ => mutbl,
|
_ => ast::MutImmutable,
|
||||||
};
|
};
|
||||||
let t: ty::t = fcx.infcx().next_ty_var();
|
let t: ty::t = fcx.infcx().next_ty_var();
|
||||||
for e in args.iter() {
|
for e in args.iter() {
|
||||||
@ -2509,13 +2509,13 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
|||||||
ty::mk_vec(tcx, ty::mt {ty: t, mutbl: mutability}, tt)
|
ty::mk_vec(tcx, ty::mt {ty: t, mutbl: mutability}, tt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::ExprRepeat(element, count_expr, mutbl) => {
|
ast::ExprRepeat(element, count_expr) => {
|
||||||
check_expr_with_hint(fcx, count_expr, ty::mk_uint());
|
check_expr_with_hint(fcx, count_expr, ty::mk_uint());
|
||||||
let _ = ty::eval_repeat_count(fcx, count_expr);
|
let _ = ty::eval_repeat_count(fcx, count_expr);
|
||||||
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
|
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
|
||||||
let mutability = match vst {
|
let mutability = match vst {
|
||||||
ast::ExprVstoreMutSlice => ast::MutMutable,
|
ast::ExprVstoreMutSlice => ast::MutMutable,
|
||||||
_ => mutbl,
|
_ => ast::MutImmutable,
|
||||||
};
|
};
|
||||||
let t: ty::t = fcx.infcx().next_ty_var();
|
let t: ty::t = fcx.infcx().next_ty_var();
|
||||||
check_expr_has_type(fcx, element, t);
|
check_expr_has_type(fcx, element, t);
|
||||||
@ -3017,16 +3017,16 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
|||||||
fcx.write_ty(id, t_1);
|
fcx.write_ty(id, t_1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::ExprVec(ref args, mutbl) => {
|
ast::ExprVec(ref args) => {
|
||||||
let t: ty::t = fcx.infcx().next_ty_var();
|
let t: ty::t = fcx.infcx().next_ty_var();
|
||||||
for e in args.iter() {
|
for e in args.iter() {
|
||||||
check_expr_has_type(fcx, *e, t);
|
check_expr_has_type(fcx, *e, t);
|
||||||
}
|
}
|
||||||
let typ = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: mutbl},
|
let typ = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: ast::MutImmutable},
|
||||||
ty::vstore_fixed(args.len()));
|
ty::vstore_fixed(args.len()));
|
||||||
fcx.write_ty(id, typ);
|
fcx.write_ty(id, typ);
|
||||||
}
|
}
|
||||||
ast::ExprRepeat(element, count_expr, mutbl) => {
|
ast::ExprRepeat(element, count_expr) => {
|
||||||
check_expr_with_hint(fcx, count_expr, ty::mk_uint());
|
check_expr_with_hint(fcx, count_expr, ty::mk_uint());
|
||||||
let count = ty::eval_repeat_count(fcx, count_expr);
|
let count = ty::eval_repeat_count(fcx, count_expr);
|
||||||
let t: ty::t = fcx.infcx().next_ty_var();
|
let t: ty::t = fcx.infcx().next_ty_var();
|
||||||
@ -3039,7 +3039,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
|||||||
fcx.write_bot(id);
|
fcx.write_bot(id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let t = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: mutbl},
|
let t = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: ast::MutImmutable},
|
||||||
ty::vstore_fixed(count));
|
ty::vstore_fixed(count));
|
||||||
fcx.write_ty(id, t);
|
fcx.write_ty(id, t);
|
||||||
}
|
}
|
||||||
@ -3864,7 +3864,7 @@ pub fn ast_expr_vstore_to_vstore(fcx: &FnCtxt,
|
|||||||
// string literals and *empty slices* live in static memory
|
// string literals and *empty slices* live in static memory
|
||||||
ty::vstore_slice(ty::ReStatic)
|
ty::vstore_slice(ty::ReStatic)
|
||||||
}
|
}
|
||||||
ast::ExprVec(ref elements, _) if elements.len() == 0 => {
|
ast::ExprVec(ref elements) if elements.len() == 0 => {
|
||||||
// string literals and *empty slices* live in static memory
|
// string literals and *empty slices* live in static memory
|
||||||
ty::vstore_slice(ty::ReStatic)
|
ty::vstore_slice(ty::ReStatic)
|
||||||
}
|
}
|
||||||
|
@ -493,7 +493,7 @@ pub enum Expr_ {
|
|||||||
ExprVstore(@Expr, ExprVstore),
|
ExprVstore(@Expr, ExprVstore),
|
||||||
// First expr is the place; second expr is the value.
|
// First expr is the place; second expr is the value.
|
||||||
ExprBox(@Expr, @Expr),
|
ExprBox(@Expr, @Expr),
|
||||||
ExprVec(Vec<@Expr>, Mutability),
|
ExprVec(Vec<@Expr>),
|
||||||
ExprCall(@Expr, Vec<@Expr>),
|
ExprCall(@Expr, Vec<@Expr>),
|
||||||
ExprMethodCall(Ident, Vec<P<Ty>>, Vec<@Expr>),
|
ExprMethodCall(Ident, Vec<P<Ty>>, Vec<@Expr>),
|
||||||
ExprTup(Vec<@Expr>),
|
ExprTup(Vec<@Expr>),
|
||||||
@ -536,7 +536,7 @@ pub enum Expr_ {
|
|||||||
ExprStruct(Path, Vec<Field> , Option<@Expr> /* base */),
|
ExprStruct(Path, Vec<Field> , Option<@Expr> /* base */),
|
||||||
|
|
||||||
// A vector literal constructed from one repeated element.
|
// A vector literal constructed from one repeated element.
|
||||||
ExprRepeat(@Expr /* element */, @Expr /* count */, Mutability),
|
ExprRepeat(@Expr /* element */, @Expr /* count */),
|
||||||
|
|
||||||
// No-op: used solely so we can pretty-print faithfully
|
// No-op: used solely so we can pretty-print faithfully
|
||||||
ExprParen(@Expr)
|
ExprParen(@Expr)
|
||||||
|
@ -579,7 +579,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||||||
self.expr(sp, ast::ExprVstore(expr, vst))
|
self.expr(sp, ast::ExprVstore(expr, vst))
|
||||||
}
|
}
|
||||||
fn expr_vec(&self, sp: Span, exprs: Vec<@ast::Expr> ) -> @ast::Expr {
|
fn expr_vec(&self, sp: Span, exprs: Vec<@ast::Expr> ) -> @ast::Expr {
|
||||||
self.expr(sp, ast::ExprVec(exprs, ast::MutImmutable))
|
self.expr(sp, ast::ExprVec(exprs))
|
||||||
}
|
}
|
||||||
fn expr_vec_ng(&self, sp: Span) -> @ast::Expr {
|
fn expr_vec_ng(&self, sp: Span) -> @ast::Expr {
|
||||||
self.expr_call_global(sp,
|
self.expr_call_global(sp,
|
||||||
|
@ -740,11 +740,11 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr {
|
|||||||
ExprBox(p, e) => {
|
ExprBox(p, e) => {
|
||||||
ExprBox(folder.fold_expr(p), folder.fold_expr(e))
|
ExprBox(folder.fold_expr(p), folder.fold_expr(e))
|
||||||
}
|
}
|
||||||
ExprVec(ref exprs, mutt) => {
|
ExprVec(ref exprs) => {
|
||||||
ExprVec(exprs.iter().map(|&x| folder.fold_expr(x)).collect(), mutt)
|
ExprVec(exprs.iter().map(|&x| folder.fold_expr(x)).collect())
|
||||||
}
|
}
|
||||||
ExprRepeat(expr, count, mutt) => {
|
ExprRepeat(expr, count) => {
|
||||||
ExprRepeat(folder.fold_expr(expr), folder.fold_expr(count), mutt)
|
ExprRepeat(folder.fold_expr(expr), folder.fold_expr(count))
|
||||||
}
|
}
|
||||||
ExprTup(ref elts) => ExprTup(elts.iter().map(|x| folder.fold_expr(*x)).collect()),
|
ExprTup(ref elts) => ExprTup(elts.iter().map(|x| folder.fold_expr(*x)).collect()),
|
||||||
ExprCall(f, ref args) => {
|
ExprCall(f, ref args) => {
|
||||||
|
@ -1819,12 +1819,11 @@ impl<'a> Parser<'a> {
|
|||||||
return self.parse_block_expr(lo, UnsafeBlock(ast::UserProvided));
|
return self.parse_block_expr(lo, UnsafeBlock(ast::UserProvided));
|
||||||
} else if self.token == token::LBRACKET {
|
} else if self.token == token::LBRACKET {
|
||||||
self.bump();
|
self.bump();
|
||||||
let mutbl = MutImmutable;
|
|
||||||
|
|
||||||
if self.token == token::RBRACKET {
|
if self.token == token::RBRACKET {
|
||||||
// Empty vector.
|
// Empty vector.
|
||||||
self.bump();
|
self.bump();
|
||||||
ex = ExprVec(Vec::new(), mutbl);
|
ex = ExprVec(Vec::new());
|
||||||
} else {
|
} else {
|
||||||
// Nonempty vector.
|
// Nonempty vector.
|
||||||
let first_expr = self.parse_expr();
|
let first_expr = self.parse_expr();
|
||||||
@ -1835,7 +1834,7 @@ impl<'a> Parser<'a> {
|
|||||||
self.bump();
|
self.bump();
|
||||||
let count = self.parse_expr();
|
let count = self.parse_expr();
|
||||||
self.expect(&token::RBRACKET);
|
self.expect(&token::RBRACKET);
|
||||||
ex = ExprRepeat(first_expr, count, mutbl);
|
ex = ExprRepeat(first_expr, count);
|
||||||
} else if self.token == token::COMMA {
|
} else if self.token == token::COMMA {
|
||||||
// Vector with two or more elements.
|
// Vector with two or more elements.
|
||||||
self.bump();
|
self.bump();
|
||||||
@ -1846,11 +1845,11 @@ impl<'a> Parser<'a> {
|
|||||||
);
|
);
|
||||||
let mut exprs = vec!(first_expr);
|
let mut exprs = vec!(first_expr);
|
||||||
exprs.push_all_move(remaining_exprs);
|
exprs.push_all_move(remaining_exprs);
|
||||||
ex = ExprVec(exprs, mutbl);
|
ex = ExprVec(exprs);
|
||||||
} else {
|
} else {
|
||||||
// Vector with one element.
|
// Vector with one element.
|
||||||
self.expect(&token::RBRACKET);
|
self.expect(&token::RBRACKET);
|
||||||
ex = ExprVec(vec!(first_expr), mutbl);
|
ex = ExprVec(vec!(first_expr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hi = self.last_span.hi;
|
hi = self.last_span.hi;
|
||||||
|
@ -1110,25 +1110,17 @@ impl<'a> State<'a> {
|
|||||||
try!(self.word_space(")"));
|
try!(self.word_space(")"));
|
||||||
try!(self.print_expr(e));
|
try!(self.print_expr(e));
|
||||||
}
|
}
|
||||||
ast::ExprVec(ref exprs, mutbl) => {
|
ast::ExprVec(ref exprs) => {
|
||||||
try!(self.ibox(indent_unit));
|
try!(self.ibox(indent_unit));
|
||||||
try!(word(&mut self.s, "["));
|
try!(word(&mut self.s, "["));
|
||||||
if mutbl == ast::MutMutable {
|
|
||||||
try!(word(&mut self.s, "mut"));
|
|
||||||
if exprs.len() > 0u { try!(self.nbsp()); }
|
|
||||||
}
|
|
||||||
try!(self.commasep_exprs(Inconsistent, exprs.as_slice()));
|
try!(self.commasep_exprs(Inconsistent, exprs.as_slice()));
|
||||||
try!(word(&mut self.s, "]"));
|
try!(word(&mut self.s, "]"));
|
||||||
try!(self.end());
|
try!(self.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::ExprRepeat(element, count, mutbl) => {
|
ast::ExprRepeat(element, count) => {
|
||||||
try!(self.ibox(indent_unit));
|
try!(self.ibox(indent_unit));
|
||||||
try!(word(&mut self.s, "["));
|
try!(word(&mut self.s, "["));
|
||||||
if mutbl == ast::MutMutable {
|
|
||||||
try!(word(&mut self.s, "mut"));
|
|
||||||
try!(self.nbsp());
|
|
||||||
}
|
|
||||||
try!(self.print_expr(element));
|
try!(self.print_expr(element));
|
||||||
try!(word(&mut self.s, ","));
|
try!(word(&mut self.s, ","));
|
||||||
try!(word(&mut self.s, ".."));
|
try!(word(&mut self.s, ".."));
|
||||||
|
@ -635,10 +635,10 @@ pub fn walk_expr<E: Clone, V: Visitor<E>>(visitor: &mut V, expression: &Expr, en
|
|||||||
visitor.visit_expr(place, env.clone());
|
visitor.visit_expr(place, env.clone());
|
||||||
visitor.visit_expr(subexpression, env.clone())
|
visitor.visit_expr(subexpression, env.clone())
|
||||||
}
|
}
|
||||||
ExprVec(ref subexpressions, _) => {
|
ExprVec(ref subexpressions) => {
|
||||||
walk_exprs(visitor, subexpressions.as_slice(), env.clone())
|
walk_exprs(visitor, subexpressions.as_slice(), env.clone())
|
||||||
}
|
}
|
||||||
ExprRepeat(element, count, _) => {
|
ExprRepeat(element, count) => {
|
||||||
visitor.visit_expr(element, env.clone());
|
visitor.visit_expr(element, env.clone());
|
||||||
visitor.visit_expr(count, env.clone())
|
visitor.visit_expr(count, env.clone())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user