rustc: Do some plumbing work in preparation for common fields in enums
This commit is contained in:
@@ -23,15 +23,15 @@ import ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
|
||||
capture_item, cdir_dir_mod, cdir_src_mod, cdir_view_item,
|
||||
class_immutable, class_member, class_method, class_mutable,
|
||||
crate, crate_cfg, crate_directive, decl, decl_item, decl_local,
|
||||
default_blk, deref, div, enum_variant_kind, expl, expr, expr_,
|
||||
expr_addr_of, expr_match, expr_again, expr_assert, expr_assign,
|
||||
expr_assign_op, expr_binary, expr_block, expr_break, expr_call,
|
||||
expr_cast, expr_copy, expr_do_body, expr_fail, expr_field,
|
||||
expr_fn, expr_fn_block, expr_if, expr_index, expr_lit, expr_log,
|
||||
expr_loop, expr_loop_body, expr_mac, expr_move, expr_path,
|
||||
expr_rec, expr_repeat, expr_ret, expr_swap, expr_struct,
|
||||
expr_tup, expr_unary, expr_unary_move, expr_vec, expr_vstore,
|
||||
expr_while, extern_fn, field, fn_decl, foreign_item,
|
||||
default_blk, deref, div, enum_def, enum_variant_kind, expl, expr,
|
||||
expr_, expr_addr_of, expr_match, expr_again, expr_assert,
|
||||
expr_assign, expr_assign_op, expr_binary, expr_block, expr_break,
|
||||
expr_call, expr_cast, expr_copy, expr_do_body, expr_fail,
|
||||
expr_field, expr_fn, expr_fn_block, expr_if, expr_index,
|
||||
expr_lit, expr_log, expr_loop, expr_loop_body, expr_mac,
|
||||
expr_move, expr_path, expr_rec, expr_repeat, expr_ret, expr_swap,
|
||||
expr_struct, expr_tup, expr_unary, expr_unary_move, expr_vec,
|
||||
expr_vstore, expr_while, extern_fn, field, fn_decl, foreign_item,
|
||||
foreign_item_fn, foreign_mod, ident, impure_fn, infer, inherited,
|
||||
init_assign, init_move, initializer, instance_var, item, item_,
|
||||
item_class, item_const, item_enum, item_fn, item_foreign_mod,
|
||||
@@ -2841,7 +2841,7 @@ class parser {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_enum_body(ty_params: ~[ast::ty_param]) -> ~[ast::variant] {
|
||||
fn parse_enum_def(ty_params: ~[ast::ty_param]) -> enum_def {
|
||||
let mut variants: ~[variant] = ~[];
|
||||
let mut all_nullary = true, have_disr = false;
|
||||
|
||||
@@ -2932,7 +2932,7 @@ class parser {
|
||||
enum");
|
||||
}
|
||||
|
||||
return variants;
|
||||
return enum_def({ variants: variants });
|
||||
}
|
||||
|
||||
fn parse_item_enum() -> item_info {
|
||||
@@ -2954,12 +2954,13 @@ class parser {
|
||||
id: self.get_id(),
|
||||
disr_expr: none,
|
||||
vis: public});
|
||||
return (id, item_enum(~[variant], ty_params), none);
|
||||
return (id, item_enum(enum_def({ variants: ~[variant] }),
|
||||
ty_params), none);
|
||||
}
|
||||
self.expect(token::LBRACE);
|
||||
|
||||
let variants = self.parse_enum_body(ty_params);
|
||||
(id, item_enum(variants, ty_params), none)
|
||||
let enum_definition = self.parse_enum_def(ty_params);
|
||||
(id, item_enum(enum_definition, ty_params), none)
|
||||
}
|
||||
|
||||
fn parse_fn_ty_proto() -> proto {
|
||||
|
||||
Reference in New Issue
Block a user