Merge pull request #4498 from erickt/incoming
More records-to-structs conversions
This commit is contained in:
commit
e90142e536
@ -133,14 +133,19 @@ fn filter_stmt(cx: ctxt, &&stmt: @ast::stmt) ->
|
||||
}
|
||||
}
|
||||
|
||||
fn fold_block(cx: ctxt, b: ast::blk_, fld: fold::ast_fold) ->
|
||||
ast::blk_ {
|
||||
fn fold_block(
|
||||
cx: ctxt,
|
||||
b: ast::blk_,
|
||||
fld: fold::ast_fold
|
||||
) -> ast::blk_ {
|
||||
let filtered_stmts = vec::filter_map(b.stmts, |a| filter_stmt(cx, *a));
|
||||
return {view_items: /*bad*/copy b.view_items,
|
||||
stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(*x)),
|
||||
expr: option::map(&b.expr, |x| fld.fold_expr(*x)),
|
||||
id: b.id,
|
||||
rules: b.rules};
|
||||
ast::blk_ {
|
||||
view_items: /*bad*/copy b.view_items,
|
||||
stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(*x)),
|
||||
expr: option::map(&b.expr, |x| fld.fold_expr(*x)),
|
||||
id: b.id,
|
||||
rules: b.rules,
|
||||
}
|
||||
}
|
||||
|
||||
fn item_in_cfg(cx: ctxt, item: @ast::item) -> bool {
|
||||
|
@ -69,7 +69,7 @@ fn inject_libcore_ref(sess: Session,
|
||||
new_module = fld.fold_mod(new_module);
|
||||
|
||||
// XXX: Bad copy.
|
||||
let new_crate = { module: new_module, ..copy crate };
|
||||
let new_crate = ast::crate_ { module: new_module, ..copy crate };
|
||||
(new_crate, span)
|
||||
},
|
||||
fold_mod: |module, fld| {
|
||||
|
@ -37,8 +37,13 @@ fn inject_intrinsic(sess: Session, crate: @ast::crate) -> @ast::crate {
|
||||
let items = vec::append(~[item], crate.node.module.items);
|
||||
|
||||
@ast::spanned {
|
||||
node: { module: { items: items ,.. /*bad*/copy crate.node.module },
|
||||
.. /*bad*/copy crate.node},
|
||||
node: ast::crate_ {
|
||||
module: {
|
||||
items: items,
|
||||
.. /*bad*/copy crate.node.module
|
||||
},
|
||||
.. /*bad*/copy crate.node
|
||||
},
|
||||
.. /*bad*/copy *crate
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,8 @@ fn fold_crate(cx: test_ctxt, c: ast::crate_, fld: fold::ast_fold) ->
|
||||
|
||||
// Add a special __test module to the crate that will contain code
|
||||
// generated for the test harness
|
||||
return {module: add_test_module(cx, /*bad*/copy folded.module),.. folded};
|
||||
ast::crate_ { module: add_test_module(cx, /*bad*/copy folded.module),
|
||||
.. folded }
|
||||
}
|
||||
|
||||
|
||||
@ -339,13 +340,13 @@ fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::Ty {
|
||||
node: ast::ty_path(test_desc_ty_path, cx.sess.next_node_id()),
|
||||
span: dummy_sp()};
|
||||
|
||||
let vec_mt: ast::mt = {ty: @test_desc_ty, mutbl: ast::m_imm};
|
||||
let vec_mt = ast::mt {ty: @test_desc_ty, mutbl: ast::m_imm};
|
||||
|
||||
let inner_ty = @{id: cx.sess.next_node_id(),
|
||||
node: ast::ty_vec(vec_mt),
|
||||
span: dummy_sp()};
|
||||
return @{id: cx.sess.next_node_id(),
|
||||
node: ast::ty_uniq({ty: inner_ty, mutbl: ast::m_imm}),
|
||||
node: ast::ty_uniq(ast::mt {ty: inner_ty, mutbl: ast::m_imm}),
|
||||
span: dummy_sp()};
|
||||
}
|
||||
|
||||
@ -388,9 +389,11 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
|
||||
span: dummy_sp()};
|
||||
|
||||
|
||||
let name_field: ast::field =
|
||||
nospan({mutbl: ast::m_imm, ident: cx.sess.ident_of(~"name"),
|
||||
expr: @name_expr});
|
||||
let name_field = nospan(ast::field_ {
|
||||
mutbl: ast::m_imm,
|
||||
ident: cx.sess.ident_of(~"name"),
|
||||
expr: @name_expr,
|
||||
});
|
||||
|
||||
let fn_path = path_node_global(path);
|
||||
|
||||
@ -402,9 +405,11 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
|
||||
|
||||
let fn_wrapper_expr = mk_test_wrapper(cx, fn_expr, span);
|
||||
|
||||
let fn_field: ast::field =
|
||||
nospan({mutbl: ast::m_imm, ident: cx.sess.ident_of(~"testfn"),
|
||||
expr: fn_wrapper_expr});
|
||||
let fn_field = nospan(ast::field_ {
|
||||
mutbl: ast::m_imm,
|
||||
ident: cx.sess.ident_of(~"testfn"),
|
||||
expr: fn_wrapper_expr,
|
||||
});
|
||||
|
||||
let ignore_lit: ast::lit = nospan(ast::lit_bool(test.ignore));
|
||||
|
||||
@ -414,9 +419,11 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
|
||||
node: ast::expr_lit(@ignore_lit),
|
||||
span: span};
|
||||
|
||||
let ignore_field: ast::field =
|
||||
nospan({mutbl: ast::m_imm, ident: cx.sess.ident_of(~"ignore"),
|
||||
expr: @ignore_expr});
|
||||
let ignore_field = nospan(ast::field_ {
|
||||
mutbl: ast::m_imm,
|
||||
ident: cx.sess.ident_of(~"ignore"),
|
||||
expr: @ignore_expr,
|
||||
});
|
||||
|
||||
let fail_lit: ast::lit = nospan(ast::lit_bool(test.should_fail));
|
||||
|
||||
@ -426,10 +433,11 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
|
||||
node: ast::expr_lit(@fail_lit),
|
||||
span: span};
|
||||
|
||||
let fail_field: ast::field =
|
||||
nospan({mutbl: ast::m_imm,
|
||||
ident: cx.sess.ident_of(~"should_fail"),
|
||||
expr: @fail_expr});
|
||||
let fail_field = nospan(ast::field_ {
|
||||
mutbl: ast::m_imm,
|
||||
ident: cx.sess.ident_of(~"should_fail"),
|
||||
expr: @fail_expr,
|
||||
});
|
||||
|
||||
let test_desc_path =
|
||||
mk_path(cx, ~[cx.sess.ident_of(~"test"),
|
||||
@ -468,7 +476,7 @@ fn mk_test_wrapper(cx: test_ctxt,
|
||||
cf: ast::return_val
|
||||
};
|
||||
|
||||
let wrapper_body: ast::blk = nospan({
|
||||
let wrapper_body = nospan(ast::blk_ {
|
||||
view_items: ~[],
|
||||
stmts: ~[@call_stmt],
|
||||
expr: option::None,
|
||||
|
@ -353,7 +353,7 @@ fn parse_mt(st: @pstate, conv: conv_did) -> ty::mt {
|
||||
'?' => { next(st); m = ast::m_const; }
|
||||
_ => { m = ast::m_imm; }
|
||||
}
|
||||
return {ty: parse_ty(st, conv), mutbl: m};
|
||||
ty::mt { ty: parse_ty(st, conv), mutbl: m }
|
||||
}
|
||||
|
||||
fn parse_def(st: @pstate, conv: conv_did) -> ast::def_id {
|
||||
|
@ -267,7 +267,10 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
|
||||
}
|
||||
};
|
||||
// XXX: Bad copy.
|
||||
let blk_sans_items = { stmts: stmts_sans_items,.. copy blk };
|
||||
let blk_sans_items = ast::blk_ {
|
||||
stmts: stmts_sans_items,
|
||||
.. copy blk
|
||||
};
|
||||
fold::noop_fold_block(blk_sans_items, fld)
|
||||
}
|
||||
|
||||
|
@ -478,7 +478,7 @@ fn ctor_arity(cx: @MatchCheckCtxt, ctor: ctor, ty: ty::t) -> uint {
|
||||
}
|
||||
|
||||
fn wild() -> @pat {
|
||||
@{id: 0, node: pat_wild, span: ast_util::dummy_sp()}
|
||||
@pat {id: 0, node: pat_wild, span: ast_util::dummy_sp()}
|
||||
}
|
||||
|
||||
fn specialize(cx: @MatchCheckCtxt, r: ~[@pat], ctor_id: ctor, arity: uint,
|
||||
|
@ -728,7 +728,7 @@ impl &mem_categorization_ctxt {
|
||||
// know what type lies at the other end, so we just call it
|
||||
// `()` (the empty tuple).
|
||||
|
||||
let mt = {ty: ty::mk_tup(self.tcx, ~[]), mutbl: m_imm};
|
||||
let mt = ty::mt {ty: ty::mk_tup(self.tcx, ~[]), mutbl: m_imm};
|
||||
return self.cat_deref_common(node, base_cmt, deref_cnt, mt);
|
||||
}
|
||||
|
||||
|
@ -499,7 +499,7 @@ fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
|
||||
let _indenter = indenter();
|
||||
|
||||
let tcx = bcx.tcx();
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(bcx, tcx.def_map, m, col, val) |p| {
|
||||
match /*bad*/copy p.node {
|
||||
ast::pat_enum(_, subpats) => {
|
||||
@ -600,7 +600,7 @@ fn enter_rec_or_struct(bcx: block, dm: DefMap, m: &[@Match/&r], col: uint,
|
||||
bcx.val_str(val));
|
||||
let _indenter = indenter();
|
||||
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(bcx, dm, m, col, val) |p| {
|
||||
match /*bad*/copy p.node {
|
||||
ast::pat_rec(fpats, _) | ast::pat_struct(_, fpats, _) => {
|
||||
@ -632,7 +632,7 @@ fn enter_tup(bcx: block, dm: DefMap, m: &[@Match/&r],
|
||||
bcx.val_str(val));
|
||||
let _indenter = indenter();
|
||||
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(bcx, dm, m, col, val) |p| {
|
||||
match /*bad*/copy p.node {
|
||||
ast::pat_tup(elts) => {
|
||||
@ -657,7 +657,7 @@ fn enter_tuple_struct(bcx: block, dm: DefMap, m: &[@Match/&r], col: uint,
|
||||
bcx.val_str(val));
|
||||
let _indenter = indenter();
|
||||
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(bcx, dm, m, col, val) |p| {
|
||||
match /*bad*/copy p.node {
|
||||
ast::pat_enum(_, Some(elts)) => Some(elts),
|
||||
@ -680,7 +680,7 @@ fn enter_box(bcx: block, dm: DefMap, m: &[@Match/&r],
|
||||
bcx.val_str(val));
|
||||
let _indenter = indenter();
|
||||
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(bcx, dm, m, col, val) |p| {
|
||||
match p.node {
|
||||
ast::pat_box(sub) => {
|
||||
@ -705,7 +705,7 @@ fn enter_uniq(bcx: block, dm: DefMap, m: &[@Match/&r],
|
||||
bcx.val_str(val));
|
||||
let _indenter = indenter();
|
||||
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(bcx, dm, m, col, val) |p| {
|
||||
match p.node {
|
||||
ast::pat_uniq(sub) => {
|
||||
@ -730,7 +730,7 @@ fn enter_region(bcx: block, dm: DefMap, m: &[@Match/&r],
|
||||
bcx.val_str(val));
|
||||
let _indenter = indenter();
|
||||
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
let dummy = @ast::pat { id: 0, node: ast::pat_wild, span: dummy_sp() };
|
||||
do enter_match(bcx, dm, m, col, val) |p| {
|
||||
match p.node {
|
||||
ast::pat_region(sub) => {
|
||||
@ -857,7 +857,7 @@ fn extract_vec_elems(bcx: block, pat_id: ast::node_id,
|
||||
let tail_begin = tvec::pointer_add(bcx, base, tail_offset);
|
||||
let tail_len = Sub(bcx, len, tail_offset);
|
||||
let tail_ty = ty::mk_evec(bcx.tcx(),
|
||||
{ty: vt.unit_ty, mutbl: ast::m_imm},
|
||||
ty::mt {ty: vt.unit_ty, mutbl: ast::m_imm},
|
||||
ty::vstore_slice(ty::re_static)
|
||||
);
|
||||
let scratch = scratch_datum(bcx, tail_ty, false);
|
||||
|
@ -2184,7 +2184,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef) {
|
||||
let unit_ty = ty::mk_estr(ccx.tcx, ty::vstore_uniq);
|
||||
let vecarg_ty: ty::arg =
|
||||
{mode: ast::expl(ast::by_val),
|
||||
ty: ty::mk_evec(ccx.tcx, {ty: unit_ty, mutbl: ast::m_imm},
|
||||
ty: ty::mk_evec(ccx.tcx, ty::mt {ty: unit_ty, mutbl: ast::m_imm},
|
||||
ty::vstore_uniq)};
|
||||
let nt = ty::mk_nil(ccx.tcx);
|
||||
let llfty = type_of_fn(ccx, ~[vecarg_ty], nt);
|
||||
|
@ -224,7 +224,7 @@ fn store_environment(bcx: block,
|
||||
// tuple. This could be a ptr in uniq or a box or on stack,
|
||||
// whatever.
|
||||
let cbox_ty = tuplify_box_ty(tcx, cdata_ty);
|
||||
let cboxptr_ty = ty::mk_ptr(tcx, {ty:cbox_ty, mutbl:ast::m_imm});
|
||||
let cboxptr_ty = ty::mk_ptr(tcx, ty::mt {ty:cbox_ty, mutbl:ast::m_imm});
|
||||
|
||||
let llbox = PointerCast(bcx, llbox, type_of(ccx, cboxptr_ty));
|
||||
debug!("tuplify_box_ty = %s", ty_to_str(tcx, cbox_ty));
|
||||
|
@ -945,7 +945,10 @@ fn T_opaque_vec(targ_cfg: @session::config) -> TypeRef {
|
||||
// representation of @T as a tuple (i.e., the ty::t version of what T_box()
|
||||
// returns).
|
||||
fn tuplify_box_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
|
||||
let ptr = ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx), mutbl: ast::m_imm});
|
||||
let ptr = ty::mk_ptr(
|
||||
tcx,
|
||||
ty::mt {ty: ty::mk_nil(tcx), mutbl: ast::m_imm}
|
||||
);
|
||||
return ty::mk_tup(tcx, ~[ty::mk_uint(tcx), ty::mk_type(tcx),
|
||||
ptr, ptr,
|
||||
t]);
|
||||
|
@ -251,7 +251,8 @@ fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock {
|
||||
|
||||
// this type may have a different region/mutability than the
|
||||
// real one, but it will have the same runtime representation
|
||||
let slice_ty = ty::mk_evec(tcx, {ty: unit_ty, mutbl: ast::m_imm},
|
||||
let slice_ty = ty::mk_evec(tcx,
|
||||
ty::mt { ty: unit_ty, mutbl: ast::m_imm },
|
||||
ty::vstore_slice(ty::re_static));
|
||||
|
||||
let scratch = scratch_datum(bcx, slice_ty, false);
|
||||
|
@ -26,7 +26,7 @@ use syntax::parse::token::special_idents;
|
||||
// nominal type that has pointers to itself in it.
|
||||
pub fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t {
|
||||
fn nilptr(tcx: ty::ctxt) -> ty::t {
|
||||
ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx), mutbl: ast::m_imm})
|
||||
ty::mk_ptr(tcx, ty::mt {ty: ty::mk_nil(tcx), mutbl: ast::m_imm})
|
||||
}
|
||||
fn simplifier(tcx: ty::ctxt, typ: ty::t) -> ty::t {
|
||||
match ty::get(typ).sty {
|
||||
@ -45,13 +45,12 @@ pub fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t {
|
||||
let simpl_fields = (if ty::ty_dtor(tcx, did).is_present() {
|
||||
// remember the drop flag
|
||||
~[{ident: special_idents::dtor,
|
||||
mt: {ty: ty::mk_u8(tcx),
|
||||
mutbl: ast::m_mutbl}}] }
|
||||
mt: ty::mt {ty: ty::mk_u8(tcx), mutbl: ast::m_mutbl}}] }
|
||||
else { ~[] }) +
|
||||
do ty::lookup_struct_fields(tcx, did).map |f| {
|
||||
let t = ty::lookup_field_type(tcx, did, f.id, substs);
|
||||
{ident: f.ident,
|
||||
mt: {ty: simplify_type(tcx, t), mutbl: ast::m_const}}
|
||||
mt: ty::mt {ty: simplify_type(tcx, t), mutbl: ast::m_const}}
|
||||
};
|
||||
ty::mk_rec(tcx, simpl_fields)
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ fn trans_slice_vstore(bcx: block,
|
||||
|
||||
// Arrange for the backing array to be cleaned up.
|
||||
let fixed_ty = ty::mk_evec(bcx.tcx(),
|
||||
{ty: vt.unit_ty, mutbl: ast::m_mutbl},
|
||||
ty::mt {ty: vt.unit_ty, mutbl: ast::m_mutbl},
|
||||
ty::vstore_fixed(count));
|
||||
let llfixed_ty = T_ptr(type_of::type_of(bcx.ccx(), fixed_ty));
|
||||
let llfixed_casted = BitCast(bcx, llfixed, llfixed_ty);
|
||||
|
@ -258,7 +258,10 @@ type method = {ident: ast::ident,
|
||||
vis: ast::visibility,
|
||||
def_id: ast::def_id};
|
||||
|
||||
type mt = {ty: t, mutbl: ast::mutability};
|
||||
struct mt {
|
||||
ty: t,
|
||||
mutbl: ast::mutability,
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
@ -1149,34 +1152,37 @@ fn mk_enum(cx: ctxt, did: ast::def_id, +substs: substs) -> t {
|
||||
|
||||
fn mk_box(cx: ctxt, tm: mt) -> t { mk_t(cx, ty_box(tm)) }
|
||||
|
||||
fn mk_imm_box(cx: ctxt, ty: t) -> t { mk_box(cx, {ty: ty,
|
||||
mutbl: ast::m_imm}) }
|
||||
fn mk_imm_box(cx: ctxt, ty: t) -> t {
|
||||
mk_box(cx, mt {ty: ty, mutbl: ast::m_imm})
|
||||
}
|
||||
|
||||
fn mk_uniq(cx: ctxt, tm: mt) -> t { mk_t(cx, ty_uniq(tm)) }
|
||||
|
||||
fn mk_imm_uniq(cx: ctxt, ty: t) -> t { mk_uniq(cx, {ty: ty,
|
||||
mutbl: ast::m_imm}) }
|
||||
fn mk_imm_uniq(cx: ctxt, ty: t) -> t {
|
||||
mk_uniq(cx, mt {ty: ty, mutbl: ast::m_imm})
|
||||
}
|
||||
|
||||
fn mk_ptr(cx: ctxt, tm: mt) -> t { mk_t(cx, ty_ptr(tm)) }
|
||||
|
||||
fn mk_rptr(cx: ctxt, r: Region, tm: mt) -> t { mk_t(cx, ty_rptr(r, tm)) }
|
||||
|
||||
fn mk_mut_rptr(cx: ctxt, r: Region, ty: t) -> t {
|
||||
mk_rptr(cx, r, {ty: ty, mutbl: ast::m_mutbl})
|
||||
mk_rptr(cx, r, mt {ty: ty, mutbl: ast::m_mutbl})
|
||||
}
|
||||
fn mk_imm_rptr(cx: ctxt, r: Region, ty: t) -> t {
|
||||
mk_rptr(cx, r, {ty: ty, mutbl: ast::m_imm})
|
||||
mk_rptr(cx, r, mt {ty: ty, mutbl: ast::m_imm})
|
||||
}
|
||||
|
||||
fn mk_mut_ptr(cx: ctxt, ty: t) -> t { mk_ptr(cx, {ty: ty,
|
||||
mutbl: ast::m_mutbl}) }
|
||||
fn mk_mut_ptr(cx: ctxt, ty: t) -> t {
|
||||
mk_ptr(cx, mt {ty: ty, mutbl: ast::m_mutbl})
|
||||
}
|
||||
|
||||
fn mk_imm_ptr(cx: ctxt, ty: t) -> t {
|
||||
mk_ptr(cx, {ty: ty, mutbl: ast::m_imm})
|
||||
mk_ptr(cx, mt {ty: ty, mutbl: ast::m_imm})
|
||||
}
|
||||
|
||||
fn mk_nil_ptr(cx: ctxt) -> t {
|
||||
mk_ptr(cx, {ty: mk_nil(cx), mutbl: ast::m_imm})
|
||||
mk_ptr(cx, mt {ty: mk_nil(cx), mutbl: ast::m_imm})
|
||||
}
|
||||
|
||||
fn mk_evec(cx: ctxt, tm: mt, t: vstore) -> t {
|
||||
@ -1187,7 +1193,7 @@ fn mk_unboxed_vec(cx: ctxt, tm: mt) -> t {
|
||||
mk_t(cx, ty_unboxed_vec(tm))
|
||||
}
|
||||
fn mk_mut_unboxed_vec(cx: ctxt, ty: t) -> t {
|
||||
mk_t(cx, ty_unboxed_vec({ty: ty, mutbl: ast::m_imm}))
|
||||
mk_t(cx, ty_unboxed_vec(mt {ty: ty, mutbl: ast::m_imm}))
|
||||
}
|
||||
|
||||
fn mk_rec(cx: ctxt, +fs: ~[field]) -> t { mk_t(cx, ty_rec(fs)) }
|
||||
@ -1353,19 +1359,19 @@ fn fold_sty(sty: &sty, fldop: fn(t) -> t) -> sty {
|
||||
|
||||
match /*bad*/copy *sty {
|
||||
ty_box(tm) => {
|
||||
ty_box({ty: fldop(tm.ty), mutbl: tm.mutbl})
|
||||
ty_box(mt {ty: fldop(tm.ty), mutbl: tm.mutbl})
|
||||
}
|
||||
ty_uniq(tm) => {
|
||||
ty_uniq({ty: fldop(tm.ty), mutbl: tm.mutbl})
|
||||
ty_uniq(mt {ty: fldop(tm.ty), mutbl: tm.mutbl})
|
||||
}
|
||||
ty_ptr(tm) => {
|
||||
ty_ptr({ty: fldop(tm.ty), mutbl: tm.mutbl})
|
||||
ty_ptr(mt {ty: fldop(tm.ty), mutbl: tm.mutbl})
|
||||
}
|
||||
ty_unboxed_vec(tm) => {
|
||||
ty_unboxed_vec({ty: fldop(tm.ty), mutbl: tm.mutbl})
|
||||
ty_unboxed_vec(mt {ty: fldop(tm.ty), mutbl: tm.mutbl})
|
||||
}
|
||||
ty_evec(tm, vst) => {
|
||||
ty_evec({ty: fldop(tm.ty), mutbl: tm.mutbl}, vst)
|
||||
ty_evec(mt {ty: fldop(tm.ty), mutbl: tm.mutbl}, vst)
|
||||
}
|
||||
ty_enum(tid, ref substs) => {
|
||||
ty_enum(tid, fold_substs(substs, fldop))
|
||||
@ -1376,7 +1382,7 @@ fn fold_sty(sty: &sty, fldop: fn(t) -> t) -> sty {
|
||||
ty_rec(fields) => {
|
||||
let new_fields = do vec::map(fields) |fl| {
|
||||
let new_ty = fldop(fl.mt.ty);
|
||||
let new_mt = {ty: new_ty, mutbl: fl.mt.mutbl};
|
||||
let new_mt = mt {ty: new_ty, mutbl: fl.mt.mutbl};
|
||||
{ident: fl.ident, mt: new_mt}
|
||||
};
|
||||
ty_rec(new_fields)
|
||||
@ -1390,7 +1396,7 @@ fn fold_sty(sty: &sty, fldop: fn(t) -> t) -> sty {
|
||||
ty_fn(FnTyBase {meta: f.meta, sig: sig})
|
||||
}
|
||||
ty_rptr(r, tm) => {
|
||||
ty_rptr(r, {ty: fldop(tm.ty), mutbl: tm.mutbl})
|
||||
ty_rptr(r, mt {ty: fldop(tm.ty), mutbl: tm.mutbl})
|
||||
}
|
||||
ty_struct(did, ref substs) => {
|
||||
ty_struct(did, fold_substs(substs, fldop))
|
||||
@ -1446,7 +1452,7 @@ fn fold_regions_and_ty(
|
||||
ty::ty_rptr(r, mt) => {
|
||||
let m_r = fldr(r);
|
||||
let m_t = fldt(mt.ty);
|
||||
ty::mk_rptr(cx, m_r, {ty: m_t, mutbl: mt.mutbl})
|
||||
ty::mk_rptr(cx, m_r, mt {ty: m_t, mutbl: mt.mutbl})
|
||||
}
|
||||
ty_estr(vstore_slice(r)) => {
|
||||
let m_r = fldr(r);
|
||||
@ -1455,7 +1461,7 @@ fn fold_regions_and_ty(
|
||||
ty_evec(mt, vstore_slice(r)) => {
|
||||
let m_r = fldr(r);
|
||||
let m_t = fldt(mt.ty);
|
||||
ty::mk_evec(cx, {ty: m_t, mutbl: mt.mutbl}, vstore_slice(m_r))
|
||||
ty::mk_evec(cx, mt {ty: m_t, mutbl: mt.mutbl}, vstore_slice(m_r))
|
||||
}
|
||||
ty_enum(def_id, ref substs) => {
|
||||
ty::mk_enum(cx, def_id, fold_substs(substs, fldr, fldt))
|
||||
@ -1527,19 +1533,19 @@ fn fold_region(cx: ctxt, t0: t, fldop: fn(Region, bool) -> Region) -> t {
|
||||
let tb = get(t0);
|
||||
if !tbox_has_flag(tb, has_regions) { return t0; }
|
||||
match tb.sty {
|
||||
ty_rptr(r, {ty: t1, mutbl: m}) => {
|
||||
ty_rptr(r, mt {ty: t1, mutbl: m}) => {
|
||||
let m_r = fldop(r, under_r);
|
||||
let m_t1 = do_fold(cx, t1, true, fldop);
|
||||
ty::mk_rptr(cx, m_r, {ty: m_t1, mutbl: m})
|
||||
ty::mk_rptr(cx, m_r, mt {ty: m_t1, mutbl: m})
|
||||
}
|
||||
ty_estr(vstore_slice(r)) => {
|
||||
let m_r = fldop(r, under_r);
|
||||
ty::mk_estr(cx, vstore_slice(m_r))
|
||||
}
|
||||
ty_evec({ty: t1, mutbl: m}, vstore_slice(r)) => {
|
||||
ty_evec(mt {ty: t1, mutbl: m}, vstore_slice(r)) => {
|
||||
let m_r = fldop(r, under_r);
|
||||
let m_t1 = do_fold(cx, t1, true, fldop);
|
||||
ty::mk_evec(cx, {ty: m_t1, mutbl: m}, vstore_slice(m_r))
|
||||
ty::mk_evec(cx, mt {ty: m_t1, mutbl: m}, vstore_slice(m_r))
|
||||
}
|
||||
ty_fn(_) => {
|
||||
// do not recurse into functions, which introduce fresh bindings
|
||||
@ -2707,7 +2713,7 @@ fn deref_sty(cx: ctxt, sty: &sty, explicit: bool) -> Option<mt> {
|
||||
let variants = enum_variants(cx, did);
|
||||
if vec::len(*variants) == 1u && vec::len(variants[0].args) == 1u {
|
||||
let v_t = subst(cx, substs, variants[0].args[0]);
|
||||
Some({ty: v_t, mutbl: ast::m_imm})
|
||||
Some(mt {ty: v_t, mutbl: ast::m_imm})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -2717,7 +2723,7 @@ fn deref_sty(cx: ctxt, sty: &sty, explicit: bool) -> Option<mt> {
|
||||
let fields = struct_fields(cx, did, substs);
|
||||
if fields.len() == 1 && fields[0].ident ==
|
||||
syntax::parse::token::special_idents::unnamed_field {
|
||||
Some({ty: fields[0].mt.ty, mutbl: ast::m_imm})
|
||||
Some(mt {ty: fields[0].mt.ty, mutbl: ast::m_imm})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -2745,7 +2751,7 @@ fn index(cx: ctxt, t: t) -> Option<mt> {
|
||||
fn index_sty(cx: ctxt, sty: &sty) -> Option<mt> {
|
||||
match *sty {
|
||||
ty_evec(mt, _) => Some(mt),
|
||||
ty_estr(_) => Some({ty: mk_u8(cx), mutbl: ast::m_imm}),
|
||||
ty_estr(_) => Some(mt {ty: mk_u8(cx), mutbl: ast::m_imm}),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
@ -4111,15 +4117,17 @@ fn struct_item_fields(cx:ctxt,
|
||||
substs: &substs,
|
||||
frob_mutability: fn(struct_mutability) -> mutability)
|
||||
-> ~[field] {
|
||||
let mut rslt = ~[];
|
||||
for lookup_struct_fields(cx, did).each |f| {
|
||||
do lookup_struct_fields(cx, did).map |f| {
|
||||
// consider all instance vars mut, because the
|
||||
// constructor may mutate all vars
|
||||
rslt.push({ident: f.ident, mt:
|
||||
{ty: lookup_field_type(cx, did, f.id, substs),
|
||||
mutbl: frob_mutability(f.mutability)}});
|
||||
{
|
||||
ident: f.ident,
|
||||
mt: mt {
|
||||
ty: lookup_field_type(cx, did, f.id, substs),
|
||||
mutbl: frob_mutability(f.mutability)
|
||||
}
|
||||
}
|
||||
}
|
||||
rslt
|
||||
}
|
||||
|
||||
fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool {
|
||||
@ -4199,7 +4207,7 @@ fn ty_params_to_tys(tcx: ty::ctxt, tps: ~[ast::ty_param]) -> ~[t] {
|
||||
/// Returns an equivalent type with all the typedefs and self regions removed.
|
||||
fn normalize_ty(cx: ctxt, t: t) -> t {
|
||||
fn normalize_mt(cx: ctxt, mt: mt) -> mt {
|
||||
{ ty: normalize_ty(cx, mt.ty), mutbl: mt.mutbl }
|
||||
mt { ty: normalize_ty(cx, mt.ty), mutbl: mt.mutbl }
|
||||
}
|
||||
fn normalize_vstore(vstore: vstore) -> vstore {
|
||||
match vstore {
|
||||
|
@ -185,7 +185,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope Copy Durable>(
|
||||
fn ast_mt_to_mt<AC: ast_conv, RS: region_scope Copy Durable>(
|
||||
self: AC, rscope: RS, mt: ast::mt) -> ty::mt {
|
||||
|
||||
return {ty: ast_ty_to_ty(self, rscope, mt.ty), mutbl: mt.mutbl};
|
||||
ty::mt {ty: ast_ty_to_ty(self, rscope, mt.ty), mutbl: mt.mutbl}
|
||||
}
|
||||
|
||||
// Handle @, ~, and & being able to mean estrs and evecs.
|
||||
@ -204,7 +204,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope Copy Durable>(
|
||||
ast::ty_vec(mt) => {
|
||||
let mut mt = ast_mt_to_mt(self, rscope, mt);
|
||||
if a_seq_ty.mutbl == ast::m_mutbl {
|
||||
mt = { ty: mt.ty, mutbl: ast::m_mutbl };
|
||||
mt = ty::mt { ty: mt.ty, mutbl: ast::m_mutbl };
|
||||
}
|
||||
return ty::mk_evec(tcx, mt, vst);
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
||||
let region_var =
|
||||
fcx.infcx().next_region_var_with_lb(
|
||||
pat.span, pcx.block_region);
|
||||
let mt = {ty: expected, mutbl: mutbl};
|
||||
let mt = ty::mt {ty: expected, mutbl: mutbl};
|
||||
let region_ty = ty::mk_rptr(tcx, region_var, mt);
|
||||
demand::eqtype(fcx, pat.span, region_ty, typ);
|
||||
}
|
||||
@ -575,7 +575,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
||||
match tail {
|
||||
Some(tail_pat) => {
|
||||
let slice_ty = ty::mk_evec(tcx,
|
||||
{ty: elt_type.ty, mutbl: elt_type.mutbl},
|
||||
ty::mt {ty: elt_type.ty, mutbl: elt_type.mutbl},
|
||||
ty::vstore_slice(region_var)
|
||||
);
|
||||
check_pat(pcx, tail_pat, slice_ty);
|
||||
|
@ -731,7 +731,7 @@ impl LookupContext {
|
||||
let entry = self.search_for_some_kind_of_autorefd_method(
|
||||
AutoBorrowVec, autoderefs, [m_const, m_imm, m_mutbl],
|
||||
|m,r| ty::mk_evec(tcx,
|
||||
{ty:mt.ty, mutbl:m},
|
||||
ty::mt {ty:mt.ty, mutbl:m},
|
||||
vstore_slice(r)));
|
||||
|
||||
if entry.is_some() { return entry; }
|
||||
@ -741,14 +741,14 @@ impl LookupContext {
|
||||
AutoBorrowVecRef, autoderefs, [m_const, m_imm, m_mutbl],
|
||||
|m,r| {
|
||||
let slice_ty = ty::mk_evec(tcx,
|
||||
{ty:mt.ty, mutbl:m},
|
||||
ty::mt {ty:mt.ty, mutbl:m},
|
||||
vstore_slice(r));
|
||||
// NB: we do not try to autoref to a mutable
|
||||
// pointer. That would be creating a pointer
|
||||
// to a temporary pointer (the borrowed
|
||||
// slice), so any update the callee makes to
|
||||
// it can't be observed.
|
||||
ty::mk_rptr(tcx, r, {ty:slice_ty, mutbl:m_imm})
|
||||
ty::mk_rptr(tcx, r, ty::mt {ty:slice_ty, mutbl:m_imm})
|
||||
})
|
||||
}
|
||||
|
||||
@ -765,7 +765,7 @@ impl LookupContext {
|
||||
AutoBorrowVecRef, autoderefs, [m_imm],
|
||||
|m,r| {
|
||||
let slice_ty = ty::mk_estr(tcx, vstore_slice(r));
|
||||
ty::mk_rptr(tcx, r, {ty:slice_ty, mutbl:m})
|
||||
ty::mk_rptr(tcx, r, ty::mt {ty:slice_ty, mutbl:m})
|
||||
})
|
||||
}
|
||||
|
||||
@ -802,7 +802,7 @@ impl LookupContext {
|
||||
ty_trait(*) | ty_fn(*) => {
|
||||
self.search_for_some_kind_of_autorefd_method(
|
||||
AutoPtr, autoderefs, [m_const, m_imm, m_mutbl],
|
||||
|m,r| ty::mk_rptr(tcx, r, {ty:self_ty, mutbl:m}))
|
||||
|m,r| ty::mk_rptr(tcx, r, ty::mt {ty:self_ty, mutbl:m}))
|
||||
}
|
||||
|
||||
ty_err => None,
|
||||
@ -1183,12 +1183,12 @@ fn transform_self_type_for_method(tcx: ty::ctxt,
|
||||
sty_region(mutability) => {
|
||||
mk_rptr(tcx,
|
||||
self_region.expect(~"self region missing for &self param"),
|
||||
{ ty: impl_ty, mutbl: mutability })
|
||||
ty::mt { ty: impl_ty, mutbl: mutability })
|
||||
}
|
||||
sty_box(mutability) => {
|
||||
match flag {
|
||||
TransformTypeNormally => {
|
||||
mk_box(tcx, { ty: impl_ty, mutbl: mutability })
|
||||
mk_box(tcx, ty::mt { ty: impl_ty, mutbl: mutability })
|
||||
}
|
||||
TransformTypeForObject => impl_ty
|
||||
}
|
||||
@ -1196,7 +1196,7 @@ fn transform_self_type_for_method(tcx: ty::ctxt,
|
||||
sty_uniq(mutability) => {
|
||||
match flag {
|
||||
TransformTypeNormally => {
|
||||
mk_uniq(tcx, { ty: impl_ty, mutbl: mutability })
|
||||
mk_uniq(tcx, ty::mt { ty: impl_ty, mutbl: mutability })
|
||||
}
|
||||
TransformTypeForObject => impl_ty
|
||||
}
|
||||
|
@ -1936,7 +1936,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
}
|
||||
let t: ty::t = fcx.infcx().next_ty_var();
|
||||
for args.each |e| { bot |= check_expr_with(fcx, *e, t); }
|
||||
ty::mk_evec(tcx, {ty: t, mutbl: mutability}, tt)
|
||||
ty::mk_evec(tcx, ty::mt {ty: t, mutbl: mutability}, tt)
|
||||
}
|
||||
ast::expr_repeat(element, count_expr, mutbl) => {
|
||||
let count = ty::eval_repeat_count(tcx, count_expr, expr.span);
|
||||
@ -1944,7 +1944,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
let tt = ast_expr_vstore_to_vstore(fcx, ev, count, vst);
|
||||
let t: ty::t = fcx.infcx().next_ty_var();
|
||||
bot |= check_expr_with(fcx, element, t);
|
||||
ty::mk_evec(tcx, {ty: t, mutbl: mutbl}, tt)
|
||||
ty::mk_evec(tcx, ty::mt {ty: t, mutbl: mutbl}, tt)
|
||||
}
|
||||
_ =>
|
||||
tcx.sess.span_bug(expr.span, ~"vstore modifier on non-sequence")
|
||||
@ -1986,10 +1986,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
let mut oprnd_t = fcx.expr_ty(oprnd);
|
||||
match unop {
|
||||
ast::box(mutbl) => {
|
||||
oprnd_t = ty::mk_box(tcx, {ty: oprnd_t, mutbl: mutbl});
|
||||
oprnd_t = ty::mk_box(tcx, ty::mt {ty: oprnd_t, mutbl: mutbl});
|
||||
}
|
||||
ast::uniq(mutbl) => {
|
||||
oprnd_t = ty::mk_uniq(tcx, {ty: oprnd_t, mutbl: mutbl});
|
||||
oprnd_t = ty::mk_uniq(tcx, ty::mt {ty: oprnd_t, mutbl: mutbl});
|
||||
}
|
||||
ast::deref => {
|
||||
let sty = structure_of(fcx, expr.span, oprnd_t);
|
||||
@ -2075,7 +2075,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
// it needs to live.
|
||||
let region = fcx.infcx().next_region_var(expr.span, expr.id);
|
||||
|
||||
let tm = { ty: fcx.expr_ty(oprnd), mutbl: mutbl };
|
||||
let tm = ty::mt { ty: fcx.expr_ty(oprnd), mutbl: mutbl };
|
||||
let oprnd_t = ty::mk_rptr(tcx, region, tm);
|
||||
fcx.write_ty(id, oprnd_t);
|
||||
}
|
||||
@ -2339,7 +2339,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
ast::expr_vec(args, mutbl) => {
|
||||
let t: ty::t = fcx.infcx().next_ty_var();
|
||||
for args.each |e| { bot |= check_expr_with(fcx, *e, t); }
|
||||
let typ = ty::mk_evec(tcx, {ty: t, mutbl: mutbl},
|
||||
let typ = ty::mk_evec(tcx, ty::mt {ty: t, mutbl: mutbl},
|
||||
ty::vstore_fixed(args.len()));
|
||||
fcx.write_ty(id, typ);
|
||||
}
|
||||
@ -2348,7 +2348,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
fcx.write_ty(count_expr.id, ty::mk_uint(tcx));
|
||||
let t: ty::t = fcx.infcx().next_ty_var();
|
||||
bot |= check_expr_with(fcx, element, t);
|
||||
let t = ty::mk_evec(tcx, {ty: t, mutbl: mutbl},
|
||||
let t = ty::mk_evec(tcx, ty::mt {ty: t, mutbl: mutbl},
|
||||
ty::vstore_fixed(count));
|
||||
fcx.write_ty(id, t);
|
||||
}
|
||||
@ -2379,7 +2379,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
vec::find(*flds, |tf| tf.ident == f.node.ident)
|
||||
).map(|tf| tf.mt.ty));
|
||||
let expr_t = fcx.expr_ty(f.node.expr);
|
||||
let expr_mt = {ty: expr_t, mutbl: f.node.mutbl};
|
||||
let expr_mt = ty::mt {ty: expr_t, mutbl: f.node.mutbl};
|
||||
// for the most precise error message,
|
||||
// should be f.node.expr.span, not f.span
|
||||
respan(f.node.expr.span, {ident: f.node.ident, mt: expr_mt})
|
||||
@ -2804,7 +2804,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
|
||||
region_param: None,
|
||||
ty: ty::mk_ptr(
|
||||
fcx.ccx.tcx,
|
||||
{
|
||||
ty::mt {
|
||||
ty: ty::mk_mach_uint(fcx.ccx.tcx, ast::ty_u8),
|
||||
mutbl: ast::m_imm
|
||||
})
|
||||
@ -3078,8 +3078,8 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) {
|
||||
assert ccx.tcx.intrinsic_defs.contains_key(ty_visitor_name);
|
||||
let (_, tydesc_ty) = tcx.intrinsic_defs.get(tydesc_name);
|
||||
let (_, visitor_trait) = tcx.intrinsic_defs.get(ty_visitor_name);
|
||||
let td_ptr = ty::mk_ptr(ccx.tcx, {ty: tydesc_ty,
|
||||
mutbl: ast::m_imm});
|
||||
let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt {ty: tydesc_ty,
|
||||
mutbl: ast::m_imm});
|
||||
(0u, ~[arg(ast::by_val, td_ptr),
|
||||
arg(ast::by_ref, visitor_trait)], ty::mk_nil(tcx))
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ pub fn replace_bound_regions_in_fn_sig(
|
||||
_}, _}) => {
|
||||
let region = ty::re_bound(ty::br_self);
|
||||
let ty = ty::mk_rptr(tcx, region,
|
||||
{ ty: ty::mk_self(tcx), mutbl: m });
|
||||
ty::mt { ty: ty::mk_self(tcx), mutbl: m });
|
||||
all_tys.push(ty);
|
||||
}
|
||||
_ => {}
|
||||
|
@ -173,14 +173,16 @@ priv impl Assign {
|
||||
// being assigned to a region pointer:
|
||||
(ty::ty_box(_), ty::ty_rptr(r_b, mt_b)) => {
|
||||
let nr_b = ty::mk_box(self.infcx.tcx,
|
||||
{ty: mt_b.ty, mutbl: m_const});
|
||||
ty::mt {ty: mt_b.ty,
|
||||
mutbl: m_const});
|
||||
self.try_assign(1, ty::AutoPtr,
|
||||
a, nr_b,
|
||||
mt_b.mutbl, r_b)
|
||||
}
|
||||
(ty::ty_uniq(_), ty::ty_rptr(r_b, mt_b)) => {
|
||||
let nr_b = ty::mk_uniq(self.infcx.tcx,
|
||||
{ty: mt_b.ty, mutbl: m_const});
|
||||
ty::mt {ty: mt_b.ty,
|
||||
mutbl: m_const});
|
||||
self.try_assign(1, ty::AutoPtr,
|
||||
a, nr_b,
|
||||
mt_b.mutbl, r_b)
|
||||
@ -198,7 +200,8 @@ priv impl Assign {
|
||||
ty::ty_evec(mt_b, ty::vstore_slice(r_b)))
|
||||
if is_borrowable(vs_a) => {
|
||||
let nr_b = ty::mk_evec(self.infcx.tcx,
|
||||
{ty: mt_b.ty, mutbl: m_const},
|
||||
ty::mt {ty: mt_b.ty,
|
||||
mutbl: m_const},
|
||||
vs_a);
|
||||
self.try_assign(0, ty::AutoBorrowVec,
|
||||
a, nr_b,
|
||||
|
@ -50,17 +50,17 @@ impl Glb: Combine {
|
||||
// the precise type from the mut side.
|
||||
(m_mutbl, m_const) => {
|
||||
Sub(*self).tys(a.ty, b.ty).chain(|_t| {
|
||||
Ok({ty: a.ty, mutbl: m_mutbl})
|
||||
Ok(ty::mt {ty: a.ty, mutbl: m_mutbl})
|
||||
})
|
||||
}
|
||||
(m_const, m_mutbl) => {
|
||||
Sub(*self).tys(b.ty, a.ty).chain(|_t| {
|
||||
Ok({ty: b.ty, mutbl: m_mutbl})
|
||||
Ok(ty::mt {ty: b.ty, mutbl: m_mutbl})
|
||||
})
|
||||
}
|
||||
(m_mutbl, m_mutbl) => {
|
||||
eq_tys(&self, a.ty, b.ty).then(|| {
|
||||
Ok({ty: a.ty, mutbl: m_mutbl})
|
||||
Ok(ty::mt {ty: a.ty, mutbl: m_mutbl})
|
||||
})
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ impl Glb: Combine {
|
||||
(m_const, m_imm) |
|
||||
(m_imm, m_imm) => {
|
||||
self.tys(a.ty, b.ty).chain(|t| {
|
||||
Ok({ty: t, mutbl: m_imm})
|
||||
Ok(ty::mt {ty: t, mutbl: m_imm})
|
||||
})
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ impl Glb: Combine {
|
||||
// sides and mutbl of only `m_const`.
|
||||
(m_const, m_const) => {
|
||||
self.tys(a.ty, b.ty).chain(|t| {
|
||||
Ok({ty: t, mutbl: m_const})
|
||||
Ok(ty::mt {ty: t, mutbl: m_const})
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -59,17 +59,17 @@ impl Lub: Combine {
|
||||
|
||||
match m {
|
||||
m_imm | m_const => {
|
||||
self.tys(a.ty, b.ty).chain(|t| Ok({ty: t, mutbl: m}) )
|
||||
self.tys(a.ty, b.ty).chain(|t| Ok(ty::mt {ty: t, mutbl: m}) )
|
||||
}
|
||||
|
||||
m_mutbl => {
|
||||
self.infcx.try(|| {
|
||||
eq_tys(&self, a.ty, b.ty).then(|| {
|
||||
Ok({ty: a.ty, mutbl: m})
|
||||
Ok(ty::mt {ty: a.ty, mutbl: m})
|
||||
})
|
||||
}).chain_err(|_e| {
|
||||
self.tys(a.ty, b.ty).chain(|t| {
|
||||
Ok({ty: t, mutbl: m_const})
|
||||
Ok(ty::mt {ty: t, mutbl: m_const})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -293,10 +293,11 @@ type crate_cfg = ~[@meta_item];
|
||||
|
||||
type crate = spanned<crate_>;
|
||||
|
||||
type crate_ =
|
||||
{module: _mod,
|
||||
attrs: ~[attribute],
|
||||
config: crate_cfg};
|
||||
struct crate_ {
|
||||
module: _mod,
|
||||
attrs: ~[attribute],
|
||||
config: crate_cfg,
|
||||
}
|
||||
|
||||
type meta_item = spanned<meta_item_>;
|
||||
|
||||
@ -312,19 +313,28 @@ type blk = spanned<blk_>;
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
type blk_ = {view_items: ~[@view_item],
|
||||
stmts: ~[@stmt],
|
||||
expr: Option<@expr>,
|
||||
id: node_id,
|
||||
rules: blk_check_mode};
|
||||
struct blk_ {
|
||||
view_items: ~[@view_item],
|
||||
stmts: ~[@stmt],
|
||||
expr: Option<@expr>,
|
||||
id: node_id,
|
||||
rules: blk_check_mode,
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
type pat = {id: node_id, node: pat_, span: span};
|
||||
struct pat {
|
||||
id: node_id,
|
||||
node: pat_,
|
||||
span: span,
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
type field_pat = {ident: ident, pat: @pat};
|
||||
struct field_pat {
|
||||
ident: ident,
|
||||
pat: @pat,
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
@ -634,8 +644,13 @@ enum stmt_ {
|
||||
// a refinement on pat.
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
type local_ = {is_mutbl: bool, ty: @Ty, pat: @pat,
|
||||
init: Option<@expr>, id: node_id};
|
||||
struct local_ {
|
||||
is_mutbl: bool,
|
||||
ty: @Ty,
|
||||
pat: @pat,
|
||||
init: Option<@expr>,
|
||||
id: node_id,
|
||||
}
|
||||
|
||||
type local = spanned<local_>;
|
||||
|
||||
@ -647,11 +662,19 @@ enum decl_ { decl_local(~[@local]), decl_item(@item), }
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
type arm = {pats: ~[@pat], guard: Option<@expr>, body: blk};
|
||||
struct arm {
|
||||
pats: ~[@pat],
|
||||
guard: Option<@expr>,
|
||||
body: blk,
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
type field_ = {mutbl: mutability, ident: ident, expr: @expr};
|
||||
struct field_ {
|
||||
mutbl: mutability,
|
||||
ident: ident,
|
||||
expr: @expr,
|
||||
}
|
||||
|
||||
type field = spanned<field_>;
|
||||
|
||||
@ -743,12 +766,12 @@ enum expr_ {
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
type capture_item_ = {
|
||||
struct capture_item_ {
|
||||
id: int,
|
||||
is_move: bool,
|
||||
name: ident, // Currently, can only capture a local var.
|
||||
span: span
|
||||
};
|
||||
span: span,
|
||||
}
|
||||
|
||||
type capture_item = @capture_item_;
|
||||
|
||||
@ -904,7 +927,10 @@ impl lit_: cmp::Eq {
|
||||
// type structure in middle/ty.rs as well.
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
type mt = {ty: @Ty, mutbl: mutability};
|
||||
struct mt {
|
||||
ty: @Ty,
|
||||
mutbl: mutability,
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
|
@ -289,10 +289,18 @@ fn block_from_expr(e: @expr) -> blk {
|
||||
return spanned {node: blk_, span: e.span};
|
||||
}
|
||||
|
||||
fn default_block(+stmts1: ~[@stmt], expr1: Option<@expr>, id1: node_id) ->
|
||||
blk_ {
|
||||
{view_items: ~[], stmts: stmts1,
|
||||
expr: expr1, id: id1, rules: default_blk}
|
||||
fn default_block(
|
||||
+stmts1: ~[@stmt],
|
||||
expr1: Option<@expr>,
|
||||
id1: node_id
|
||||
) -> blk_ {
|
||||
ast::blk_ {
|
||||
view_items: ~[],
|
||||
stmts: stmts1,
|
||||
expr: expr1,
|
||||
id: id1,
|
||||
rules: default_blk,
|
||||
}
|
||||
}
|
||||
|
||||
fn ident_to_path(s: span, +i: ident) -> @path {
|
||||
@ -304,9 +312,9 @@ fn ident_to_path(s: span, +i: ident) -> @path {
|
||||
}
|
||||
|
||||
fn ident_to_pat(id: node_id, s: span, +i: ident) -> @pat {
|
||||
@{id: id,
|
||||
node: pat_ident(bind_by_value, ident_to_path(s, i), None),
|
||||
span: s}
|
||||
@ast::pat { id: id,
|
||||
node: pat_ident(bind_by_value, ident_to_path(s, i), None),
|
||||
span: s }
|
||||
}
|
||||
|
||||
pure fn is_unguarded(a: &arm) -> bool {
|
||||
|
@ -317,11 +317,14 @@ priv impl ext_ctxt {
|
||||
}
|
||||
|
||||
fn binder_pat(span: span, nm: ast::ident) -> @ast::pat {
|
||||
@{id: self.next_id(),
|
||||
node: ast::pat_ident(ast::bind_by_ref(ast::m_imm),
|
||||
self.path(span, ~[nm]),
|
||||
None),
|
||||
span: span}
|
||||
@ast::pat {
|
||||
id: self.next_id(),
|
||||
node: ast::pat_ident(
|
||||
ast::bind_by_ref(ast::m_imm),
|
||||
self.path(span, ~[nm]),
|
||||
None),
|
||||
span: span,
|
||||
}
|
||||
}
|
||||
|
||||
fn stmt(expr: @ast::expr) -> @ast::stmt {
|
||||
@ -356,21 +359,29 @@ priv impl ext_ctxt {
|
||||
}
|
||||
|
||||
fn blk(span: span, stmts: ~[@ast::stmt]) -> ast::blk {
|
||||
ast::spanned { node: { view_items: ~[],
|
||||
stmts: stmts,
|
||||
expr: None,
|
||||
id: self.next_id(),
|
||||
rules: ast::default_blk},
|
||||
span: span }
|
||||
ast::spanned {
|
||||
node: ast::blk_ {
|
||||
view_items: ~[],
|
||||
stmts: stmts,
|
||||
expr: None,
|
||||
id: self.next_id(),
|
||||
rules: ast::default_blk,
|
||||
},
|
||||
span: span,
|
||||
}
|
||||
}
|
||||
|
||||
fn expr_blk(expr: @ast::expr) -> ast::blk {
|
||||
ast::spanned { node: { view_items: ~[],
|
||||
stmts: ~[],
|
||||
expr: Some(expr),
|
||||
id: self.next_id(),
|
||||
rules: ast::default_blk},
|
||||
span: expr.span }
|
||||
ast::spanned {
|
||||
node: ast::blk_ {
|
||||
view_items: ~[],
|
||||
stmts: ~[],
|
||||
expr: Some(expr),
|
||||
id: self.next_id(),
|
||||
rules: ast::default_blk,
|
||||
},
|
||||
span: expr.span,
|
||||
}
|
||||
}
|
||||
|
||||
fn expr_path(span: span, strs: ~[ast::ident]) -> @ast::expr {
|
||||
@ -560,7 +571,7 @@ fn mk_ser_method(
|
||||
id: cx.next_id(),
|
||||
node: ast::re_anon,
|
||||
},
|
||||
{
|
||||
ast::mt {
|
||||
ty: cx.ty_path(span, ~[cx.ident_of(~"__S")], ~[]),
|
||||
mutbl: ast::m_imm
|
||||
}
|
||||
@ -571,12 +582,14 @@ fn mk_ser_method(
|
||||
let ser_inputs = ~[{
|
||||
mode: ast::infer(cx.next_id()),
|
||||
ty: ty_s,
|
||||
pat: @{id: cx.next_id(),
|
||||
node: ast::pat_ident(
|
||||
ast::bind_by_value,
|
||||
ast_util::ident_to_path(span, cx.ident_of(~"__s")),
|
||||
None),
|
||||
span: span},
|
||||
pat: @ast::pat {
|
||||
id: cx.next_id(),
|
||||
node: ast::pat_ident(
|
||||
ast::bind_by_value,
|
||||
ast_util::ident_to_path(span, cx.ident_of(~"__s")),
|
||||
None),
|
||||
span: span,
|
||||
},
|
||||
id: cx.next_id(),
|
||||
}];
|
||||
|
||||
@ -621,7 +634,7 @@ fn mk_deser_method(
|
||||
id: cx.next_id(),
|
||||
node: ast::re_anon,
|
||||
},
|
||||
{
|
||||
ast::mt {
|
||||
ty: cx.ty_path(span, ~[cx.ident_of(~"__D")], ~[]),
|
||||
mutbl: ast::m_imm
|
||||
}
|
||||
@ -632,12 +645,14 @@ fn mk_deser_method(
|
||||
let deser_inputs = ~[{
|
||||
mode: ast::infer(cx.next_id()),
|
||||
ty: ty_d,
|
||||
pat: @{id: cx.next_id(),
|
||||
node: ast::pat_ident(
|
||||
ast::bind_by_value,
|
||||
ast_util::ident_to_path(span, cx.ident_of(~"__d")),
|
||||
None),
|
||||
span: span},
|
||||
pat: @ast::pat {
|
||||
id: cx.next_id(),
|
||||
node: ast::pat_ident(
|
||||
ast::bind_by_value,
|
||||
ast_util::ident_to_path(span, cx.ident_of(~"__d")),
|
||||
None),
|
||||
span: span,
|
||||
},
|
||||
id: cx.next_id(),
|
||||
}];
|
||||
|
||||
@ -893,7 +908,11 @@ fn mk_deser_fields(
|
||||
);
|
||||
|
||||
ast::spanned {
|
||||
node: { mutbl: field.mutbl, ident: field.ident, expr: expr },
|
||||
node: ast::field_ {
|
||||
mutbl: field.mutbl,
|
||||
ident: field.ident,
|
||||
expr: expr,
|
||||
},
|
||||
span: span,
|
||||
}
|
||||
}
|
||||
@ -959,7 +978,7 @@ fn ser_variant(
|
||||
)
|
||||
};
|
||||
|
||||
let pat = @{
|
||||
let pat = @ast::pat {
|
||||
id: cx.next_id(),
|
||||
node: pat_node,
|
||||
span: span,
|
||||
@ -1012,7 +1031,7 @@ fn ser_variant(
|
||||
]
|
||||
);
|
||||
|
||||
{ pats: ~[pat], guard: None, body: cx.expr_blk(body) }
|
||||
ast::arm { pats: ~[pat], guard: None, body: cx.expr_blk(body) }
|
||||
}
|
||||
|
||||
fn mk_enum_ser_body(
|
||||
@ -1124,21 +1143,25 @@ fn mk_enum_deser_body(
|
||||
fail ~"enum variants unimplemented",
|
||||
};
|
||||
|
||||
let pat = @{
|
||||
let pat = @ast::pat {
|
||||
id: cx.next_id(),
|
||||
node: ast::pat_lit(cx.lit_uint(span, v_idx)),
|
||||
span: span,
|
||||
};
|
||||
|
||||
{
|
||||
ast::arm {
|
||||
pats: ~[pat],
|
||||
guard: None,
|
||||
body: cx.expr_blk(body),
|
||||
}
|
||||
};
|
||||
|
||||
let impossible_case = {
|
||||
pats: ~[@{ id: cx.next_id(), node: ast::pat_wild, span: span}],
|
||||
let impossible_case = ast::arm {
|
||||
pats: ~[@ast::pat {
|
||||
id: cx.next_id(),
|
||||
node: ast::pat_wild,
|
||||
span: span,
|
||||
}],
|
||||
guard: None,
|
||||
|
||||
// FIXME(#3198): proper error message
|
||||
@ -1159,13 +1182,14 @@ fn mk_enum_deser_body(
|
||||
node: ast::ty_infer,
|
||||
span: span
|
||||
},
|
||||
pat: @{id: cx.next_id(),
|
||||
node: ast::pat_ident(
|
||||
ast::bind_by_value,
|
||||
ast_util::ident_to_path(span,
|
||||
cx.ident_of(~"i")),
|
||||
None),
|
||||
span: span},
|
||||
pat: @ast::pat {
|
||||
id: cx.next_id(),
|
||||
node: ast::pat_ident(
|
||||
ast::bind_by_value,
|
||||
ast_util::ident_to_path(span, cx.ident_of(~"i")),
|
||||
None),
|
||||
span: span,
|
||||
},
|
||||
id: cx.next_id(),
|
||||
}],
|
||||
output: @{
|
||||
|
@ -145,8 +145,10 @@ fn mk_uniq_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr {
|
||||
}
|
||||
fn mk_field(sp: span, f: &{ident: ast::ident, ex: @ast::expr})
|
||||
-> ast::field {
|
||||
ast::spanned { node: {mutbl: ast::m_imm, ident: f.ident, expr: f.ex},
|
||||
span: sp }
|
||||
ast::spanned {
|
||||
node: ast::field_ { mutbl: ast::m_imm, ident: f.ident, expr: f.ex },
|
||||
span: sp,
|
||||
}
|
||||
}
|
||||
fn mk_fields(sp: span, fields: ~[{ident: ast::ident, ex: @ast::expr}]) ->
|
||||
~[ast::field] {
|
||||
@ -181,54 +183,67 @@ fn mk_glob_use(cx: ext_ctxt, sp: span,
|
||||
fn mk_local(cx: ext_ctxt, sp: span, mutbl: bool,
|
||||
ident: ast::ident, ex: @ast::expr) -> @ast::stmt {
|
||||
|
||||
let pat : @ast::pat = @{id: cx.next_id(),
|
||||
node: ast::pat_ident(ast::bind_by_value,
|
||||
mk_raw_path(sp, ~[ident]),
|
||||
None),
|
||||
span: sp};
|
||||
let pat = @ast::pat {
|
||||
id: cx.next_id(),
|
||||
node: ast::pat_ident(
|
||||
ast::bind_by_value,
|
||||
mk_raw_path(sp, ~[ident]),
|
||||
None),
|
||||
span: sp,
|
||||
};
|
||||
let ty : @ast::Ty = @{ id: cx.next_id(), node: ast::ty_infer, span: sp };
|
||||
let local : @ast::local = @ast::spanned { node: { is_mutbl: mutbl,
|
||||
ty: ty,
|
||||
pat: pat,
|
||||
init: Some(ex),
|
||||
id: cx.next_id()},
|
||||
span: sp};
|
||||
let local = @ast::spanned {
|
||||
node: ast::local_ {
|
||||
is_mutbl: mutbl,
|
||||
ty: ty,
|
||||
pat: pat,
|
||||
init: Some(ex),
|
||||
id: cx.next_id(),
|
||||
},
|
||||
span: sp,
|
||||
};
|
||||
let decl = ast::spanned {node: ast::decl_local(~[local]), span: sp};
|
||||
@ast::spanned { node: ast::stmt_decl(@decl, cx.next_id()), span: sp }
|
||||
}
|
||||
fn mk_block(cx: ext_ctxt, sp: span,
|
||||
fn mk_block(cx: ext_ctxt, span: span,
|
||||
view_items: ~[@ast::view_item],
|
||||
stmts: ~[@ast::stmt],
|
||||
expr: Option<@ast::expr>) -> @ast::expr {
|
||||
let blk = ast::spanned { node: { view_items: view_items,
|
||||
stmts: stmts,
|
||||
expr: expr,
|
||||
id: cx.next_id(),
|
||||
rules: ast::default_blk },
|
||||
span: sp };
|
||||
mk_expr(cx, sp, ast::expr_block(blk))
|
||||
let blk = ast::spanned {
|
||||
node: ast::blk_ {
|
||||
view_items: view_items,
|
||||
stmts: stmts,
|
||||
expr: expr,
|
||||
id: cx.next_id(),
|
||||
rules: ast::default_blk,
|
||||
},
|
||||
span: span,
|
||||
};
|
||||
mk_expr(cx, span, ast::expr_block(blk))
|
||||
}
|
||||
fn mk_block_(cx: ext_ctxt, sp: span, +stmts: ~[@ast::stmt]) -> ast::blk {
|
||||
fn mk_block_(cx: ext_ctxt, span: span, +stmts: ~[@ast::stmt]) -> ast::blk {
|
||||
ast::spanned {
|
||||
node: {
|
||||
node: ast::blk_ {
|
||||
view_items: ~[],
|
||||
stmts: move stmts,
|
||||
stmts: stmts,
|
||||
expr: None,
|
||||
id: cx.next_id(),
|
||||
rules: ast::default_blk
|
||||
rules: ast::default_blk,
|
||||
},
|
||||
span: sp
|
||||
span: span,
|
||||
}
|
||||
}
|
||||
fn mk_simple_block(cx: ext_ctxt, span: span, expr: @ast::expr) -> ast::blk {
|
||||
let block = {
|
||||
view_items: ~[],
|
||||
stmts: ~[],
|
||||
expr: Some(expr),
|
||||
id: cx.next_id(),
|
||||
rules: ast::default_blk
|
||||
};
|
||||
ast::spanned { node: block, span: span }
|
||||
ast::spanned {
|
||||
node: ast::blk_ {
|
||||
view_items: ~[],
|
||||
stmts: ~[],
|
||||
expr: Some(expr),
|
||||
id: cx.next_id(),
|
||||
rules: ast::default_blk,
|
||||
},
|
||||
span: span,
|
||||
}
|
||||
}
|
||||
fn mk_copy(cx: ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
|
||||
mk_expr(cx, sp, ast::expr_copy(e))
|
||||
@ -237,7 +252,7 @@ fn mk_managed(cx: ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
|
||||
mk_expr(cx, sp, ast::expr_unary(ast::box(ast::m_imm), e))
|
||||
}
|
||||
fn mk_pat(cx: ext_ctxt, span: span, +pat: ast::pat_) -> @ast::pat {
|
||||
@{ id: cx.next_id(), node: move pat, span: span }
|
||||
@ast::pat { id: cx.next_id(), node: pat, span: span }
|
||||
}
|
||||
fn mk_pat_ident(cx: ext_ctxt, span: span, ident: ast::ident) -> @ast::pat {
|
||||
let path = mk_raw_path(span, ~[ ident ]);
|
||||
|
@ -136,7 +136,10 @@ fn create_eq_method(cx: ext_ctxt,
|
||||
type_ident,
|
||||
ty_params);
|
||||
let arg_region = @{ id: cx.next_id(), node: re_anon };
|
||||
let arg_type = ty_rptr(arg_region, { ty: arg_path_type, mutbl: m_imm });
|
||||
let arg_type = ty_rptr(
|
||||
arg_region,
|
||||
ast::mt { ty: arg_path_type, mutbl: m_imm }
|
||||
);
|
||||
let arg_type = @{ id: cx.next_id(), node: move arg_type, span: span };
|
||||
|
||||
// Create the `other` parameter.
|
||||
@ -374,22 +377,17 @@ fn create_enum_variant_pattern(cx: ext_ctxt,
|
||||
prefix,
|
||||
struct_def.fields.len());
|
||||
|
||||
let field_pats = dvec::DVec();
|
||||
for struct_def.fields.eachi |i, struct_field| {
|
||||
let field_pats = do struct_def.fields.mapi |i, struct_field| {
|
||||
let ident = match struct_field.node.kind {
|
||||
named_field(ident, _, _) => ident,
|
||||
unnamed_field => {
|
||||
cx.span_bug(span, ~"unexpected unnamed field");
|
||||
}
|
||||
};
|
||||
field_pats.push({ ident: ident, pat: subpats[i] });
|
||||
}
|
||||
let field_pats = dvec::unwrap(move field_pats);
|
||||
ast::field_pat { ident: ident, pat: subpats[i] }
|
||||
};
|
||||
|
||||
return build::mk_pat_struct(cx,
|
||||
span,
|
||||
matching_path,
|
||||
move field_pats);
|
||||
build::mk_pat_struct(cx, span, matching_path, field_pats)
|
||||
}
|
||||
enum_variant_kind(*) => {
|
||||
cx.span_unimpl(span, ~"enum variants for `deriving`");
|
||||
@ -732,7 +730,7 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
|
||||
matching_body_expr);
|
||||
|
||||
// Create the matching arm.
|
||||
let matching_arm = {
|
||||
let matching_arm = ast::arm {
|
||||
pats: ~[ matching_pat ],
|
||||
guard: None,
|
||||
body: move matching_body_block
|
||||
@ -743,7 +741,7 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
|
||||
// variant then there will always be a match.
|
||||
if enum_definition.variants.len() > 1 {
|
||||
// Create the nonmatching pattern.
|
||||
let nonmatching_pat = @{
|
||||
let nonmatching_pat = @ast::pat {
|
||||
id: cx.next_id(),
|
||||
node: pat_wild,
|
||||
span: span
|
||||
@ -757,12 +755,12 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
|
||||
nonmatching_expr);
|
||||
|
||||
// Create the nonmatching arm.
|
||||
let nonmatching_arm = {
|
||||
let nonmatching_arm = ast::arm {
|
||||
pats: ~[ nonmatching_pat ],
|
||||
guard: None,
|
||||
body: move nonmatching_body_block
|
||||
body: nonmatching_body_block,
|
||||
};
|
||||
other_arms.push(move nonmatching_arm);
|
||||
other_arms.push(nonmatching_arm);
|
||||
}
|
||||
|
||||
// Create the self pattern.
|
||||
@ -784,10 +782,10 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
|
||||
other_match_expr);
|
||||
|
||||
// Create the self arm.
|
||||
let self_arm = {
|
||||
let self_arm = ast::arm {
|
||||
pats: ~[ self_pat ],
|
||||
guard: None,
|
||||
body: move other_match_body_block
|
||||
body: other_match_body_block,
|
||||
};
|
||||
self_arms.push(move self_arm);
|
||||
}
|
||||
@ -813,8 +811,7 @@ fn expand_deriving_iter_bytes_enum_method(cx: ext_ctxt,
|
||||
enum_definition: &enum_def)
|
||||
-> @method {
|
||||
// Create the arms of the match in the method body.
|
||||
let arms = dvec::DVec();
|
||||
for enum_definition.variants.eachi |i, variant| {
|
||||
let arms = do enum_definition.variants.mapi |i, variant| {
|
||||
// Create the matching pattern.
|
||||
let pat = create_enum_variant_pattern(cx, span, variant, ~"__self");
|
||||
|
||||
@ -850,24 +847,22 @@ fn expand_deriving_iter_bytes_enum_method(cx: ext_ctxt,
|
||||
let match_body_block = build::mk_block_(cx, span, move stmts);
|
||||
|
||||
// Create the arm.
|
||||
let arm = {
|
||||
ast::arm {
|
||||
pats: ~[ pat ],
|
||||
guard: None,
|
||||
body: move match_body_block
|
||||
};
|
||||
arms.push(move arm);
|
||||
}
|
||||
body: match_body_block,
|
||||
}
|
||||
};
|
||||
|
||||
// Create the method body.
|
||||
let self_ident = cx.ident_of(~"self");
|
||||
let self_expr = build::mk_path(cx, span, ~[ self_ident ]);
|
||||
let self_expr = build::mk_unary(cx, span, deref, self_expr);
|
||||
let arms = dvec::unwrap(move arms);
|
||||
let self_match_expr = expr_match(self_expr, move arms);
|
||||
let self_match_expr = build::mk_expr(cx, span, move self_match_expr);
|
||||
let self_match_expr = expr_match(self_expr, arms);
|
||||
let self_match_expr = build::mk_expr(cx, span, self_match_expr);
|
||||
let self_match_stmt = build::mk_stmt(cx, span, self_match_expr);
|
||||
|
||||
// Create the method.
|
||||
return create_iter_bytes_method(cx, span, ~[ self_match_stmt ]);
|
||||
create_iter_bytes_method(cx, span, ~[ self_match_stmt ])
|
||||
}
|
||||
|
||||
|
@ -146,8 +146,10 @@ impl ext_ctxt: ext_ctxt_ast_builder {
|
||||
}
|
||||
|
||||
fn field_imm(name: ident, e: @ast::expr) -> ast::field {
|
||||
spanned { node: { mutbl: ast::m_imm, ident: name, expr: e },
|
||||
span: dummy_sp()}
|
||||
spanned {
|
||||
node: ast::field_ { mutbl: ast::m_imm, ident: name, expr: e },
|
||||
span: dummy_sp(),
|
||||
}
|
||||
}
|
||||
|
||||
fn rec(+fields: ~[ast::field]) -> @ast::expr {
|
||||
@ -158,8 +160,13 @@ impl ext_ctxt: ext_ctxt_ast_builder {
|
||||
}
|
||||
|
||||
fn ty_field_imm(name: ident, ty: @ast::Ty) -> ast::ty_field {
|
||||
spanned { node: { ident: name, mt: { ty: ty, mutbl: ast::m_imm } },
|
||||
span: dummy_sp() }
|
||||
spanned {
|
||||
node: {
|
||||
ident: name,
|
||||
mt: ast::mt { ty: ty, mutbl: ast::m_imm },
|
||||
},
|
||||
span: dummy_sp(),
|
||||
}
|
||||
}
|
||||
|
||||
fn ty_rec(+fields: ~[ast::ty_field]) -> @ast::Ty {
|
||||
@ -181,23 +188,29 @@ impl ext_ctxt: ext_ctxt_ast_builder {
|
||||
}
|
||||
|
||||
fn arg(name: ident, ty: @ast::Ty) -> ast::arg {
|
||||
{mode: ast::infer(self.next_id()),
|
||||
ty: ty,
|
||||
pat: @{id: self.next_id(),
|
||||
{
|
||||
mode: ast::infer(self.next_id()),
|
||||
ty: ty,
|
||||
pat: @ast::pat {
|
||||
id: self.next_id(),
|
||||
node: ast::pat_ident(
|
||||
ast::bind_by_value,
|
||||
ast_util::ident_to_path(dummy_sp(), name),
|
||||
None),
|
||||
span: dummy_sp()},
|
||||
id: self.next_id()}
|
||||
span: dummy_sp(),
|
||||
},
|
||||
id: self.next_id(),
|
||||
}
|
||||
}
|
||||
|
||||
fn block(+stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk {
|
||||
let blk = {view_items: ~[],
|
||||
stmts: stmts,
|
||||
expr: Some(e),
|
||||
id: self.next_id(),
|
||||
rules: ast::default_blk};
|
||||
let blk = ast::blk_ {
|
||||
view_items: ~[],
|
||||
stmts: stmts,
|
||||
expr: Some(e),
|
||||
id: self.next_id(),
|
||||
rules: ast::default_blk,
|
||||
};
|
||||
|
||||
spanned { node: blk, span: dummy_sp() }
|
||||
}
|
||||
|
@ -165,11 +165,11 @@ fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ {
|
||||
let fold_meta_item = |x| fold_meta_item_(x, fld);
|
||||
let fold_attribute = |x| fold_attribute_(x, fld);
|
||||
|
||||
return {
|
||||
crate_ {
|
||||
module: fld.fold_mod(c.module),
|
||||
attrs: vec::map(c.attrs, |x| fold_attribute(*x)),
|
||||
config: vec::map(c.config, |x| fold_meta_item(*x))
|
||||
};
|
||||
attrs: c.attrs.map(|x| fold_attribute(*x)),
|
||||
config: c.config.map(|x| fold_meta_item(*x)),
|
||||
}
|
||||
}
|
||||
|
||||
fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ {
|
||||
@ -319,11 +319,13 @@ fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method {
|
||||
|
||||
|
||||
fn noop_fold_block(b: blk_, fld: ast_fold) -> blk_ {
|
||||
return {view_items: vec::map(b.view_items, |x| fld.fold_view_item(*x)),
|
||||
stmts: vec::map(b.stmts, |x| fld.fold_stmt(*x)),
|
||||
expr: option::map(&b.expr, |x| fld.fold_expr(*x)),
|
||||
id: fld.new_id(b.id),
|
||||
rules: b.rules};
|
||||
ast::blk_ {
|
||||
view_items: b.view_items.map(|x| fld.fold_view_item(*x)),
|
||||
stmts: b.stmts.map(|x| fld.fold_stmt(*x)),
|
||||
expr: b.expr.map(|x| fld.fold_expr(*x)),
|
||||
id: fld.new_id(b.id),
|
||||
rules: b.rules,
|
||||
}
|
||||
}
|
||||
|
||||
fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ {
|
||||
@ -337,9 +339,11 @@ fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ {
|
||||
}
|
||||
|
||||
fn noop_fold_arm(a: arm, fld: ast_fold) -> arm {
|
||||
return {pats: vec::map(a.pats, |x| fld.fold_pat(*x)),
|
||||
guard: option::map(&a.guard, |x| fld.fold_expr(*x)),
|
||||
body: fld.fold_block(a.body)};
|
||||
arm {
|
||||
pats: vec::map(a.pats, |x| fld.fold_pat(*x)),
|
||||
guard: option::map(&a.guard, |x| fld.fold_expr(*x)),
|
||||
body: fld.fold_block(a.body),
|
||||
}
|
||||
}
|
||||
|
||||
fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
|
||||
@ -356,20 +360,22 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
|
||||
|pats| vec::map(*pats, |x| fld.fold_pat(*x))))
|
||||
}
|
||||
pat_rec(fields, etc) => {
|
||||
let mut fs = ~[];
|
||||
for fields.each |f| {
|
||||
fs.push({ident: /* FIXME (#2543) */ copy f.ident,
|
||||
pat: fld.fold_pat(f.pat)});
|
||||
}
|
||||
let fs = do fields.map |f| {
|
||||
ast::field_pat {
|
||||
ident: /* FIXME (#2543) */ copy f.ident,
|
||||
pat: fld.fold_pat(f.pat),
|
||||
}
|
||||
};
|
||||
pat_rec(fs, etc)
|
||||
}
|
||||
pat_struct(pth, fields, etc) => {
|
||||
let pth_ = fld.fold_path(pth);
|
||||
let mut fs = ~[];
|
||||
for fields.each |f| {
|
||||
fs.push({ident: /* FIXME (#2543) */ copy f.ident,
|
||||
pat: fld.fold_pat(f.pat)});
|
||||
}
|
||||
let fs = do fields.map |f| {
|
||||
ast::field_pat {
|
||||
ident: /* FIXME (#2543) */ copy f.ident,
|
||||
pat: fld.fold_pat(f.pat)
|
||||
}
|
||||
};
|
||||
pat_struct(pth_, fs, etc)
|
||||
}
|
||||
pat_tup(elts) => pat_tup(vec::map(elts, |x| fld.fold_pat(*x))),
|
||||
@ -406,10 +412,14 @@ fn wrap<T>(f: fn@(T, ast_fold) -> T)
|
||||
|
||||
fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
||||
fn fold_field_(field: field, fld: ast_fold) -> field {
|
||||
spanned { node: { mutbl: field.node.mutbl,
|
||||
ident: fld.fold_ident(field.node.ident),
|
||||
expr: fld.fold_expr(field.node.expr)},
|
||||
span: fld.new_span(field.span) }
|
||||
spanned {
|
||||
node: ast::field_ {
|
||||
mutbl: field.node.mutbl,
|
||||
ident: fld.fold_ident(field.node.ident),
|
||||
expr: fld.fold_expr(field.node.expr),
|
||||
},
|
||||
span: fld.new_span(field.span),
|
||||
}
|
||||
}
|
||||
let fold_field = |x| fold_field_(x, fld);
|
||||
|
||||
@ -466,17 +476,25 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
||||
vec::map((*arms), |x| fld.fold_arm(*x)))
|
||||
}
|
||||
expr_fn(proto, decl, ref body, captures) => {
|
||||
let captures = do captures.map |cap_item| {
|
||||
@ast::capture_item_ {
|
||||
id: fld.new_id(cap_item.id),
|
||||
..**cap_item
|
||||
}
|
||||
};
|
||||
expr_fn(proto, fold_fn_decl(decl, fld),
|
||||
fld.fold_block((*body)),
|
||||
@((*captures).map(|cap_item| {
|
||||
@({id: fld.new_id(cap_item.id),
|
||||
..**cap_item})})))
|
||||
@captures)
|
||||
}
|
||||
expr_fn_block(decl, ref body, captures) => {
|
||||
let captures = do captures.map |cap_item| {
|
||||
@ast::capture_item_ {
|
||||
id: fld.new_id(cap_item.id),
|
||||
..**cap_item
|
||||
}
|
||||
};
|
||||
expr_fn_block(fold_fn_decl(decl, fld), fld.fold_block((*body)),
|
||||
@((*captures).map(|cap_item| {
|
||||
@({id: fld.new_id(cap_item.id),
|
||||
..**cap_item})})))
|
||||
@captures)
|
||||
}
|
||||
expr_block(ref blk) => expr_block(fld.fold_block((*blk))),
|
||||
expr_copy(e) => expr_copy(fld.fold_expr(e)),
|
||||
@ -520,7 +538,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
||||
fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ {
|
||||
let fold_mac = |x| fold_mac_(x, fld);
|
||||
fn fold_mt(mt: mt, fld: ast_fold) -> mt {
|
||||
{ty: fld.fold_ty(mt.ty), mutbl: mt.mutbl}
|
||||
mt { ty: fld.fold_ty(mt.ty), mutbl: mt.mutbl }
|
||||
}
|
||||
fn fold_field(f: ty_field, fld: ast_fold) -> ty_field {
|
||||
spanned { node: { ident: fld.fold_ident(f.node.ident),
|
||||
@ -632,11 +650,13 @@ fn noop_fold_path(&&p: path, fld: ast_fold) -> path {
|
||||
}
|
||||
|
||||
fn noop_fold_local(l: local_, fld: ast_fold) -> local_ {
|
||||
return {is_mutbl: l.is_mutbl,
|
||||
ty: fld.fold_ty(l.ty),
|
||||
pat: fld.fold_pat(l.pat),
|
||||
init: l.init.map(|e| fld.fold_expr(*e)),
|
||||
id: fld.new_id(l.id)};
|
||||
local_ {
|
||||
is_mutbl: l.is_mutbl,
|
||||
ty: fld.fold_ty(l.ty),
|
||||
pat: fld.fold_pat(l.pat),
|
||||
init: l.init.map(|e| fld.fold_expr(*e)),
|
||||
id: fld.new_id(l.id),
|
||||
}
|
||||
}
|
||||
|
||||
/* temporarily eta-expand because of a compiler bug with using `fn<T>` as a
|
||||
@ -729,9 +749,11 @@ impl ast_fold_fns: ast_fold {
|
||||
}
|
||||
fn fold_pat(&&x: @pat) -> @pat {
|
||||
let (n, s) = (self.fold_pat)(x.node, x.span, self as ast_fold);
|
||||
return @{id: (self.new_id)(x.id),
|
||||
node: n,
|
||||
span: (self.new_span)(s)};
|
||||
@pat {
|
||||
id: (self.new_id)(x.id),
|
||||
node: n,
|
||||
span: (self.new_span)(s),
|
||||
}
|
||||
}
|
||||
fn fold_decl(&&x: @decl) -> @decl {
|
||||
let (n, s) = (self.fold_decl)(x.node, x.span, self as ast_fold);
|
||||
|
@ -30,8 +30,9 @@ fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool {
|
||||
|
||||
fn expr_is_simple_block(e: @ast::expr) -> bool {
|
||||
match e.node {
|
||||
ast::expr_block(ast::spanned {node: {rules: ast::default_blk, _}, _}) =>
|
||||
true,
|
||||
ast::expr_block(
|
||||
ast::spanned { node: ast::blk_ { rules: ast::default_blk, _ }, _ }
|
||||
) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ impl Parser {
|
||||
fn parse_mt() -> mt {
|
||||
let mutbl = self.parse_mutability();
|
||||
let t = self.parse_ty(false);
|
||||
return {ty: t, mutbl: mutbl};
|
||||
mt { ty: t, mutbl: mutbl }
|
||||
}
|
||||
|
||||
fn parse_ty_field() -> ty_field {
|
||||
@ -464,9 +464,14 @@ impl Parser {
|
||||
let id = self.parse_ident();
|
||||
self.expect(token::COLON);
|
||||
let ty = self.parse_ty(false);
|
||||
return spanned(lo, ty.span.hi, {
|
||||
ident: id, mt: {ty: ty, mutbl: mutbl}
|
||||
});
|
||||
spanned(
|
||||
lo,
|
||||
ty.span.hi,
|
||||
{
|
||||
ident: id,
|
||||
mt: ast::mt { ty: ty, mutbl: mutbl }
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fn parse_ret_ty() -> (ret_style, @Ty) {
|
||||
@ -673,7 +678,12 @@ impl Parser {
|
||||
fn parse_capture_item(p:Parser, is_move: bool) -> capture_item {
|
||||
let sp = mk_sp(p.span.lo, p.span.hi);
|
||||
let ident = p.parse_ident();
|
||||
@{id: p.get_id(), is_move: is_move, name: ident, span: sp}
|
||||
@ast::capture_item_ {
|
||||
id: p.get_id(),
|
||||
is_move: is_move,
|
||||
name: ident,
|
||||
span: sp,
|
||||
}
|
||||
}
|
||||
|
||||
if self.eat_keyword(~"move") {
|
||||
@ -874,7 +884,7 @@ impl Parser {
|
||||
let i = self.parse_ident();
|
||||
self.expect(sep);
|
||||
let e = self.parse_expr();
|
||||
return spanned(lo, e.span.hi, {mutbl: m, ident: i, expr: e});
|
||||
spanned(lo, e.span.hi, ast::field_ { mutbl: m, ident: i, expr: e })
|
||||
}
|
||||
|
||||
fn mk_expr(+lo: BytePos, +hi: BytePos, +node: expr_) -> @expr {
|
||||
@ -1574,8 +1584,13 @@ impl Parser {
|
||||
let lo = self.last_span.lo;
|
||||
let (decl, captures) = parse_decl();
|
||||
let body = parse_body();
|
||||
let fakeblock = {view_items: ~[], stmts: ~[], expr: Some(body),
|
||||
id: self.get_id(), rules: default_blk};
|
||||
let fakeblock = ast::blk_ {
|
||||
view_items: ~[],
|
||||
stmts: ~[],
|
||||
expr: Some(body),
|
||||
id: self.get_id(),
|
||||
rules: default_blk,
|
||||
};
|
||||
let fakeblock = spanned(body.span.lo, body.span.hi,
|
||||
fakeblock);
|
||||
return self.mk_expr(lo, body.span.hi,
|
||||
@ -1753,14 +1768,18 @@ impl Parser {
|
||||
self.eat(token::COMMA);
|
||||
}
|
||||
|
||||
let blk = spanned { node: { view_items: ~[],
|
||||
stmts: ~[],
|
||||
expr: Some(expr),
|
||||
id: self.get_id(),
|
||||
rules: default_blk},
|
||||
span: expr.span };
|
||||
let blk = spanned {
|
||||
node: ast::blk_ {
|
||||
view_items: ~[],
|
||||
stmts: ~[],
|
||||
expr: Some(expr),
|
||||
id: self.get_id(),
|
||||
rules: default_blk,
|
||||
},
|
||||
span: expr.span,
|
||||
};
|
||||
|
||||
arms.push({pats: pats, guard: guard, body: blk});
|
||||
arms.push(ast::arm { pats: pats, guard: guard, body: blk });
|
||||
}
|
||||
let mut hi = self.span.hi;
|
||||
self.bump();
|
||||
@ -1824,9 +1843,9 @@ impl Parser {
|
||||
let subpat = self.parse_pat(refutable);
|
||||
if is_tail {
|
||||
match subpat {
|
||||
@{ node: pat_wild, _ } => (),
|
||||
@{ node: pat_ident(_, _, _), _ } => (),
|
||||
@{ span, _ } => self.span_fatal(
|
||||
@ast::pat { node: pat_wild, _ } => (),
|
||||
@ast::pat { node: pat_ident(_, _, _), _ } => (),
|
||||
@ast::pat { span, _ } => self.span_fatal(
|
||||
span, ~"expected an identifier or `_`"
|
||||
)
|
||||
}
|
||||
@ -1872,13 +1891,13 @@ impl Parser {
|
||||
self.bump();
|
||||
subpat = self.parse_pat(refutable);
|
||||
} else {
|
||||
subpat = @{
|
||||
subpat = @ast::pat {
|
||||
id: self.get_id(),
|
||||
node: pat_ident(bind_infer, fieldpath, None),
|
||||
span: self.last_span
|
||||
};
|
||||
}
|
||||
fields.push({ident: fieldname, pat: subpat});
|
||||
fields.push(ast::field_pat { ident: fieldname, pat: subpat });
|
||||
}
|
||||
return (fields, etc);
|
||||
}
|
||||
@ -2083,7 +2102,7 @@ impl Parser {
|
||||
hi = self.span.hi;
|
||||
}
|
||||
}
|
||||
return @{id: self.get_id(), node: pat, span: mk_sp(lo, hi)};
|
||||
@ast::pat { id: self.get_id(), node: pat, span: mk_sp(lo, hi) }
|
||||
}
|
||||
|
||||
fn parse_pat_ident(refutable: bool,
|
||||
@ -2122,9 +2141,17 @@ impl Parser {
|
||||
span: mk_sp(lo, lo)};
|
||||
if self.eat(token::COLON) { ty = self.parse_ty(false); }
|
||||
let init = if allow_init { self.parse_initializer() } else { None };
|
||||
return @spanned(lo, self.last_span.hi,
|
||||
{is_mutbl: is_mutbl, ty: ty, pat: pat,
|
||||
init: init, id: self.get_id()});
|
||||
@spanned(
|
||||
lo,
|
||||
self.last_span.hi,
|
||||
ast::local_ {
|
||||
is_mutbl: is_mutbl,
|
||||
ty: ty,
|
||||
pat: pat,
|
||||
init: init,
|
||||
id: self.get_id(),
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fn parse_let() -> @decl {
|
||||
@ -2378,9 +2405,14 @@ impl Parser {
|
||||
}
|
||||
let mut hi = self.span.hi;
|
||||
self.bump();
|
||||
let bloc = {view_items: view_items, stmts: stmts, expr: expr,
|
||||
id: self.get_id(), rules: s};
|
||||
return spanned(lo, hi, bloc);
|
||||
let bloc = ast::blk_ {
|
||||
view_items: view_items,
|
||||
stmts: stmts,
|
||||
expr: expr,
|
||||
id: self.get_id(),
|
||||
rules: s,
|
||||
};
|
||||
spanned(lo, hi, bloc)
|
||||
}
|
||||
|
||||
fn mk_ty_path(i: ident) -> @Ty {
|
||||
@ -3855,10 +3887,10 @@ impl Parser {
|
||||
let crate_attrs = self.parse_inner_attrs_and_next();
|
||||
let first_item_outer_attrs = crate_attrs.next;
|
||||
let m = self.parse_mod_items(token::EOF, first_item_outer_attrs);
|
||||
return @spanned(lo, self.span.lo,
|
||||
{module: m,
|
||||
attrs: crate_attrs.inner,
|
||||
config: self.cfg});
|
||||
@spanned(lo, self.span.lo,
|
||||
ast::crate_ { module: m,
|
||||
attrs: crate_attrs.inner,
|
||||
config: self.cfg })
|
||||
}
|
||||
|
||||
fn parse_str() -> @~str {
|
||||
|
Loading…
x
Reference in New Issue
Block a user