convert ast::{field_,capture_item_,mt} and middle::ty::mt into structs
This commit is contained in:
parent
4bcd19f6be
commit
293cd3480c
@ -340,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()};
|
||||
}
|
||||
|
||||
@ -389,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);
|
||||
|
||||
@ -403,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));
|
||||
|
||||
@ -415,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));
|
||||
|
||||
@ -427,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"),
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -670,7 +670,11 @@ struct arm {
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
type field_ = {mutbl: mutability, ident: ident, expr: @expr};
|
||||
struct field_ {
|
||||
mutbl: mutability,
|
||||
ident: ident,
|
||||
expr: @expr,
|
||||
}
|
||||
|
||||
type field = spanned<field_>;
|
||||
|
||||
@ -762,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_;
|
||||
|
||||
@ -923,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]
|
||||
|
@ -571,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
|
||||
}
|
||||
@ -634,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
|
||||
}
|
||||
@ -908,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,
|
||||
}
|
||||
}
|
||||
|
@ -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] {
|
||||
|
@ -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.
|
||||
|
@ -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 {
|
||||
|
@ -412,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);
|
||||
|
||||
@ -472,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)),
|
||||
@ -526,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),
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user