mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-14 09:36:06 +00:00
libsyntax: Remove newtype enums from libsyntax. rs=deenum
This commit is contained in:
parent
dc4869945c
commit
7538450b8d
@ -1086,16 +1086,11 @@ pub enum variant_kind {
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
#[deriving_eq]
|
||||
pub struct enum_def_ {
|
||||
pub struct enum_def {
|
||||
variants: ~[variant],
|
||||
common: Option<@struct_def>,
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
#[deriving_eq]
|
||||
pub enum enum_def = enum_def_;
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
#[deriving_eq]
|
||||
|
@ -35,11 +35,11 @@ pub trait Pos {
|
||||
}
|
||||
|
||||
/// A byte offset
|
||||
pub enum BytePos = uint;
|
||||
pub struct BytePos(uint);
|
||||
/// A character offset. Because of multibyte utf8 characters, a byte offset
|
||||
/// is not equivalent to a character offset. The CodeMap will convert BytePos
|
||||
/// 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
|
||||
// have been unsuccessful
|
||||
|
@ -1327,16 +1327,4 @@ mod test {
|
||||
CallToEmitEnumVariantArg (1),
|
||||
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)]);
|
||||
}
|
||||
}
|
||||
|
@ -238,9 +238,7 @@ impl to_type_decls for state {
|
||||
cx.item_enum_poly(
|
||||
name,
|
||||
self.span,
|
||||
ast::enum_def(enum_def_ {
|
||||
variants: items_msg,
|
||||
common: None }),
|
||||
ast::enum_def { variants: items_msg, common: None },
|
||||
cx.strip_bounds(&self.generics)
|
||||
)
|
||||
]
|
||||
|
@ -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(
|
||||
ast::enum_def(
|
||||
ast::enum_def_ {
|
||||
variants: do enum_definition.variants.map |x| {
|
||||
fld.fold_variant(x)
|
||||
},
|
||||
common: do enum_definition.common.map |x| {
|
||||
fold_struct_def(*x, fld)
|
||||
}
|
||||
ast::enum_def {
|
||||
variants: do enum_definition.variants.map |x| {
|
||||
fld.fold_variant(x)
|
||||
},
|
||||
common: do enum_definition.common.map |x| {
|
||||
fold_struct_def(*x, fld)
|
||||
}
|
||||
),
|
||||
},
|
||||
fold_generics(generics, fld))
|
||||
}
|
||||
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)
|
||||
};
|
||||
kind = enum_variant_kind(
|
||||
ast::enum_def(ast::enum_def_ {
|
||||
variants: variants,
|
||||
common: common
|
||||
})
|
||||
ast::enum_def { variants: variants, common: common }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -3775,7 +3775,7 @@ pub impl Parser {
|
||||
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 {
|
||||
@ -3801,9 +3801,7 @@ pub impl Parser {
|
||||
return (
|
||||
id,
|
||||
item_enum(
|
||||
enum_def(
|
||||
ast::enum_def_ { variants: ~[variant], common: None }
|
||||
),
|
||||
ast::enum_def { variants: ~[variant], common: None },
|
||||
generics),
|
||||
None
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user