diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs index d8b59d579c815..bc3cb92e0cc48 100644 --- a/src/librustc/front/config.rs +++ b/src/librustc/front/config.rs @@ -96,10 +96,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, ref c, ref methods) => { + ast::item_impl(ref a, ref b, c, ref methods) => { let methods = methods.iter().filter(|m| method_in_cfg(cx, **m)) .transform(|x| *x).collect(); - ast::item_impl((*a).clone(), (*b).clone(), (*c).clone(), methods) + ast::item_impl((*a).clone(), (*b).clone(), 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/tydecode.rs b/src/librustc/metadata/tydecode.rs index b76743fc468f8..b0e7ef80949ed 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -202,7 +202,7 @@ fn parse_substs(st: &mut PState, conv: conv_did) -> ty::substs { }; } -fn parse_region_substs(st: &mut PState, conv: conv_did) -> ty::RegionSubsts { +fn parse_region_substs(st: &mut PState, _conv: conv_did) -> ty::RegionSubsts { match next(st) { 'e' => ty::ErasedRegions, 'n' => { diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 99aae34911b3b..877ceafca4b24 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -116,7 +116,7 @@ fn check_item(item: @item, (cx, visitor): (Context, visit::vt)) { // If this is a destructor, check kinds. if !attr::contains_name(item.attrs, "unsafe_destructor") { match item.node { - item_impl(_, Some(ref trait_ref), ref self_type, _) => { + item_impl(_, Some(ref trait_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) => { @@ -313,7 +313,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 d6e6db8354a0f..76834ea8cb023 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -707,9 +707,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 { @@ -719,7 +719,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(ref t, _) => { check_ty(cx, t); } + ast::foreign_item_static(t, _) => { check_ty(cx, t); } } } } diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index bbe3abd3dd219..9da848e3b93e4 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -714,10 +714,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)); @@ -732,7 +732,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 @@ -816,8 +816,8 @@ fn determine_rp_in_ty(ty: &ast::Ty, } match ty.node { - 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) => { + ast::ty_box(mt) | ast::ty_uniq(mt) | ast::ty_vec(mt) | + ast::ty_rptr(_, mt) | ast::ty_ptr(mt) => { visit_mt(mt, (cx, visitor)); } @@ -825,7 +825,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)); } } } @@ -838,10 +838,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)); } } @@ -850,7 +850,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 e2d2ac9cf238a..caba5394233e5 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1216,7 +1216,7 @@ impl Resolver { visit_item(item, (new_parent, visitor)); } - item_impl(_, None, ref ty, ref methods) => { + item_impl(_, None, 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. @@ -1226,8 +1226,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 => { @@ -1296,7 +1296,7 @@ impl Resolver { visit_item(item, (parent, visitor)); } - item_impl(_, Some(_), _, _) => { + item_impl(_, Some(_), _ty, ref _methods) => { visit_item(item, (parent, visitor)); } @@ -3517,7 +3517,7 @@ impl Resolver { item_impl(ref generics, ref implemented_traits, - ref self_type, + self_type, ref methods) => { self.resolve_implementation(item.id, generics, @@ -3568,10 +3568,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) => { @@ -3761,12 +3761,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); } } @@ -3863,7 +3863,7 @@ impl Resolver { // Resolve fields. for fields.iter().advance |field| { - self.resolve_type(&field.node.ty, visitor); + self.resolve_type(field.node.ty, visitor); } } } @@ -3899,7 +3899,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. @@ -3987,7 +3987,7 @@ impl Resolver { let mutability = if local.is_mutbl {Mutable} else {Immutable}; // Resolve the type. - self.resolve_type(&local.ty, visitor); + self.resolve_type(local.ty, visitor); // Resolve the initializer, if necessary. match local.init { @@ -4098,7 +4098,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. @@ -4320,7 +4320,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); } } @@ -4353,7 +4353,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); } } @@ -4382,7 +4382,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); } } @@ -4478,7 +4478,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 50ea6537544ef..bcc6cbdb646c3 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1791,7 +1791,7 @@ pub fn copy_args_to_allocas(fcx: @mut FunctionContext, bcx = _match::store_arg(bcx, args[arg_n].pat, llarg); if fcx.ccx.sess.opts.extra_debuginfo && fcx_has_nonzero_span(fcx) { - debuginfo::create_argument_metadata(bcx, &args[arg_n], args[arg_n].ty.span); + debuginfo::create_argument_metadata(bcx, args[arg_n], args[arg_n].ty.span); } } @@ -2011,17 +2011,17 @@ pub fn trans_tuple_struct(ccx: @mut CrateContext, trait IdAndTy { fn id(&self) -> ast::node_id; - fn ty<'a>(&'a self) -> &'a ast::Ty; + fn ty(&self) -> @ast::Ty; } impl IdAndTy for ast::variant_arg { fn id(&self) -> ast::node_id { self.id } - fn ty<'a>(&'a self) -> &'a ast::Ty { &self.ty } + fn ty<'a>(&self) -> @ast::Ty { self.ty } } impl IdAndTy for @ast::struct_field { fn id(&self) -> ast::node_id { self.node.id } - fn ty<'a>(&'a self) -> &'a ast::Ty { &self.node.ty } + fn ty<'a>(&self) -> @ast::Ty { self.node.ty } } pub fn trans_enum_variant_or_tuple_like_struct( @@ -2036,7 +2036,7 @@ pub fn trans_enum_variant_or_tuple_like_struct( let fn_args = do args.map |varg| { ast::arg { is_mutbl: false, - ty: (*varg.ty()).clone(), + ty: varg.ty(), pat: ast_util::ident_to_pat( ccx.tcx.sess.next_node_id(), codemap::dummy_sp(), diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index cc690f070ccfc..da617a5440e7f 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -197,7 +197,7 @@ pub fn create_local_var_metadata(bcx: @mut Block, local: @ast::Local) -> DIVaria /// /// 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_argument_metadata(bcx: @mut Block, arg: &ast::arg, span: span) -> Option { +pub fn create_argument_metadata(bcx: @mut Block, arg: ast::arg, span: span) -> Option { debug!("create_argument_metadata"); if true { // XXX create_argument_metadata disabled for now because "node_id_type(bcx, arg.id)" below @@ -278,9 +278,9 @@ pub fn create_function_metadata(fcx: &FunctionContext) -> DISubprogram { let fnitem = cx.tcx.items.get_copy(&fcx.id); let (ident, ret_ty, id) = match fnitem { - ast_map::node_item(ref item, _) => { + ast_map::node_item(item, _) => { match item.node { - ast::item_fn(ast::fn_decl { output: ref ty, _}, _, _, _, _) => { + ast::item_fn(ast::fn_decl { output: ty, _}, _, _, _, _) => { (item.ident, ty, item.id) } _ => fcx.ccx.sess.span_bug(item.span, @@ -289,7 +289,7 @@ pub fn create_function_metadata(fcx: &FunctionContext) -> DISubprogram { } ast_map::node_method( @ast::method { - decl: ast::fn_decl { output: ref ty, _ }, + decl: ast::fn_decl { output: ty, _ }, id: id, ident: ident, _ @@ -302,7 +302,7 @@ pub fn create_function_metadata(fcx: &FunctionContext) -> DISubprogram { 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_metadata: expected an expr_fn_block here") @@ -311,7 +311,7 @@ pub fn create_function_metadata(fcx: &FunctionContext) -> DISubprogram { ast_map::node_trait_method( @ast::provided( @ast::method { - decl: ast::fn_decl { output: ref ty, _ }, + decl: ast::fn_decl { output: ty, _ }, id: id, ident: ident, _ diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index a506142a971b0..325fc41f33078 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -180,7 +180,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 {regions:ty::NonerasedRegions(regions), self_ty:self_ty, tps:tps} } @@ -379,7 +379,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) => { @@ -527,13 +527,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), } } @@ -625,11 +625,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, @@ -730,14 +730,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 0b80c0cb3c649..1ac87a47a2b36 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -488,7 +488,7 @@ pub fn check_fn(ccx: @mut CrateCtxt, |local, (e, v)| { let o_ty = match local.ty.node { ast::ty_infer => None, - _ => Some(fcx.to_ty(&local.ty)) + _ => Some(fcx.to_ty(local.ty)) }; assign(local.id, o_ty); debug!("Local variable %s is assigned type %s", @@ -636,7 +636,7 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) { ast::item_struct(*) => { check_struct(ccx, it.id, it.span); } - ast::item_ty(ref t, ref generics) => { + ast::item_ty(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); } @@ -802,7 +802,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) } @@ -1405,7 +1405,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); @@ -1414,7 +1414,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, @@ -1804,7 +1804,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, @@ -1834,7 +1834,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, _ => () } - let tps : ~[ty::t] = tys.iter().transform(|ty| fcx.to_ty(ty)).collect(); + let tps = tys.iter().transform(|ty| fcx.to_ty(*ty)).collect::<~[ty::t]>(); match method::lookup(fcx, expr, base, @@ -2648,7 +2648,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_bot(id); } } - ast::expr_cast(e, ref t) => { + ast::expr_cast(e, t) => { check_expr(fcx, e); let t_1 = fcx.to_ty(t); let t_e = fcx.expr_ty(e); @@ -3354,7 +3354,7 @@ pub fn instantiate_path(fcx: @mut FnCtxt, ty_param_count, ty_substs_len)); 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 {regions: ty::NonerasedRegions(regions), diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index ca3710e19a4c2..11e330171fc71 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -439,7 +439,7 @@ impl CoherenceChecker { -> UniversalQuantificationResult { let regions = match polytype.generics.region_param { None => opt_vec::Empty, - Some(r) => { + Some(_) => { opt_vec::with( self.inference_context.next_region_var( infer::BoundRegionInCoherence)) @@ -490,7 +490,7 @@ impl CoherenceChecker { // Then visit the module items. visit_mod(module_, item.span, item.id, ((), visitor)); } - item_impl(_, None, ref ast_ty, _) => { + item_impl(_, None, ast_ty, _) => { if !self.ast_type_is_defined_in_local_crate(ast_ty) { // This is an error. let session = self.crate_context.tcx.sess; @@ -569,7 +569,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 98b4de9d719a8..fb5a06412a7d9 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -153,7 +153,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)); } @@ -701,7 +701,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), @@ -833,7 +833,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) { generics, rp); } - ast::item_impl(ref generics, ref opt_trait_ref, ref selfty, ref ms) => { + ast::item_impl(ref generics, ref opt_trait_ref, selfty, ref ms) => { let i_ty_generics = ty_generics(ccx, rp, generics, 0); let region_parameterization = RegionParameterization::from_variance_and_generics(rp, generics); @@ -1051,7 +1051,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(ref t, _, _) => { + ast::item_static(t, _, _) => { let typ = ccx.to_ty(&empty_rscope, t); let tpt = no_params(typ); tcx.tcache.insert(local_def(it.id), tpt); @@ -1080,7 +1080,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(ref t, ref generics) => { + ast::item_ty(t, ref generics) => { match tcx.tcache.find(&local_def(it.id)) { Some(&tpt) => return tpt, None => { } @@ -1144,7 +1144,7 @@ pub fn ty_of_foreign_item(ccx: &CrateCtxt, generics, abis) } - ast::foreign_item_static(ref t, _) => { + ast::foreign_item_static(t, _) => { ty::ty_param_bounds_and_ty { generics: ty::Generics { type_param_defs: @~[], @@ -1236,8 +1236,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/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs index 044ab3226053d..26f4f1701d167 100644 --- a/src/librustdoc/tystr_pass.rs +++ b/src/librustdoc/tystr_pass.rs @@ -94,7 +94,7 @@ fn fold_const( do astsrv::exec(srv) |ctxt| { match ctxt.ast_map.get_copy(&doc.id()) { ast_map::node_item(@ast::item { - node: ast::item_static(ref ty, _, _), _ + node: ast::item_static(@ref ty, _, _), _ }, _) => { pprust::ty_to_str(ty, extract::interner()) } @@ -245,7 +245,7 @@ fn fold_impl( do astsrv::exec(srv) |ctxt| { match ctxt.ast_map.get_copy(&doc.id()) { ast_map::node_item(@ast::item { - node: ast::item_impl(ref generics, ref opt_trait_type, ref self_ty, _), _ + node: ast::item_impl(ref generics, ref opt_trait_type, @ref self_ty, _), _ }, _) => { let bounds = pprust::generics_to_str(generics, extract::interner()); let bounds = if bounds.is_empty() { None } else { Some(bounds) }; @@ -285,7 +285,7 @@ fn fold_type( match ctxt.ast_map.get_copy(&doc.id()) { ast_map::node_item(@ast::item { ident: ident, - node: ast::item_ty(ref ty, ref params), _ + node: ast::item_ty(@ref ty, ref params), _ }, _) => { Some(fmt!( "type %s%s = %s", diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 470e05223db16..66081629c7160 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -113,8 +113,7 @@ pub struct Path { idents: ~[ident], /// "Region parameter", currently only one lifetime is allowed in a path. rp: Option, - /// These are the type parameters, ie, the `a, b` in `foo::bar::` - types: ~[Ty], + types: ~[@Ty], } pub type CrateNum = int; @@ -388,7 +387,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, @@ -457,12 +456,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, Block, Option<@expr>), expr_while(@expr, Block), /* Conditionless loop (can be exited with break, cont, or ret) @@ -481,7 +480,7 @@ pub enum 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), @@ -631,7 +630,7 @@ pub enum lit_ { // type structure in middle/ty.rs as well. #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct mt { - ty: ~Ty, + ty: @Ty, mutbl: mutability, } @@ -777,7 +776,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 @@ -806,7 +805,7 @@ pub struct inline_asm { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct arg { is_mutbl: bool, - ty: Ty, + ty: @Ty, pat: @pat, id: node_id, } @@ -814,7 +813,7 @@ pub struct arg { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct fn_decl { inputs: ~[arg], - output: Ty, + output: @Ty, cf: ret_style, } @@ -892,7 +891,7 @@ pub struct foreign_mod { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct variant_arg { - ty: Ty, + ty: @Ty, id: node_id, } @@ -1013,7 +1012,7 @@ impl visibility { pub struct struct_field_ { kind: struct_field_kind, id: node_id, - ty: Ty, + ty: @Ty, attrs: ~[Attribute], } @@ -1049,17 +1048,17 @@ pub struct item { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub enum item_ { - item_static(Ty, mutability, @expr), + item_static(@Ty, mutability, @expr), item_fn(fn_decl, purity, AbiSet, Generics, Block), 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), @@ -1078,7 +1077,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 b3d65dfa9e2fa..493779bd98d6c 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -39,30 +39,31 @@ 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; @@ -165,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::Block) -> @ast::item; fn item_fn(&self, span: span, name: ident, inputs: ~[ast::arg], - output: ast::Ty, + output: @ast::Ty, body: ast::Block) -> @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, @@ -205,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::MetaItem) -> ast::Attribute; @@ -237,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, @@ -248,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 @@ -264,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())) } @@ -272,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, @@ -306,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(), @@ -333,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))) @@ -637,7 +638,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, @@ -648,7 +649,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, @@ -672,7 +673,7 @@ impl AstBuilder for @ExtCtxt { span: span, name: ident, inputs: ~[ast::arg], - output: ast::Ty, + output: @ast::Ty, generics: Generics, body: ast::Block) -> @ast::item { self.item(span, @@ -689,7 +690,7 @@ impl AstBuilder for @ExtCtxt { span: span, name: ident, inputs: ~[ast::arg], - output: ast::Ty, + output: @ast::Ty, body: ast::Block ) -> @ast::item { self.item_fn_poly( @@ -701,10 +702,10 @@ impl AstBuilder for @ExtCtxt { body) } - 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(); + 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() } + }; respan(span, ast::variant_ { @@ -768,12 +769,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 04bbe5ae1d6a9..414a666d59f6f 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -457,7 +457,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) } @@ -467,7 +467,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 = ~[]; @@ -515,7 +515,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 255bc6c98775b..c820371714bfa 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 eb8b01c427dcb..cc6500a7477cb 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(self.types.clone(), ty), .. (*self).clone() } } - fn add_tys(&self, tys: ~[ast::Ty]) -> ast::Path { + fn add_tys(&self, tys: ~[@ast::Ty]) -> ast::Path { ast::Path { types: vec::append(self.types.clone(), tys), .. (*self).clone() diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs index adf10215cb566..8c2898737a35f 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 b046c99d144e6..cd037058616f9 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; @@ -57,7 +57,7 @@ impl gen_send for message { 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).clone(), (*t).clone())).collect(); + cx.arg(span, *n, *t)).collect(); let pipe_ty = cx.ty_path( path(~[this.data_name()], span) @@ -139,7 +139,7 @@ impl gen_send for message { let args_ast: ~[ast::arg] = arg_names.iter().zip(tys.iter()) .transform(|(n, t)| - cx.arg(span, cx.ident_of(*n), (*t).clone())).collect(); + cx.arg(span, cx.ident_of(*n), *t)).collect(); let args_ast = vec::append( ~[cx.arg(span, @@ -191,7 +191,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) } @@ -371,7 +371,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 c93b89daa4021..fcd1deadb5aa2 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -38,12 +38,12 @@ impl direction { #[deriving(Clone)] pub struct next_state { state: @str, - tys: ~[ast::Ty], + tys: ~[@ast::Ty], } // name, span, data, current state, next state #[deriving(Clone)] -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 { @@ -83,7 +83,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)); @@ -98,7 +98,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) @@ -209,7 +209,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 1439f4cabab14..dc0068ba9841a 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -86,13 +86,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() } @@ -214,13 +214,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 f27e68641e3af..bdb36d9da0ea8 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; @@ -106,7 +106,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), } @@ -153,8 +153,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_(/*bad*/ (*x).clone(), fld)), - output: fld.fold_ty(&decl.output), + inputs: decl.inputs.map(|x| fold_arg_(*x, fld)), + output: fld.fold_ty(decl.output), cf: decl.cf, } } @@ -226,15 +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(/*bad*/(*a).clone())), - output: fld.fold_ty(&fdec.output), + inputs: fdec.inputs.map(|a| fold_arg(*a)), + output: fld.fold_ty(fdec.output), cf: fdec.cf, }, purity, fold_generics(generics, fld)) } - foreign_item_static(ref t, m) => { + foreign_item_static(t, m) => { foreign_item_static(fld.fold_ty(t), m) } }, @@ -263,7 +262,7 @@ fn noop_fold_struct_field(sf: @struct_field, fld: @ast_fold) node: ast::struct_field_ { kind: 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 @@ -272,7 +271,7 @@ fn noop_fold_struct_field(sf: @struct_field, fld: @ast_fold) pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ { match *i { - item_static(ref t, m, e) => item_static(fld.fold_ty(t), m, fld.fold_expr(e)), + item_static(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), @@ -286,7 +285,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(ref t, ref generics) => { + item_ty(t, ref generics) => { item_ty(fld.fold_ty(t), fold_generics(generics, fld)) } item_enum(ref enum_definition, ref generics) => { @@ -302,7 +301,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) */ (*generics).clone()) } - item_impl(ref generics, ref ifce, ref ty, ref methods) => { + item_impl(ref generics, ref ifce, ty, ref methods) => { item_impl( fold_generics(generics, fld), ifce.map(|p| fold_trait_ref(p, fld)), @@ -353,7 +352,7 @@ fn fold_struct_field(f: @struct_field, fld: @ast_fold) -> @struct_field { node: ast::struct_field_ { kind: 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) */ f.node.attrs.clone(), }, span: fld.new_span(f.span), @@ -522,7 +521,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 ) @@ -545,8 +544,8 @@ 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(_) => (*e).clone(), - expr_cast(expr, ref ty) => { - expr_cast(fld.fold_expr(expr), (*ty).clone()) + expr_cast(expr, ty) => { + expr_cast(fld.fold_expr(expr), ty) } expr_addr_of(m, ohs) => expr_addr_of(m, fld.fold_expr(ohs)), expr_if(cond, ref tr, fl) => { @@ -592,7 +591,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) => { @@ -642,7 +641,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, } } @@ -687,7 +686,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) => { @@ -719,7 +718,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); @@ -727,7 +726,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(/*bad*/ (*x).clone()) + fold_variant_arg(*x) }) } struct_variant_kind(struct_def) => { @@ -766,14 +765,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), @@ -843,7 +842,7 @@ impl ast_fold for AstFoldFns { node: ast::struct_field_ { kind: sf.node.kind, id: sf.node.id, - ty: self.fold_ty(&sf.node.ty), + ty: self.fold_ty(sf.node.ty), attrs: sf.node.attrs.clone(), }, span: (self.new_span)(sf.span), @@ -891,9 +890,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/mod.rs b/src/libsyntax/parse/mod.rs index 5cdf0ec1acc71..e848cd73f0cc0 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -478,7 +478,7 @@ mod test { assert_eq!(parser.parse_arg_general(true), ast::arg{ is_mutbl: false, - ty: ast::Ty{id:3, // fixme + ty: @ast::Ty{id:3, // fixme node: ast::ty_path(ast::Path{ span:sp(4,4), // this is bizarre... // check this in the original parser? @@ -515,7 +515,7 @@ mod test { node: ast::item_fn(ast::fn_decl{ inputs: ~[ast::arg{ is_mutbl: false, - ty: ast::Ty{id:3, // fixme + ty: @ast::Ty{id:3, // fixme node: ast::ty_path(ast::Path{ span:sp(10,13), global:false, @@ -538,7 +538,7 @@ mod test { span: sp(6,7)}, id: 4 // fixme }], - output: ast::Ty{id:5, // fixme + output: @ast::Ty{id:5, // fixme node: ast::ty_nil, span:sp(15,15)}, // not sure cf: ast::return_val diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index bb3c185c2a95b..cced0d247f28a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -883,7 +883,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 } } @@ -894,7 +894,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, @@ -906,13 +906,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) @@ -925,7 +925,7 @@ impl Parser { let pos = self.span.lo; ( return_val, - Ty { + @Ty { id: self.get_id(), node: ty_nil, span: mk_sp(pos, pos), @@ -937,7 +937,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; @@ -1036,7 +1036,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 ~ @@ -1177,7 +1177,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), @@ -1531,7 +1531,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) @@ -1541,7 +1541,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) } @@ -2271,7 +2271,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 @@ -2934,7 +2934,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), @@ -3356,7 +3356,7 @@ impl Parser { } // parse a generic use site - fn parse_generic_values(&self) -> (OptVec, ~[Ty]) { + fn parse_generic_values(&self) -> (OptVec, ~[@Ty]) { if !self.eat(&token::LT) { (opt_vec::Empty, ~[]) } else { @@ -3364,7 +3364,7 @@ impl Parser { } } - fn parse_generic_values_after_lt(&self) -> (OptVec, ~[Ty]) { + fn parse_generic_values_after_lt(&self) -> (OptVec, ~[@Ty]) { let lifetimes = self.parse_lifetimes(); let result = self.parse_seq_to_gt( Some(token::COMMA), @@ -3574,7 +3574,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 { @@ -4293,9 +4293,9 @@ impl Parser { seq_sep_trailing_disallowed(token::COMMA), |p| p.parse_ty(false) ); - for arg_tys.consume_iter().advance |ty| { + for arg_tys.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 52b6d4459bf48..89b3e9dfa1f95 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -103,7 +103,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 8e2c24cacfed7..4d4d8bfba3334 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -402,7 +402,7 @@ pub fn print_type(s: @ps, ty: &ast::Ty) { } ast::ty_tup(ref elts) => { popen(s); - commasep(s, inconsistent, *elts, print_type); + commasep(s, inconsistent, *elts, |p, &t| print_type(p, t)); if elts.len() == 1 { word(s.s, ","); } @@ -462,7 +462,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(ref t, m) => { + ast::foreign_item_static(t, m) => { head(s, visibility_qualified(item.vis, "static")); if m { word_space(s, "mut"); @@ -484,7 +484,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(ref ty, m, expr) => { + ast::item_static(ty, m, expr) => { head(s, visibility_qualified(item.vis, "static")); if m == ast::m_mutbl { word_space(s, "mut"); @@ -538,7 +538,7 @@ pub fn print_item(s: @ps, item: &ast::item) { print_foreign_mod(s, nmod, item.attrs); bclose(s, item.span); } - ast::item_ty(ref ty, ref params) => { + ast::item_ty(ty, ref params) => { ibox(s, indent_unit); ibox(s, 0u); word_nbsp(s, visibility_qualified(item.vis, "type")); @@ -567,7 +567,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, ref ty, ref methods) => { + ast::item_impl(ref generics, ref opt_trait, ty, ref methods) => { head(s, visibility_qualified(item.vis, "impl")); if generics.is_parameterized() { print_generics(s, generics); @@ -702,7 +702,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); } } } @@ -726,7 +726,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, ","); } } @@ -785,7 +785,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); @@ -1187,7 +1187,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, print_type); + commasep(s, inconsistent, *tys, |p, &e| print_type(p, e)); word(s.s, ">"); } print_call_post(s, sugar, &blk, &mut base_args); @@ -1213,7 +1213,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, ref ty) => { + ast::expr_cast(expr, ty) => { print_expr(s, expr); space(s.s); word_space(s, "as"); @@ -1362,7 +1362,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, print_type); + commasep(s, inconsistent, *tys, |p, &e| print_type(p, e)); word(s.s, ">"); } } @@ -1451,7 +1451,7 @@ pub fn print_local_decl(s: @ps, loc: &ast::Local) { print_pat(s, loc.pat); match loc.ty.node { ast::ty_infer => (), - _ => { word_space(s, ":"); print_type(s, &loc.ty); } + _ => { word_space(s, ":"); print_type(s, loc.ty); } } } @@ -1524,7 +1524,7 @@ fn print_path_(s: @ps, path: &ast::Path, colons_before_params: bool, } } - commasep(s, inconsistent, path.types, print_type); + commasep(s, inconsistent, path.types, |p, &e| print_type(p, e)); word(s.s, ">"); } @@ -1697,7 +1697,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); @@ -1715,7 +1715,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); } } } @@ -1730,7 +1730,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); } } @@ -1884,7 +1884,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"); @@ -1904,7 +1904,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); @@ -1946,7 +1946,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); @@ -1960,7 +1960,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); } } @@ -2276,7 +2276,7 @@ mod test { let decl = ast::fn_decl { inputs: ~[], - output: ast::Ty {id: 0, + output: @ast::Ty {id: 0, node: ast::ty_nil, span: codemap::dummy_sp()}, cf: ast::return_val diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 7e86adfcb6306..247393a88a12d 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, &Block, span, node_id, (E, vt)), visit_ty_method: @fn(&ty_method, (E, vt)), @@ -138,7 +138,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.pat, (e.clone(), v)); - (v.visit_ty)(&loc.ty, (e.clone(), v)); + (v.visit_ty)(loc.ty, (e.clone(), v)); match loc.init { None => (), Some(ex) => (v.visit_expr)(ex, (e, v)) @@ -151,7 +151,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(ref t, _, ex) => { + item_static(t, _, ex) => { (v.visit_ty)(t, (e.clone(), v)); (v.visit_expr)(ex, (e.clone(), v)); } @@ -180,7 +180,7 @@ pub fn visit_item(i: &item, (e, v): (E, vt)) { (v.visit_foreign_item)(*ni, (e.clone(), v)); } } - item_ty(ref t, ref tps) => { + item_ty(t, ref tps) => { (v.visit_ty)(t, (e.clone(), v)); (v.visit_generics)(tps, (e, v)); } @@ -192,7 +192,7 @@ pub fn visit_item(i: &item, (e, v): (E, vt)) { (e, v) ); } - item_impl(ref tps, ref traits, ref ty, ref methods) => { + item_impl(ref tps, ref traits, ty, ref methods) => { (v.visit_generics)(tps, (e.clone(), v)); for traits.iter().advance |p| { visit_trait_ref(p, (e.clone(), v)); @@ -226,7 +226,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, (e.clone(), v)); + (v.visit_ty)(va.ty, (e.clone(), v)); } } struct_variant_kind(struct_def) => { @@ -245,29 +245,29 @@ 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(ref mt) | ty_uniq(ref mt) | - ty_vec(ref mt) | ty_ptr(ref mt) | ty_rptr(_, ref mt) => { + ty_box(mt) | ty_uniq(mt) | + ty_vec(mt) | ty_ptr(mt) | ty_rptr(_, mt) => { (v.visit_ty)(mt.ty, (e, v)); }, ty_tup(ref ts) => { for ts.iter().advance |tt| { - (v.visit_ty)(tt, (e.clone(), v)); + (v.visit_ty)(*tt, (e.clone(), v)); } }, ty_closure(ref f) => { for f.decl.inputs.iter().advance |a| { - (v.visit_ty)(&a.ty, (e.clone(), v)); + (v.visit_ty)(a.ty, (e.clone(), v)); } - (v.visit_ty)(&f.decl.output, (e.clone(), v)); + (v.visit_ty)(f.decl.output, (e.clone(), v)); do f.bounds.map |bounds| { visit_ty_param_bounds(bounds, (e.clone(), v)); }; }, ty_bare_fn(ref f) => { for f.decl.inputs.iter().advance |a| { - (v.visit_ty)(&a.ty, (e.clone(), v)); + (v.visit_ty)(a.ty, (e.clone(), v)); } - (v.visit_ty)(&f.decl.output, (e, v)); + (v.visit_ty)(f.decl.output, (e, v)); }, ty_path(ref p, ref bounds, _) => { visit_path(p, (e.clone(), v)); @@ -284,7 +284,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, (e.clone(), v)); } + for p.types.iter().advance |tp| { (v.visit_ty)(*tp, (e.clone(), v)); } } pub fn visit_pat(p: &pat, (e, v): (E, vt)) { @@ -343,7 +343,7 @@ pub fn visit_foreign_item(ni: &foreign_item, (e, v): (E, vt)) { visit_fn_decl(fd, (e.clone(), v)); (v.visit_generics)(generics, (e, v)); } - foreign_item_static(ref t, _) => { + foreign_item_static(t, _) => { (v.visit_ty)(t, (e, v)); } } @@ -368,9 +368,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, (e.clone(), v)); - (v.visit_ty)(&a.ty, (e.clone(), v)); + (v.visit_ty)(a.ty, (e.clone(), 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 @@ -396,10 +396,10 @@ pub fn visit_fn(fk: &fn_kind, decl: &fn_decl, body: &Block, _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, (e.clone(), v)); + (v.visit_ty)(a.ty, (e.clone(), v)); } (v.visit_generics)(&m.generics, (e.clone(), 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)) { @@ -422,7 +422,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: &Block, (e, v): (E, vt)) { @@ -488,7 +488,7 @@ pub fn visit_expr(ex: @expr, (e, v): (E, vt)) { expr_method_call(_, callee, _, ref tys, ref args, _) => { visit_exprs(*args, (e.clone(), v)); for tys.iter().advance |tp| { - (v.visit_ty)(tp, (e.clone(), v)); + (v.visit_ty)(*tp, (e.clone(), v)); } (v.visit_expr)(callee, (e.clone(), v)); } @@ -499,7 +499,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, (e.clone(), v)), expr_lit(_) => (), - expr_cast(x, ref t) => { + expr_cast(x, t) => { (v.visit_expr)(x, (e.clone(), v)); (v.visit_ty)(t, (e.clone(), v)); } @@ -539,7 +539,7 @@ pub fn visit_expr(ex: @expr, (e, v): (E, vt)) { expr_field(x, _, ref tys) => { (v.visit_expr)(x, (e.clone(), v)); for tys.iter().advance |tp| { - (v.visit_ty)(tp, (e.clone(), v)); + (v.visit_ty)(*tp, (e.clone(), v)); } } expr_index(_, a, b) => { @@ -591,7 +591,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, &Block, span, node_id), visit_ty_method: @fn(&ty_method), @@ -603,7 +603,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 { @@ -684,7 +684,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)); } @@ -729,7 +729,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);