convert ast::struct_dtor_ into a struct
This commit is contained in:
parent
5c0d674a45
commit
ebea895d02
@ -288,10 +288,12 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
|
||||
}
|
||||
ast::ii_dtor(ref dtor, nm, ref tps, parent_id) => {
|
||||
let dtor_body = fld.fold_block((*dtor).node.body);
|
||||
ast::ii_dtor(ast::spanned { node: { body: dtor_body,
|
||||
.. /*bad*/copy (*dtor).node },
|
||||
.. (/*bad*/copy *dtor) },
|
||||
nm, /*bad*/copy *tps, parent_id)
|
||||
ast::ii_dtor(
|
||||
ast::spanned {
|
||||
node: ast::struct_dtor_ { body: dtor_body,
|
||||
.. /*bad*/copy (*dtor).node },
|
||||
.. (/*bad*/copy *dtor) },
|
||||
nm, /*bad*/copy *tps, parent_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -327,12 +329,15 @@ fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item)
|
||||
let dtor_id = fld.new_id((*dtor).node.id);
|
||||
let new_parent = xcx.tr_def_id(parent_id);
|
||||
let new_self = fld.new_id((*dtor).node.self_id);
|
||||
ast::ii_dtor(ast::spanned { node: { id: dtor_id,
|
||||
attrs: dtor_attrs,
|
||||
self_id: new_self,
|
||||
body: dtor_body },
|
||||
.. (/*bad*/copy *dtor)},
|
||||
nm, new_params, new_parent)
|
||||
ast::ii_dtor(
|
||||
ast::spanned {
|
||||
node: ast::struct_dtor_ { id: dtor_id,
|
||||
attrs: dtor_attrs,
|
||||
self_id: new_self,
|
||||
body: dtor_body },
|
||||
.. (/*bad*/copy *dtor)
|
||||
},
|
||||
nm, new_params, new_parent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1567,10 +1567,12 @@ type struct_dtor = spanned<struct_dtor_>;
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
type struct_dtor_ = {id: node_id,
|
||||
attrs: ~[attribute],
|
||||
self_id: node_id,
|
||||
body: blk};
|
||||
struct struct_dtor_ {
|
||||
id: node_id,
|
||||
attrs: ~[attribute],
|
||||
self_id: node_id,
|
||||
body: blk,
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
|
@ -185,8 +185,12 @@ fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
|
||||
match fk {
|
||||
visit::fk_dtor(tps, ref attrs, self_id, parent_id) => {
|
||||
let dt = @spanned {
|
||||
node: {id: id, attrs: (*attrs), self_id: self_id,
|
||||
body: /* FIXME (#2543) */ copy body},
|
||||
node: ast::struct_dtor_ {
|
||||
id: id,
|
||||
attrs: (*attrs),
|
||||
self_id: self_id,
|
||||
body: /* FIXME (#2543) */ copy body,
|
||||
},
|
||||
span: sp,
|
||||
};
|
||||
cx.map.insert(id, node_dtor(/* FIXME (#2543) */ copy tps, dt,
|
||||
|
@ -276,8 +276,9 @@ fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold)
|
||||
let dtor = do option::map(&struct_def.dtor) |dtor| {
|
||||
let dtor_body = fld.fold_block(dtor.node.body);
|
||||
let dtor_id = fld.new_id(dtor.node.id);
|
||||
spanned { node: { body: dtor_body,
|
||||
id: dtor_id, .. dtor.node},
|
||||
spanned { node: ast::struct_dtor_ { body: dtor_body,
|
||||
id: dtor_id,
|
||||
.. dtor.node},
|
||||
span: dtor.span }
|
||||
};
|
||||
return @{
|
||||
@ -576,8 +577,9 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
||||
let dtor = do option::map(&struct_def.dtor) |dtor| {
|
||||
let dtor_body = fld.fold_block(dtor.node.body);
|
||||
let dtor_id = fld.new_id(dtor.node.id);
|
||||
spanned { node: { body: dtor_body,
|
||||
id: dtor_id, .. dtor.node},
|
||||
spanned { node: ast::struct_dtor_ { body: dtor_body,
|
||||
id: dtor_id,
|
||||
.. dtor.node},
|
||||
.. *dtor }
|
||||
};
|
||||
kind = struct_variant_kind(@{
|
||||
|
@ -2836,16 +2836,16 @@ impl Parser {
|
||||
|
||||
let actual_dtor = do the_dtor.map |dtor| {
|
||||
let (d_body, d_attrs, d_s) = *dtor;
|
||||
spanned { node: { id: self.get_id(),
|
||||
attrs: d_attrs,
|
||||
self_id: self.get_id(),
|
||||
body: d_body},
|
||||
spanned { node: ast::struct_dtor_ { id: self.get_id(),
|
||||
attrs: d_attrs,
|
||||
self_id: self.get_id(),
|
||||
body: d_body},
|
||||
span: d_s}};
|
||||
let _ = self.get_id(); // XXX: Workaround for crazy bug.
|
||||
let new_id = self.get_id();
|
||||
(class_name,
|
||||
item_struct(@{
|
||||
fields: move fields,
|
||||
fields: fields,
|
||||
dtor: actual_dtor,
|
||||
ctor_id: if is_tuple_like { Some(new_id) } else { None }
|
||||
}, ty_params),
|
||||
@ -3333,15 +3333,15 @@ impl Parser {
|
||||
self.bump();
|
||||
let mut actual_dtor = do the_dtor.map |dtor| {
|
||||
let (d_body, d_attrs, d_s) = *dtor;
|
||||
spanned { node: { id: self.get_id(),
|
||||
attrs: d_attrs,
|
||||
self_id: self.get_id(),
|
||||
body: d_body },
|
||||
spanned { node: ast::struct_dtor_ { id: self.get_id(),
|
||||
attrs: d_attrs,
|
||||
self_id: self.get_id(),
|
||||
body: d_body },
|
||||
span: d_s }
|
||||
};
|
||||
|
||||
return @{
|
||||
fields: move fields,
|
||||
fields: fields,
|
||||
dtor: actual_dtor,
|
||||
ctor_id: None
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user