From 7538450b8d5e831dca7891bdd54ebdf25d865970 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 7 Mar 2013 18:04:21 -0800 Subject: [PATCH] libsyntax: Remove newtype enums from libsyntax. rs=deenum --- src/libsyntax/ast.rs | 7 +------ src/libsyntax/codemap.rs | 4 ++-- src/libsyntax/ext/auto_encode.rs | 12 ------------ src/libsyntax/ext/pipes/pipec.rs | 4 +--- src/libsyntax/fold.rs | 21 ++++++++------------- src/libsyntax/parse/parser.rs | 6 ++---- 6 files changed, 14 insertions(+), 40 deletions(-) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index f3e73823f69..27dba9c2b5e 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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] diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 3397ca91c96..0d6ece8ad92 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -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 diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index 8aa03e14fa4..c99d8977643 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -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)]); - } } diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 001e1b0daf6..fd8b2dbf72f 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -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) ) ] diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 2a5fe788770..427760c920f 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -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 } ); } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1c3d906e164..b2f11b8c437 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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 );