diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 94b28bf1397..90686441778 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -164,7 +164,7 @@ fn reserve_id_range(sess: Session, let to_id_min = sess.parse_sess.next_id; let to_id_max = sess.parse_sess.next_id + cnt; sess.parse_sess.next_id = to_id_max; - return {min: to_id_min, max: to_id_min}; + ast_util::id_range { min: to_id_min, max: to_id_min } } impl extended_decode_ctxt { diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 1f3d25e7af0..71f2a0002ac 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -108,8 +108,12 @@ enum ast_node { } type map = std::map::HashMap; -type ctx = {map: map, mut path: path, - mut local_id: uint, diag: span_handler}; +struct ctx { + map: map, + mut path: path, + mut local_id: uint, + diag: span_handler, +} type vt = visit::vt; fn extend(cx: ctx, +elt: ident) -> @path { @@ -131,12 +135,14 @@ fn mk_ast_map_visitor() -> vt { } fn map_crate(diag: span_handler, c: crate) -> map { - let cx = {map: std::map::HashMap(), - mut path: ~[], - mut local_id: 0u, - diag: diag}; + let cx = ctx { + map: std::map::HashMap(), + mut path: ~[], + mut local_id: 0u, + diag: diag, + }; visit::visit_crate(c, cx, mk_ast_map_visitor()); - return cx.map; + cx.map } // Used for items loaded from external crate that are being inlined into this @@ -150,10 +156,12 @@ fn map_decoded_item(diag: span_handler, // alias analysis, which we will not be running on the inlined items, and // even if we did I think it only needs an ordering between local // variables that are simultaneously in scope). - let cx = {map: map, - mut path: /* FIXME (#2543) */ copy path, - mut local_id: 0u, - diag: diag}; + let cx = ctx { + map: map, + mut path: /* FIXME (#2543) */ copy path, + mut local_id: 0u, + diag: diag, + }; let v = mk_ast_map_visitor(); // methods get added to the AST map when their impl is visited. Since we diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 73be0598d69..fe0da2e17b8 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -455,7 +455,10 @@ fn dtor_dec() -> fn_decl { #[auto_encode] #[auto_decode] -type id_range = {min: node_id, max: node_id}; +struct id_range { + min: node_id, + max: node_id, +} fn empty(range: id_range) -> bool { range.min >= range.max @@ -596,7 +599,7 @@ fn compute_id_range(visit_ids_fn: fn(fn@(node_id))) -> id_range { *min = int::min(*min, id); *max = int::max(*max, id + 1); } - return {min:*min, max:*max}; + id_range { min: *min, max: *max } } fn compute_id_range_for_inlined_item(item: inlined_item) -> id_range { diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 6e335c318dd..c00b956f553 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -57,15 +57,15 @@ trait handler { fn emit(cmsp: Option<(@codemap::CodeMap, span)>, msg: &str, lvl: level); } -type handler_t = @{ +struct handler_t { mut err_count: uint, - emit: emitter -}; + emit: emitter, +} -type codemap_t = @{ +struct codemap_t { handler: handler, - cm: @codemap::CodeMap -}; + cm: @codemap::CodeMap, +} impl codemap_t: span_handler { fn span_fatal(sp: span, msg: &str) -> ! { @@ -138,7 +138,7 @@ fn ice_msg(msg: &str) -> ~str { } fn mk_span_handler(handler: handler, cm: @codemap::CodeMap) -> span_handler { - @{ handler: handler, cm: cm } as span_handler + @codemap_t { handler: handler, cm: cm } as span_handler } fn mk_handler(emitter: Option) -> handler { @@ -154,12 +154,7 @@ fn mk_handler(emitter: Option) -> handler { } }; - let x: handler_t = @{ - mut err_count: 0, - emit: emit - }; - - x as handler + @handler_t { mut err_count: 0, emit: emit } as handler } enum level { diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index 9578a2f6317..1354b816a00 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -46,7 +46,7 @@ references other non-built-in types. A type definition like: #[auto_encode] #[auto_decode] - type spanned = {node: T, span: span}; + struct spanned {node: T, span: span} would yield functions like: @@ -810,11 +810,15 @@ fn mk_struct_deser_impl( // Records and structs don't have the same fields types, but they share enough // that if we extract the right subfields out we can share the code // generator code. -type field = { span: span, ident: ast::ident, mutbl: ast::mutability }; +struct field { + span: span, + ident: ast::ident, + mutbl: ast::mutability, +} fn mk_rec_fields(fields: ~[ast::ty_field]) -> ~[field] { do fields.map |field| { - { + field { span: field.span, ident: field.node.ident, mutbl: field.node.mt.mutbl, @@ -830,7 +834,7 @@ fn mk_struct_fields(fields: ~[@ast::struct_field]) -> ~[field] { unnamed fields", }; - { + field { span: field.span, ident: ident, mutbl: match mutbl { @@ -886,7 +890,7 @@ fn mk_ser_fields( fn mk_deser_fields( cx: ext_ctxt, span: span, - fields: ~[{ span: span, ident: ast::ident, mutbl: ast::mutability }] + fields: ~[field] ) -> ~[ast::field] { do fields.mapi |idx, field| { // ast for `|| std::serialize::decode(__d)` diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 7b69084a827..dab57dd0ad4 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -32,17 +32,27 @@ use std::map::HashMap; // is now probably a redundant AST node, can be merged with // ast::mac_invoc_tt. -type macro_def = {name: ~str, ext: syntax_extension}; +struct macro_def { + name: ~str, + ext: syntax_extension, +} type item_decorator = fn@(ext_ctxt, span, ast::meta_item, ~[@ast::item]) -> ~[@ast::item]; -type syntax_expander_tt = {expander: syntax_expander_tt_, span: Option}; +struct syntax_expander_tt { + expander: syntax_expander_tt_, + span: Option, +} + type syntax_expander_tt_ = fn@(ext_ctxt, span, ~[ast::token_tree]) -> mac_result; -type syntax_expander_tt_item - = {expander: syntax_expander_tt_item_, span: Option}; +struct syntax_expander_tt_item { + expander: syntax_expander_tt_item_, + span: Option, +} + type syntax_expander_tt_item_ = fn@(ext_ctxt, span, ast::ident, ~[ast::token_tree]) -> mac_result; @@ -70,10 +80,10 @@ enum syntax_extension { // AST nodes into full ASTs fn syntax_expander_table() -> HashMap<~str, syntax_extension> { fn builtin_normal_tt(f: syntax_expander_tt_) -> syntax_extension { - normal_tt({expander: f, span: None}) + normal_tt(syntax_expander_tt {expander: f, span: None}) } fn builtin_item_tt(f: syntax_expander_tt_item_) -> syntax_extension { - item_tt({expander: f, span: None}) + item_tt(syntax_expander_tt_item {expander: f, span: None}) } let syntax_expanders = HashMap(); syntax_expanders.insert(~"macro_rules", diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index eb571b99b4e..4b096f07b75 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -46,7 +46,9 @@ fn expand_expr(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt, cx.span_fatal(pth.span, fmt!("macro undefined: '%s'", *extname)) } - Some(normal_tt({expander: exp, span: exp_sp})) => { + Some(normal_tt( + syntax_expander_tt { expander: exp, span: exp_sp } + )) => { cx.bt_push(ExpandedFrom({call_site: s, callie: {name: *extname, span: exp_sp}})); @@ -231,7 +233,9 @@ fn expand_stmt(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt, None => cx.span_fatal(pth.span, fmt!("macro undefined: '%s'", *extname)), - Some(normal_tt({expander: exp, span: exp_sp})) => { + Some(normal_tt( + syntax_expander_tt { expander: exp, span: exp_sp } + )) => { cx.bt_push(ExpandedFrom( {call_site: sp, callie: {name: *extname, span: exp_sp}})); let expanded = match exp(cx, mac.span, tts) { diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs index f2ba413dd38..95d3308dd2f 100644 --- a/src/libsyntax/ext/pipes/check.rs +++ b/src/libsyntax/ext/pipes/check.rs @@ -52,9 +52,9 @@ impl ext_ctxt: proto::visitor<(), (), ()> { } fn visit_message(name: ~str, _span: span, _tys: &[@ast::Ty], - this: state, next: next_state) { + this: state, next: Option) { match next { - Some({state: ref next, tys: next_tys}) => { + Some(next_state { state: ref next, tys: next_tys }) => { let proto = this.proto; if !proto.has_state((*next)) { // This should be a span fatal, but then we need to diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs index 6a6e895bd40..e87a044fa01 100644 --- a/src/libsyntax/ext/pipes/parse_proto.rs +++ b/src/libsyntax/ext/pipes/parse_proto.rs @@ -88,7 +88,7 @@ impl parser::Parser: proto_parser { |p| p.parse_ty(false)) } else { ~[] }; - Some({state: name, tys: ntys}) + Some(next_state {state: name, tys: ntys}) } token::NOT => { // -> ! diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 306df24e79f..6c12736b7ea 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -49,7 +49,7 @@ impl message: gen_send { debug!("pipec: gen_send"); match self { message(ref _id, span, tys, this, - Some({state: ref next, tys: next_tys})) => { + Some(next_state {state: ref next, tys: next_tys})) => { debug!("pipec: next state exists"); let next = this.proto.get_state((*next)); assert next_tys.len() == next.ty_params.len(); @@ -217,7 +217,7 @@ impl state: to_type_decls { let message(name, span, tys, this, next) = *m; let tys = match next { - Some({state: ref next, tys: next_tys}) => { + Some(next_state { state: ref next, tys: next_tys }) => { let next = this.proto.get_state((*next)); let next_name = cx.str_of(next.data_name()); diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 9953b4de50d..26638cd8cd6 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -51,11 +51,14 @@ impl direction { } } -type next_state = Option<{state: ~str, tys: ~[@ast::Ty]}>; +struct next_state { + state: ~str, + tys: ~[@ast::Ty], +} enum message { // name, span, data, current state, next state - message(~str, span, ~[@ast::Ty], state, next_state) + message(~str, span, ~[@ast::Ty], state, Option) } impl message { @@ -94,7 +97,7 @@ enum state { impl state { fn add_message(name: ~str, span: span, - +data: ~[@ast::Ty], next: next_state) { + +data: ~[@ast::Ty], next: Option) { self.messages.push(message(name, span, data, self, next)); } @@ -119,7 +122,7 @@ impl state { fn reachable(f: fn(state) -> bool) { for self.messages.each |m| { match *m { - message(_, _, _, _, Some({state: ref id, _})) => { + message(_, _, _, _, Some(next_state { state: ref id, _ })) => { let state = self.proto.get_state((*id)); if !f(state) { break } } @@ -217,7 +220,7 @@ trait visitor { fn visit_proto(proto: protocol, st: &[Tstate]) -> Tproto; fn visit_state(state: state, m: &[Tmessage]) -> Tstate; fn visit_message(name: ~str, spane: span, tys: &[@ast::Ty], - this: state, next: next_state) -> Tmessage; + this: state, next: Option) -> Tmessage; } fn visit>( diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index d68e5a34fbc..4ee9ddf48c8 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -139,8 +139,11 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, let exp: @fn(ext_ctxt, span, ~[ast::token_tree]) -> mac_result = |cx, sp, arg| generic_extension(cx, sp, name, arg, lhses, rhses); - return mr_def({ + mr_def(base::macro_def { name: *cx.parse_sess().interner.get(name), - ext: normal_tt({expander: exp, span: Some(sp)}) - }); + ext: normal_tt(base::syntax_expander_tt { + expander: exp, + span: Some(sp), + }) + }) }