librustc: Allow expr_repeat to be used with any vstore
This commit is contained in:
parent
b93393e907
commit
e5dda811a9
4 changed files with 41 additions and 14 deletions
|
@ -126,7 +126,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
|
||||||
type Registers = [uint, ..22];
|
type Registers = [uint, ..22];
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
fn new_regs() -> ~Registers { ~[0, .. 22] }
|
fn new_regs() -> ~Registers { ~([0, .. 22]) }
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp: *mut uint) {
|
fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp: *mut uint) {
|
||||||
|
|
|
@ -2186,17 +2186,21 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
||||||
let count = ty::eval_repeat_count(tcx, count_expr);
|
let count = ty::eval_repeat_count(tcx, count_expr);
|
||||||
check_expr_with_hint(fcx, count_expr, ty::mk_uint(tcx));
|
check_expr_with_hint(fcx, count_expr, ty::mk_uint(tcx));
|
||||||
let tt = ast_expr_vstore_to_vstore(fcx, ev, count, vst);
|
let tt = ast_expr_vstore_to_vstore(fcx, ev, count, vst);
|
||||||
|
let mutability = match vst {
|
||||||
|
ast::expr_vstore_mut_box | ast::expr_vstore_mut_slice => {
|
||||||
|
ast::m_mutbl
|
||||||
|
}
|
||||||
|
_ => mutbl
|
||||||
|
};
|
||||||
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);
|
||||||
let arg_t = fcx.expr_ty(element);
|
let arg_t = fcx.expr_ty(element);
|
||||||
if ty::type_is_error(arg_t) {
|
if ty::type_is_error(arg_t) {
|
||||||
ty::mk_err(tcx)
|
ty::mk_err(tcx)
|
||||||
}
|
} else if ty::type_is_bot(arg_t) {
|
||||||
else if ty::type_is_bot(arg_t) {
|
|
||||||
ty::mk_bot(tcx)
|
ty::mk_bot(tcx)
|
||||||
}
|
} else {
|
||||||
else {
|
ty::mk_evec(tcx, ty::mt {ty: t, mutbl: mutability}, tt)
|
||||||
ty::mk_evec(tcx, ty::mt {ty: t, mutbl: mutbl}, tt)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ =>
|
_ =>
|
||||||
|
|
|
@ -232,7 +232,7 @@ pub fn Parser(sess: @mut ParseSess,
|
||||||
token: @mut copy tok0.tok,
|
token: @mut copy tok0.tok,
|
||||||
span: @mut copy tok0.sp,
|
span: @mut copy tok0.sp,
|
||||||
last_span: @mut copy tok0.sp,
|
last_span: @mut copy tok0.sp,
|
||||||
buffer: @mut [copy tok0, .. 4],
|
buffer: @mut ([copy tok0, .. 4]),
|
||||||
buffer_start: @mut 0,
|
buffer_start: @mut 0,
|
||||||
buffer_end: @mut 0,
|
buffer_end: @mut 0,
|
||||||
tokens_consumed: @mut 0,
|
tokens_consumed: @mut 0,
|
||||||
|
@ -1660,12 +1660,11 @@ pub impl Parser {
|
||||||
hi = e.span.hi;
|
hi = e.span.hi;
|
||||||
// HACK: turn @[...] into a @-evec
|
// HACK: turn @[...] into a @-evec
|
||||||
ex = match e.node {
|
ex = match e.node {
|
||||||
expr_vec(*) if m == m_mutbl =>
|
expr_vec(*) | expr_repeat(*) if m == m_mutbl =>
|
||||||
expr_vstore(e, expr_vstore_mut_box),
|
expr_vstore(e, expr_vstore_mut_box),
|
||||||
expr_vec(*) if m == m_imm => expr_vstore(e, expr_vstore_box),
|
expr_vec(*) |
|
||||||
expr_lit(@codemap::spanned {
|
expr_lit(@codemap::spanned { node: lit_str(_), span: _}) |
|
||||||
node: lit_str(_), span: _}) if m == m_imm =>
|
expr_repeat(*) if m == m_imm => expr_vstore(e, expr_vstore_box),
|
||||||
expr_vstore(e, expr_vstore_box),
|
|
||||||
_ => expr_unary(box(m), e)
|
_ => expr_unary(box(m), e)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1680,8 +1679,9 @@ pub impl Parser {
|
||||||
hi = e.span.hi;
|
hi = e.span.hi;
|
||||||
// HACK: turn ~[...] into a ~-evec
|
// HACK: turn ~[...] into a ~-evec
|
||||||
ex = match e.node {
|
ex = match e.node {
|
||||||
expr_vec(*) | expr_lit(@codemap::spanned {
|
expr_vec(*) |
|
||||||
node: lit_str(_), span: _})
|
expr_lit(@codemap::spanned { node: lit_str(_), span: _}) |
|
||||||
|
expr_repeat(*)
|
||||||
if m == m_imm => expr_vstore(e, expr_vstore_uniq),
|
if m == m_imm => expr_vstore(e, expr_vstore_uniq),
|
||||||
_ => expr_unary(uniq(m), e)
|
_ => expr_unary(uniq(m), e)
|
||||||
};
|
};
|
||||||
|
|
23
src/test/run-pass/expr-repeat-vstore.rs
Normal file
23
src/test/run-pass/expr-repeat-vstore.rs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
use core::io::println;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let v: ~[int] = ~[ 1, ..5 ];
|
||||||
|
println(v[0].to_str());
|
||||||
|
println(v[1].to_str());
|
||||||
|
println(v[2].to_str());
|
||||||
|
println(v[3].to_str());
|
||||||
|
println(v[4].to_str());
|
||||||
|
let v: @[int] = @[ 2, ..5 ];
|
||||||
|
println(v[0].to_str());
|
||||||
|
println(v[1].to_str());
|
||||||
|
println(v[2].to_str());
|
||||||
|
println(v[3].to_str());
|
||||||
|
println(v[4].to_str());
|
||||||
|
let v: @mut [int] = @mut [ 3, ..5 ];
|
||||||
|
println((copy v[0]).to_str());
|
||||||
|
println((copy v[1]).to_str());
|
||||||
|
println((copy v[2]).to_str());
|
||||||
|
println((copy v[3]).to_str());
|
||||||
|
println((copy v[4]).to_str());
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue