1
Fork 0

libsyntax: Remove newtype enums from libsyntax. rs=deenum

This commit is contained in:
Patrick Walton 2013-03-07 18:04:21 -08:00
parent dc4869945c
commit 7538450b8d
6 changed files with 14 additions and 40 deletions

View file

@ -1086,16 +1086,11 @@ pub enum variant_kind {
#[auto_encode] #[auto_encode]
#[auto_decode] #[auto_decode]
#[deriving_eq] #[deriving_eq]
pub struct enum_def_ { pub struct enum_def {
variants: ~[variant], variants: ~[variant],
common: Option<@struct_def>, common: Option<@struct_def>,
} }
#[auto_encode]
#[auto_decode]
#[deriving_eq]
pub enum enum_def = enum_def_;
#[auto_encode] #[auto_encode]
#[auto_decode] #[auto_decode]
#[deriving_eq] #[deriving_eq]

View file

@ -35,11 +35,11 @@ pub trait Pos {
} }
/// A byte offset /// A byte offset
pub enum BytePos = uint; pub struct BytePos(uint);
/// A character offset. Because of multibyte utf8 characters, a byte offset /// A character offset. Because of multibyte utf8 characters, a byte offset
/// is not equivalent to a character offset. The CodeMap will convert BytePos /// is not equivalent to a character offset. The CodeMap will convert BytePos
/// values to CharPos values as necessary. /// values to CharPos values as necessary.
pub enum CharPos = uint; pub struct CharPos(uint);
// XXX: Lots of boilerplate in these impls, but so far my attempts to fix // XXX: Lots of boilerplate in these impls, but so far my attempts to fix
// have been unsuccessful // have been unsuccessful

View file

@ -1327,16 +1327,4 @@ mod test {
CallToEmitEnumVariantArg (1), CallToEmitEnumVariantArg (1),
CallToEmitUint (44)]); CallToEmitUint (44)]);
} }
pub enum BPos = uint;
#[auto_encode]
pub struct HasPos { pos : BPos }
#[test] fn encode_newtype_test () {
check_equal (to_call_log (HasPos {pos:BPos(48)}),
~[CallToEmitStruct(~"HasPos",1),
CallToEmitField(~"pos",0),
CallToEmitUint(48)]);
}
} }

View file

@ -238,9 +238,7 @@ impl to_type_decls for state {
cx.item_enum_poly( cx.item_enum_poly(
name, name,
self.span, self.span,
ast::enum_def(enum_def_ { ast::enum_def { variants: items_msg, common: None },
variants: items_msg,
common: None }),
cx.strip_bounds(&self.generics) cx.strip_bounds(&self.generics)
) )
] ]

View file

@ -254,16 +254,14 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ {
} }
item_enum(ref enum_definition, ref generics) => { item_enum(ref enum_definition, ref generics) => {
item_enum( item_enum(
ast::enum_def( ast::enum_def {
ast::enum_def_ { variants: do enum_definition.variants.map |x| {
variants: do enum_definition.variants.map |x| { fld.fold_variant(x)
fld.fold_variant(x) },
}, common: do enum_definition.common.map |x| {
common: do enum_definition.common.map |x| { fold_struct_def(*x, fld)
fold_struct_def(*x, fld)
}
} }
), },
fold_generics(generics, fld)) fold_generics(generics, fld))
} }
item_struct(ref struct_def, ref generics) => { item_struct(ref struct_def, ref generics) => {
@ -684,10 +682,7 @@ fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ {
fold_struct_def(*x, fld) fold_struct_def(*x, fld)
}; };
kind = enum_variant_kind( kind = enum_variant_kind(
ast::enum_def(ast::enum_def_ { ast::enum_def { variants: variants, common: common }
variants: variants,
common: common
})
); );
} }
} }

View file

@ -3775,7 +3775,7 @@ pub impl Parser {
enum"); enum");
} }
enum_def(ast::enum_def_ { variants: variants, common: common_fields }) ast::enum_def { variants: variants, common: common_fields }
} }
fn parse_item_enum(&self) -> item_info { fn parse_item_enum(&self) -> item_info {
@ -3801,9 +3801,7 @@ pub impl Parser {
return ( return (
id, id,
item_enum( item_enum(
enum_def( ast::enum_def { variants: ~[variant], common: None },
ast::enum_def_ { variants: ~[variant], common: None }
),
generics), generics),
None None
); );