Skip to content

Commit 7c04000

Browse files
committed
libsyntax: Remove newtype enums from libsyntax. rs=deenum
1 parent bd0bc17 commit 7c04000

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
@@ -1102,16 +1102,11 @@ pub enum variant_kind {
11021102
#[auto_encode]
11031103
#[auto_decode]
11041104
#[deriving_eq]
1105-
pub struct enum_def_ {
1105+
pub struct enum_def {
11061106
variants: ~[variant],
11071107
common: Option<@struct_def>,
11081108
}
11091109
1110-
#[auto_encode]
1111-
#[auto_decode]
1112-
#[deriving_eq]
1113-
pub enum enum_def = enum_def_;
1114-
11151110
#[auto_encode]
11161111
#[auto_decode]
11171112
#[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
@@ -1333,16 +1333,4 @@ mod test {
13331333
CallToEmitEnumVariantArg (1),
13341334
CallToEmitUint (44)]);
13351335
}
1336-
1337-
pub enum BPos = uint;
1338-
1339-
#[auto_encode]
1340-
pub struct HasPos { pos : BPos }
1341-
1342-
#[test] fn encode_newtype_test () {
1343-
check_equal (to_call_log (HasPos {pos:BPos(48)}),
1344-
~[CallToEmitStruct(~"HasPos",1),
1345-
CallToEmitField(~"pos",0),
1346-
CallToEmitUint(48)]);
1347-
}
13481336
}

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) => {
@@ -683,10 +681,7 @@ fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ {
683681
fold_struct_def(*x, fld)
684682
};
685683
kind = enum_variant_kind(
686-
ast::enum_def(ast::enum_def_ {
687-
variants: variants,
688-
common: common
689-
})
684+
ast::enum_def { variants: variants, common: common }
690685
);
691686
}
692687
}

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3774,7 +3774,7 @@ pub impl Parser {
37743774
enum");
37753775
}
37763776

3777-
enum_def(ast::enum_def_ { variants: variants, common: common_fields })
3777+
ast::enum_def { variants: variants, common: common_fields }
37783778
}
37793779

37803780
fn parse_item_enum(&self) -> item_info {
@@ -3800,9 +3800,7 @@ pub impl Parser {
38003800
return (
38013801
id,
38023802
item_enum(
3803-
enum_def(
3804-
ast::enum_def_ { variants: ~[variant], common: None }
3805-
),
3803+
ast::enum_def { variants: ~[variant], common: None },
38063804
generics),
38073805
None
38083806
);

0 commit comments

Comments
 (0)