convert ast::struct_def to a struct
This commit is contained in:
parent
530a113bfa
commit
1f5e9ff362
6 changed files with 12 additions and 10 deletions
|
@ -3798,7 +3798,9 @@ fn ty_dtor(cx: ctxt, struct_id: def_id) -> DtorKind {
|
||||||
if is_local(struct_id) {
|
if is_local(struct_id) {
|
||||||
match cx.items.find(struct_id.node) {
|
match cx.items.find(struct_id.node) {
|
||||||
Some(ast_map::node_item(@ast::item {
|
Some(ast_map::node_item(@ast::item {
|
||||||
node: ast::item_struct(@{ dtor: Some(ref dtor), _ }, _),
|
node: ast::item_struct(@ast::struct_def { dtor: Some(ref dtor),
|
||||||
|
_ },
|
||||||
|
_),
|
||||||
_
|
_
|
||||||
}, _)) =>
|
}, _)) =>
|
||||||
LegacyDtor(local_def((*dtor).node.id)),
|
LegacyDtor(local_def((*dtor).node.id)),
|
||||||
|
|
|
@ -371,7 +371,7 @@ fn fold_struct(
|
||||||
fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item {
|
fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item {
|
||||||
let node = match item.node {
|
let node = match item.node {
|
||||||
ast::item_struct(def, tys) => {
|
ast::item_struct(def, tys) => {
|
||||||
let def = @{
|
let def = @ast::struct_def {
|
||||||
dtor: None, // Remove the drop { } block
|
dtor: None, // Remove the drop { } block
|
||||||
.. *def
|
.. *def
|
||||||
};
|
};
|
||||||
|
|
|
@ -1501,7 +1501,7 @@ impl struct_field_kind : cmp::Eq {
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
type struct_def = {
|
struct struct_def {
|
||||||
fields: ~[@struct_field], /* fields */
|
fields: ~[@struct_field], /* fields */
|
||||||
/* (not including ctor or dtor) */
|
/* (not including ctor or dtor) */
|
||||||
/* dtor is optional */
|
/* dtor is optional */
|
||||||
|
@ -1509,7 +1509,7 @@ type struct_def = {
|
||||||
/* ID of the constructor. This is only used for tuple- or enum-like
|
/* ID of the constructor. This is only used for tuple- or enum-like
|
||||||
* structs. */
|
* structs. */
|
||||||
ctor_id: Option<node_id>
|
ctor_id: Option<node_id>
|
||||||
};
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FIXME (#3300): Should allow items to be anonymous. Right now
|
FIXME (#3300): Should allow items to be anonymous. Right now
|
||||||
|
|
|
@ -141,7 +141,7 @@ fn expand_auto_encode(
|
||||||
|
|
||||||
~[filter_attrs(*item), ser_impl]
|
~[filter_attrs(*item), ser_impl]
|
||||||
},
|
},
|
||||||
ast::item_struct(@{ fields, _}, tps) => {
|
ast::item_struct(@ast::struct_def { fields, _}, tps) => {
|
||||||
let ser_impl = mk_struct_ser_impl(
|
let ser_impl = mk_struct_ser_impl(
|
||||||
cx,
|
cx,
|
||||||
item.span,
|
item.span,
|
||||||
|
@ -207,7 +207,7 @@ fn expand_auto_decode(
|
||||||
|
|
||||||
~[filter_attrs(*item), deser_impl]
|
~[filter_attrs(*item), deser_impl]
|
||||||
},
|
},
|
||||||
ast::item_struct(@{ fields, _}, tps) => {
|
ast::item_struct(@ast::struct_def { fields, _}, tps) => {
|
||||||
let deser_impl = mk_struct_deser_impl(
|
let deser_impl = mk_struct_deser_impl(
|
||||||
cx,
|
cx,
|
||||||
item.span,
|
item.span,
|
||||||
|
|
|
@ -281,7 +281,7 @@ fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold)
|
||||||
.. dtor.node},
|
.. dtor.node},
|
||||||
span: dtor.span }
|
span: dtor.span }
|
||||||
};
|
};
|
||||||
return @{
|
return @ast::struct_def {
|
||||||
fields: vec::map(struct_def.fields, |f| fold_struct_field(*f, fld)),
|
fields: vec::map(struct_def.fields, |f| fold_struct_field(*f, fld)),
|
||||||
dtor: dtor,
|
dtor: dtor,
|
||||||
ctor_id: option::map(&struct_def.ctor_id, |cid| fld.new_id(*cid))
|
ctor_id: option::map(&struct_def.ctor_id, |cid| fld.new_id(*cid))
|
||||||
|
@ -582,7 +582,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
||||||
.. dtor.node},
|
.. dtor.node},
|
||||||
.. *dtor }
|
.. *dtor }
|
||||||
};
|
};
|
||||||
kind = struct_variant_kind(@{
|
kind = struct_variant_kind(@ast::struct_def {
|
||||||
fields: vec::map(struct_def.fields,
|
fields: vec::map(struct_def.fields,
|
||||||
|f| fld.fold_struct_field(*f)),
|
|f| fld.fold_struct_field(*f)),
|
||||||
dtor: dtor,
|
dtor: dtor,
|
||||||
|
|
|
@ -2844,7 +2844,7 @@ impl Parser {
|
||||||
let _ = self.get_id(); // XXX: Workaround for crazy bug.
|
let _ = self.get_id(); // XXX: Workaround for crazy bug.
|
||||||
let new_id = self.get_id();
|
let new_id = self.get_id();
|
||||||
(class_name,
|
(class_name,
|
||||||
item_struct(@{
|
item_struct(@ast::struct_def {
|
||||||
fields: fields,
|
fields: fields,
|
||||||
dtor: actual_dtor,
|
dtor: actual_dtor,
|
||||||
ctor_id: if is_tuple_like { Some(new_id) } else { None }
|
ctor_id: if is_tuple_like { Some(new_id) } else { None }
|
||||||
|
@ -3340,7 +3340,7 @@ impl Parser {
|
||||||
span: d_s }
|
span: d_s }
|
||||||
};
|
};
|
||||||
|
|
||||||
return @{
|
return @ast::struct_def {
|
||||||
fields: fields,
|
fields: fields,
|
||||||
dtor: actual_dtor,
|
dtor: actual_dtor,
|
||||||
ctor_id: None
|
ctor_id: None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue