From 47eca2113c5c55a4ffbb8c11a38c8ca7a79a1d72 Mon Sep 17 00:00:00 2001 From: James Miller Date: Sat, 6 Jul 2013 16:57:11 +1200 Subject: [PATCH] De-share ast::Ty --- src/librustc/front/config.rs | 4 +- src/librustc/metadata/encoder.rs | 2 +- src/librustc/middle/kind.rs | 4 +- src/librustc/middle/lint.rs | 6 +- src/librustc/middle/region.rs | 18 ++--- src/librustc/middle/resolve.rs | 34 ++++---- src/librustc/middle/trans/base.rs | 6 +- src/librustc/middle/trans/debuginfo.rs | 20 ++--- src/librustc/middle/typeck/astconv.rs | 16 ++-- src/librustc/middle/typeck/check/mod.rs | 18 ++--- src/librustc/middle/typeck/coherence.rs | 4 +- src/librustc/middle/typeck/collect.rs | 16 ++-- src/libsyntax/ast.rs | 30 +++---- src/libsyntax/ext/build.rs | 103 ++++++++++++------------ src/libsyntax/ext/deriving/generic.rs | 6 +- src/libsyntax/ext/deriving/ty.rs | 4 +- src/libsyntax/ext/pipes/ast_builder.rs | 8 +- src/libsyntax/ext/pipes/check.rs | 2 +- src/libsyntax/ext/pipes/pipec.rs | 12 +-- src/libsyntax/ext/pipes/proto.rs | 10 +-- src/libsyntax/ext/quote.rs | 10 +-- src/libsyntax/fold.rs | 48 +++++------ src/libsyntax/parse/parser.rs | 34 ++++---- src/libsyntax/parse/token.rs | 2 +- src/libsyntax/print/pprust.rs | 40 ++++----- src/libsyntax/visit.rs | 54 ++++++------- 26 files changed, 256 insertions(+), 255 deletions(-) diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs index 0f71eeff5a2f1..df829d5e20961 100644 --- a/src/librustc/front/config.rs +++ b/src/librustc/front/config.rs @@ -98,10 +98,10 @@ fn fold_foreign_mod( fn fold_item_underscore(cx: @Context, item: &ast::item_, fld: @fold::ast_fold) -> ast::item_ { let item = match *item { - ast::item_impl(ref a, ref b, c, ref methods) => { + ast::item_impl(ref a, ref b, ref c, ref methods) => { let methods = methods.iter().filter(|m| method_in_cfg(cx, **m)) .transform(|x| *x).collect(); - ast::item_impl(/*bad*/ copy *a, /*bad*/ copy *b, c, methods) + ast::item_impl(/*bad*/ copy *a, /*bad*/ copy *b, /*bad*/ copy *c, methods) } ast::item_trait(ref a, ref b, ref methods) => { let methods = methods.iter().filter(|m| trait_method_in_cfg(cx, *m) ) diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 8273b3e663a45..a9f3200af1284 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1003,7 +1003,7 @@ fn encode_info_for_item(ecx: &EncodeContext, index); } } - item_impl(ref generics, ref opt_trait, ty, ref methods) => { + item_impl(ref generics, ref opt_trait, ref ty, ref methods) => { add_to_index(); ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, local_def(item.id)); diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 0bc7a4a011413..335a54a975353 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -117,7 +117,7 @@ fn check_item(item: @item, (cx, visitor): (Context, visit::vt)) { // If this is a destructor, check kinds. if !attrs_contains_name(item.attrs, "unsafe_destructor") { match item.node { - item_impl(_, Some(ref trait_ref), self_type, _) => { + item_impl(_, Some(ref trait_ref), ref self_type, _) => { match cx.tcx.def_map.find(&trait_ref.ref_id) { None => cx.tcx.sess.bug("trait ref not in def map!"), Some(&trait_def) => { @@ -321,7 +321,7 @@ pub fn check_expr(e: @expr, (cx, v): (Context, visit::vt)) { visit::visit_expr(e, (cx, v)); } -fn check_ty(aty: @Ty, (cx, v): (Context, visit::vt)) { +fn check_ty(aty: &Ty, (cx, v): (Context, visit::vt)) { match aty.node { ty_path(_, _, id) => { let r = cx.tcx.node_type_substs.find(&id); diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index c39b676b97f01..0dce9c69bfdbe 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -747,9 +747,9 @@ fn check_item_ctypes(cx: &Context, it: &ast::item) { fn check_foreign_fn(cx: &Context, decl: &ast::fn_decl) { for decl.inputs.iter().advance |in| { - check_ty(cx, in.ty); + check_ty(cx, &in.ty); } - check_ty(cx, decl.output) + check_ty(cx, &decl.output) } match it.node { @@ -759,7 +759,7 @@ fn check_item_ctypes(cx: &Context, it: &ast::item) { ast::foreign_item_fn(ref decl, _, _) => { check_foreign_fn(cx, decl); } - ast::foreign_item_static(t, _) => { check_ty(cx, t); } + ast::foreign_item_static(ref t, _) => { check_ty(cx, t); } } } } diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index f76d9541baab1..b1b2a0083acc3 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -713,10 +713,10 @@ fn determine_rp_in_fn(fk: &visit::fn_kind, do cx.with(cx.item_id, false) { do cx.with_ambient_variance(rv_contravariant) { for decl.inputs.iter().advance |a| { - (visitor.visit_ty)(a.ty, (cx, visitor)); + (visitor.visit_ty)(&a.ty, (cx, visitor)); } } - (visitor.visit_ty)(decl.output, (cx, visitor)); + (visitor.visit_ty)(&decl.output, (cx, visitor)); let generics = visit::generics_of_fn(fk); (visitor.visit_generics)(&generics, (cx, visitor)); (visitor.visit_block)(body, (cx, visitor)); @@ -731,7 +731,7 @@ fn determine_rp_in_ty_method(ty_m: &ast::ty_method, } } -fn determine_rp_in_ty(ty: @ast::Ty, +fn determine_rp_in_ty(ty: &ast::Ty, (cx, visitor): (@mut DetermineRpCtxt, visit::vt<@mut DetermineRpCtxt>)) { // we are only interested in types that will require an item to @@ -815,8 +815,8 @@ fn determine_rp_in_ty(ty: @ast::Ty, } match ty.node { - ast::ty_box(mt) | ast::ty_uniq(mt) | ast::ty_vec(mt) | - ast::ty_rptr(_, mt) | ast::ty_ptr(mt) => { + ast::ty_box(ref mt) | ast::ty_uniq(ref mt) | ast::ty_vec(ref mt) | + ast::ty_rptr(_, ref mt) | ast::ty_ptr(ref mt) => { visit_mt(mt, (cx, visitor)); } @@ -824,7 +824,7 @@ fn determine_rp_in_ty(ty: @ast::Ty, // type parameters are---for now, anyway---always invariant do cx.with_ambient_variance(rv_invariant) { for path.types.iter().advance |tp| { - (visitor.visit_ty)(*tp, (cx, visitor)); + (visitor.visit_ty)(tp, (cx, visitor)); } } } @@ -837,10 +837,10 @@ fn determine_rp_in_ty(ty: @ast::Ty, // parameters are contravariant do cx.with_ambient_variance(rv_contravariant) { for decl.inputs.iter().advance |a| { - (visitor.visit_ty)(a.ty, (cx, visitor)); + (visitor.visit_ty)(&a.ty, (cx, visitor)); } } - (visitor.visit_ty)(decl.output, (cx, visitor)); + (visitor.visit_ty)(&decl.output, (cx, visitor)); } } @@ -849,7 +849,7 @@ fn determine_rp_in_ty(ty: @ast::Ty, } } - fn visit_mt(mt: ast::mt, + fn visit_mt(mt: &ast::mt, (cx, visitor): (@mut DetermineRpCtxt, visit::vt<@mut DetermineRpCtxt>)) { // mutability is invariant diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 99ec1ccb1f1e5..861c61e497aa8 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1233,7 +1233,7 @@ impl Resolver { visit_item(item, (new_parent, visitor)); } - item_impl(_, None, ty, ref methods) => { + item_impl(_, None, ref ty, ref methods) => { // If this implements an anonymous trait, then add all the // methods within to a new module, if the type was defined // within this module. @@ -1243,8 +1243,8 @@ impl Resolver { // the same module that declared the type. // Create the module and add all methods. - match *ty { - Ty { + match ty { + &Ty { node: ty_path(ref path, _, _), _ } if path.idents.len() == 1 => { @@ -1313,7 +1313,7 @@ impl Resolver { visit_item(item, (parent, visitor)); } - item_impl(_, Some(_), _ty, ref _methods) => { + item_impl(_, Some(_), _, _) => { visit_item(item, (parent, visitor)); } @@ -3534,7 +3534,7 @@ impl Resolver { item_impl(ref generics, ref implemented_traits, - self_type, + ref self_type, ref methods) => { self.resolve_implementation(item.id, generics, @@ -3585,10 +3585,10 @@ impl Resolver { visitor); for ty_m.decl.inputs.iter().advance |argument| { - self.resolve_type(argument.ty, visitor); + self.resolve_type(&argument.ty, visitor); } - self.resolve_type(ty_m.decl.output, visitor); + self.resolve_type(&ty_m.decl.output, visitor); } } provided(m) => { @@ -3778,12 +3778,12 @@ impl Resolver { None, visitor); - self.resolve_type(argument.ty, visitor); + self.resolve_type(&argument.ty, visitor); debug!("(resolving function) recorded argument"); } - self.resolve_type(declaration.output, visitor); + self.resolve_type(&declaration.output, visitor); } } @@ -3878,7 +3878,7 @@ impl Resolver { // Resolve fields. for fields.iter().advance |field| { - self.resolve_type(field.node.ty, visitor); + self.resolve_type(&field.node.ty, visitor); } } } @@ -3914,7 +3914,7 @@ impl Resolver { id: node_id, generics: &Generics, opt_trait_reference: &Option, - self_type: @Ty, + self_type: &Ty, methods: &[@method], visitor: ResolveVisitor) { // If applicable, create a rib for the type parameters. @@ -4001,7 +4001,7 @@ impl Resolver { let mutability = if local.node.is_mutbl {Mutable} else {Immutable}; // Resolve the type. - self.resolve_type(local.node.ty, visitor); + self.resolve_type(&local.node.ty, visitor); // Resolve the initializer, if necessary. match local.node.init { @@ -4112,7 +4112,7 @@ impl Resolver { debug!("(resolving block) leaving block"); } - pub fn resolve_type(@mut self, ty: @Ty, visitor: ResolveVisitor) { + pub fn resolve_type(@mut self, ty: &Ty, visitor: ResolveVisitor) { match ty.node { // Like path expressions, the interpretation of path types depends // on whether the path has multiple elements in it or not. @@ -4334,7 +4334,7 @@ impl Resolver { // Check the types in the path pattern. for path.types.iter().advance |ty| { - self.resolve_type(*ty, visitor); + self.resolve_type(ty, visitor); } } @@ -4367,7 +4367,7 @@ impl Resolver { // Check the types in the path pattern. for path.types.iter().advance |ty| { - self.resolve_type(*ty, visitor); + self.resolve_type(ty, visitor); } } @@ -4396,7 +4396,7 @@ impl Resolver { // Check the types in the path pattern. for path.types.iter().advance |ty| { - self.resolve_type(*ty, visitor); + self.resolve_type(ty, visitor); } } @@ -4491,7 +4491,7 @@ impl Resolver { -> Option { // First, resolve the types. for path.types.iter().advance |ty| { - self.resolve_type(*ty, visitor); + self.resolve_type(ty, visitor); } if path.global { diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index e5edd43cf0513..e6384ae4d0d34 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1737,7 +1737,7 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt, fcx.llargs.insert(arg_id, llarg); if fcx.ccx.sess.opts.extra_debuginfo && fcx_has_nonzero_span(fcx) { - debuginfo::create_arg(bcx, args[arg_n], args[arg_n].ty.span); + debuginfo::create_arg(bcx, &args[arg_n], args[arg_n].ty.span); } } @@ -1911,7 +1911,7 @@ pub fn trans_enum_variant(ccx: @mut CrateContext, let fn_args = do args.map |varg| { ast::arg { is_mutbl: false, - ty: varg.ty, + ty: copy varg.ty, pat: ast_util::ident_to_pat( ccx.tcx.sess.next_node_id(), codemap::dummy_sp(), @@ -1985,7 +1985,7 @@ pub fn trans_tuple_struct(ccx: @mut CrateContext, let fn_args = do fields.map |field| { ast::arg { is_mutbl: false, - ty: field.node.ty, + ty: copy field.node.ty, pat: ast_util::ident_to_pat(ccx.tcx.sess.next_node_id(), codemap::dummy_sp(), special_idents::arg), diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 32a71ea701972..fc73d80537987 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -182,7 +182,7 @@ pub fn create_local_var(bcx: block, local: @ast::local) -> DIVariable { /// /// Adds the created metadata nodes directly to the crate's IR. /// The return value should be ignored if called from outside of the debuginfo module. -pub fn create_arg(bcx: block, arg: ast::arg, span: span) -> Option { +pub fn create_arg(bcx: block, arg: &ast::arg, span: span) -> Option { debug!("create_arg"); if true { // XXX create_arg disabled for now because "node_id_type(bcx, arg.id)" below blows @@ -259,23 +259,25 @@ pub fn create_function(fcx: fn_ctxt) -> DISubprogram { let fcx = &mut *fcx; let span = fcx.span.get(); - let (ident, ret_ty, id) = match cx.tcx.items.get_copy(&fcx.id) { - ast_map::node_item(item, _) => { + let fnitem = cx.tcx.items.get_copy(&fcx.id); + let (ident, ret_ty, id) = match fnitem { + ast_map::node_item(ref item, _) => { match item.node { - ast::item_fn(ref decl, _, _, _, _) => { - (item.ident, decl.output, item.id) + ast::item_fn(ast::fn_decl { output: ref ty, _}, _, _, _, _) => { + (item.ident, ty, item.id) } _ => fcx.ccx.sess.span_bug(item.span, "create_function: item bound to non-function") } } - ast_map::node_method(method, _, _) => { - (method.ident, method.decl.output, method.id) + ast_map::node_method(@ast::method { decl: ast::fn_decl { output: ref ty, _ }, + id: id, ident: ident, _}, _, _) => { + (ident, ty, id) } - ast_map::node_expr(expr) => { + ast_map::node_expr(ref expr) => { match expr.node { ast::expr_fn_block(ref decl, _) => { let name = gensym_name("fn"); - (name, decl.output, expr.id) + (name, &decl.output, expr.id) } _ => fcx.ccx.sess.span_bug(expr.span, "create_function: expected an expr_fn_block here") diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 6aac077bbd9a0..9442eb0b83869 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -179,7 +179,7 @@ fn ast_path_substs( fmt!("wrong number of type arguments: expected %u but found %u", decl_generics.type_param_defs.len(), path.types.len())); } - let tps = path.types.map(|a_t| ast_ty_to_ty(this, rscope, *a_t)); + let tps = path.types.map(|a_t| ast_ty_to_ty(this, rscope, a_t)); substs {self_r:self_r, self_ty:self_ty, tps:tps} } @@ -377,7 +377,7 @@ pub fn ast_ty_to_ty( |tmt| ty::mk_rptr(tcx, r, tmt)) } ast::ty_tup(ref fields) => { - let flds = fields.map(|t| ast_ty_to_ty(this, rscope, *t)); + let flds = fields.map(|t| ast_ty_to_ty(this, rscope, t)); ty::mk_tup(tcx, flds) } ast::ty_bare_fn(ref bf) => { @@ -525,13 +525,13 @@ pub fn ty_of_arg( this: &AC, rscope: &RS, - a: ast::arg, + a: &ast::arg, expected_ty: Option) -> ty::t { match a.ty.node { ast::ty_infer if expected_ty.is_some() => expected_ty.get(), ast::ty_infer => this.ty_infer(a.ty.span), - _ => ast_ty_to_ty(this, rscope, a.ty), + _ => ast_ty_to_ty(this, rscope, &a.ty), } } @@ -621,11 +621,11 @@ fn ty_of_method_or_bare_fn( transform_self_ty(this, &rb, self_info) }); - let input_tys = decl.inputs.map(|a| ty_of_arg(this, &rb, *a, None)); + let input_tys = decl.inputs.map(|a| ty_of_arg(this, &rb, a, None)); let output_ty = match decl.output.node { ast::ty_infer => this.ty_infer(decl.output.span), - _ => ast_ty_to_ty(this, &rb, decl.output) + _ => ast_ty_to_ty(this, &rb, &decl.output) }; return (opt_transformed_self_ty, @@ -724,14 +724,14 @@ pub fn ty_of_closure( // were supplied if i < e.inputs.len() {Some(e.inputs[i])} else {None} }; - ty_of_arg(this, &rb, *a, expected_arg_ty) + ty_of_arg(this, &rb, a, expected_arg_ty) }.collect(); let expected_ret_ty = expected_sig.map(|e| e.output); let output_ty = match decl.output.node { ast::ty_infer if expected_ret_ty.is_some() => expected_ret_ty.get(), ast::ty_infer => this.ty_infer(decl.output.span), - _ => ast_ty_to_ty(this, &rb, decl.output) + _ => ast_ty_to_ty(this, &rb, &decl.output) }; ty::ClosureTy { diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index cd66c765a2d6c..51159c0391a1c 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -476,7 +476,7 @@ pub fn check_fn(ccx: @mut CrateCtxt, |local, (e, v)| { let o_ty = match local.node.ty.node { ast::ty_infer => None, - _ => Some(fcx.to_ty(local.node.ty)) + _ => Some(fcx.to_ty(&local.node.ty)) }; assign(local.node.id, o_ty); debug!("Local variable %s is assigned type %s", @@ -624,7 +624,7 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) { ast::item_struct(*) => { check_struct(ccx, it.id, it.span); } - ast::item_ty(t, ref generics) => { + ast::item_ty(ref t, ref generics) => { let tpt_ty = ty::node_id_to_type(ccx.tcx, it.id); check_bounds_are_used(ccx, t.span, &generics.ty_params, tpt_ty); } @@ -790,7 +790,7 @@ impl FnCtxt { self.write_ty(node_id, ty::mk_err()); } - pub fn to_ty(&self, ast_t: @ast::Ty) -> ty::t { + pub fn to_ty(&self, ast_t: &ast::Ty) -> ty::t { ast_ty_to_ty(self, self, ast_t) } @@ -1381,7 +1381,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, rcvr: @ast::expr, method_name: ast::ident, args: &[@ast::expr], - tps: &[@ast::Ty], + tps: &[ast::Ty], sugar: ast::CallSugar) { check_expr(fcx, rcvr); @@ -1390,7 +1390,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, expr.span, fcx.expr_ty(rcvr)); - let tps = tps.map(|ast_ty| fcx.to_ty(*ast_ty)); + let tps = tps.map(|ast_ty| fcx.to_ty(ast_ty)); match method::lookup(fcx, expr, rcvr, @@ -1779,7 +1779,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, expr: @ast::expr, base: @ast::expr, field: ast::ident, - tys: &[@ast::Ty]) { + tys: &[ast::Ty]) { let tcx = fcx.ccx.tcx; let bot = check_expr(fcx, base); let expr_t = structurally_resolved_type(fcx, expr.span, @@ -1809,7 +1809,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, _ => () } - let tps = tys.iter().transform(|ty| fcx.to_ty(*ty)).collect::<~[ty::t]>(); + let tps : ~[ty::t] = tys.iter().transform(|ty| fcx.to_ty(ty)).collect(); match method::lookup(fcx, expr, base, @@ -2622,7 +2622,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_bot(id); } } - ast::expr_cast(e, t) => { + ast::expr_cast(e, ref t) => { check_expr(fcx, e); let t_1 = fcx.to_ty(t); let t_e = fcx.expr_ty(e); @@ -3336,7 +3336,7 @@ pub fn instantiate_path(fcx: @mut FnCtxt, (span, "not enough type parameters provided for this item"); fcx.infcx().next_ty_vars(ty_param_count) } else { - pth.types.map(|aty| fcx.to_ty(*aty)) + pth.types.map(|aty| fcx.to_ty(aty)) }; let substs = substs { self_r: self_r, self_ty: None, tps: tps }; diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index aef0e4b200b97..473d5b8e6e880 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -638,7 +638,7 @@ impl CoherenceChecker { // Then visit the module items. visit_mod(module_, item.span, item.id, ((), visitor)); } - item_impl(_, None, ast_ty, _) => { + item_impl(_, None, ref ast_ty, _) => { if !self.ast_type_is_defined_in_local_crate(ast_ty) { // This is an error. let session = self.crate_context.tcx.sess; @@ -725,7 +725,7 @@ impl CoherenceChecker { /// For coherence, when we have `impl Type`, we need to guarantee that /// `Type` is "local" to the crate. For our purposes, this means that it /// must precisely name some nominal type defined in this crate. - pub fn ast_type_is_defined_in_local_crate(&self, original_type: @ast::Ty) + pub fn ast_type_is_defined_in_local_crate(&self, original_type: &ast::Ty) -> bool { match original_type.node { ty_path(_, _, path_id) => { diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index edd90be26474d..fb88f198231f8 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -148,7 +148,7 @@ pub fn get_enum_variant_types(ccx: &CrateCtxt, match variant.node.kind { ast::tuple_variant_kind(ref args) if args.len() > 0 => { let rs = type_rscope(region_parameterization); - let input_tys = args.map(|va| ccx.to_ty(&rs, va.ty)); + let input_tys = args.map(|va| ccx.to_ty(&rs, &va.ty)); result_ty = Some(ty::mk_ctor_fn(tcx, input_tys, enum_ty)); } @@ -684,7 +684,7 @@ pub fn convert_field(ccx: &CrateCtxt, generics: &ast::Generics) { let region_parameterization = RegionParameterization::from_variance_and_generics(rp, generics); - let tt = ccx.to_ty(&type_rscope(region_parameterization), v.node.ty); + let tt = ccx.to_ty(&type_rscope(region_parameterization), &v.node.ty); write_ty_to_tcx(ccx.tcx, v.node.id, tt); /* add the field to the tcache */ ccx.tcx.tcache.insert(local_def(v.node.id), @@ -813,7 +813,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) { generics, rp); } - ast::item_impl(ref generics, ref opt_trait_ref, selfty, ref ms) => { + ast::item_impl(ref generics, ref opt_trait_ref, ref selfty, ref ms) => { let i_ty_generics = ty_generics(ccx, rp, generics, 0); let region_parameterization = RegionParameterization::from_variance_and_generics(rp, generics); @@ -1031,7 +1031,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item) } let rp = tcx.region_paramd_items.find(&it.id).map_consume(|x| *x); match it.node { - ast::item_static(t, _, _) => { + ast::item_static(ref t, _, _) => { let typ = ccx.to_ty(&empty_rscope, t); let tpt = no_params(typ); tcx.tcache.insert(local_def(it.id), tpt); @@ -1060,7 +1060,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item) ccx.tcx.tcache.insert(local_def(it.id), tpt); return tpt; } - ast::item_ty(t, ref generics) => { + ast::item_ty(ref t, ref generics) => { match tcx.tcache.find(&local_def(it.id)) { Some(&tpt) => return tpt, None => { } @@ -1124,7 +1124,7 @@ pub fn ty_of_foreign_item(ccx: &CrateCtxt, generics, abis) } - ast::foreign_item_static(t, _) => { + ast::foreign_item_static(ref t, _) => { ty::ty_param_bounds_and_ty { generics: ty::Generics { type_param_defs: @~[], @@ -1215,8 +1215,8 @@ pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt, let ty_generics = ty_generics(ccx, None, ast_generics, 0); let region_param_names = RegionParamNames::from_generics(ast_generics); let rb = in_binding_rscope(&empty_rscope, region_param_names); - let input_tys = decl.inputs.map(|a| ty_of_arg(ccx, &rb, *a, None) ); - let output_ty = ast_ty_to_ty(ccx, &rb, decl.output); + let input_tys = decl.inputs.map(|a| ty_of_arg(ccx, &rb, a, None) ); + let output_ty = ast_ty_to_ty(ccx, &rb, &decl.output); let t_fn = ty::mk_bare_fn( ccx.tcx, diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index d0c8ff03e3884..8c37c1510cf20 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -110,7 +110,7 @@ pub struct Path { global: bool, idents: ~[ident], rp: Option, - types: ~[@Ty], + types: ~[Ty], } pub type crate_num = int; @@ -361,7 +361,7 @@ pub enum stmt_ { #[deriving(Eq, Encodable, Decodable,IterBytes)] pub struct local_ { is_mutbl: bool, - ty: @Ty, + ty: Ty, pat: @pat, init: Option<@expr>, id: node_id, @@ -429,12 +429,12 @@ pub enum expr_ { expr_vstore(@expr, expr_vstore), expr_vec(~[@expr], mutability), expr_call(@expr, ~[@expr], CallSugar), - expr_method_call(node_id, @expr, ident, ~[@Ty], ~[@expr], CallSugar), + expr_method_call(node_id, @expr, ident, ~[Ty], ~[@expr], CallSugar), expr_tup(~[@expr]), expr_binary(node_id, binop, @expr, @expr), expr_unary(node_id, unop, @expr), expr_lit(@lit), - expr_cast(@expr, @Ty), + expr_cast(@expr, Ty), expr_if(@expr, blk, Option<@expr>), expr_while(@expr, blk), /* Conditionless loop (can be exited with break, cont, or ret) @@ -454,7 +454,7 @@ pub enum expr_ { expr_copy(@expr), expr_assign(@expr, @expr), expr_assign_op(node_id, binop, @expr, @expr), - expr_field(@expr, ident, ~[@Ty]), + expr_field(@expr, ident, ~[Ty]), expr_index(node_id, @expr, @expr), expr_path(Path), @@ -604,7 +604,7 @@ pub enum lit_ { // type structure in middle/ty.rs as well. #[deriving(Eq, Encodable, Decodable,IterBytes)] pub struct mt { - ty: @Ty, + ty: ~Ty, mutbl: mutability, } @@ -733,7 +733,7 @@ pub enum ty_ { ty_rptr(Option, mt), ty_closure(@TyClosure), ty_bare_fn(@TyBareFn), - ty_tup(~[@Ty]), + ty_tup(~[Ty]), ty_path(Path, Option>, node_id), // for #7264; see above ty_mac(mac), // ty_infer means the type should be inferred instead of it having been @@ -762,7 +762,7 @@ pub struct inline_asm { #[deriving(Eq, Encodable, Decodable,IterBytes)] pub struct arg { is_mutbl: bool, - ty: @Ty, + ty: Ty, pat: @pat, id: node_id, } @@ -770,7 +770,7 @@ pub struct arg { #[deriving(Eq, Encodable, Decodable,IterBytes)] pub struct fn_decl { inputs: ~[arg], - output: @Ty, + output: Ty, cf: ret_style, } @@ -845,7 +845,7 @@ pub struct foreign_mod { #[deriving(Eq, Encodable, Decodable,IterBytes)] pub struct variant_arg { - ty: @Ty, + ty: Ty, id: node_id, } @@ -959,7 +959,7 @@ impl visibility { pub struct struct_field_ { kind: struct_field_kind, id: node_id, - ty: @Ty, + ty: Ty, attrs: ~[attribute], } @@ -995,17 +995,17 @@ pub struct item { #[deriving(Eq, Encodable, Decodable,IterBytes)] pub enum item_ { - item_static(@Ty, mutability, @expr), + item_static(Ty, mutability, @expr), item_fn(fn_decl, purity, AbiSet, Generics, blk), item_mod(_mod), item_foreign_mod(foreign_mod), - item_ty(@Ty, Generics), + item_ty(Ty, Generics), item_enum(enum_def, Generics), item_struct(@struct_def, Generics), item_trait(Generics, ~[trait_ref], ~[trait_method]), item_impl(Generics, Option, // (optional) trait this impl implements - @Ty, // self + Ty, // self ~[@method]), // a macro invocation (which includes macro definition) item_mac(mac), @@ -1024,7 +1024,7 @@ pub struct foreign_item { #[deriving(Eq, Encodable, Decodable,IterBytes)] pub enum foreign_item_ { foreign_item_fn(fn_decl, purity, Generics), - foreign_item_static(@Ty, /* is_mutbl */ bool), + foreign_item_static(Ty, /* is_mutbl */ bool), } // The data we save and restore about an inlined item or method. This is not diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 0388115d7ef95..73220ec288170 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -39,31 +39,30 @@ pub trait AstBuilder { global: bool, idents: ~[ast::ident], rp: Option, - types: ~[@ast::Ty]) + types: ~[ast::Ty]) -> ast::Path; // types - fn ty_mt(&self, ty: @ast::Ty, mutbl: ast::mutability) -> ast::mt; + fn ty_mt(&self, ty: ast::Ty, mutbl: ast::mutability) -> ast::mt; - fn ty(&self, span: span, ty: ast::ty_) -> @ast::Ty; - fn ty_path(&self, ast::Path, Option>) -> @ast::Ty; - fn ty_ident(&self, span: span, idents: ast::ident) -> @ast::Ty; + fn ty(&self, span: span, ty: ast::ty_) -> ast::Ty; + fn ty_path(&self, ast::Path, Option>) -> ast::Ty; + fn ty_ident(&self, span: span, idents: ast::ident) -> ast::Ty; fn ty_rptr(&self, span: span, - ty: @ast::Ty, + ty: ast::Ty, lifetime: Option, - mutbl: ast::mutability) - -> @ast::Ty; - fn ty_uniq(&self, span: span, ty: @ast::Ty) -> @ast::Ty; - fn ty_box(&self, span: span, ty: @ast::Ty, mutbl: ast::mutability) -> @ast::Ty; + mutbl: ast::mutability) -> ast::Ty; + fn ty_uniq(&self, span: span, ty: ast::Ty) -> ast::Ty; + fn ty_box(&self, span: span, ty: ast::Ty, mutbl: ast::mutability) -> ast::Ty; - fn ty_option(&self, ty: @ast::Ty) -> @ast::Ty; - fn ty_infer(&self, sp: span) -> @ast::Ty; - fn ty_nil(&self) -> @ast::Ty; + fn ty_option(&self, ty: ast::Ty) -> ast::Ty; + fn ty_infer(&self, sp: span) -> ast::Ty; + fn ty_nil(&self) -> ast::Ty; - fn ty_vars(&self, ty_params: &OptVec) -> ~[@ast::Ty]; - fn ty_vars_global(&self, ty_params: &OptVec) -> ~[@ast::Ty]; - fn ty_field_imm(&self, span: span, name: ident, ty: @ast::Ty) -> ast::ty_field; + fn ty_vars(&self, ty_params: &OptVec) -> ~[ast::Ty]; + fn ty_vars_global(&self, ty_params: &OptVec) -> ~[ast::Ty]; + fn ty_field_imm(&self, span: span, name: ident, ty: ast::Ty) -> ast::ty_field; fn strip_bounds(&self, bounds: &Generics) -> Generics; fn typaram(&self, id: ast::ident, bounds: OptVec) -> ast::TyParam; @@ -167,25 +166,25 @@ pub trait AstBuilder { fn item(&self, span: span, name: ident, attrs: ~[ast::attribute], node: ast::item_) -> @ast::item; - fn arg(&self, span: span, name: ident, ty: @ast::Ty) -> ast::arg; + fn arg(&self, span: span, name: ident, ty: ast::Ty) -> ast::arg; // XXX unused self - fn fn_decl(&self, inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl; + fn fn_decl(&self, inputs: ~[ast::arg], output: ast::Ty) -> ast::fn_decl; fn item_fn_poly(&self, span: span, name: ident, inputs: ~[ast::arg], - output: @ast::Ty, + output: ast::Ty, generics: Generics, body: ast::blk) -> @ast::item; fn item_fn(&self, span: span, name: ident, inputs: ~[ast::arg], - output: @ast::Ty, + output: ast::Ty, body: ast::blk) -> @ast::item; - fn variant(&self, span: span, name: ident, tys: ~[@ast::Ty]) -> ast::variant; + fn variant(&self, span: span, name: ident, tys: ~[ast::Ty]) -> ast::variant; fn item_enum_poly(&self, span: span, name: ident, @@ -207,9 +206,9 @@ pub trait AstBuilder { fn item_ty_poly(&self, span: span, name: ident, - ty: @ast::Ty, + ty: ast::Ty, generics: Generics) -> @ast::item; - fn item_ty(&self, span: span, name: ident, ty: @ast::Ty) -> @ast::item; + fn item_ty(&self, span: span, name: ident, ty: ast::Ty) -> @ast::item; fn attribute(&self, sp: span, mi: @ast::meta_item) -> ast::attribute; @@ -239,7 +238,7 @@ impl AstBuilder for @ExtCtxt { global: bool, idents: ~[ast::ident], rp: Option, - types: ~[@ast::Ty]) + types: ~[ast::Ty]) -> ast::Path { ast::Path { span: sp, @@ -250,15 +249,15 @@ impl AstBuilder for @ExtCtxt { } } - fn ty_mt(&self, ty: @ast::Ty, mutbl: ast::mutability) -> ast::mt { + fn ty_mt(&self, ty: ast::Ty, mutbl: ast::mutability) -> ast::mt { ast::mt { - ty: ty, + ty: ~ty, mutbl: mutbl } } - fn ty(&self, span: span, ty: ast::ty_) -> @ast::Ty { - @ast::Ty { + fn ty(&self, span: span, ty: ast::ty_) -> ast::Ty { + ast::Ty { id: self.next_id(), span: span, node: ty @@ -266,7 +265,7 @@ impl AstBuilder for @ExtCtxt { } fn ty_path(&self, path: ast::Path, bounds: Option>) - -> @ast::Ty { + -> ast::Ty { self.ty(path.span, ast::ty_path(path, bounds, self.next_id())) } @@ -274,28 +273,28 @@ impl AstBuilder for @ExtCtxt { // Might need to take bounds as an argument in the future, if you ever want // to generate a bounded existential trait type. fn ty_ident(&self, span: span, ident: ast::ident) - -> @ast::Ty { + -> ast::Ty { self.ty_path(self.path_ident(span, ident), None) } fn ty_rptr(&self, span: span, - ty: @ast::Ty, + ty: ast::Ty, lifetime: Option, mutbl: ast::mutability) - -> @ast::Ty { + -> ast::Ty { self.ty(span, ast::ty_rptr(lifetime, self.ty_mt(ty, mutbl))) } - fn ty_uniq(&self, span: span, ty: @ast::Ty) -> @ast::Ty { + fn ty_uniq(&self, span: span, ty: ast::Ty) -> ast::Ty { self.ty(span, ast::ty_uniq(self.ty_mt(ty, ast::m_imm))) } fn ty_box(&self, span: span, - ty: @ast::Ty, mutbl: ast::mutability) -> @ast::Ty { + ty: ast::Ty, mutbl: ast::mutability) -> ast::Ty { self.ty(span, ast::ty_box(self.ty_mt(ty, mutbl))) } - fn ty_option(&self, ty: @ast::Ty) -> @ast::Ty { + fn ty_option(&self, ty: ast::Ty) -> ast::Ty { self.ty_path( self.path_all(dummy_sp(), true, @@ -308,20 +307,20 @@ impl AstBuilder for @ExtCtxt { ~[ ty ]), None) } - fn ty_field_imm(&self, span: span, name: ident, ty: @ast::Ty) -> ast::ty_field { + fn ty_field_imm(&self, span: span, name: ident, ty: ast::Ty) -> ast::ty_field { respan(span, ast::ty_field_ { ident: name, - mt: ast::mt { ty: ty, mutbl: ast::m_imm }, + mt: ast::mt { ty: ~ty, mutbl: ast::m_imm }, }) } - fn ty_infer(&self, span: span) -> @ast::Ty { + fn ty_infer(&self, span: span) -> ast::Ty { self.ty(span, ast::ty_infer) } - fn ty_nil(&self) -> @ast::Ty { - @ast::Ty { + fn ty_nil(&self) -> ast::Ty { + ast::Ty { id: self.next_id(), node: ast::ty_nil, span: dummy_sp(), @@ -335,12 +334,12 @@ impl AstBuilder for @ExtCtxt { // these are strange, and probably shouldn't be used outside of // pipes. Specifically, the global version possible generates // incorrect code. - fn ty_vars(&self, ty_params: &OptVec) -> ~[@ast::Ty] { + fn ty_vars(&self, ty_params: &OptVec) -> ~[ast::Ty] { opt_vec::take_vec( ty_params.map(|p| self.ty_ident(dummy_sp(), p.ident))) } - fn ty_vars_global(&self, ty_params: &OptVec) -> ~[@ast::Ty] { + fn ty_vars_global(&self, ty_params: &OptVec) -> ~[ast::Ty] { opt_vec::take_vec( ty_params.map(|p| self.ty_path( self.path_global(dummy_sp(), ~[p.ident]), None))) @@ -642,7 +641,7 @@ impl AstBuilder for @ExtCtxt { self.lambda1(span, self.blk(span, stmts, None), ident) } - fn arg(&self, span: span, ident: ast::ident, ty: @ast::Ty) -> ast::arg { + fn arg(&self, span: span, ident: ast::ident, ty: ast::Ty) -> ast::arg { let arg_pat = self.pat_ident(span, ident); ast::arg { is_mutbl: false, @@ -653,7 +652,7 @@ impl AstBuilder for @ExtCtxt { } // XXX unused self - fn fn_decl(&self, inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl { + fn fn_decl(&self, inputs: ~[ast::arg], output: ast::Ty) -> ast::fn_decl { ast::fn_decl { inputs: inputs, output: output, @@ -677,7 +676,7 @@ impl AstBuilder for @ExtCtxt { span: span, name: ident, inputs: ~[ast::arg], - output: @ast::Ty, + output: ast::Ty, generics: Generics, body: ast::blk) -> @ast::item { self.item(span, @@ -694,7 +693,7 @@ impl AstBuilder for @ExtCtxt { span: span, name: ident, inputs: ~[ast::arg], - output: @ast::Ty, + output: ast::Ty, body: ast::blk ) -> @ast::item { self.item_fn_poly( @@ -706,10 +705,10 @@ impl AstBuilder for @ExtCtxt { body) } - fn variant(&self, span: span, name: ident, tys: ~[@ast::Ty]) -> ast::variant { - let args = do tys.map |ty| { - ast::variant_arg { ty: *ty, id: self.next_id() } - }; + fn variant(&self, span: span, name: ident, tys: ~[ast::Ty]) -> ast::variant { + let args = tys.consume_iter().transform(|ty| { + ast::variant_arg { ty: ty, id: self.next_id() } + }).collect(); respan(span, ast::variant_ { @@ -773,12 +772,12 @@ impl AstBuilder for @ExtCtxt { ) } - fn item_ty_poly(&self, span: span, name: ident, ty: @ast::Ty, + fn item_ty_poly(&self, span: span, name: ident, ty: ast::Ty, generics: Generics) -> @ast::item { self.item(span, name, ~[], ast::item_ty(ty, generics)) } - fn item_ty(&self, span: span, name: ident, ty: @ast::Ty) -> @ast::item { + fn item_ty(&self, span: span, name: ident, ty: ast::Ty) -> @ast::item { self.item_ty_poly(span, name, ty, ast_util::empty_generics()) } diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 10282cb6f0ae9..01769482d0829 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -456,7 +456,7 @@ impl<'self> MethodDef<'self> { } fn get_ret_ty(&self, cx: @ExtCtxt, span: span, - generics: &Generics, type_ident: ident) -> @ast::Ty { + generics: &Generics, type_ident: ident) -> ast::Ty { self.ret_ty.to_ty(cx, span, type_ident, generics) } @@ -466,7 +466,7 @@ impl<'self> MethodDef<'self> { fn split_self_nonself_args(&self, cx: @ExtCtxt, span: span, type_ident: ident, generics: &Generics) - -> (ast::explicit_self, ~[@expr], ~[@expr], ~[(ident, @ast::Ty)]) { + -> (ast::explicit_self, ~[@expr], ~[@expr], ~[(ident, ast::Ty)]) { let mut self_args = ~[]; let mut nonself_args = ~[]; @@ -514,7 +514,7 @@ impl<'self> MethodDef<'self> { type_ident: ident, generics: &Generics, explicit_self: ast::explicit_self, - arg_types: ~[(ident, @ast::Ty)], + arg_types: ~[(ident, ast::Ty)], body: @expr) -> @ast::method { // create the generics that aren't for Self let fn_generics = self.generics.to_generics(cx, span, type_ident, generics); diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index c820371714bfa..255bc6c98775b 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -61,7 +61,7 @@ impl<'self> Path<'self> { span: span, self_ty: ident, self_generics: &Generics) - -> @ast::Ty { + -> ast::Ty { cx.ty_path(self.to_path(cx, span, self_ty, self_generics), None) } pub fn to_path(&self, @@ -122,7 +122,7 @@ impl<'self> Ty<'self> { span: span, self_ty: ident, self_generics: &Generics) - -> @ast::Ty { + -> ast::Ty { match *self { Ptr(ref ty, ref ptr) => { let raw_ty = ty.to_ty(cx, span, self_ty, self_generics); diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index 58838b0c40bd0..a4873e6e34b45 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -42,19 +42,19 @@ pub fn path_global(ids: ~[ident], span: span) -> ast::Path { } pub trait append_types { - fn add_ty(&self, ty: @ast::Ty) -> ast::Path; - fn add_tys(&self, tys: ~[@ast::Ty]) -> ast::Path; + fn add_ty(&self, ty: ast::Ty) -> ast::Path; + fn add_tys(&self, tys: ~[ast::Ty]) -> ast::Path; } impl append_types for ast::Path { - fn add_ty(&self, ty: @ast::Ty) -> ast::Path { + fn add_ty(&self, ty: ast::Ty) -> ast::Path { ast::Path { types: vec::append_one(copy self.types, ty), .. copy *self } } - fn add_tys(&self, tys: ~[@ast::Ty]) -> ast::Path { + fn add_tys(&self, tys: ~[ast::Ty]) -> ast::Path { ast::Path { types: vec::append(copy self.types, tys), .. copy *self diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs index 8c2898737a35f..adf10215cb566 100644 --- a/src/libsyntax/ext/pipes/check.rs +++ b/src/libsyntax/ext/pipes/check.rs @@ -49,7 +49,7 @@ impl proto::visitor<(), (), ()> for @ExtCtxt { } } - fn visit_message(&self, name: @str, _span: span, _tys: &[@ast::Ty], + fn visit_message(&self, name: @str, _span: span, _tys: &[ast::Ty], this: state, next: Option) { match next { Some(ref next_state) => { diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 57174f216fe5a..98fc9aa61784d 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -25,7 +25,7 @@ use std::vec; pub trait gen_send { fn gen_send(&mut self, cx: @ExtCtxt, try: bool) -> @ast::item; - fn to_ty(&mut self, cx: @ExtCtxt) -> @ast::Ty; + fn to_ty(&mut self, cx: @ExtCtxt) -> ast::Ty; } pub trait to_type_decls { @@ -37,7 +37,7 @@ pub trait to_type_decls { pub trait gen_init { fn gen_init(&self, cx: @ExtCtxt) -> @ast::item; fn compile(&self, cx: @ExtCtxt) -> @ast::item; - fn buffer_ty_path(&self, cx: @ExtCtxt) -> @ast::Ty; + fn buffer_ty_path(&self, cx: @ExtCtxt) -> ast::Ty; fn gen_buffer_type(&self, cx: @ExtCtxt) -> @ast::item; fn gen_buffer_init(&self, ext_cx: @ExtCtxt) -> @ast::expr; fn gen_init_bounded(&self, ext_cx: @ExtCtxt) -> @ast::expr; @@ -56,7 +56,7 @@ impl gen_send for message { next.generics.ty_params.len()); let arg_names = vec::from_fn(tys.len(), |i| cx.ident_of("x_"+i.to_str())); let args_ast: ~[ast::arg] = arg_names.iter().zip(tys.iter()) - .transform(|(n, t)| cx.arg(span, *n, *t)).collect(); + .transform(|(n, t)| cx.arg(span, copy *n, copy *t)).collect(); let pipe_ty = cx.ty_path( path(~[this.data_name()], span) @@ -137,7 +137,7 @@ impl gen_send for message { let arg_names = vec::from_fn(tys.len(), |i| "x_" + i.to_str()); let args_ast: ~[ast::arg] = arg_names.iter().zip(tys.iter()) - .transform(|(n, t)| cx.arg(span, cx.ident_of(*n), *t)).collect(); + .transform(|(&n, t)| cx.arg(span, cx.ident_of(n), copy *t)).collect(); let args_ast = vec::append( ~[cx.arg(span, @@ -189,7 +189,7 @@ impl gen_send for message { } } - fn to_ty(&mut self, cx: @ExtCtxt) -> @ast::Ty { + fn to_ty(&mut self, cx: @ExtCtxt) -> ast::Ty { cx.ty_path(path(~[cx.ident_of(self.name())], self.span()) .add_tys(cx.ty_vars(&self.get_generics().ty_params)), None) } @@ -369,7 +369,7 @@ impl gen_init for protocol { }) } - fn buffer_ty_path(&self, cx: @ExtCtxt) -> @ast::Ty { + fn buffer_ty_path(&self, cx: @ExtCtxt) -> ast::Ty { let mut params: OptVec = opt_vec::Empty; for self.states.iter().advance |s| { for s.generics.ty_params.iter().advance |tp| { diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index f3d7158de5269..2fe8456c2749c 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -37,11 +37,11 @@ impl direction { pub struct next_state { state: @str, - tys: ~[@ast::Ty], + tys: ~[ast::Ty], } // name, span, data, current state, next state -pub struct message(@str, span, ~[@ast::Ty], state, Option); +pub struct message(@str, span, ~[ast::Ty], state, Option); impl message { pub fn name(&mut self) -> @str { @@ -81,7 +81,7 @@ impl state_ { pub fn add_message(@self, name: @str, span: span, - data: ~[@ast::Ty], + data: ~[ast::Ty], next: Option) { self.messages.push(message(name, span, data, self, next)); @@ -96,7 +96,7 @@ impl state_ { } /// Returns the type that is used for the messages. - pub fn to_ty(&self, cx: @ExtCtxt) -> @ast::Ty { + pub fn to_ty(&self, cx: @ExtCtxt) -> ast::Ty { cx.ty_path (path(~[cx.ident_of(self.name)],self.span).add_tys( cx.ty_vars(&self.generics.ty_params)), None) @@ -206,7 +206,7 @@ impl protocol_ { pub trait visitor { fn visit_proto(&self, proto: protocol, st: &[Tstate]) -> Tproto; fn visit_state(&self, state: state, m: &[Tmessage]) -> Tstate; - fn visit_message(&self, name: @str, spane: span, tys: &[@ast::Ty], + fn visit_message(&self, name: @str, spane: span, tys: &[ast::Ty], this: state, next: Option) -> Tmessage; } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index db1902753a384..c550e3382a233 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -88,13 +88,13 @@ pub mod rt { } } - impl ToSource for @ast::Ty { + impl ToSource for ast::Ty { fn to_source(&self) -> @str { - pprust::ty_to_str(*self, get_ident_interner()).to_managed() + pprust::ty_to_str(self, get_ident_interner()).to_managed() } } - impl<'self> ToSource for &'self [@ast::Ty] { + impl<'self> ToSource for &'self [ast::Ty] { fn to_source(&self) -> @str { self.map(|i| i.to_source()).connect(", ").to_managed() } @@ -216,13 +216,13 @@ pub mod rt { } } - impl ToTokens for @ast::Ty { + impl ToTokens for ast::Ty { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] { cx.parse_tts(self.to_source()) } } - impl<'self> ToTokens for &'self [@ast::Ty] { + impl<'self> ToTokens for &'self [ast::Ty] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] { cx.parse_tts(self.to_source()) } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index c6592d36e4097..e2beebcead26d 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -28,7 +28,7 @@ pub trait ast_fold { fn fold_pat(@self, @pat) -> @pat; fn fold_decl(@self, @decl) -> Option<@decl>; fn fold_expr(@self, @expr) -> @expr; - fn fold_ty(@self, @Ty) -> @Ty; + fn fold_ty(@self, &Ty) -> Ty; fn fold_mod(@self, &_mod) -> _mod; fn fold_foreign_mod(@self, &foreign_mod) -> foreign_mod; fn fold_variant(@self, &variant) -> variant; @@ -107,7 +107,7 @@ fn fold_attribute_(at: attribute, fld: @ast_fold) -> attribute { fn fold_arg_(a: arg, fld: @ast_fold) -> arg { ast::arg { is_mutbl: a.is_mutbl, - ty: fld.fold_ty(a.ty), + ty: fld.fold_ty(&a.ty), pat: fld.fold_pat(a.pat), id: fld.new_id(a.id), } @@ -154,8 +154,8 @@ fn maybe_fold_ident(t : &token::Token, fld: @ast_fold) -> token::Token { pub fn fold_fn_decl(decl: &ast::fn_decl, fld: @ast_fold) -> ast::fn_decl { ast::fn_decl { - inputs: decl.inputs.map(|x| fold_arg_(*x, fld)), - output: fld.fold_ty(decl.output), + inputs: decl.inputs.map(|x| fold_arg_(/*bad*/ copy *x, fld)), + output: fld.fold_ty(&decl.output), cf: decl.cf, } } @@ -226,14 +226,14 @@ fn noop_fold_foreign_item(ni: @foreign_item, fld: @ast_fold) foreign_item_fn(ref fdec, purity, ref generics) => { foreign_item_fn( ast::fn_decl { - inputs: fdec.inputs.map(|a| fold_arg(*a)), - output: fld.fold_ty(fdec.output), + inputs: fdec.inputs.map(|a| fold_arg(/*bad*/copy *a)), + output: fld.fold_ty(&fdec.output), cf: fdec.cf, }, purity, fold_generics(generics, fld)) } - foreign_item_static(t, m) => { + foreign_item_static(ref t, m) => { foreign_item_static(fld.fold_ty(t), m) } }, @@ -260,14 +260,14 @@ fn noop_fold_struct_field(sf: @struct_field, fld: @ast_fold) @spanned { node: ast::struct_field_ { kind: copy sf.node.kind, id: sf.node.id, - ty: fld.fold_ty(sf.node.ty), + ty: fld.fold_ty(&sf.node.ty), attrs: sf.node.attrs.map(|e| fold_attribute(*e)) }, span: sf.span } } pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ { match *i { - item_static(t, m, e) => item_static(fld.fold_ty(t), m, fld.fold_expr(e)), + item_static(ref t, m, e) => item_static(fld.fold_ty(t), m, fld.fold_expr(e)), item_fn(ref decl, purity, abi, ref generics, ref body) => { item_fn( fold_fn_decl(decl, fld), @@ -281,7 +281,7 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ { item_foreign_mod(ref nm) => { item_foreign_mod(fld.fold_foreign_mod(nm)) } - item_ty(t, ref generics) => { + item_ty(ref t, ref generics) => { item_ty(fld.fold_ty(t), fold_generics(generics, fld)) } item_enum(ref enum_definition, ref generics) => { @@ -297,7 +297,7 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ { let struct_def = fold_struct_def(*struct_def, fld); item_struct(struct_def, /* FIXME (#2543) */ copy *generics) } - item_impl(ref generics, ref ifce, ty, ref methods) => { + item_impl(ref generics, ref ifce, ref ty, ref methods) => { item_impl( fold_generics(generics, fld), ifce.map(|p| fold_trait_ref(p, fld)), @@ -348,7 +348,7 @@ fn fold_struct_field(f: @struct_field, fld: @ast_fold) -> @struct_field { node: ast::struct_field_ { kind: copy f.node.kind, id: fld.new_id(f.node.id), - ty: fld.fold_ty(f.node.ty), + ty: fld.fold_ty(&f.node.ty), attrs: /* FIXME (#2543) */ copy f.node.attrs, }, span: fld.new_span(f.span), @@ -518,7 +518,7 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ { fld.new_id(callee_id), fld.fold_expr(f), fld.fold_ident(i), - tps.map(|x| fld.fold_ty(*x)), + tps.map(|x| fld.fold_ty(x)), fld.map_exprs(|x| fld.fold_expr(x), *args), blk ) @@ -541,7 +541,7 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ { expr_loop_body(f) => expr_loop_body(fld.fold_expr(f)), expr_do_body(f) => expr_do_body(fld.fold_expr(f)), expr_lit(_) => copy *e, - expr_cast(expr, ty) => expr_cast(fld.fold_expr(expr), ty), + expr_cast(expr, ref ty) => expr_cast(fld.fold_expr(expr), copy *ty), expr_addr_of(m, ohs) => expr_addr_of(m, fld.fold_expr(ohs)), expr_if(cond, ref tr, fl) => { expr_if( @@ -587,7 +587,7 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ { expr_field(el, id, ref tys) => { expr_field( fld.fold_expr(el), fld.fold_ident(id), - tys.map(|x| fld.fold_ty(*x)) + tys.map(|x| fld.fold_ty(x)) ) } expr_index(callee_id, el, er) => { @@ -637,7 +637,7 @@ pub fn noop_fold_ty(t: &ty_, fld: @ast_fold) -> ty_ { let fold_mac = |x| fold_mac_(x, fld); fn fold_mt(mt: &mt, fld: @ast_fold) -> mt { mt { - ty: fld.fold_ty(mt.ty), + ty: ~fld.fold_ty(mt.ty), mutbl: mt.mutbl, } } @@ -682,7 +682,7 @@ pub fn noop_fold_ty(t: &ty_, fld: @ast_fold) -> ty_ { decl: fold_fn_decl(&f.decl, fld) }) } - ty_tup(ref tys) => ty_tup(tys.map(|ty| fld.fold_ty(*ty))), + ty_tup(ref tys) => ty_tup(tys.map(|ty| fld.fold_ty(ty))), ty_path(ref path, ref bounds, id) => ty_path(fld.fold_path(path), fold_opt_bounds(bounds, fld), fld.new_id(id)), ty_fixed_length_vec(ref mt, e) => { @@ -714,7 +714,7 @@ fn noop_fold_foreign_mod(nm: &foreign_mod, fld: @ast_fold) -> foreign_mod { fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ { fn fold_variant_arg_(va: variant_arg, fld: @ast_fold) -> variant_arg { - ast::variant_arg { ty: fld.fold_ty(va.ty), id: fld.new_id(va.id) } + ast::variant_arg { ty: fld.fold_ty(&va.ty), id: fld.new_id(va.id) } } let fold_variant_arg = |x| fold_variant_arg_(x, fld); @@ -722,7 +722,7 @@ fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ { match v.kind { tuple_variant_kind(ref variant_args) => { kind = tuple_variant_kind(do variant_args.map |x| { - fold_variant_arg(*x) + fold_variant_arg(/*bad*/ copy *x) }) } struct_variant_kind(struct_def) => { @@ -761,14 +761,14 @@ fn noop_fold_path(p: &Path, fld: @ast_fold) -> Path { global: p.global, idents: p.idents.map(|x| fld.fold_ident(*x)), rp: p.rp, - types: p.types.map(|x| fld.fold_ty(*x)), + types: p.types.map(|x| fld.fold_ty(x)), } } fn noop_fold_local(l: &local_, fld: @ast_fold) -> local_ { local_ { is_mutbl: l.is_mutbl, - ty: fld.fold_ty(l.ty), + ty: fld.fold_ty(&l.ty), pat: fld.fold_pat(l.pat), init: l.init.map(|e| fld.fold_expr(*e)), id: fld.new_id(l.id), @@ -838,7 +838,7 @@ impl ast_fold for AstFoldFns { node: ast::struct_field_ { kind: copy sf.node.kind, id: sf.node.id, - ty: (self as @ast_fold).fold_ty(sf.node.ty), + ty: self.fold_ty(&sf.node.ty), attrs: copy sf.node.attrs, }, span: (self.new_span)(sf.span), @@ -887,9 +887,9 @@ impl ast_fold for AstFoldFns { span: (self.new_span)(s), } } - fn fold_ty(@self, x: @Ty) -> @Ty { + fn fold_ty(@self, x: &Ty) -> Ty { let (n, s) = (self.fold_ty)(&x.node, x.span, self as @ast_fold); - @Ty { + Ty { id: (self.new_id)(x.id), node: n, span: (self.new_span)(s), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4c662cc46213f..d18d24c2b90e0 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -824,7 +824,7 @@ impl Parser { // parse a possibly mutable type pub fn parse_mt(&self) -> mt { let mutbl = self.parse_mutability(); - let t = self.parse_ty(false); + let t = ~self.parse_ty(false); mt { ty: t, mutbl: mutbl } } @@ -835,7 +835,7 @@ impl Parser { let mutbl = self.parse_mutability(); let id = self.parse_ident(); self.expect(&token::COLON); - let ty = self.parse_ty(false); + let ty = ~self.parse_ty(false); spanned( lo, ty.span.hi, @@ -847,13 +847,13 @@ impl Parser { } // parse optional return type [ -> TY ] in function decl - pub fn parse_ret_ty(&self) -> (ret_style, @Ty) { + pub fn parse_ret_ty(&self) -> (ret_style, Ty) { return if self.eat(&token::RARROW) { let lo = self.span.lo; if self.eat(&token::NOT) { ( noreturn, - @Ty { + Ty { id: self.get_id(), node: ty_bot, span: mk_sp(lo, self.last_span.hi) @@ -866,7 +866,7 @@ impl Parser { let pos = self.span.lo; ( return_val, - @Ty { + Ty { id: self.get_id(), node: ty_nil, span: mk_sp(pos, pos), @@ -878,7 +878,7 @@ impl Parser { // parse a type. // Useless second parameter for compatibility with quasiquote macros. // Bleh! - pub fn parse_ty(&self, _: bool) -> @Ty { + pub fn parse_ty(&self, _: bool) -> Ty { maybe_whole!(self, nt_ty); let lo = self.span.lo; @@ -975,7 +975,7 @@ impl Parser { }; let sp = mk_sp(lo, self.last_span.hi); - @Ty {id: self.get_id(), node: t, span: sp} + Ty {id: self.get_id(), node: t, span: sp} } // parse the type following a @ or a ~ @@ -1116,7 +1116,7 @@ impl Parser { let t = if self.eat(&token::COLON) { self.parse_ty(false) } else { - @Ty { + Ty { id: self.get_id(), node: ty_infer, span: mk_sp(self.span.lo, self.span.hi), @@ -1463,7 +1463,7 @@ impl Parser { pub fn mk_method_call(&self, rcvr: @expr, ident: ident, - tps: ~[@Ty], + tps: ~[Ty], args: ~[@expr], sugar: CallSugar) -> ast::expr_ { expr_method_call(self.get_id(), rcvr, ident, tps, args, sugar) @@ -1473,7 +1473,7 @@ impl Parser { expr_index(self.get_id(), expr, idx) } - pub fn mk_field(&self, expr: @expr, ident: ident, tys: ~[@Ty]) -> ast::expr_ { + pub fn mk_field(&self, expr: @expr, ident: ident, tys: ~[Ty]) -> ast::expr_ { expr_field(expr, ident, tys) } @@ -2215,7 +2215,7 @@ impl Parser { // No argument list - `do foo {` ast::fn_decl { inputs: ~[], - output: @Ty { + output: Ty { id: self.get_id(), node: ty_infer, span: *self.span @@ -2826,7 +2826,7 @@ impl Parser { self.obsolete(*self.span, ObsoleteMutWithMultipleBindings) } - let mut ty = @Ty { + let mut ty = Ty { id: self.get_id(), node: ty_infer, span: mk_sp(lo, lo), @@ -3235,7 +3235,7 @@ impl Parser { // parse a generic use site fn parse_generic_values( - &self) -> (OptVec, ~[@Ty]) + &self) -> (OptVec, ~[Ty]) { if !self.eat(&token::LT) { (opt_vec::Empty, ~[]) @@ -3245,7 +3245,7 @@ impl Parser { } fn parse_generic_values_after_lt( - &self) -> (OptVec, ~[@Ty]) + &self) -> (OptVec, ~[Ty]) { let lifetimes = self.parse_lifetimes(); let result = self.parse_seq_to_gt( @@ -3455,7 +3455,7 @@ impl Parser { let output = if self.eat(&token::RARROW) { self.parse_ty(false) } else { - @Ty { id: self.get_id(), node: ty_infer, span: *self.span } + Ty { id: self.get_id(), node: ty_infer, span: *self.span } }; ast::fn_decl { @@ -4155,9 +4155,9 @@ impl Parser { seq_sep_trailing_disallowed(token::COMMA), |p| p.parse_ty(false) ); - for arg_tys.iter().advance |ty| { + for arg_tys.consume_iter().advance |ty| { args.push(ast::variant_arg { - ty: *ty, + ty: ty, id: self.get_id(), }); } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 0264903076b9c..09d6ecb40fc0b 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -104,7 +104,7 @@ pub enum nonterminal { nt_stmt(@ast::stmt), nt_pat( @ast::pat), nt_expr(@ast::expr), - nt_ty( @ast::Ty), + nt_ty( ast::Ty), nt_ident(ast::ident, bool), nt_path( ast::Path), nt_tt( @ast::token_tree), //needs @ed to break a circularity diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index d054f9278945a..517065ab1b5c0 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -398,7 +398,7 @@ pub fn print_type(s: @ps, ty: &ast::Ty) { } ast::ty_tup(ref elts) => { popen(s); - commasep(s, inconsistent, *elts, |p, &t| print_type(p, t)); + commasep(s, inconsistent, *elts, print_type); if elts.len() == 1 { word(s.s, ","); } @@ -454,7 +454,7 @@ pub fn print_foreign_item(s: @ps, item: &ast::foreign_item) { word(s.s, ";"); end(s); // end the outer fn box } - ast::foreign_item_static(t, m) => { + ast::foreign_item_static(ref t, m) => { head(s, "static"); if m { word_space(s, "mut"); @@ -476,7 +476,7 @@ pub fn print_item(s: @ps, item: &ast::item) { let ann_node = node_item(s, item); (s.ann.pre)(ann_node); match item.node { - ast::item_static(ty, m, expr) => { + ast::item_static(ref ty, m, expr) => { head(s, visibility_qualified(item.vis, "static")); if m == ast::m_mutbl { word_space(s, "mut"); @@ -530,7 +530,7 @@ pub fn print_item(s: @ps, item: &ast::item) { print_foreign_mod(s, nmod, item.attrs); bclose(s, item.span); } - ast::item_ty(ty, ref params) => { + ast::item_ty(ref ty, ref params) => { ibox(s, indent_unit); ibox(s, 0u); word_nbsp(s, visibility_qualified(item.vis, "type")); @@ -559,7 +559,7 @@ pub fn print_item(s: @ps, item: &ast::item) { print_struct(s, struct_def, generics, item.ident, item.span); } - ast::item_impl(ref generics, ref opt_trait, ty, ref methods) => { + ast::item_impl(ref generics, ref opt_trait, ref ty, ref methods) => { head(s, visibility_qualified(item.vis, "impl")); if generics.is_parameterized() { print_generics(s, generics); @@ -694,7 +694,7 @@ pub fn print_struct(s: @ps, ast::named_field(*) => fail!("unexpected named field"), ast::unnamed_field => { maybe_print_comment(s, field.span.lo); - print_type(s, field.node.ty); + print_type(s, &field.node.ty); } } } @@ -718,7 +718,7 @@ pub fn print_struct(s: @ps, print_visibility(s, visibility); print_ident(s, ident); word_nbsp(s, ":"); - print_type(s, field.node.ty); + print_type(s, &field.node.ty); word(s.s, ","); } } @@ -777,7 +777,7 @@ pub fn print_variant(s: @ps, v: &ast::variant) { if !args.is_empty() { popen(s); fn print_variant_arg(s: @ps, arg: &ast::variant_arg) { - print_type(s, arg.ty); + print_type(s, &arg.ty); } commasep(s, consistent, *args, print_variant_arg); pclose(s); @@ -1172,7 +1172,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { print_ident(s, ident); if tys.len() > 0u { word(s.s, "::<"); - commasep(s, inconsistent, *tys, |p, &e| print_type(p, e)); + commasep(s, inconsistent, *tys, print_type); word(s.s, ">"); } print_call_post(s, sugar, &blk, &mut base_args); @@ -1198,7 +1198,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { print_expr(s, expr); } ast::expr_lit(lit) => print_literal(s, lit), - ast::expr_cast(expr, ty) => { + ast::expr_cast(expr, ref ty) => { print_expr(s, expr); space(s.s); word_space(s, "as"); @@ -1348,7 +1348,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { print_ident(s, id); if tys.len() > 0u { word(s.s, "::<"); - commasep(s, inconsistent, *tys, |p, &e| print_type(p, e)); + commasep(s, inconsistent, *tys, print_type); word(s.s, ">"); } } @@ -1437,7 +1437,7 @@ pub fn print_local_decl(s: @ps, loc: &ast::local) { print_irrefutable_pat(s, loc.node.pat); match loc.node.ty.node { ast::ty_infer => (), - _ => { word_space(s, ":"); print_type(s, loc.node.ty); } + _ => { word_space(s, ":"); print_type(s, &loc.node.ty); } } } @@ -1510,7 +1510,7 @@ fn print_path_(s: @ps, path: &ast::Path, colons_before_params: bool, } } - commasep(s, inconsistent, path.types, |p, &e| print_type(p, e)); + commasep(s, inconsistent, path.types, print_type); word(s.s, ">"); } @@ -1693,7 +1693,7 @@ pub fn print_fn_args(s: @ps, decl: &ast::fn_decl, for decl.inputs.iter().advance |arg| { if first { first = false; } else { word_space(s, ","); } - print_arg(s, *arg); + print_arg(s, arg); } end(s); @@ -1711,7 +1711,7 @@ pub fn print_fn_args_and_ret(s: @ps, decl: &ast::fn_decl, _ => { space_if_not_bol(s); word_space(s, "->"); - print_type(s, decl.output); + print_type(s, &decl.output); } } } @@ -1726,7 +1726,7 @@ pub fn print_fn_block_args(s: @ps, decl: &ast::fn_decl) { _ => { space_if_not_bol(s); word_space(s, "->"); - print_type(s, decl.output); + print_type(s, &decl.output); } } @@ -1882,7 +1882,7 @@ pub fn print_mt(s: @ps, mt: &ast::mt) { print_type(s, mt.ty); } -pub fn print_arg(s: @ps, input: ast::arg) { +pub fn print_arg(s: @ps, input: &ast::arg) { ibox(s, indent_unit); if input.is_mutbl { word_space(s, "mut"); @@ -1902,7 +1902,7 @@ pub fn print_arg(s: @ps, input: ast::arg) { space(s.s); } } - print_type(s, input.ty); + print_type(s, &input.ty); } } end(s); @@ -1944,7 +1944,7 @@ pub fn print_ty_fn(s: @ps, } for decl.inputs.iter().advance |arg| { if first { first = false; } else { word_space(s, ","); } - print_arg(s, *arg); + print_arg(s, arg); } end(s); pclose(s); @@ -1958,7 +1958,7 @@ pub fn print_ty_fn(s: @ps, ibox(s, indent_unit); word_space(s, "->"); if decl.cf == ast::noreturn { word_nbsp(s, "!"); } - else { print_type(s, decl.output); } + else { print_type(s, &decl.output); } end(s); } } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index b513b68b74f8b..b2d9d49f0ee77 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -83,7 +83,7 @@ pub struct Visitor { visit_decl: @fn(@decl, (E, vt)), visit_expr: @fn(@expr, (E, vt)), visit_expr_post: @fn(@expr, (E, vt)), - visit_ty: @fn(@Ty, (E, vt)), + visit_ty: @fn(&Ty, (E, vt)), visit_generics: @fn(&Generics, (E, vt)), visit_fn: @fn(&fn_kind, &fn_decl, &blk, span, node_id, (E, vt)), visit_ty_method: @fn(&ty_method, (E, vt)), @@ -131,7 +131,7 @@ pub fn visit_view_item(_vi: &view_item, (_e, _v): (E, vt)) { } pub fn visit_local(loc: &local, (e, v): (E, vt)) { (v.visit_pat)(loc.node.pat, (copy e, v)); - (v.visit_ty)(loc.node.ty, (copy e, v)); + (v.visit_ty)(&loc.node.ty, (copy e, v)); match loc.node.init { None => (), Some(ex) => (v.visit_expr)(ex, (e, v)) @@ -144,7 +144,7 @@ fn visit_trait_ref(tref: &ast::trait_ref, (e, v): (E, vt)) { pub fn visit_item(i: &item, (e, v): (E, vt)) { match i.node { - item_static(t, _, ex) => { + item_static(ref t, _, ex) => { (v.visit_ty)(t, (copy e, v)); (v.visit_expr)(ex, (copy e, v)); } @@ -169,7 +169,7 @@ pub fn visit_item(i: &item, (e, v): (E, vt)) { for nm.view_items.iter().advance |vi| { (v.visit_view_item)(vi, (copy e, v)); } for nm.items.iter().advance |ni| { (v.visit_foreign_item)(*ni, (copy e, v)); } } - item_ty(t, ref tps) => { + item_ty(ref t, ref tps) => { (v.visit_ty)(t, (copy e, v)); (v.visit_generics)(tps, (e, v)); } @@ -181,7 +181,7 @@ pub fn visit_item(i: &item, (e, v): (E, vt)) { (e, v) ); } - item_impl(ref tps, ref traits, ty, ref methods) => { + item_impl(ref tps, ref traits, ref ty, ref methods) => { (v.visit_generics)(tps, (copy e, v)); for traits.iter().advance |p| { visit_trait_ref(p, (copy e, v)); @@ -213,7 +213,7 @@ pub fn visit_enum_def(enum_definition: &ast::enum_def, match vr.node.kind { tuple_variant_kind(ref variant_args) => { for variant_args.iter().advance |va| { - (v.visit_ty)(va.ty, (copy e, v)); + (v.visit_ty)(&va.ty, (copy e, v)); } } struct_variant_kind(struct_def) => { @@ -232,25 +232,25 @@ pub fn skip_ty(_t: &Ty, (_e,_v): (E, vt)) {} pub fn visit_ty(t: &Ty, (e, v): (E, vt)) { match t.node { - ty_box(mt) | ty_uniq(mt) | - ty_vec(mt) | ty_ptr(mt) | ty_rptr(_, mt) => { + ty_box(ref mt) | ty_uniq(ref mt) | + ty_vec(ref mt) | ty_ptr(ref mt) | ty_rptr(_, ref mt) => { (v.visit_ty)(mt.ty, (e, v)); }, ty_tup(ref ts) => { for ts.iter().advance |tt| { - (v.visit_ty)(*tt, (copy e, v)); + (v.visit_ty)(tt, (copy e, v)); } }, ty_closure(ref f) => { - for f.decl.inputs.iter().advance |a| { (v.visit_ty)(a.ty, (copy e, v)); } - (v.visit_ty)(f.decl.output, (copy e, v)); + for f.decl.inputs.iter().advance |a| { (v.visit_ty)(&a.ty, (copy e, v)); } + (v.visit_ty)(&f.decl.output, (copy e, v)); do f.bounds.map |bounds| { visit_ty_param_bounds(bounds, (copy e, v)); }; }, ty_bare_fn(ref f) => { - for f.decl.inputs.iter().advance |a| { (v.visit_ty)(a.ty, (copy e, v)); } - (v.visit_ty)(f.decl.output, (e, v)); + for f.decl.inputs.iter().advance |a| { (v.visit_ty)(&a.ty, (copy e, v)); } + (v.visit_ty)(&f.decl.output, (e, v)); }, ty_path(ref p, ref bounds, _) => { visit_path(p, (copy e, v)); @@ -267,7 +267,7 @@ pub fn visit_ty(t: &Ty, (e, v): (E, vt)) { } pub fn visit_path(p: &Path, (e, v): (E, vt)) { - for p.types.iter().advance |tp| { (v.visit_ty)(*tp, (copy e, v)); } + for p.types.iter().advance |tp| { (v.visit_ty)(tp, (copy e, v)); } } pub fn visit_pat(p: &pat, (e, v): (E, vt)) { @@ -326,7 +326,7 @@ pub fn visit_foreign_item(ni: &foreign_item, (e, v): (E, vt)) { visit_fn_decl(fd, (copy e, v)); (v.visit_generics)(generics, (e, v)); } - foreign_item_static(t, _) => { + foreign_item_static(ref t, _) => { (v.visit_ty)(t, (e, v)); } } @@ -351,9 +351,9 @@ pub fn visit_generics(generics: &Generics, (e, v): (E, vt)) { pub fn visit_fn_decl(fd: &fn_decl, (e, v): (E, vt)) { for fd.inputs.iter().advance |a| { (v.visit_pat)(a.pat, (copy e, v)); - (v.visit_ty)(a.ty, (copy e, v)); + (v.visit_ty)(&a.ty, (copy e, v)); } - (v.visit_ty)(fd.output, (e, v)); + (v.visit_ty)(&fd.output, (e, v)); } // Note: there is no visit_method() method in the visitor, instead override @@ -384,9 +384,9 @@ pub fn visit_fn(fk: &fn_kind, decl: &fn_decl, body: &blk, _sp: span, } pub fn visit_ty_method(m: &ty_method, (e, v): (E, vt)) { - for m.decl.inputs.iter().advance |a| { (v.visit_ty)(a.ty, (copy e, v)); } + for m.decl.inputs.iter().advance |a| { (v.visit_ty)(&a.ty, (copy e, v)); } (v.visit_generics)(&m.generics, (copy e, v)); - (v.visit_ty)(m.decl.output, (e, v)); + (v.visit_ty)(&m.decl.output, (e, v)); } pub fn visit_trait_method(m: &trait_method, (e, v): (E, vt)) { @@ -409,7 +409,7 @@ pub fn visit_struct_def( } pub fn visit_struct_field(sf: &struct_field, (e, v): (E, vt)) { - (v.visit_ty)(sf.node.ty, (e, v)); + (v.visit_ty)(&sf.node.ty, (e, v)); } pub fn visit_block(b: &blk, (e, v): (E, vt)) { @@ -475,7 +475,7 @@ pub fn visit_expr(ex: @expr, (e, v): (E, vt)) { expr_method_call(_, callee, _, ref tys, ref args, _) => { visit_exprs(*args, (copy e, v)); for tys.iter().advance |tp| { - (v.visit_ty)(*tp, (copy e, v)); + (v.visit_ty)(tp, (copy e, v)); } (v.visit_expr)(callee, (copy e, v)); } @@ -486,7 +486,7 @@ pub fn visit_expr(ex: @expr, (e, v): (E, vt)) { expr_addr_of(_, x) | expr_unary(_, _, x) | expr_loop_body(x) | expr_do_body(x) => (v.visit_expr)(x, (copy e, v)), expr_lit(_) => (), - expr_cast(x, t) => { + expr_cast(x, ref t) => { (v.visit_expr)(x, (copy e, v)); (v.visit_ty)(t, (copy e, v)); } @@ -527,7 +527,7 @@ pub fn visit_expr(ex: @expr, (e, v): (E, vt)) { expr_field(x, _, ref tys) => { (v.visit_expr)(x, (copy e, v)); for tys.iter().advance |tp| { - (v.visit_ty)(*tp, (copy e, v)); + (v.visit_ty)(tp, (copy e, v)); } } expr_index(_, a, b) => { @@ -579,7 +579,7 @@ pub struct SimpleVisitor { visit_decl: @fn(@decl), visit_expr: @fn(@expr), visit_expr_post: @fn(@expr), - visit_ty: @fn(@Ty), + visit_ty: @fn(&Ty), visit_generics: @fn(&Generics), visit_fn: @fn(&fn_kind, &fn_decl, &blk, span, node_id), visit_ty_method: @fn(&ty_method), @@ -591,7 +591,7 @@ pub struct SimpleVisitor { pub type simple_visitor = @SimpleVisitor; -pub fn simple_ignore_ty(_t: @Ty) {} +pub fn simple_ignore_ty(_t: &Ty) {} pub fn default_simple_visitor() -> @SimpleVisitor { @SimpleVisitor { @@ -672,7 +672,7 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { fn v_expr_post(f: @fn(@expr), ex: @expr, (_e, _v): ((), vt<()>)) { f(ex); } - fn v_ty(f: @fn(@Ty), ty: @Ty, (e, v): ((), vt<()>)) { + fn v_ty(f: @fn(&Ty), ty: &Ty, (e, v): ((), vt<()>)) { f(ty); visit_ty(ty, (e, v)); } @@ -717,7 +717,7 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { f(fk, decl, body, sp, id); visit_fn(fk, decl, body, sp, id, (e, v)); } - let visit_ty: @fn(@Ty, ((), vt<()>)) = + let visit_ty: @fn(&Ty, ((), vt<()>)) = |a,b| v_ty(v.visit_ty, a, b); fn v_struct_field(f: @fn(@struct_field), sf: @struct_field, (e, v): ((), vt<()>)) { f(sf);