Skip to content

Commit 7538450

Browse files
committed
libsyntax: Remove newtype enums from libsyntax. rs=deenum
1 parent dc48699 commit 7538450

File tree

6 files changed

+14
-40
lines changed

6 files changed

+14
-40
lines changed

src/libsyntax/ast.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,16 +1086,11 @@ pub enum variant_kind {
10861086
#[auto_encode]
10871087
#[auto_decode]
10881088
#[deriving_eq]
1089-
pub struct enum_def_ {
1089+
pub struct enum_def {
10901090
variants: ~[variant],
10911091
common: Option<@struct_def>,
10921092
}
10931093
1094-
#[auto_encode]
1095-
#[auto_decode]
1096-
#[deriving_eq]
1097-
pub enum enum_def = enum_def_;
1098-
10991094
#[auto_encode]
11001095
#[auto_decode]
11011096
#[deriving_eq]

src/libsyntax/codemap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ pub trait Pos {
3535
}
3636

3737
/// A byte offset
38-
pub enum BytePos = uint;
38+
pub struct BytePos(uint);
3939
/// A character offset. Because of multibyte utf8 characters, a byte offset
4040
/// is not equivalent to a character offset. The CodeMap will convert BytePos
4141
/// values to CharPos values as necessary.
42-
pub enum CharPos = uint;
42+
pub struct CharPos(uint);
4343

4444
// XXX: Lots of boilerplate in these impls, but so far my attempts to fix
4545
// have been unsuccessful

src/libsyntax/ext/auto_encode.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,16 +1327,4 @@ mod test {
13271327
CallToEmitEnumVariantArg (1),
13281328
CallToEmitUint (44)]);
13291329
}
1330-
1331-
pub enum BPos = uint;
1332-
1333-
#[auto_encode]
1334-
pub struct HasPos { pos : BPos }
1335-
1336-
#[test] fn encode_newtype_test () {
1337-
check_equal (to_call_log (HasPos {pos:BPos(48)}),
1338-
~[CallToEmitStruct(~"HasPos",1),
1339-
CallToEmitField(~"pos",0),
1340-
CallToEmitUint(48)]);
1341-
}
13421330
}

src/libsyntax/ext/pipes/pipec.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,7 @@ impl to_type_decls for state {
238238
cx.item_enum_poly(
239239
name,
240240
self.span,
241-
ast::enum_def(enum_def_ {
242-
variants: items_msg,
243-
common: None }),
241+
ast::enum_def { variants: items_msg, common: None },
244242
cx.strip_bounds(&self.generics)
245243
)
246244
]

src/libsyntax/fold.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,14 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ {
254254
}
255255
item_enum(ref enum_definition, ref generics) => {
256256
item_enum(
257-
ast::enum_def(
258-
ast::enum_def_ {
259-
variants: do enum_definition.variants.map |x| {
260-
fld.fold_variant(x)
261-
},
262-
common: do enum_definition.common.map |x| {
263-
fold_struct_def(*x, fld)
264-
}
257+
ast::enum_def {
258+
variants: do enum_definition.variants.map |x| {
259+
fld.fold_variant(x)
260+
},
261+
common: do enum_definition.common.map |x| {
262+
fold_struct_def(*x, fld)
265263
}
266-
),
264+
},
267265
fold_generics(generics, fld))
268266
}
269267
item_struct(ref struct_def, ref generics) => {
@@ -684,10 +682,7 @@ fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ {
684682
fold_struct_def(*x, fld)
685683
};
686684
kind = enum_variant_kind(
687-
ast::enum_def(ast::enum_def_ {
688-
variants: variants,
689-
common: common
690-
})
685+
ast::enum_def { variants: variants, common: common }
691686
);
692687
}
693688
}

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3775,7 +3775,7 @@ pub impl Parser {
37753775
enum");
37763776
}
37773777
3778-
enum_def(ast::enum_def_ { variants: variants, common: common_fields })
3778+
ast::enum_def { variants: variants, common: common_fields }
37793779
}
37803780
37813781
fn parse_item_enum(&self) -> item_info {
@@ -3801,9 +3801,7 @@ pub impl Parser {
38013801
return (
38023802
id,
38033803
item_enum(
3804-
enum_def(
3805-
ast::enum_def_ { variants: ~[variant], common: None }
3806-
),
3804+
ast::enum_def { variants: ~[variant], common: None },
38073805
generics),
38083806
None
38093807
);

0 commit comments

Comments
 (0)