diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs index 7d478afee41a1..df829d5e20961 100644 --- a/src/librustc/front/config.rs +++ b/src/librustc/front/config.rs @@ -12,7 +12,7 @@ use std::option; use syntax::{ast, fold, attr}; -type in_cfg_pred = @fn(attrs: ~[ast::attribute]) -> bool; +type in_cfg_pred = @fn(attrs: &[ast::attribute]) -> bool; struct Context { in_cfg: in_cfg_pred @@ -50,8 +50,7 @@ fn filter_item(cx: @Context, item: @ast::item) -> if item_in_cfg(cx, item) { option::Some(item) } else { option::None } } -fn filter_view_item(cx: @Context, view_item: @ast::view_item - )-> Option<@ast::view_item> { +fn filter_view_item<'r>(cx: @Context, view_item: &'r ast::view_item)-> Option<&'r ast::view_item> { if view_item_in_cfg(cx, view_item) { option::Some(view_item) } else { @@ -64,7 +63,7 @@ fn fold_mod(cx: @Context, m: &ast::_mod, fld: @fold::ast_fold) -> ast::_mod { filter_item(cx, *a).chain(|x| fld.fold_item(x)) }.collect(); let filtered_view_items = do m.view_items.iter().filter_map |a| { - filter_view_item(cx, *a).map(|x| fld.fold_view_item(*x)) + filter_view_item(cx, a).map(|&x| fld.fold_view_item(x)) }.collect(); ast::_mod { view_items: filtered_view_items, @@ -86,7 +85,7 @@ fn fold_foreign_mod( ) -> ast::foreign_mod { let filtered_items = nm.items.iter().filter_map(|a| filter_foreign_item(cx, *a)).collect(); let filtered_view_items = do nm.view_items.iter().filter_map |a| { - filter_view_item(cx, *a).map(|x| fld.fold_view_item(*x)) + filter_view_item(cx, a).map(|&x| fld.fold_view_item(x)) }.collect(); ast::foreign_mod { sort: nm.sort, @@ -99,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, 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, 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) ) @@ -141,7 +140,7 @@ fn fold_block( filter_stmt(cx, *a).chain(|stmt| fld.fold_stmt(stmt)) }.collect(); let filtered_view_items = do b.view_items.iter().filter_map |a| { - filter_view_item(cx, *a).map(|x| fld.fold_view_item(*x)) + filter_view_item(cx, a).map(|&x| fld.fold_view_item(x)) }.collect(); ast::blk_ { view_items: filtered_view_items, @@ -160,8 +159,8 @@ fn foreign_item_in_cfg(cx: @Context, item: @ast::foreign_item) -> bool { return (cx.in_cfg)(/*bad*/copy item.attrs); } -fn view_item_in_cfg(cx: @Context, item: @ast::view_item) -> bool { - return (cx.in_cfg)(/*bad*/copy item.attrs); +fn view_item_in_cfg(cx: @Context, item: &ast::view_item) -> bool { + return (cx.in_cfg)(item.attrs); } fn method_in_cfg(cx: @Context, meth: @ast::method) -> bool { diff --git a/src/librustc/front/std_inject.rs b/src/librustc/front/std_inject.rs index 735fe54f3480f..699799929ba00 100644 --- a/src/librustc/front/std_inject.rs +++ b/src/librustc/front/std_inject.rs @@ -41,7 +41,7 @@ fn inject_libstd_ref(sess: Session, crate: &ast::crate) -> @ast::crate { let precursor = @fold::AstFoldFns { fold_crate: |crate, span, fld| { let n1 = sess.next_node_id(); - let vi1 = @ast::view_item { + let vi1 = ast::view_item { node: ast::view_item_extern_mod( sess.ident_of("std"), ~[], n1), attrs: ~[ @@ -75,7 +75,7 @@ fn inject_libstd_ref(sess: Session, crate: &ast::crate) -> @ast::crate { fold_mod: |module, fld| { let n2 = sess.next_node_id(); - let prelude_path = @ast::Path { + let prelude_path = ast::Path { span: dummy_sp(), global: false, idents: ~[ @@ -87,7 +87,7 @@ fn inject_libstd_ref(sess: Session, crate: &ast::crate) -> @ast::crate { }; let vp = @spanned(ast::view_path_glob(prelude_path, n2)); - let vi2 = @ast::view_item { node: ast::view_item_use(~[vp]), + let vi2 = ast::view_item { node: ast::view_item_use(~[vp]), attrs: ~[], vis: ast::private, span: dummy_sp() }; diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index bbac4a2907c0f..f2670a663ea0c 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -272,7 +272,7 @@ mod __test { */ -fn mk_std(cx: &TestCtxt) -> @ast::view_item { +fn mk_std(cx: &TestCtxt) -> ast::view_item { let vers = ast::lit_str(@"0.7"); let vers = nospan(vers); let mi = ast::meta_name_value(@"vers", vers); @@ -287,13 +287,12 @@ fn mk_std(cx: &TestCtxt) -> @ast::view_item { ast::view_item_extern_mod(id_std, ~[@mi], cx.sess.next_node_id()) }; - let vi = ast::view_item { + ast::view_item { node: vi, attrs: ~[], vis: ast::public, span: dummy_sp() - }; - return @vi; + } } fn mk_test_module(cx: &TestCtxt) -> @ast::item { @@ -343,16 +342,16 @@ fn nospan(t: T) -> codemap::spanned { codemap::spanned { node: t, span: dummy_sp() } } -fn path_node(ids: ~[ast::ident]) -> @ast::Path { - @ast::Path { span: dummy_sp(), +fn path_node(ids: ~[ast::ident]) -> ast::Path { + ast::Path { span: dummy_sp(), global: false, idents: ids, rp: None, types: ~[] } } -fn path_node_global(ids: ~[ast::ident]) -> @ast::Path { - @ast::Path { span: dummy_sp(), +fn path_node_global(ids: ~[ast::ident]) -> ast::Path { + ast::Path { span: dummy_sp(), global: true, idents: ids, rp: None, diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 2a712b0756477..8c62f4dbbe357 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -136,7 +136,7 @@ fn visit_crate(e: &Env, c: &ast::crate) { } } -fn visit_view_item(e: @mut Env, i: @ast::view_item) { +fn visit_view_item(e: @mut Env, i: &ast::view_item) { match i.node { ast::view_item_extern_mod(ident, ref meta_items, id) => { debug!("resolving extern mod stmt. ident: %?, meta: %?", diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 2c7a991f6146a..1e508d0813184 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -1141,7 +1141,7 @@ fn list_crate_attributes(intr: @ident_interner, md: ebml::Doc, hash: &str, let r = get_attributes(md); for r.iter().advance |attr| { - out.write_str(fmt!("%s\n", pprust::attribute_to_str(*attr, intr))); + out.write_str(fmt!("%s\n", pprust::attribute_to_str(attr, intr))); } out.write_str("\n\n"); diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 77a8d1792dbc8..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, 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)); @@ -1014,7 +1014,7 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_name(ecx, ebml_w, item.ident); encode_attributes(ebml_w, item.attrs); match ty.node { - ast::ty_path(path, bounds, _) if path.idents.len() == 1 => { + ast::ty_path(ref path, ref bounds, _) if path.idents.len() == 1 => { assert!(bounds.is_none()); encode_impl_type_basename(ecx, ebml_w, ast_util::path_to_ident(path)); diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 59918137467aa..7113244c7f6cf 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -112,7 +112,7 @@ pub fn check_expr(sess: Session, "` in a constant expression"); } } - expr_path(pth) => { + expr_path(ref pth) => { // NB: In the future you might wish to relax this slightly // to handle on-demand instantiation of functions via // foo:: in a const. Currently that is only done on diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index cba094d619e01..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(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) => { @@ -125,7 +125,7 @@ fn check_item(item: @item, (cx, visitor): (Context, visit::vt)) { if cx.tcx.lang_items.drop_trait() == trait_def_id { // Yes, it's a destructor. match self_type.node { - ty_path(_, bounds, path_node_id) => { + ty_path(_, ref bounds, path_node_id) => { assert!(bounds.is_none()); let struct_def = cx.tcx.def_map.get_copy( &path_node_id); @@ -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/pat_util.rs b/src/librustc/middle/pat_util.rs index f6da8f392cc1d..7dd7ae6ec9ae0 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -71,10 +71,10 @@ pub fn pat_is_binding_or_wild(dm: resolve::DefMap, pat: @pat) -> bool { } pub fn pat_bindings(dm: resolve::DefMap, pat: @pat, - it: &fn(binding_mode, node_id, span, @Path)) { + it: &fn(binding_mode, node_id, span, &Path)) { for walk_pat(pat) |p| { match p.node { - pat_ident(binding_mode, pth, _) if pat_is_binding(dm, p) => { + pat_ident(binding_mode, ref pth, _) if pat_is_binding(dm, p) => { it(binding_mode, p.id, p.span, pth); } _ => {} diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 64ed3b0211d39..dd6b5615c3f3f 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -276,7 +276,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt, }; // Checks that a private path is in scope. - let check_path: @fn(span: span, def: def, path: @Path) = + let check_path: @fn(span: span, def: def, path: &Path) = |span, def, path| { debug!("checking path"); match def { @@ -449,7 +449,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt, _ => {} } } - expr_path(path) => { + expr_path(ref path) => { check_path(expr.span, tcx.def_map.get_copy(&expr.id), path); } expr_struct(_, ref fields, _) => { diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 97bad93dc358a..70833813cc087 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -141,7 +141,7 @@ impl ReachableContext { } } } - item_impl(ref generics, trait_ref, _, ref methods) => { + item_impl(ref generics, ref trait_ref, _, ref methods) => { // XXX(pcwalton): We conservatively assume any methods // on a trait implementation are reachable, when this // is not the case. We could be more precise by only diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index f65d3ad464c46..b1b2a0083acc3 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -651,18 +651,18 @@ impl DetermineRpCtxt { // with &self type, &self is also bound. We detect those last two // cases via flags (anon_implies_rp and self_implies_rp) that are // true when the anon or self region implies RP. - pub fn region_is_relevant(&self, r: Option<@ast::Lifetime>) -> bool { + pub fn region_is_relevant(&self, r: &Option) -> bool { match r { - None => { + &None => { self.anon_implies_rp } - Some(ref l) if l.ident == special_idents::statik => { + &Some(ref l) if l.ident == special_idents::statik => { false } - Some(ref l) if l.ident == special_idents::self_ => { + &Some(ref l) if l.ident == special_idents::self_ => { true } - Some(_) => { + &Some(_) => { false } } @@ -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 @@ -747,7 +747,7 @@ fn determine_rp_in_ty(ty: @ast::Ty, // locations) let sess = cx.sess; match ty.node { - ast::ty_rptr(r, _) => { + ast::ty_rptr(ref r, _) => { debug!("referenced rptr type %s", pprust::ty_to_str(ty, sess.intr())); @@ -762,7 +762,7 @@ fn determine_rp_in_ty(ty: @ast::Ty, pprust::ty_to_str(ty, sess.intr())); match f.region { Some(_) => { - if cx.region_is_relevant(f.region) { + if cx.region_is_relevant(&f.region) { let rv = cx.add_variance(rv_contravariant); cx.add_rp(cx.item_id, rv) } @@ -784,13 +784,13 @@ fn determine_rp_in_ty(ty: @ast::Ty, // then check whether it is region-parameterized and consider // that as a direct dependency. match ty.node { - ast::ty_path(path, _bounds, id) => { + ast::ty_path(ref path, _, id) => { match cx.def_map.find(&id) { Some(&ast::def_ty(did)) | Some(&ast::def_trait(did)) | Some(&ast::def_struct(did)) => { if did.crate == ast::local_crate { - if cx.region_is_relevant(path.rp) { + if cx.region_is_relevant(&path.rp) { cx.add_dep(did.node); } } else { @@ -800,7 +800,7 @@ fn determine_rp_in_ty(ty: @ast::Ty, Some(variance) => { debug!("reference to external, rp'd type %s", pprust::ty_to_str(ty, sess.intr())); - if cx.region_is_relevant(path.rp) { + if cx.region_is_relevant(&path.rp) { let rv = cx.add_variance(variance); cx.add_rp(cx.item_id, rv) } @@ -815,16 +815,16 @@ 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)); } - ast::ty_path(path, _bounds, _) => { + ast::ty_path(ref path, _, _) => { // 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 dc55dcad99d1b..041d52a690425 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,9 +1243,9 @@ impl Resolver { // the same module that declared the type. // Create the module and add all methods. - match *ty { - Ty { - node: ty_path(path, _, _), + match ty { + &Ty { + node: ty_path(ref path, _, _), _ } if path.idents.len() == 1 => { let name = path_to_ident(path); @@ -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)); } @@ -1432,7 +1432,7 @@ impl Resolver { /// Constructs the reduced graph for one 'view item'. View items consist /// of imports and use directives. pub fn build_reduced_graph_for_view_item(@mut self, - view_item: @view_item, + view_item: &view_item, (parent, _): (ReducedGraphParent, vt)) { @@ -1446,7 +1446,7 @@ impl Resolver { let mut module_path = ~[]; match view_path.node { - view_path_simple(_, full_path, _) => { + view_path_simple(_, ref full_path, _) => { let path_len = full_path.idents.len(); assert!(path_len != 0); @@ -1457,8 +1457,8 @@ impl Resolver { } } - view_path_glob(module_ident_path, _) | - view_path_list(module_ident_path, _, _) => { + view_path_glob(ref module_ident_path, _) | + view_path_list(ref module_ident_path, _, _) => { for module_ident_path.idents.iter().advance |ident| { module_path.push(*ident); } @@ -1468,7 +1468,7 @@ impl Resolver { // Build up the import directives. let module_ = self.get_module_from_parent(parent); match view_path.node { - view_path_simple(binding, full_path, id) => { + view_path_simple(binding, ref full_path, id) => { let source_ident = *full_path.idents.last(); let subclass = @SingleImport(binding, source_ident); @@ -3533,8 +3533,8 @@ impl Resolver { } item_impl(ref generics, - implemented_traits, - self_type, + ref implemented_traits, + ref self_type, ref methods) => { self.resolve_implementation(item.id, generics, @@ -3561,7 +3561,7 @@ impl Resolver { // Resolve derived traits. for traits.iter().advance |trt| { - self.resolve_trait_reference(*trt, visitor, TraitDerivation); + self.resolve_trait_reference(trt, visitor, TraitDerivation); } for (*methods).iter().advance |method| { @@ -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); } } @@ -3811,7 +3811,7 @@ impl Resolver { type_parameter_bound: &TyParamBound, visitor: ResolveVisitor) { match *type_parameter_bound { - TraitTyParamBound(tref) => { + TraitTyParamBound(ref tref) => { self.resolve_trait_reference(tref, visitor, TraitBoundingTypeParameter) } RegionTyParamBound => {} @@ -3822,7 +3822,7 @@ impl Resolver { trait_reference: &trait_ref, visitor: ResolveVisitor, reference_type: TraitReferenceType) { - match self.resolve_path(trait_reference.path, TypeNS, true, visitor) { + match self.resolve_path(&trait_reference.path, TypeNS, true, visitor) { None => { let path_str = self.idents_to_str(trait_reference.path.idents); @@ -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); } } } @@ -3913,8 +3913,8 @@ impl Resolver { pub fn resolve_implementation(@mut self, id: node_id, generics: &Generics, - opt_trait_reference: Option<@trait_ref>, - self_type: @Ty, + opt_trait_reference: &Option, + self_type: &Ty, methods: &[@method], visitor: ResolveVisitor) { // If applicable, create a rib for the type parameters. @@ -3929,7 +3929,7 @@ impl Resolver { // Resolve the trait reference, if necessary. let original_trait_refs; match opt_trait_reference { - Some(trait_reference) => { + &Some(ref trait_reference) => { self.resolve_trait_reference(trait_reference, visitor, TraitImplementation); // Record the current set of trait references. @@ -3944,7 +3944,7 @@ impl Resolver { &mut self.current_trait_refs, Some(new_trait_refs))); } - None => { + &None => { original_trait_refs = None; } } @@ -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,12 +4112,12 @@ 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. - ty_path(path, bounds, path_id) => { + ty_path(ref path, ref bounds, path_id) => { // This is a path in the type namespace. Walk through scopes // scopes looking for it. let mut result_def = None; @@ -4211,7 +4211,7 @@ impl Resolver { let pat_id = pattern.id; for walk_pat(pattern) |pattern| { match pattern.node { - pat_ident(binding_mode, path, _) + pat_ident(binding_mode, ref path, _) if !path.global && path.idents.len() == 1 => { // The meaning of pat_ident with no type parameters @@ -4334,11 +4334,11 @@ 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); } } - pat_ident(binding_mode, path, _) => { + pat_ident(binding_mode, ref path, _) => { // This must be an enum variant, struct, or constant. match self.resolve_path(path, ValueNS, false, visitor) { Some(def @ def_variant(*)) | @@ -4367,11 +4367,11 @@ 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); } } - pat_enum(path, _) => { + pat_enum(ref path, _) => { // This must be an enum variant, struct or const. match self.resolve_path(path, ValueNS, false, visitor) { Some(def @ def_fn(*)) | @@ -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); } } @@ -4409,7 +4409,7 @@ impl Resolver { self.resolve_expr(last_expr, visitor); } - pat_struct(path, _, _) => { + pat_struct(ref path, _, _) => { match self.resolve_path(path, TypeNS, false, visitor) { Some(def_ty(class_id)) if self.structs.contains(&class_id) => { @@ -4484,14 +4484,14 @@ impl Resolver { /// If `check_ribs` is true, checks the local definitions first; i.e. /// doesn't skip straight to the containing module. pub fn resolve_path(@mut self, - path: @Path, + path: &Path, namespace: Namespace, check_ribs: bool, visitor: ResolveVisitor) -> Option { // First, resolve the types. for path.types.iter().advance |ty| { - self.resolve_type(*ty, visitor); + self.resolve_type(ty, visitor); } if path.global { @@ -4610,7 +4610,7 @@ impl Resolver { return NoNameDefinition; } - pub fn intern_module_part_of_path(@mut self, path: @Path) -> ~[ident] { + pub fn intern_module_part_of_path(@mut self, path: &Path) -> ~[ident] { let mut module_path_idents = ~[]; for path.idents.iter().enumerate().advance |(index, ident)| { if index == path.idents.len() - 1 { @@ -4624,7 +4624,7 @@ impl Resolver { } pub fn resolve_module_relative_path(@mut self, - path: @Path, + path: &Path, xray: XrayFlag, namespace: Namespace) -> Option { @@ -4690,7 +4690,7 @@ impl Resolver { /// Invariant: This must be called only during main resolution, not during /// import resolution. pub fn resolve_crate_relative_path(@mut self, - path: @Path, + path: &Path, xray: XrayFlag, namespace: Namespace) -> Option { @@ -4916,7 +4916,7 @@ impl Resolver { // The interpretation of paths depends on whether the path has // multiple elements in it or not. - expr_path(path) => { + expr_path(ref path) => { // This is a local path in the value namespace. Walk through // scopes looking for it. @@ -4985,7 +4985,7 @@ impl Resolver { visitor); } - expr_struct(path, _, _) => { + expr_struct(ref path, _, _) => { // Resolve the path to the structure it goes to. match self.resolve_path(path, TypeNS, false, visitor) { Some(def_ty(class_id)) | Some(def_struct(class_id)) @@ -5295,7 +5295,7 @@ impl Resolver { visit_crate(self.crate, ((), vt)); } - pub fn check_for_item_unused_imports(&mut self, vi: @view_item) { + pub fn check_for_item_unused_imports(&mut self, vi: &view_item) { // Ignore public import statements because there's no way to be sure // whether they're used or not. Also ignore imports with a dummy span // because this means that they were generated in some fashion by the diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 1d69b20f5c446..3e828a891d49e 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -385,7 +385,7 @@ pub fn expand_nested_bindings<'r>(bcx: block, do m.map |br| { match br.pats[col].node { - ast::pat_ident(_, path, Some(inner)) => { + ast::pat_ident(_, ref path, Some(inner)) => { let pats = vec::append( br.pats.slice(0u, col).to_owned(), vec::append(~[inner], @@ -441,7 +441,7 @@ pub fn enter_match<'r>(bcx: block, let this = br.pats[col]; match this.node { - ast::pat_ident(_, path, None) => { + ast::pat_ident(_, ref path, None) => { if pat_is_binding(dm, this) { let binding_info = br.data.bindings_map.get( diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index d6105cc1dded8..e6384ae4d0d34 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1399,7 +1399,7 @@ pub fn alloc_local(cx: block, local: &ast::local) -> block { let _icx = push_ctxt("alloc_local"); let t = node_id_type(cx, local.node.id); let simple_name = match local.node.pat.node { - ast::pat_ident(_, pth, None) => Some(path_to_ident(pth)), + ast::pat_ident(_, ref pth, None) => Some(path_to_ident(pth)), _ => None }; let val = alloc_ty(cx, t); @@ -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/common.rs b/src/librustc/middle/trans/common.rs index 865fb26b94558..1030af9787868 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -34,9 +34,6 @@ use std::cast::transmute; use std::cast; use std::hashmap::{HashMap}; use std::libc::{c_uint, c_longlong, c_ulonglong}; -use std::to_bytes; -use std::str; -use std::vec::raw::to_ptr; use std::vec; use syntax::ast::ident; use syntax::ast_map::{path, path_elt}; diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 9566f41a45fd7..bbec78880fe23 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -525,7 +525,7 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { _ => cx.sess.span_bug(e.span, "bad const-slice expr") } } - ast::expr_path(pth) => { + ast::expr_path(ref pth) => { assert_eq!(pth.types.len(), 0); let tcx = cx.tcx; match tcx.def_map.find(&e.id) { diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index ac5eb6b067c9a..fc73d80537987 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -133,7 +133,7 @@ pub fn create_local_var(bcx: block, local: @ast::local) -> DIVariable { let cx = bcx.ccx(); let ident = match local.node.pat.node { - ast::pat_ident(_, pth, _) => ast_util::path_to_ident(pth), + ast::pat_ident(_, ref pth, _) => ast_util::path_to_ident(pth), // FIXME this should be handled (#2533) _ => { bcx.sess().span_note(local.span, "debuginfo for pattern bindings NYI"); @@ -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 @@ -204,7 +204,7 @@ pub fn create_arg(bcx: block, arg: ast::arg, span: span) -> Option { let context = create_function(fcx); match arg.pat.node { - ast::pat_ident(_, path, _) => { + ast::pat_ident(_, ref path, _) => { // XXX: This is wrong; it should work for multiple bindings. let ident = path.idents.last(); let name: &str = cx.sess.str_of(*ident); @@ -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/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 65271faa7b086..ca469a42103a2 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -548,7 +548,6 @@ pub fn trans_trait_callee_from_llval(bcx: block, let _icx = push_ctxt("impl::trans_trait_callee"); let ccx = bcx.ccx(); - let mut bcx = bcx; // Load the vtable from the @Trait pair debug!("(translating trait callee) loading vtable from pair %s", diff --git a/src/librustc/middle/trans/uniq.rs b/src/librustc/middle/trans/uniq.rs index ada85c82b304b..adecd61bc4f4c 100644 --- a/src/librustc/middle/trans/uniq.rs +++ b/src/librustc/middle/trans/uniq.rs @@ -9,7 +9,6 @@ // except according to those terms. -use back; use lib::llvm::ValueRef; use middle::trans::base::*; use middle::trans::build::*; diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index feac8be8efd8b..129208a9aa37e 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -3624,12 +3624,12 @@ pub fn impl_trait_ref(cx: ctxt, id: ast::def_id) -> Option<@TraitRef> { debug!("(impl_trait_ref) searching for trait impl %?", id); match cx.items.find(&id.node) { Some(&ast_map::node_item(@ast::item { - node: ast::item_impl(_, opt_trait, _, _), + node: ast::item_impl(_, ref opt_trait, _, _), _}, _)) => { match opt_trait { - Some(t) => Some(ty::node_id_to_trait_ref(cx, t.ref_id)), - None => None + &Some(ref t) => Some(ty::node_id_to_trait_ref(cx, t.ref_id)), + &None => None } } _ => None diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 4d2849c521058..9442eb0b83869 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -85,15 +85,15 @@ pub trait AstConv { pub fn get_region_reporting_err( tcx: ty::ctxt, span: span, - a_r: Option<@ast::Lifetime>, + a_r: &Option, res: Result) -> ty::Region { match res { result::Ok(r) => r, result::Err(ref e) => { let descr = match a_r { - None => ~"anonymous lifetime", - Some(a) => fmt!("lifetime %s", + &None => ~"anonymous lifetime", + &Some(ref a) => fmt!("lifetime %s", lifetime_to_str(a, tcx.sess.intr())) }; tcx.sess.span_err( @@ -109,19 +109,19 @@ pub fn ast_region_to_region( this: &AC, rscope: &RS, default_span: span, - opt_lifetime: Option<@ast::Lifetime>) -> ty::Region + opt_lifetime: &Option) -> ty::Region { let (span, res) = match opt_lifetime { - None => { + &None => { (default_span, rscope.anon_region(default_span)) } - Some(ref lifetime) if lifetime.ident == special_idents::statik => { + &Some(ref lifetime) if lifetime.ident == special_idents::statik => { (lifetime.span, Ok(ty::re_static)) } - Some(ref lifetime) if lifetime.ident == special_idents::self_ => { + &Some(ref lifetime) if lifetime.ident == special_idents::self_ => { (lifetime.span, rscope.self_region(lifetime.span)) } - Some(ref lifetime) => { + &Some(ref lifetime) => { (lifetime.span, rscope.named_region(lifetime.span, lifetime.ident)) } @@ -136,7 +136,7 @@ fn ast_path_substs( def_id: ast::def_id, decl_generics: &ty::Generics, self_ty: Option, - path: @ast::Path) -> ty::substs + path: &ast::Path) -> ty::substs { /*! * @@ -164,11 +164,11 @@ fn ast_path_substs( } (&Some(_), &None) => { let res = rscope.anon_region(path.span); - let r = get_region_reporting_err(this.tcx(), path.span, None, res); + let r = get_region_reporting_err(this.tcx(), path.span, &None, res); Some(r) } (&Some(_), &Some(_)) => { - Some(ast_region_to_region(this, rscope, path.span, path.rp)) + Some(ast_region_to_region(this, rscope, path.span, &path.rp)) } }; @@ -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} } @@ -188,7 +188,7 @@ pub fn ast_path_to_substs_and_ty( this: &AC, rscope: &RS, did: ast::def_id, - path: @ast::Path) -> ty_param_substs_and_ty + path: &ast::Path) -> ty_param_substs_and_ty { let tcx = this.tcx(); let ty::ty_param_bounds_and_ty { @@ -206,7 +206,7 @@ pub fn ast_path_to_trait_ref( rscope: &RS, trait_def_id: ast::def_id, self_ty: Option, - path: @ast::Path) -> @ty::TraitRef + path: &ast::Path) -> @ty::TraitRef { let trait_def = this.get_trait_def(trait_def_id); @@ -228,7 +228,7 @@ pub fn ast_path_to_ty( this: &AC, rscope: &RS, did: ast::def_id, - path: @ast::Path) + path: &ast::Path) -> ty_param_substs_and_ty { // Look up the polytype of the item and then substitute the provided types @@ -276,7 +276,7 @@ pub fn ast_ty_to_ty( } return ty::mk_evec(tcx, mt, vst); } - ast::ty_path(path, bounds, id) => { + ast::ty_path(ref path, ref bounds, id) => { // Note that the "bounds must be empty if path is not a trait" // restriction is enforced in the below case for ty_path, which // will run after this as long as the path isn't a trait. @@ -321,7 +321,7 @@ pub fn ast_ty_to_ty( } fn check_path_args(tcx: ty::ctxt, - path: @ast::Path, + path: &ast::Path, flags: uint) { if (flags & NO_TPS) != 0u { if path.types.len() > 0u { @@ -371,13 +371,13 @@ pub fn ast_ty_to_ty( ast::ty_ptr(ref mt) => { ty::mk_ptr(tcx, ast_mt_to_mt(this, rscope, mt)) } - ast::ty_rptr(region, ref mt) => { + ast::ty_rptr(ref region, ref mt) => { let r = ast_region_to_region(this, rscope, ast_ty.span, region); mk_pointer(this, rscope, mt, ty::vstore_slice(r), |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) => { @@ -398,14 +398,14 @@ pub fn ast_ty_to_ty( f.purity, f.onceness, bounds, - f.region, + &f.region, &f.decl, None, &f.lifetimes, ast_ty.span); ty::mk_closure(tcx, fn_decl) } - ast::ty_path(path, bounds, id) => { + ast::ty_path(ref path, ref bounds, id) => { let a_def = match tcx.def_map.find(&id) { None => tcx.sess.span_fatal( ast_ty.span, fmt!("unbound path %s", @@ -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, @@ -647,7 +647,7 @@ fn ty_of_method_or_bare_fn( ast::sty_value => { Some(self_info.untransformed_self_ty) } - ast::sty_region(lifetime, mutability) => { + ast::sty_region(ref lifetime, mutability) => { let region = ast_region_to_region(this, rscope, self_info.explicit_self.span, @@ -677,7 +677,7 @@ pub fn ty_of_closure( purity: ast::purity, onceness: ast::Onceness, bounds: ty::BuiltinBounds, - opt_lifetime: Option<@ast::Lifetime>, + opt_lifetime: &Option, decl: &ast::fn_decl, expected_sig: Option, lifetimes: &OptVec, @@ -695,10 +695,10 @@ pub fn ty_of_closure( // resolve the function bound region in the original region // scope `rscope`, not the scope of the function parameters let bound_region = match opt_lifetime { - Some(_) => { + &Some(_) => { ast_region_to_region(this, rscope, span, opt_lifetime) } - None => { + &None => { match sigil { ast::OwnedSigil | ast::ManagedSigil => { // @fn(), ~fn() default to static as the bound @@ -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 { @@ -764,7 +764,7 @@ fn conv_builtin_bounds(tcx: ty::ctxt, ast_bounds: &Option { + ast::TraitTyParamBound(ref b) => { match lookup_def_tcx(tcx, b.path.span, b.ref_id) { ast::def_trait(trait_did) => { if try_add_builtin_trait(tcx, diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 45867ae77e080..1f7946576db5c 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -105,7 +105,7 @@ pub struct pat_ctxt { map: PatIdMap, } -pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path, +pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: &ast::Path, subpats: &Option<~[@ast::pat]>, expected: ty::t) { // Typecheck the path. @@ -271,7 +271,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path, /// `etc` is true if the pattern said '...' and false otherwise. pub fn check_struct_pat_fields(pcx: &pat_ctxt, span: span, - path: @ast::Path, + path: &ast::Path, fields: &[ast::field_pat], class_fields: ~[ty::field_ty], class_id: ast::def_id, @@ -322,7 +322,7 @@ pub fn check_struct_pat_fields(pcx: &pat_ctxt, } pub fn check_struct_pat(pcx: &pat_ctxt, pat_id: ast::node_id, span: span, - expected: ty::t, path: @ast::Path, + expected: ty::t, path: &ast::Path, fields: &[ast::field_pat], etc: bool, class_id: ast::def_id, substitutions: &ty::substs) { let fcx = pcx.fcx; @@ -356,7 +356,7 @@ pub fn check_struct_like_enum_variant_pat(pcx: &pat_ctxt, pat_id: ast::node_id, span: span, expected: ty::t, - path: @ast::Path, + path: &ast::Path, fields: &[ast::field_pat], etc: bool, enum_id: ast::def_id, @@ -440,7 +440,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { demand::suptype(fcx, pat.span, expected, const_tpt.ty); fcx.write_ty(pat.id, const_tpt.ty); } - ast::pat_ident(bm, name, sub) if pat_is_binding(tcx.def_map, pat) => { + ast::pat_ident(bm, ref name, sub) if pat_is_binding(tcx.def_map, pat) => { let typ = fcx.local_ty(pat.span, pat.id); match bm { @@ -476,13 +476,13 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { _ => () } } - ast::pat_ident(_, path, _) => { + ast::pat_ident(_, ref path, _) => { check_pat_variant(pcx, pat, path, &Some(~[]), expected); } - ast::pat_enum(path, ref subpats) => { + ast::pat_enum(ref path, ref subpats) => { check_pat_variant(pcx, pat, path, subpats, expected); } - ast::pat_struct(path, ref fields, etc) => { + ast::pat_struct(ref path, ref fields, etc) => { // Grab the class data that we care about. let structure = structure_of(fcx, pat.span, expected); let mut error_happened = false; diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 00ebca5abc147..5c8ce6b2d8bb0 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -463,7 +463,6 @@ pub fn check_fn(ccx: @mut CrateCtxt, } // Check the pattern. - let region = fcx.block_region(); let pcx = pat_ctxt { fcx: fcx, map: pat_id_map(tcx.def_map, input.pat), @@ -476,7 +475,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", @@ -489,7 +488,7 @@ pub fn check_fn(ccx: @mut CrateCtxt, // Add pattern bindings. let visit_pat: @fn(@ast::pat, ((), visit::vt<()>)) = |p, (e, v)| { match p.node { - ast::pat_ident(_, path, _) + ast::pat_ident(_, ref path, _) if pat_util::pat_is_binding(fcx.ccx.tcx.def_map, p) => { assign(p.id, None); debug!("Pattern binding %s is assigned to %s", @@ -624,7 +623,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 +789,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 +1380,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 +1389,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, @@ -1738,7 +1737,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, purity, expected_onceness, expected_bounds, - None, + &None, decl, expected_sig, &opt_vec::Empty, @@ -1779,7 +1778,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 +1808,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, @@ -2437,7 +2436,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, }; fcx.write_ty(id, oprnd_t); } - ast::expr_path(pth) => { + ast::expr_path(ref pth) => { let defn = lookup_def(fcx, pth.span, id); let tpt = ty_param_bounds_and_ty_for_def(fcx, expr.span, defn); @@ -2622,7 +2621,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); @@ -2775,7 +2774,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_ty(id, typ); } } - ast::expr_struct(path, ref fields, base_expr) => { + ast::expr_struct(ref path, ref fields, base_expr) => { // Resolve the path. match tcx.def_map.find(&id) { Some(&ast::def_struct(type_def_id)) => { @@ -2892,7 +2891,6 @@ pub fn check_decl_local(fcx: @mut FnCtxt, local: @ast::local) { _ => {} } - let region = tcx.region_maps.encl_region(local.node.id); let pcx = pat_ctxt { fcx: fcx, map: pat_id_map(tcx.def_map, local.node.pat), @@ -3286,7 +3284,7 @@ pub fn ty_param_bounds_and_ty_for_def(fcx: @mut FnCtxt, // Instantiates the given path, which must refer to an item with the given // number of type parameters and type. pub fn instantiate_path(fcx: @mut FnCtxt, - pth: @ast::Path, + pth: &ast::Path, tpt: ty_param_bounds_and_ty, span: span, node_id: ast::node_id) { @@ -3310,7 +3308,7 @@ pub fn instantiate_path(fcx: @mut FnCtxt, None } Some(_) => { // ...and the type is lifetime parameterized, ok. - Some(ast_region_to_region(fcx, fcx, span, pth.rp)) + Some(ast_region_to_region(fcx, fcx, span, &pth.rp)) } } } @@ -3336,7 +3334,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/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 2e41649e4dbb2..65b40fbd48c5d 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -36,11 +36,9 @@ use middle::typeck::check::regionmanip::relate_nested_regions; use middle::typeck::infer::resolve_and_force_all_but_regions; use middle::typeck::infer::resolve_type; use middle::typeck::infer; -use util::ppaux::{note_and_explain_region, ty_to_str, - region_to_str}; +use util::ppaux::{ty_to_str, region_to_str}; use middle::pat_util; -use std::result; use std::uint; use syntax::ast::{ManagedSigil, OwnedSigil, BorrowedSigil}; use syntax::ast::{def_arg, def_binding, def_local, def_self, def_upvar}; @@ -419,8 +417,6 @@ fn constrain_callee(rcx: @mut Rcx, call_expr: @ast::expr, callee_expr: @ast::expr) { - let tcx = rcx.fcx.tcx(); - let call_region = ty::re_scope(call_expr.id); let callee_ty = rcx.resolve_node_type(callee_id); @@ -559,8 +555,6 @@ fn constrain_index(rcx: @mut Rcx, * includes the deref expr. */ - let tcx = rcx.fcx.tcx(); - debug!("constrain_index(index_expr=?, indexed_ty=%s", rcx.fcx.infcx().ty_to_str(indexed_ty)); diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 24ac63ac7b079..473d5b8e6e880 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -207,9 +207,11 @@ impl CoherenceChecker { // self.crate_context.tcx.sess.str_of(item.ident)); match item.node { - item_impl(_, opt_trait, _, _) => { - self.check_implementation(item, - opt_trait.iter().transform(|&x| x).collect()); + item_impl(_, ref opt_trait, _, _) => { + let opt_trait : ~[trait_ref] = opt_trait.iter() + .transform(|&x| x) + .collect(); + self.check_implementation(item, opt_trait); } _ => { // Nothing to do. @@ -238,7 +240,7 @@ impl CoherenceChecker { pub fn check_implementation(&self, item: @item, - associated_traits: ~[@trait_ref]) { + associated_traits: &[trait_ref]) { let tcx = self.crate_context.tcx; let self_type = ty::lookup_item_type(tcx, local_def(item.id)); @@ -636,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; @@ -646,7 +648,7 @@ impl CoherenceChecker { a trait or new type instead"); } } - item_impl(_, Some(trait_ref), _, _) => { + item_impl(_, Some(ref trait_ref), _, _) => { // `for_ty` is `Type` in `impl Trait for Type` let for_ty = ty::node_id_to_type(self.crate_context.tcx, @@ -678,7 +680,7 @@ impl CoherenceChecker { }))); } - pub fn trait_ref_to_trait_def_id(&self, trait_ref: @trait_ref) -> def_id { + pub fn trait_ref_to_trait_def_id(&self, trait_ref: &trait_ref) -> def_id { let def_map = self.crate_context.tcx.def_map; let trait_def = def_map.get_copy(&trait_ref.ref_id); let trait_id = def_id_of_def(trait_def); @@ -723,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) => { @@ -805,7 +807,7 @@ impl CoherenceChecker { // Check that we have implementations of every trait method for trait_refs.iter().advance |trait_ref| { let trait_did = - self.trait_ref_to_trait_def_id(*trait_ref); + self.trait_ref_to_trait_def_id(trait_ref); self.please_check_that_trait_methods_are_implemented( &mut methods, trait_did, @@ -817,7 +819,7 @@ impl CoherenceChecker { // if a method of that name is not inherent to the // impl, use the provided definition in the trait. for trait_refs.iter().advance |trait_ref| { - let trait_did = self.trait_ref_to_trait_def_id(*trait_ref); + let trait_did = self.trait_ref_to_trait_def_id(trait_ref); self.add_provided_methods_to_impl( &mut methods, &trait_did, diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index de05aca61caf5..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)); } @@ -378,7 +378,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt, id: ast::node_id, sp: codemap::span, rp: Option, - ast_trait_refs: &[@ast::trait_ref], + ast_trait_refs: &[ast::trait_ref], generics: &ast::Generics) { let tcx = ccx.tcx; @@ -386,7 +386,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt, let self_ty = ty::mk_self(ccx.tcx, local_def(id)); let mut ty_trait_refs: ~[@ty::TraitRef] = ~[]; - for ast_trait_refs.iter().advance |&ast_trait_ref| { + for ast_trait_refs.iter().advance |ast_trait_ref| { let trait_ref = instantiate_trait_ref(ccx, ast_trait_ref, rp, generics, self_ty); @@ -441,7 +441,7 @@ pub fn compare_impl_method(tcx: ty::ctxt, fmt!("method `%s` has a `%s` declaration in the impl, \ but not in the trait", tcx.sess.str_of(trait_m.ident), - explicit_self_to_str(impl_m.explicit_self, tcx.sess.intr()))); + explicit_self_to_str(&impl_m.explicit_self, tcx.sess.intr()))); return; } (_, &ast::sty_static) => { @@ -450,7 +450,7 @@ pub fn compare_impl_method(tcx: ty::ctxt, fmt!("method `%s` has a `%s` declaration in the trait, \ but not in the impl", tcx.sess.str_of(trait_m.ident), - explicit_self_to_str(trait_m.explicit_self, tcx.sess.intr()))); + explicit_self_to_str(&trait_m.explicit_self, tcx.sess.intr()))); return; } _ => { @@ -671,7 +671,7 @@ pub fn check_methods_against_trait(ccx: &CrateCtxt, impl_m.span, fmt!("method `%s` is not a member of trait `%s`", tcx.sess.str_of(impl_m.mty.ident), - path_to_str(a_trait_ty.path, tcx.sess.intr()))); + path_to_str(&a_trait_ty.path, tcx.sess.intr()))); } } } @@ -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, 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); @@ -839,7 +839,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) { &i_ty_generics, generics, parent_visibility); for opt_trait_ref.iter().advance |t| { - check_methods_against_trait(ccx, generics, rp, selfty, *t, cms); + check_methods_against_trait(ccx, generics, rp, selfty, t, cms); } } ast::item_trait(ref generics, ref supertraits, ref trait_methods) => { @@ -966,7 +966,7 @@ pub fn instantiate_trait_ref(ccx: &CrateCtxt, ast::def_trait(trait_did) => { let trait_ref = astconv::ast_path_to_trait_ref( - ccx, &rscope, trait_did, Some(self_ty), ast_trait_ref.path); + ccx, &rscope, trait_did, Some(self_ty), &ast_trait_ref.path); ccx.tcx.trait_refs.insert( ast_trait_ref.ref_id, trait_ref); return trait_ref; @@ -975,7 +975,7 @@ pub fn instantiate_trait_ref(ccx: &CrateCtxt, ccx.tcx.sess.span_fatal( ast_trait_ref.path.span, fmt!("%s is not a trait", - path_to_str(ast_trait_ref.path, + path_to_str(&ast_trait_ref.path, ccx.tcx.sess.intr()))); } } @@ -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: @~[], @@ -1149,7 +1149,7 @@ pub fn ty_generics(ccx: &CrateCtxt, let param_ty = ty::param_ty {idx: base_index + offset, def_id: local_def(param.id)}; let bounds = @compute_bounds(ccx, rp, generics, - param_ty, param.bounds); + param_ty, ¶m.bounds); let def = ty::TypeParameterDef { def_id: local_def(param.id), bounds: bounds @@ -1167,7 +1167,7 @@ pub fn ty_generics(ccx: &CrateCtxt, rp: Option, generics: &ast::Generics, param_ty: ty::param_ty, - ast_bounds: @OptVec) -> ty::ParamBounds + ast_bounds: &OptVec) -> ty::ParamBounds { /*! * @@ -1184,7 +1184,7 @@ pub fn ty_generics(ccx: &CrateCtxt, }; for ast_bounds.iter().advance |ast_bound| { match *ast_bound { - TraitTyParamBound(b) => { + TraitTyParamBound(ref b) => { let ty = ty::mk_param(ccx.tcx, param_ty.idx, param_ty.def_id); let trait_ref = instantiate_trait_ref(ccx, b, rp, generics, ty); if !astconv::try_add_builtin_trait( @@ -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/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index f03f01732291f..ee90d9661c37f 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -65,7 +65,7 @@ use middle::typeck::infer::sub::Sub; use middle::typeck::infer::to_str::InferStr; use middle::typeck::infer::unify::{InferCtxtMethods}; use middle::typeck::infer::{InferCtxt, cres, ures}; -use middle::typeck::infer::{TypeOrigin, TypeTrace}; +use middle::typeck::infer::{TypeTrace}; use util::common::indent; use std::result::{iter_vec2, map_vec2}; @@ -73,7 +73,6 @@ use std::vec; use syntax::ast::{Onceness, purity}; use syntax::ast; use syntax::opt_vec; -use syntax::codemap::span; use syntax::abi::AbiSet; pub trait Combine { diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index e533f019b4692..928f33803dd8c 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -59,23 +59,18 @@ time of error detection. */ -use std::prelude::*; use middle::ty; use middle::ty::Region; use middle::typeck::infer; use middle::typeck::infer::InferCtxt; use middle::typeck::infer::TypeTrace; -use middle::typeck::infer::TypeOrigin; use middle::typeck::infer::SubregionOrigin; use middle::typeck::infer::RegionVariableOrigin; -use middle::typeck::infer::Types; -use middle::typeck::infer::TraitRefs; use middle::typeck::infer::ValuePairs; use middle::typeck::infer::region_inference::RegionResolutionError; use middle::typeck::infer::region_inference::ConcreteFailure; use middle::typeck::infer::region_inference::SubSupConflict; use middle::typeck::infer::region_inference::SupSupConflict; -use syntax::opt_vec; use syntax::opt_vec::OptVec; use util::ppaux::UserString; use util::ppaux::note_and_explain_region; @@ -362,7 +357,7 @@ impl ErrorReporting for InferCtxt { sup, ""); } - infer::ReferenceOutlivesReferent(ty, span) => { + infer::ReferenceOutlivesReferent(ty, _) => { self.tcx.sess.span_err( origin.span(), fmt!("in type `%s`, pointer has a longer lifetime than \ diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index fefbf2336c29f..32f3e8fea3a86 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -26,8 +26,7 @@ use syntax::ast::{Many, Once, extern_fn, impure_fn, m_const, m_imm, m_mutbl}; use syntax::ast::{unsafe_fn}; use syntax::ast::{Onceness, purity}; use syntax::abi::AbiSet; -use syntax::codemap::span; -use util::common::{indent, indenter}; +use util::common::{indenter}; use util::ppaux::mt_to_str; use extra::list; diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index efb1dc200b521..3f23fd6e7096f 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -21,7 +21,6 @@ use middle::typeck::infer::{cres, InferCtxt}; use middle::typeck::infer::fold_regions_in_sig; use middle::typeck::infer::{TypeTrace, Subtype}; use middle::typeck::isr_alist; -use util::common::indent; use util::ppaux::mt_to_str; use extra::list; @@ -30,7 +29,6 @@ use syntax::ast; use syntax::ast::{Many, Once, extern_fn, m_const, impure_fn}; use syntax::ast::{unsafe_fn}; use syntax::ast::{Onceness, purity}; -use syntax::codemap::span; pub struct Lub(CombineFields); // least-upper-bound: common supertype diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index 3360edc6a4678..d0a778139dbd2 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -328,7 +328,7 @@ pub fn can_mk_subty(cx: @mut InferCtxt, a: ty::t, b: ty::t) -> ures { } pub fn mk_subr(cx: @mut InferCtxt, - a_is_expected: bool, + _a_is_expected: bool, origin: SubregionOrigin, a: ty::Region, b: ty::Region) { diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index 96cb5d3c747c3..7bf4d07b72306 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -19,13 +19,12 @@ use middle::typeck::infer::cres; use middle::typeck::infer::{RegionVariableOrigin, SubregionOrigin}; use middle::typeck::infer; use util::common::indenter; -use util::ppaux::{note_and_explain_region, Repr, UserString}; +use util::ppaux::{Repr}; use std::cell::Cell; use std::hashmap::{HashMap, HashSet}; use std::uint; use std::vec; -use syntax::codemap::span; use syntax::ast; use syntax::opt_vec; use syntax::opt_vec::OptVec; diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index 72178500b54ed..cfb33732459ff 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -21,7 +21,7 @@ use middle::typeck::infer::lattice::CombineFieldsLatticeMethods; use middle::typeck::infer::lub::Lub; use middle::typeck::infer::to_str::InferStr; use middle::typeck::infer::{TypeTrace, Subtype}; -use util::common::{indent, indenter}; +use util::common::{indenter}; use util::ppaux::bound_region_to_str; use extra::list::Nil; @@ -29,7 +29,6 @@ use extra::list; use syntax::abi::AbiSet; use syntax::ast; use syntax::ast::{Onceness, m_const, purity}; -use syntax::codemap::span; pub struct Sub(CombineFields); // "subtype", "subregion" etc diff --git a/src/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs index e40bdb532da93..40c662e3a09e5 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(ty, _, _), _ + node: ast::item_static(ref ty, _, _), _ }, _) => { pprust::ty_to_str(ty, extract::interner()) } @@ -245,12 +245,12 @@ 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, opt_trait_type, 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) }; let trait_types = opt_trait_type.map_default(~[], |p| { - ~[pprust::path_to_str(p.path, extract::interner())] + ~[pprust::path_to_str(&p.path, extract::interner())] }); (bounds, trait_types, @@ -285,15 +285,14 @@ fn fold_type( match ctxt.ast_map.get_copy(&doc.id()) { ast_map::node_item(@ast::item { ident: ident, - node: ast::item_ty(ty, ref params), _ + node: ast::item_ty(ref ty, ref params), _ }, _) => { Some(fmt!( "type %s%s = %s", to_str(ident), pprust::generics_to_str(params, extract::interner()), - pprust::ty_to_str(ty, - extract::interner()) + pprust::ty_to_str(ty, extract::interner()) )) } _ => fail!("expected type") diff --git a/src/librusti/rusti.rs b/src/librusti/rusti.rs index 9911ca699dac0..d9cd52201c0c5 100644 --- a/src/librusti/rusti.rs +++ b/src/librusti/rusti.rs @@ -132,7 +132,7 @@ fn run(mut repl: Repl, input: ~str) -> Repl { // differently beause they must appear before all 'use' statements for blk.node.view_items.iter().advance |vi| { let s = do with_pp(intr) |pp, _| { - pprust::print_view_item(pp, *vi); + pprust::print_view_item(pp, vi); }; match vi.node { ast::view_item_extern_mod(*) => { diff --git a/src/librusti/utils.rs b/src/librusti/utils.rs index 0ac0f5a3c4cb4..3932df1db847a 100644 --- a/src/librusti/utils.rs +++ b/src/librusti/utils.rs @@ -14,14 +14,14 @@ use syntax::print::pp; use syntax::print::pprust; use syntax::parse::token; -pub fn each_binding(l: @ast::local, f: @fn(@ast::Path, ast::node_id)) { +pub fn each_binding(l: @ast::local, f: @fn(&ast::Path, ast::node_id)) { use syntax::visit; let vt = visit::mk_simple_visitor( @visit::SimpleVisitor { visit_pat: |pat| { match pat.node { - ast::pat_ident(_, path, _) => { + ast::pat_ident(_, ref path, _) => { f(path, pat.id); } _ => {} diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 2603cbb2dd7c5..8c37c1510cf20 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -109,8 +109,8 @@ pub struct Path { span: span, global: bool, idents: ~[ident], - rp: Option<@Lifetime>, - types: ~[@Ty], + rp: Option, + types: ~[Ty], } pub type crate_num = int; @@ -132,7 +132,7 @@ pub static crate_node_id: node_id = 0; // the "special" built-in traits (see middle::lang_items) and // detects Copy, Send, Send, and Freeze. pub enum TyParamBound { - TraitTyParamBound(@trait_ref), + TraitTyParamBound(trait_ref), RegionTyParamBound } @@ -140,7 +140,7 @@ pub enum TyParamBound { pub struct TyParam { ident: ident, id: node_id, - bounds: @OptVec + bounds: OptVec } #[deriving(Eq, Encodable, Decodable,IterBytes)] @@ -219,7 +219,7 @@ pub type blk = spanned; #[deriving(Eq, Encodable, Decodable,IterBytes)] pub struct blk_ { - view_items: ~[@view_item], + view_items: ~[view_item], stmts: ~[@stmt], expr: Option<@expr>, id: node_id, @@ -255,10 +255,10 @@ pub enum pat_ { // which it is. The resolver determines this, and // records this pattern's node_id in an auxiliary // set (of "pat_idents that refer to nullary enums") - pat_ident(binding_mode, @Path, Option<@pat>), - pat_enum(@Path, Option<~[@pat]>), /* "none" means a * pattern where + pat_ident(binding_mode, Path, Option<@pat>), + pat_enum(Path, Option<~[@pat]>), /* "none" means a * pattern where * we don't bind the fields to names */ - pat_struct(@Path, ~[field_pat], bool), + pat_struct(Path, ~[field_pat], bool), pat_tup(~[@pat]), pat_box(@pat), pat_uniq(@pat), @@ -296,7 +296,7 @@ pub enum vstore { vstore_fixed(Option), // [1,2,3,4] vstore_uniq, // ~[1,2,3,4] vstore_box, // @[1,2,3,4] - vstore_slice(Option<@Lifetime>) // &'foo? [1,2,3,4] + vstore_slice(Option) // &'foo? [1,2,3,4] } #[deriving(Eq, Encodable, Decodable,IterBytes)] @@ -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,9 +454,9 @@ 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), + expr_path(Path), /// The special identifier `self`. expr_self, @@ -471,7 +471,7 @@ pub enum expr_ { expr_mac(mac), // A struct literal expression. - expr_struct(@Path, ~[field], Option<@expr>), + expr_struct(Path, ~[field], Option<@expr>), // A vector literal constructed from one repeated element. expr_repeat(@expr /* element */, @expr /* count */, mutability), @@ -583,7 +583,7 @@ pub type mac = spanned; #[deriving(Eq, Encodable, Decodable,IterBytes)] pub enum mac_ { - mac_invoc_tt(@Path,~[token_tree]), // new macro-invocation + mac_invoc_tt(Path,~[token_tree]), // new macro-invocation } pub type lit = spanned; @@ -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, } @@ -701,7 +701,7 @@ impl ToStr for Onceness { #[deriving(Eq, Encodable, Decodable,IterBytes)] pub struct TyClosure { sigil: Sigil, - region: Option<@Lifetime>, + region: Option, lifetimes: OptVec, purity: purity, onceness: Onceness, @@ -730,11 +730,11 @@ pub enum ty_ { ty_vec(mt), ty_fixed_length_vec(mt, @expr), ty_ptr(mt), - ty_rptr(Option<@Lifetime>, mt), + ty_rptr(Option, mt), ty_closure(@TyClosure), ty_bare_fn(@TyBareFn), - ty_tup(~[@Ty]), - ty_path(@Path, @Option>, node_id), // for #7264; see above + 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 // specified. This should only appear at the "top level" of a type and not @@ -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, } @@ -803,7 +803,7 @@ pub enum ret_style { pub enum explicit_self_ { sty_static, // no self sty_value, // `self` - sty_region(Option<@Lifetime>, mutability), // `&'lt self` + sty_region(Option, mutability), // `&'lt self` sty_box(mutability), // `@self` sty_uniq // `~self` } @@ -827,7 +827,7 @@ pub struct method { #[deriving(Eq, Encodable, Decodable,IterBytes)] pub struct _mod { - view_items: ~[@view_item], + view_items: ~[view_item], items: ~[@item], } @@ -839,13 +839,13 @@ pub enum foreign_mod_sort { named, anonymous } pub struct foreign_mod { sort: foreign_mod_sort, abis: AbiSet, - view_items: ~[@view_item], + view_items: ~[view_item], items: ~[@foreign_item], } #[deriving(Eq, Encodable, Decodable,IterBytes)] pub struct variant_arg { - ty: @Ty, + ty: Ty, id: node_id, } @@ -890,13 +890,13 @@ pub enum view_path_ { // or just // // foo::bar::baz (with 'baz =' implicitly on the left) - view_path_simple(ident, @Path, node_id), + view_path_simple(ident, Path, node_id), // foo::bar::* - view_path_glob(@Path, node_id), + view_path_glob(Path, node_id), // foo::bar::{a,b,c} - view_path_list(@Path, ~[path_list_ident], node_id) + view_path_list(Path, ~[path_list_ident], node_id) } #[deriving(Eq, Encodable, Decodable,IterBytes)] @@ -939,7 +939,7 @@ pub struct attribute_ { */ #[deriving(Eq, Encodable, Decodable,IterBytes)] pub struct trait_ref { - path: @Path, + path: Path, ref_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_trait(Generics, ~[trait_ref], ~[trait_method]), item_impl(Generics, - Option<@trait_ref>, // (optional) trait this impl implements - @Ty, // self + Option, // (optional) trait this impl implements + 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/ast_map.rs b/src/libsyntax/ast_map.rs index 3abbe3970540e..59020e9d18377 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -196,7 +196,7 @@ pub fn map_block(b: &blk, (cx,v): (@mut Ctx, visit::vt<@mut Ctx>)) { pub fn map_pat(pat: @pat, (cx,v): (@mut Ctx, visit::vt<@mut Ctx>)) { match pat.node { - pat_ident(_, path, _) => { + pat_ident(_, ref path, _) => { // Note: this is at least *potentially* a pattern... cx.map.insert(pat.id, node_local(ast_util::path_to_ident(path))); } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index ce8e24fd4445a..565f181ab8598 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -27,7 +27,7 @@ pub fn path_name_i(idents: &[ident]) -> ~str { idents.map(|i| token::interner_get(i.name)).connect("::") } -pub fn path_to_ident(p: @Path) -> ident { copy *p.idents.last() } +pub fn path_to_ident(p: &Path) -> ident { copy *p.idents.last() } pub fn local_def(id: node_id) -> def_id { ast::def_id { crate: local_crate, node: id } @@ -212,8 +212,8 @@ pub fn default_block( } } -pub fn ident_to_path(s: span, i: ident) -> @Path { - @ast::Path { span: s, +pub fn ident_to_path(s: span, i: ident) -> Path { + ast::Path { span: s, global: false, idents: ~[i], rp: None, @@ -580,7 +580,7 @@ pub fn view_path_id(p: &view_path) -> node_id { /// Returns true if the given struct def is tuple-like; i.e. that its fields /// are unnamed. -pub fn struct_def_is_tuple_like(struct_def: @ast::struct_def) -> bool { +pub fn struct_def_is_tuple_like(struct_def: &ast::struct_def) -> bool { struct_def.ctor_id.is_some() } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index ad14b567b9602..5686887491615 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -326,7 +326,7 @@ pub fn expr_to_ident(cx: @ExtCtxt, expr: @ast::expr, err_msg: &str) -> ast::ident { match expr.node { - ast::expr_path(p) => { + ast::expr_path(ref p) => { if p.types.len() > 0u || p.idents.len() != 1u { cx.span_fatal(expr.span, err_msg); } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 2c1b4cfc59155..73220ec288170 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -32,44 +32,43 @@ mod syntax { pub trait AstBuilder { // paths - fn path(&self, span: span, strs: ~[ast::ident]) -> @ast::Path; - fn path_ident(&self, span: span, id: ast::ident) -> @ast::Path; - fn path_global(&self, span: span, strs: ~[ast::ident]) -> @ast::Path; + fn path(&self, span: span, strs: ~[ast::ident]) -> ast::Path; + fn path_ident(&self, span: span, id: ast::ident) -> ast::Path; + fn path_global(&self, span: span, strs: ~[ast::ident]) -> ast::Path; fn path_all(&self, sp: span, global: bool, idents: ~[ast::ident], - rp: Option<@ast::Lifetime>, - types: ~[@ast::Ty]) - -> @ast::Path; + rp: Option, + 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, - lifetime: Option<@ast::Lifetime>, - 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_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; + 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; + + 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 strip_bounds(&self, bounds: &Generics) -> Generics; - fn typaram(&self, id: ast::ident, bounds: @OptVec) -> ast::TyParam; + fn typaram(&self, id: ast::ident, bounds: OptVec) -> ast::TyParam; - fn trait_ref(&self, path: @ast::Path) -> @ast::trait_ref; - fn typarambound(&self, path: @ast::Path) -> ast::TyParamBound; + fn trait_ref(&self, path: ast::Path) -> ast::trait_ref; + fn typarambound(&self, path: ast::Path) -> ast::TyParamBound; fn lifetime(&self, span: span, ident: ast::ident) -> ast::Lifetime; // statements @@ -80,13 +79,13 @@ pub trait AstBuilder { fn blk(&self, span: span, stmts: ~[@ast::stmt], expr: Option<@ast::expr>) -> ast::blk; fn blk_expr(&self, expr: @ast::expr) -> ast::blk; fn blk_all(&self, span: span, - view_items: ~[@ast::view_item], + view_items: ~[ast::view_item], stmts: ~[@ast::stmt], expr: Option<@ast::expr>) -> ast::blk; // expressions fn expr(&self, span: span, node: ast::expr_) -> @ast::expr; - fn expr_path(&self, path: @ast::Path) -> @ast::expr; + fn expr_path(&self, path: ast::Path) -> @ast::expr; fn expr_ident(&self, span: span, id: ast::ident) -> @ast::expr; fn expr_self(&self, span: span) -> @ast::expr; @@ -110,7 +109,7 @@ pub trait AstBuilder { fn expr_blk(&self, b: ast::blk) -> @ast::expr; fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::field; - fn expr_struct(&self, span: span, path: @ast::Path, fields: ~[ast::field]) -> @ast::expr; + fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::field]) -> @ast::expr; fn expr_struct_ident(&self, span: span, id: ast::ident, fields: ~[ast::field]) -> @ast::expr; fn expr_lit(&self, sp: span, lit: ast::lit_) -> @ast::expr; @@ -138,9 +137,9 @@ pub trait AstBuilder { span: span, ident: ast::ident, bm: ast::binding_mode) -> @ast::pat; - fn pat_enum(&self, span: span, path: @ast::Path, subpats: ~[@ast::pat]) -> @ast::pat; + fn pat_enum(&self, span: span, path: ast::Path, subpats: ~[@ast::pat]) -> @ast::pat; fn pat_struct(&self, span: span, - path: @ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat; + path: ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat; fn arm(&self, span: span, pats: ~[@ast::pat], expr: @ast::expr) -> ast::arm; fn arm_unreachable(&self, span: span) -> ast::arm; @@ -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, @@ -202,14 +201,14 @@ pub trait AstBuilder { fn item_mod(&self, span: span, name: ident, attrs: ~[ast::attribute], - vi: ~[@ast::view_item], items: ~[@ast::item]) -> @ast::item; + vi: ~[ast::view_item], items: ~[@ast::item]) -> @ast::item; 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; @@ -218,30 +217,30 @@ pub trait AstBuilder { fn meta_name_value(&self, sp: span, name: @str, value: ast::lit_) -> @ast::meta_item; fn view_use(&self, sp: span, - vis: ast::visibility, vp: ~[@ast::view_path]) -> @ast::view_item; + vis: ast::visibility, vp: ~[@ast::view_path]) -> ast::view_item; fn view_use_list(&self, sp: span, vis: ast::visibility, - path: ~[ast::ident], imports: &[ast::ident]) -> @ast::view_item; + path: ~[ast::ident], imports: &[ast::ident]) -> ast::view_item; fn view_use_glob(&self, sp: span, - vis: ast::visibility, path: ~[ast::ident]) -> @ast::view_item; + vis: ast::visibility, path: ~[ast::ident]) -> ast::view_item; } impl AstBuilder for @ExtCtxt { - fn path(&self, span: span, strs: ~[ast::ident]) -> @ast::Path { + fn path(&self, span: span, strs: ~[ast::ident]) -> ast::Path { self.path_all(span, false, strs, None, ~[]) } - fn path_ident(&self, span: span, id: ast::ident) -> @ast::Path { + fn path_ident(&self, span: span, id: ast::ident) -> ast::Path { self.path(span, ~[id]) } - fn path_global(&self, span: span, strs: ~[ast::ident]) -> @ast::Path { + fn path_global(&self, span: span, strs: ~[ast::ident]) -> ast::Path { self.path_all(span, true, strs, None, ~[]) } fn path_all(&self, sp: span, global: bool, idents: ~[ast::ident], - rp: Option<@ast::Lifetime>, - types: ~[@ast::Ty]) - -> @ast::Path { - @ast::Path { + rp: Option, + types: ~[ast::Ty]) + -> ast::Path { + ast::Path { span: sp, global: global, idents: idents, @@ -250,23 +249,23 @@ 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 } } - fn ty_path(&self, path: @ast::Path, bounds: @Option>) - -> @ast::Ty { + fn ty_path(&self, path: ast::Path, bounds: Option>) + -> 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 { - self.ty_path(self.path_ident(span, ident), @None) + -> ast::Ty { + self.ty_path(self.path_ident(span, ident), None) } fn ty_rptr(&self, span: span, - ty: @ast::Ty, - lifetime: Option<@ast::Lifetime>, + 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, @@ -305,52 +304,50 @@ impl AstBuilder for @ExtCtxt { self.ident_of("Option") ], None, - ~[ ty ]), - @None) + ~[ 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(), } } - fn typaram(&self, id: ast::ident, bounds: @OptVec) -> ast::TyParam { + fn typaram(&self, id: ast::ident, bounds: OptVec) -> ast::TyParam { ast::TyParam { ident: id, id: self.next_id(), bounds: bounds } } // 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))) + self.path_global(dummy_sp(), ~[p.ident]), None))) } fn strip_bounds(&self, generics: &Generics) -> Generics { - let no_bounds = @opt_vec::Empty; let new_params = do generics.ty_params.map |ty_param| { - ast::TyParam { bounds: no_bounds, ..copy *ty_param } + ast::TyParam { bounds: opt_vec::Empty, ..copy *ty_param } }; Generics { ty_params: new_params, @@ -358,14 +355,14 @@ impl AstBuilder for @ExtCtxt { } } - fn trait_ref(&self, path: @ast::Path) -> @ast::trait_ref { - @ast::trait_ref { + fn trait_ref(&self, path: ast::Path) -> ast::trait_ref { + ast::trait_ref { path: path, ref_id: self.next_id() } } - fn typarambound(&self, path: @ast::Path) -> ast::TyParamBound { + fn typarambound(&self, path: ast::Path) -> ast::TyParamBound { ast::TraitTyParamBound(self.trait_ref(path)) } @@ -400,7 +397,7 @@ impl AstBuilder for @ExtCtxt { } fn blk_all(&self, span: span, - view_items: ~[@ast::view_item], + view_items: ~[ast::view_item], stmts: ~[@ast::stmt], expr: Option<@ast::expr>) -> ast::blk { respan(span, @@ -421,7 +418,7 @@ impl AstBuilder for @ExtCtxt { } } - fn expr_path(&self, path: @ast::Path) -> @ast::expr { + fn expr_path(&self, path: ast::Path) -> @ast::expr { self.expr(path.span, ast::expr_path(path)) } @@ -487,7 +484,7 @@ impl AstBuilder for @ExtCtxt { fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::field { respan(span, ast::field_ { ident: name, expr: e }) } - fn expr_struct(&self, span: span, path: @ast::Path, fields: ~[ast::field]) -> @ast::expr { + fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::field]) -> @ast::expr { self.expr(span, ast::expr_struct(path, fields, None)) } fn expr_struct_ident(&self, span: span, @@ -570,12 +567,12 @@ impl AstBuilder for @ExtCtxt { let pat = ast::pat_ident(bm, path, None); self.pat(span, pat) } - fn pat_enum(&self, span: span, path: @ast::Path, subpats: ~[@ast::pat]) -> @ast::pat { + fn pat_enum(&self, span: span, path: ast::Path, subpats: ~[@ast::pat]) -> @ast::pat { let pat = ast::pat_enum(path, Some(subpats)); self.pat(span, pat) } fn pat_struct(&self, span: span, - path: @ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat { + path: ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat { let pat = ast::pat_struct(path, field_pats, false); self.pat(span, pat) } @@ -644,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, @@ -655,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, @@ -679,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, @@ -696,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( @@ -708,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_ { @@ -762,7 +759,7 @@ impl AstBuilder for @ExtCtxt { fn item_mod(&self, span: span, name: ident, attrs: ~[ast::attribute], - vi: ~[@ast::view_item], + vi: ~[ast::view_item], items: ~[@ast::item]) -> @ast::item { self.item( span, @@ -775,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()) } @@ -804,8 +801,8 @@ impl AstBuilder for @ExtCtxt { } fn view_use(&self, sp: span, - vis: ast::visibility, vp: ~[@ast::view_path]) -> @ast::view_item { - @ast::view_item { + vis: ast::visibility, vp: ~[@ast::view_path]) -> ast::view_item { + ast::view_item { node: ast::view_item_use(vp), attrs: ~[], vis: vis, @@ -814,7 +811,7 @@ impl AstBuilder for @ExtCtxt { } fn view_use_list(&self, sp: span, vis: ast::visibility, - path: ~[ast::ident], imports: &[ast::ident]) -> @ast::view_item { + path: ~[ast::ident], imports: &[ast::ident]) -> ast::view_item { let imports = do imports.map |id| { respan(sp, ast::path_list_ident_ { name: *id, id: self.next_id() }) }; @@ -827,7 +824,7 @@ impl AstBuilder for @ExtCtxt { } fn view_use_glob(&self, sp: span, - vis: ast::visibility, path: ~[ast::ident]) -> @ast::view_item { + vis: ast::visibility, path: ~[ast::ident]) -> ast::view_item { self.view_use(sp, vis, ~[@respan(sp, ast::view_path_glob(self.path(sp, path), self.next_id()))]) diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index 7df8874076e09..900668df117e3 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -36,7 +36,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) let e = @ast::expr { id: cx.next_id(), node: ast::expr_path( - @ast::Path { + ast::Path { span: sp, global: false, idents: ~[res], diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 0e4fc9d96fa87..01769482d0829 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -335,9 +335,9 @@ impl<'self> TraitDef<'self> { cx.typarambound(p.to_path(cx, span, type_ident, generics)) }); // require the current trait - bounds.push(cx.typarambound(trait_path)); + bounds.push(cx.typarambound(copy trait_path)); - trait_generics.ty_params.push(cx.typaram(ty_param.ident, @bounds)); + trait_generics.ty_params.push(cx.typaram(ty_param.ident, bounds)); } // Create the reference to the trait. @@ -351,13 +351,12 @@ impl<'self> TraitDef<'self> { let self_lifetime = if generics.lifetimes.is_empty() { None } else { - Some(@*generics.lifetimes.get(0)) + Some(*generics.lifetimes.get(0)) }; // Create the type of `self`. let self_type = cx.ty_path(cx.path_all(span, false, ~[ type_ident ], self_lifetime, - opt_vec::take_vec(self_ty_params)), - @None); + opt_vec::take_vec(self_ty_params)), None); let doc_attr = cx.attribute( span, @@ -457,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) } @@ -467,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 = ~[]; @@ -515,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); @@ -890,7 +889,7 @@ fn summarise_struct(cx: @ExtCtxt, span: span, pub fn create_subpatterns(cx: @ExtCtxt, span: span, - field_paths: ~[@ast::Path], + field_paths: ~[ast::Path], mutbl: ast::mutability) -> ~[@ast::pat] { do field_paths.map |&path| { @@ -941,7 +940,7 @@ fn create_struct_pattern(cx: @ExtCtxt, }; let path = cx.path_ident(span, cx.ident_of(fmt!("%s_%u", prefix, i))); - paths.push(path); + paths.push(copy path); ident_expr.push((opt_id, cx.expr_path(path))); } @@ -987,7 +986,7 @@ fn create_enum_variant_pattern(cx: @ExtCtxt, let path = cx.path_ident(span, cx.ident_of(fmt!("%s_%u", prefix, i))); - paths.push(path); + paths.push(copy path); ident_expr.push((None, cx.expr_path(path))); } diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index e210853bfb4dc..255bc6c98775b 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -61,16 +61,15 @@ impl<'self> Path<'self> { span: span, self_ty: ident, self_generics: &Generics) - -> @ast::Ty { - cx.ty_path(self.to_path(cx, span, - self_ty, self_generics), @None) + -> ast::Ty { + cx.ty_path(self.to_path(cx, span, self_ty, self_generics), None) } pub fn to_path(&self, cx: @ExtCtxt, span: span, self_ty: ident, self_generics: &Generics) - -> @ast::Path { + -> ast::Path { let idents = self.path.map(|s| cx.ident_of(*s) ); let lt = mk_lifetime(cx, span, &self.lifetime); let tys = self.params.map(|t| t.to_ty(cx, span, self_ty, self_generics)); @@ -110,9 +109,9 @@ pub fn nil_ty() -> Ty<'static> { Tuple(~[]) } -fn mk_lifetime(cx: @ExtCtxt, span: span, lt: &Option<&str>) -> Option<@ast::Lifetime> { +fn mk_lifetime(cx: @ExtCtxt, span: span, lt: &Option<&str>) -> Option { match *lt { - Some(ref s) => Some(@cx.lifetime(span, cx.ident_of(*s))), + Some(ref s) => Some(cx.lifetime(span, cx.ident_of(*s))), None => None } } @@ -123,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); @@ -142,8 +141,7 @@ impl<'self> Ty<'self> { } Literal(ref p) => { p.to_ty(cx, span, self_ty, self_generics) } Self => { - cx.ty_path(self.to_path(cx, span, self_ty, self_generics), - @None) + cx.ty_path(self.to_path(cx, span, self_ty, self_generics), None) } Tuple(ref fields) => { let ty = if fields.is_empty() { @@ -162,7 +160,7 @@ impl<'self> Ty<'self> { span: span, self_ty: ident, self_generics: &Generics) - -> @ast::Path { + -> ast::Path { match *self { Self => { let self_params = do self_generics.ty_params.map |ty_param| { @@ -171,7 +169,7 @@ impl<'self> Ty<'self> { let lifetime = if self_generics.lifetimes.is_empty() { None } else { - Some(@*self_generics.lifetimes.get(0)) + Some(*self_generics.lifetimes.get(0)) }; cx.path_all(span, false, ~[self_ty], lifetime, @@ -194,7 +192,7 @@ fn mk_ty_param(cx: @ExtCtxt, span: span, name: &str, bounds: &[Path], let path = b.to_path(cx, span, self_ident, self_generics); cx.typarambound(path) }); - cx.typaram(cx.ident_of(name), @bounds) + cx.typaram(cx.ident_of(name), bounds) } fn mk_generics(lifetimes: ~[ast::Lifetime], ty_params: ~[ast::TyParam]) -> Generics { @@ -251,8 +249,7 @@ pub fn get_explicit_self(cx: @ExtCtxt, span: span, self_ptr: &Option) Send => ast::sty_uniq, Managed(mutbl) => ast::sty_box(mutbl), Borrowed(ref lt, mutbl) => { - let lt = lt.map(|s| @cx.lifetime(span, - cx.ident_of(*s))); + let lt = lt.map(|s| cx.lifetime(span, cx.ident_of(*s))); ast::sty_region(lt, mutbl) } }); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 2b18ede88791b..940bd5ef61c11 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -40,7 +40,7 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, expr_mac(ref mac) => { match (*mac).node { // Token-tree macros: - mac_invoc_tt(pth, ref tts) => { + mac_invoc_tt(ref pth, ref tts) => { if (pth.idents.len() > 1u) { cx.span_fatal( pth.span, @@ -208,7 +208,7 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv, fld: @ast_fold) -> Option<@ast::item> { let (pth, tts) = match it.node { - item_mac(codemap::spanned { node: mac_invoc_tt(pth, ref tts), _}) => { + item_mac(codemap::spanned { node: mac_invoc_tt(ref pth, ref tts), _}) => { (pth, copy *tts) } _ => cx.span_bug(it.span, "invalid item macro invocation") @@ -298,7 +298,7 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv, let (mac, pth, tts, semi) = match *s { stmt_mac(ref mac, semi) => { match mac.node { - mac_invoc_tt(pth, ref tts) => { + mac_invoc_tt(ref pth, ref tts) => { (copy *mac, pth, copy *tts, semi) } } @@ -372,10 +372,10 @@ pub fn new_name_finder() -> @Visitor<@mut ~[ast::ident]> { (ident_accum, v): (@mut ~[ast::ident], visit::vt<@mut ~[ast::ident]>)| { match *p { // we found a pat_ident! - ast::pat{id:_, node: ast::pat_ident(_,path,ref inner), span:_} => { + ast::pat{id:_, node: ast::pat_ident(_,ref path,ref inner), span:_} => { match path { // a path of length one: - @ast::Path{global: false,idents: [id], span:_,rp:_,types:_} => + &ast::Path{global: false,idents: [id], span:_,rp:_,types:_} => ident_accum.push(id), // I believe these must be enums... _ => () diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index 5b789cbc26c1e..9e6776363a82d 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -26,7 +26,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, cx.print_backtrace(); io::stdout().write_line( print::pprust::tt_to_str( - ast::tt_delim(vec::to_owned(tt)), + &ast::tt_delim(vec::to_owned(tt)), get_ident_interner())); //trivial expression diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index 1af6e7810a577..a4873e6e34b45 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -25,16 +25,16 @@ mod syntax { pub use parse; } -pub fn path(ids: ~[ident], span: span) -> @ast::Path { - @ast::Path { span: span, +pub fn path(ids: ~[ident], span: span) -> ast::Path { + ast::Path { span: span, global: false, idents: ids, rp: None, types: ~[] } } -pub fn path_global(ids: ~[ident], span: span) -> @ast::Path { - @ast::Path { span: span, +pub fn path_global(ids: ~[ident], span: span) -> ast::Path { + ast::Path { span: span, global: true, idents: ids, rp: None, @@ -42,22 +42,22 @@ 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 { - @ast::Path { +impl append_types for ast::Path { + fn add_ty(&self, ty: ast::Ty) -> ast::Path { + ast::Path { types: vec::append_one(copy self.types, ty), - .. copy **self + .. copy *self } } - fn add_tys(&self, tys: ~[@ast::Ty]) -> @ast::Path { - @ast::Path { + fn add_tys(&self, tys: ~[ast::Ty]) -> ast::Path { + ast::Path { types: vec::append(copy self.types, tys), - .. copy **self + .. 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 0e24725ea990c..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,11 +56,11 @@ 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) - .add_tys(cx.ty_vars(&this.generics.ty_params)), @None); + .add_tys(cx.ty_vars(&this.generics.ty_params)), None); let args_ast = vec::append( ~[cx.arg(span, cx.ident_of("pipe"), pipe_ty)], args_ast); @@ -117,7 +117,7 @@ impl gen_send for message { let mut rty = cx.ty_path(path(~[next.data_name()], span) - .add_tys(copy next_state.tys), @None); + .add_tys(copy next_state.tys), None); if try { rty = cx.ty_option(rty); } @@ -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, @@ -145,7 +145,7 @@ impl gen_send for message { cx.ty_path( path(~[this.data_name()], span) .add_tys(cx.ty_vars( - &this.generics.ty_params)), @None))], + &this.generics.ty_params)), None))], args_ast); let message_args = if arg_names.len() == 0 { @@ -189,9 +189,9 @@ 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) + .add_tys(cx.ty_vars(&self.get_generics().ty_params)), None) } } @@ -225,7 +225,7 @@ impl to_type_decls for state { cx.ty_path( path(~[cx.ident_of(dir), cx.ident_of(next_name)], span) - .add_tys(copy next_state.tys), @None)) + .add_tys(copy next_state.tys), None)) } None => tys }; @@ -278,8 +278,7 @@ impl to_type_decls for state { self.data_name()], dummy_sp()) .add_tys(cx.ty_vars( - &self.generics.ty_params)), @None)), - @None), + &self.generics.ty_params)), None)), None), cx.strip_bounds(&self.generics))); } else { @@ -298,8 +297,8 @@ impl to_type_decls for state { self.data_name()], dummy_sp()) .add_tys(cx.ty_vars_global( - &self.generics.ty_params)), @None), - self.proto.buffer_ty_path(cx)]), @None), + &self.generics.ty_params)), None), + self.proto.buffer_ty_path(cx)]), None), cx.strip_bounds(&self.generics))); }; items @@ -370,12 +369,12 @@ 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 (copy self.states).iter().advance |s| { + for self.states.iter().advance |s| { for s.generics.ty_params.iter().advance |tp| { match params.iter().find_(|tpp| tp.ident == tpp.ident) { - None => params.push(*tp), + None => params.push(copy *tp), _ => () } } @@ -384,16 +383,16 @@ impl gen_init for protocol { cx.ty_path(path(~[cx.ident_of("super"), cx.ident_of("__Buffer")], copy self.span) - .add_tys(cx.ty_vars_global(¶ms)), @None) + .add_tys(cx.ty_vars_global(¶ms)), None) } fn gen_buffer_type(&self, cx: @ExtCtxt) -> @ast::item { let ext_cx = cx; let mut params: OptVec = opt_vec::Empty; - let fields = do (copy self.states).iter().transform |s| { + let fields = do self.states.iter().transform |s| { for s.generics.ty_params.iter().advance |tp| { match params.iter().find_(|tpp| tp.ident == tpp.ident) { - None => params.push(*tp), + None => params.push(copy *tp), _ => () } } diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 0525c6664780e..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,10 +96,10 @@ 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) + cx.ty_vars(&self.generics.ty_params)), None) } /// Iterate over the states that can be reached in one message @@ -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/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 80dd0c7247b49..6de504c66fd88 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -82,7 +82,7 @@ pub fn add_new_extension(cx: @ExtCtxt, io::println(fmt!("%s! { %s }", cx.str_of(name), print::pprust::tt_to_str( - ast::tt_delim(vec::to_owned(arg)), + &ast::tt_delim(vec::to_owned(arg)), get_ident_interner()))); } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 96d7685353b2d..c36b717ea0055 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -16,7 +16,7 @@ use opt_vec::OptVec; pub trait ast_fold { fn fold_crate(@self, &crate) -> crate; - fn fold_view_item(@self, @view_item) -> @view_item; + fn fold_view_item(@self, &view_item) -> view_item; fn fold_foreign_item(@self, @foreign_item) -> @foreign_item; fn fold_item(@self, @item) -> Option<@item>; fn fold_struct_field(@self, @struct_field) -> @struct_field; @@ -28,12 +28,12 @@ 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; fn fold_ident(@self, ident) -> ident; - fn fold_path(@self, @Path) -> @Path; + fn fold_path(@self, &Path) -> Path; fn fold_local(@self, @local) -> @local; fn map_exprs(@self, @fn(@expr) -> @expr, &[@expr]) -> ~[@expr]; fn new_id(@self, node_id) -> node_id; @@ -62,7 +62,7 @@ pub struct AstFoldFns { fold_foreign_mod: @fn(&foreign_mod, @ast_fold) -> foreign_mod, fold_variant: @fn(&variant_, span, @ast_fold) -> (variant_, span), fold_ident: @fn(ident, @ast_fold) -> ident, - fold_path: @fn(@Path, @ast_fold) -> Path, + fold_path: @fn(&Path, @ast_fold) -> Path, fold_local: @fn(&local_, span, @ast_fold) -> (local_, span), map_exprs: @fn(@fn(@expr) -> @expr, &[@expr]) -> ~[@expr], new_id: @fn(node_id) -> node_id, @@ -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), } @@ -117,7 +117,7 @@ fn fold_arg_(a: arg, fld: @ast_fold) -> arg { fn fold_mac_(m: &mac, fld: @ast_fold) -> mac { spanned { node: match m.node { - mac_invoc_tt(p,ref tts) => + mac_invoc_tt(ref p,ref tts) => mac_invoc_tt(fld.fold_path(p), fold_tts(*tts,fld)) }, @@ -154,15 +154,15 @@ 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, } } fn fold_ty_param_bound(tpb: &TyParamBound, fld: @ast_fold) -> TyParamBound { match *tpb { - TraitTyParamBound(ty) => TraitTyParamBound(fold_trait_ref(ty, fld)), + TraitTyParamBound(ref ty) => TraitTyParamBound(fold_trait_ref(ty, fld)), RegionTyParamBound => RegionTyParamBound } } @@ -171,12 +171,13 @@ pub fn fold_ty_param(tp: TyParam, fld: @ast_fold) -> TyParam { TyParam {ident: tp.ident, id: fld.new_id(tp.id), - bounds: @tp.bounds.map(|x| fold_ty_param_bound(x, fld))} + bounds: tp.bounds.map(|x| fold_ty_param_bound(x, fld))} } pub fn fold_ty_params(tps: &OptVec, fld: @ast_fold) -> OptVec { - tps.map(|tp| fold_ty_param(*tp, fld)) + let tps = /*bad*/ copy *tps; + tps.map_consume(|tp| fold_ty_param(tp, fld)) } pub fn fold_lifetime(l: &Lifetime, @@ -225,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) } }, @@ -259,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), @@ -280,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) => { @@ -296,10 +297,10 @@ 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, 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)), + ifce.map(|p| fold_trait_ref(p, fld)), fld.fold_ty(ty), methods.map(|x| fld.fold_method(*x)) ) @@ -313,7 +314,7 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ { }; item_trait( fold_generics(generics, fld), - traits.map(|p| fold_trait_ref(*p, fld)), + traits.map(|p| fold_trait_ref(p, fld)), methods ) } @@ -335,9 +336,9 @@ fn fold_struct_def(struct_def: @ast::struct_def, fld: @ast_fold) } } -fn fold_trait_ref(p: @trait_ref, fld: @ast_fold) -> @trait_ref { - @ast::trait_ref { - path: fld.fold_path(p.path), +fn fold_trait_ref(p: &trait_ref, fld: @ast_fold) -> trait_ref { + ast::trait_ref { + path: fld.fold_path(&p.path), ref_id: fld.new_id(p.ref_id), } } @@ -347,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), @@ -372,7 +373,7 @@ fn noop_fold_method(m: @method, fld: @ast_fold) -> @method { pub fn noop_fold_block(b: &blk_, fld: @ast_fold) -> blk_ { - let view_items = b.view_items.map(|x| fld.fold_view_item(*x)); + let view_items = b.view_items.map(|x| fld.fold_view_item(x)); let mut stmts = ~[]; for b.stmts.iter().advance |stmt| { match fld.fold_stmt(*stmt) { @@ -419,7 +420,7 @@ fn noop_fold_arm(a: &arm, fld: @ast_fold) -> arm { pub fn noop_fold_pat(p: &pat_, fld: @ast_fold) -> pat_ { match *p { pat_wild => pat_wild, - pat_ident(binding_mode, pth, ref sub) => { + pat_ident(binding_mode, ref pth, ref sub) => { pat_ident( binding_mode, fld.fold_path(pth), @@ -427,13 +428,13 @@ pub fn noop_fold_pat(p: &pat_, fld: @ast_fold) -> pat_ { ) } pat_lit(e) => pat_lit(fld.fold_expr(e)), - pat_enum(pth, ref pats) => { + pat_enum(ref pth, ref pats) => { pat_enum( fld.fold_path(pth), pats.map(|pats| pats.map(|x| fld.fold_pat(*x))) ) } - pat_struct(pth, ref fields, etc) => { + pat_struct(ref pth, ref fields, etc) => { let pth_ = fld.fold_path(pth); let fs = do fields.map |f| { ast::field_pat { @@ -517,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 ) @@ -540,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( @@ -586,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) => { @@ -596,7 +597,7 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ { fld.fold_expr(er) ) } - expr_path(pth) => expr_path(fld.fold_path(pth)), + expr_path(ref pth) => expr_path(fld.fold_path(pth)), expr_self => expr_self, expr_break(ref opt_ident) => { expr_break(opt_ident.map(|x| fld.fold_ident(*x))) @@ -621,7 +622,7 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ { }) } expr_mac(ref mac) => expr_mac(fold_mac(mac)), - expr_struct(path, ref fields, maybe_expr) => { + expr_struct(ref path, ref fields, maybe_expr) => { expr_struct( fld.fold_path(path), fields.map(|x| fold_field(*x)), @@ -636,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, } } @@ -681,9 +682,9 @@ 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_path(path, bounds, id) => - ty_path(fld.fold_path(path), @fold_opt_bounds(bounds, fld), fld.new_id(id)), + 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) => { ty_fixed_length_vec( fold_mt(mt, fld), @@ -697,7 +698,7 @@ pub fn noop_fold_ty(t: &ty_, fld: @ast_fold) -> ty_ { // ...nor do modules pub fn noop_fold_mod(m: &_mod, fld: @ast_fold) -> _mod { ast::_mod { - view_items: m.view_items.iter().transform(|x| fld.fold_view_item(*x)).collect(), + view_items: m.view_items.iter().transform(|x| fld.fold_view_item(x)).collect(), items: m.items.iter().filter_map(|x| fld.fold_item(*x)).collect(), } } @@ -706,14 +707,14 @@ fn noop_fold_foreign_mod(nm: &foreign_mod, fld: @ast_fold) -> foreign_mod { ast::foreign_mod { sort: nm.sort, abis: nm.abis, - view_items: nm.view_items.iter().transform(|x| fld.fold_view_item(*x)).collect(), + view_items: nm.view_items.iter().transform(|x| fld.fold_view_item(x)).collect(), items: nm.items.iter().transform(|x| fld.fold_foreign_item(*x)).collect(), } } 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); @@ -721,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) => { @@ -754,20 +755,20 @@ fn noop_fold_ident(i: ident, _fld: @ast_fold) -> ident { /* FIXME (#2543) */ copy i } -fn noop_fold_path(p: @Path, fld: @ast_fold) -> Path { +fn noop_fold_path(p: &Path, fld: @ast_fold) -> Path { ast::Path { span: fld.new_span(p.span), 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), @@ -818,9 +819,8 @@ impl ast_fold for AstFoldFns { let (n, s) = (self.fold_crate)(&c.node, c.span, self as @ast_fold); spanned { node: n, span: (self.new_span)(s) } } - fn fold_view_item(@self, x: @view_item) -> - @view_item { - @ast::view_item { + fn fold_view_item(@self, x: &view_item) -> view_item { + ast::view_item { node: (self.fold_view_item)(&x.node, self as @ast_fold), attrs: x.attrs.iter().transform(|a| fold_attribute_(*a, self as @ast_fold)).collect(), vis: x.vis, @@ -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), @@ -908,8 +908,8 @@ impl ast_fold for AstFoldFns { fn fold_ident(@self, x: ident) -> ident { (self.fold_ident)(x, self as @ast_fold) } - fn fold_path(@self, x: @Path) -> @Path { - @(self.fold_path)(x, self as @ast_fold) + fn fold_path(@self, x: &Path) -> Path { + (self.fold_path)(x, self as @ast_fold) } fn fold_local(@self, x: @local) -> @local { let (n, s) = (self.fold_local)(&x.node, x.span, self as @ast_fold); @@ -964,7 +964,7 @@ mod test { } // this version doesn't care about getting comments or docstrings in. - fn fake_print_crate(s: @pprust::ps, crate: ast::crate) { + fn fake_print_crate(s: @pprust::ps, crate: &ast::crate) { pprust::print_mod(s, &crate.node.module, crate.node.attrs); } @@ -995,7 +995,7 @@ mod test { let ast = string_to_crate(@"#[a] mod b {fn c (d : e, f : g) {h!(i,j,k);l;m}}"); assert_pred!(matches_codepattern, "matches_codepattern", - pprust::to_str(zz_fold.fold_crate(ast),fake_print_crate, + pprust::to_str(&zz_fold.fold_crate(ast),fake_print_crate, token::get_ident_interner()), ~"#[a]mod zz{fn zz(zz:zz,zz:zz){zz!(zz,zz,zz);zz;zz}}"); } @@ -1007,7 +1007,7 @@ mod test { => (g $(d $d $e)+))} "); assert_pred!(matches_codepattern, "matches_codepattern", - pprust::to_str(zz_fold.fold_crate(ast),fake_print_crate, + pprust::to_str(&zz_fold.fold_crate(ast),fake_print_crate, token::get_ident_interner()), ~"zz!zz((zz$zz:zz$(zz $zz:zz)zz+=>(zz$(zz$zz$zz)+)))"); } diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index 8e2da3d6eb1aa..ba3b72ec19443 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -16,7 +16,7 @@ * other useful things like `push()` and `len()`. */ -use std::vec::VecIterator; +use std::vec::{VecIterator}; #[deriving(Encodable, Decodable,IterBytes)] pub enum OptVec { @@ -58,6 +58,13 @@ impl OptVec { } } + fn map_consume(self, op: &fn(T) -> U) -> OptVec { + match self { + Empty => Empty, + Vec(v) => Vec(v.consume_iter().transform(op).collect()) + } + } + fn get<'a>(&'a self, i: uint) -> &'a T { match *self { Empty => fail!("Invalid index %u", i), diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 6dd8d4880e3f0..fdf3f0e639ea1 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -366,7 +366,7 @@ mod test { #[test] fn path_exprs_1 () { assert_eq!(string_to_expr(@"a"), @ast::expr{id:1, - node:ast::expr_path(@ast::Path {span:sp(0,1), + node:ast::expr_path(ast::Path {span:sp(0,1), global:false, idents:~[str_to_ident("a")], rp:None, @@ -378,7 +378,7 @@ mod test { assert_eq!(string_to_expr(@"::a::b"), @ast::expr{id:1, node:ast::expr_path( - @ast::Path {span:sp(0,6), + ast::Path {span:sp(0,6), global:true, idents:strs_to_idents(~["a","b"]), rp:None, @@ -428,7 +428,7 @@ mod test { node:ast::expr_ret( Some(@ast::expr{id:1, node:ast::expr_path( - @ast::Path{span:sp(7,8), + ast::Path{span:sp(7,8), global:false, idents:~[str_to_ident("d")], rp:None, @@ -444,7 +444,7 @@ mod test { node: ast::stmt_expr(@ast::expr{ id: 1, node: ast::expr_path( - @ast::Path{ + ast::Path{ span:sp(0,1), global:false, idents:~[str_to_ident("b")], @@ -465,7 +465,7 @@ mod test { assert_eq!(parser.parse_pat(), @ast::pat{id:1, // fixme node: ast::pat_ident(ast::bind_infer, - @ast::Path{ + ast::Path{ span:sp(0,1), global:false, idents:~[str_to_ident("b")], @@ -482,19 +482,19 @@ mod test { assert_eq!(parser.parse_arg_general(true), ast::arg{ is_mutbl: false, - ty: @ast::Ty{id:3, // fixme - node: ast::ty_path(@ast::Path{ + 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? global:false, idents:~[str_to_ident("int")], rp: None, types: ~[]}, - @None, 2), + None, 2), span:sp(4,7)}, pat: @ast::pat{id:1, node: ast::pat_ident(ast::bind_infer, - @ast::Path{ + ast::Path{ span:sp(0,1), global:false, idents:~[str_to_ident("b")], @@ -519,19 +519,19 @@ mod test { node: ast::item_fn(ast::fn_decl{ inputs: ~[ast::arg{ is_mutbl: false, - ty: @ast::Ty{id:3, // fixme - node: ast::ty_path(@ast::Path{ + ty: ast::Ty{id:3, // fixme + node: ast::ty_path(ast::Path{ span:sp(10,13), global:false, idents:~[str_to_ident("int")], rp: None, types: ~[]}, - @None, 2), + None, 2), span:sp(10,13)}, pat: @ast::pat{id:1, // fixme node: ast::pat_ident( ast::bind_infer, - @ast::Path{ + ast::Path{ span:sp(6,7), global:false, idents:~[str_to_ident("b")], @@ -542,7 +542,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 @@ -561,7 +561,7 @@ mod test { node: ast::stmt_semi(@ast::expr{ id: 6, node: ast::expr_path( - @ast::Path{ + ast::Path{ span:sp(17,18), global:false, idents:~[str_to_ident("b")], diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ae87fd8774a9a..d18d24c2b90e0 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -115,7 +115,7 @@ pub enum item_or_view_item { iovi_none, iovi_item(@item), iovi_foreign_item(@foreign_item), - iovi_view_item(@view_item) + iovi_view_item(view_item) } #[deriving(Eq)] @@ -130,20 +130,28 @@ The important thing is to make sure that lookahead doesn't balk at INTERPOLATED tokens */ macro_rules! maybe_whole_expr ( ($p:expr) => ( - match *($p).token { - INTERPOLATED(token::nt_expr(e)) => { - $p.bump(); - return e; - } - INTERPOLATED(token::nt_path(pt)) => { - $p.bump(); - return $p.mk_expr( - ($p).span.lo, - ($p).span.hi, - expr_path(pt) - ); + { + // This horrible convolution is brought to you by + // @mut, have a terrible day + let ret = match *($p).token { + INTERPOLATED(token::nt_expr(e)) => { + Some(e) + } + INTERPOLATED(token::nt_path(ref pt)) => { + Some($p.mk_expr( + ($p).span.lo, + ($p).span.hi, + expr_path(/* bad */ copy *pt))) + } + _ => None + }; + match ret { + Some(e) => { + $p.bump(); + return e; + } + None => () } - _ => () } ) ) @@ -208,7 +216,7 @@ fn maybe_append(lhs: ~[attribute], rhs: Option<~[attribute]>) struct ParsedItemsAndViewItems { attrs_remaining: ~[attribute], - view_items: ~[@view_item], + view_items: ~[view_item], items: ~[@item], foreign_items: ~[@foreign_item] } @@ -638,7 +646,7 @@ impl Parser { // parse a ty_closure type pub fn parse_ty_closure(&self, sigil: ast::Sigil, - region: Option<@ast::Lifetime>) + region: Option) -> ty_ { /* @@ -816,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 } } @@ -827,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, @@ -839,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) @@ -858,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), @@ -870,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; @@ -960,14 +968,14 @@ impl Parser { || is_ident_or_path(self.token) { // NAMED TYPE let (path, bounds) = self.parse_type_path(); - ty_path(path, @bounds, self.get_id()) + ty_path(path, bounds, self.get_id()) } else { self.fatal(fmt!("expected type, found token %?", *self.token)); }; 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 ~ @@ -977,7 +985,7 @@ impl Parser { // @'foo fn() or @foo/fn() or @fn() are parsed directly as fn types: match *self.token { token::LIFETIME(*) => { - let lifetime = @self.parse_lifetime(); + let lifetime = self.parse_lifetime(); self.bump(); return self.parse_ty_closure(sigil, Some(lifetime)); } @@ -986,7 +994,7 @@ impl Parser { if self.look_ahead(1u) == token::BINOP(token::SLASH) && self.token_is_closure_keyword(&self.look_ahead(2u)) { - let lifetime = @self.parse_lifetime(); + let lifetime = self.parse_lifetime(); self.obsolete(*self.last_span, ObsoleteLifetimeNotation); return self.parse_ty_closure(sigil, Some(lifetime)); } else if self.token_is_closure_keyword(© *self.token) { @@ -1108,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), @@ -1218,10 +1226,10 @@ impl Parser { } // parse a path that doesn't have type parameters attached - pub fn parse_path_without_tps(&self) -> @ast::Path { + pub fn parse_path_without_tps(&self) -> ast::Path { maybe_whole!(self, nt_path); let (ids,is_global,sp) = self.parse_path(); - @ast::Path { span: sp, + ast::Path { span: sp, global: is_global, idents: ids, rp: None, @@ -1229,7 +1237,7 @@ impl Parser { } pub fn parse_bounded_path_with_tps(&self, colons: bool, - before_tps: Option<&fn()>) -> @ast::Path { + before_tps: Option<&fn()>) -> ast::Path { debug!("parse_path_with_tps(colons=%b)", colons); maybe_whole!(self, nt_path); @@ -1255,7 +1263,7 @@ impl Parser { token::IDENT(sid, _) => { let span = copy self.span; self.bump(); - Some(@ast::Lifetime { + Some(ast::Lifetime { id: self.get_id(), span: *span, ident: sid @@ -1280,7 +1288,7 @@ impl Parser { if v.len() == 0 { None } else if v.len() == 1 { - Some(@*v.get(0)) + Some(*v.get(0)) } else { self.fatal(fmt!("Expected at most one \ lifetime name (for now)")); @@ -1288,22 +1296,22 @@ impl Parser { } }; - @ast::Path { span: mk_sp(lo, hi), + ast::Path { span: mk_sp(lo, hi), rp: rp, types: tps, - .. copy *path } + .. path } } // parse a path optionally with type parameters. If 'colons' // is true, then type parameters must be preceded by colons, // as in a::t:: - pub fn parse_path_with_tps(&self, colons: bool) -> @ast::Path { + pub fn parse_path_with_tps(&self, colons: bool) -> ast::Path { self.parse_bounded_path_with_tps(colons, None) } // Like the above, but can also parse kind bounds in the case of a // path to be used as a type that might be a trait. - pub fn parse_type_path(&self) -> (@ast::Path, Option>) { + pub fn parse_type_path(&self) -> (ast::Path, Option>) { let mut bounds = None; let path = self.parse_bounded_path_with_tps(false, Some(|| { // Note: this closure might not even get called in the case of a @@ -1314,17 +1322,17 @@ impl Parser { } /// parses 0 or 1 lifetime - pub fn parse_opt_lifetime(&self) -> Option<@ast::Lifetime> { + pub fn parse_opt_lifetime(&self) -> Option { match *self.token { token::LIFETIME(*) => { - Some(@self.parse_lifetime()) + Some(self.parse_lifetime()) } // Also accept the (obsolete) syntax `foo/` token::IDENT(*) => { if self.look_ahead(1u) == token::BINOP(token::SLASH) { self.obsolete(*self.last_span, ObsoleteLifetimeNotation); - Some(@self.parse_lifetime()) + Some(self.parse_lifetime()) } else { None } @@ -1455,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) @@ -1465,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) } @@ -2207,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 @@ -2818,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), @@ -3205,7 +3213,7 @@ impl Parser { let ident = self.parse_ident(); let opt_bounds = self.parse_optional_ty_param_bounds(); // For typarams we don't care about the difference b/w "" and "". - let bounds = @opt_bounds.get_or_default(opt_vec::Empty); + let bounds = opt_bounds.get_or_default(opt_vec::Empty); ast::TyParam { ident: ident, id: self.get_id(), bounds: bounds } } @@ -3227,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, ~[]) @@ -3237,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( @@ -3335,14 +3343,14 @@ impl Parser { } else if (this.token_is_lifetime(&this.look_ahead(1)) && token::is_keyword(keywords::Self, &this.look_ahead(2))) { this.bump(); - let lifetime = @this.parse_lifetime(); + let lifetime = this.parse_lifetime(); this.expect_self_ident(); sty_region(Some(lifetime), m_imm) } else if (this.token_is_lifetime(&this.look_ahead(1)) && this.token_is_mutability(&this.look_ahead(2)) && token::is_keyword(keywords::Self, &this.look_ahead(3))) { this.bump(); - let lifetime = @this.parse_lifetime(); + let lifetime = this.parse_lifetime(); let mutability = this.parse_mutability(); this.expect_self_ident(); sty_region(Some(lifetime), mutability) @@ -3447,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 { @@ -3557,9 +3565,9 @@ impl Parser { let opt_trait = if could_be_trait && self.eat_keyword(keywords::For) { // New-style trait. Reinterpret the type as a trait. let opt_trait_ref = match ty.node { - ty_path(path, @None, node_id) => { - Some(@trait_ref { - path: path, + ty_path(ref path, None, node_id) => { + Some(trait_ref { + path: /* bad */ copy *path, ref_id: node_id }) } @@ -3600,15 +3608,15 @@ impl Parser { } // parse a::B<~str,int> - fn parse_trait_ref(&self) -> @trait_ref { - @ast::trait_ref { + fn parse_trait_ref(&self) -> trait_ref { + ast::trait_ref { path: self.parse_path_with_tps(false), ref_id: self.get_id(), } } // parse B + C<~str,int> + D - fn parse_trait_ref_list(&self, ket: &token::Token) -> ~[@trait_ref] { + fn parse_trait_ref_list(&self, ket: &token::Token) -> ~[trait_ref] { self.parse_seq_to_before_end( ket, seq_sep_trailing_disallowed(token::BINOP(token::PLUS)), @@ -4074,7 +4082,7 @@ impl Parser { // extern mod foo; let metadata = self.parse_optional_meta(); self.expect(&token::SEMI); - iovi_view_item(@ast::view_item { + iovi_view_item(ast::view_item { node: view_item_extern_mod(ident, metadata, self.get_id()), attrs: copy attrs, vis: visibility, @@ -4147,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(), }); } @@ -4308,7 +4316,7 @@ impl Parser { // USE ITEM (iovi_view_item) let view_item = self.parse_use(); self.expect(&token::SEMI); - return iovi_view_item(@ast::view_item { + return iovi_view_item(ast::view_item { node: view_item, attrs: attrs, vis: visibility, @@ -4558,7 +4566,7 @@ impl Parser { let id = self.parse_ident(); path.push(id); } - let path = @ast::Path { span: mk_sp(lo, self.span.hi), + let path = ast::Path { span: mk_sp(lo, self.span.hi), global: false, idents: path, rp: None, @@ -4588,7 +4596,7 @@ impl Parser { seq_sep_trailing_allowed(token::COMMA), |p| p.parse_path_list_ident() ); - let path = @ast::Path { span: mk_sp(lo, self.span.hi), + let path = ast::Path { span: mk_sp(lo, self.span.hi), global: false, idents: path, rp: None, @@ -4600,7 +4608,7 @@ impl Parser { // foo::bar::* token::BINOP(token::STAR) => { self.bump(); - let path = @ast::Path { span: mk_sp(lo, self.span.hi), + let path = ast::Path { span: mk_sp(lo, self.span.hi), global: false, idents: path, rp: None, @@ -4616,7 +4624,7 @@ impl Parser { _ => () } let last = path[path.len() - 1u]; - let path = @ast::Path { span: mk_sp(lo, self.span.hi), + let path = ast::Path { span: mk_sp(lo, self.span.hi), global: false, idents: path, rp: None, @@ -4656,7 +4664,7 @@ impl Parser { &self, attrs: ~[attribute], vis: visibility - ) -> @view_item { + ) -> view_item { let lo = self.span.lo; let node = if self.eat_keyword(keywords::Use) { self.parse_use() @@ -4669,7 +4677,7 @@ impl Parser { self.bug("expected view item"); }; self.expect(&token::SEMI); - @ast::view_item { node: node, + ast::view_item { node: node, attrs: attrs, vis: vis, span: mk_sp(lo, self.last_span.hi) } @@ -4687,7 +4695,7 @@ impl Parser { let mut attrs = vec::append(first_item_attrs, self.parse_outer_attributes()); // First, parse view items. - let mut view_items = ~[]; + let mut view_items : ~[ast::view_item] = ~[]; let mut items = ~[]; let mut done = false; // I think this code would probably read better as a single diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index a50fa4168320c..09d6ecb40fc0b 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -104,9 +104,9 @@ 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_path( ast::Path), nt_tt( @ast::token_tree), //needs @ed to break a circularity nt_matchers(~[ast::matcher]) } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 5e685d85f95df..b545c56778e90 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -34,9 +34,9 @@ use std::uint; // The @ps is stored here to prevent recursive type. pub enum ann_node<'self> { node_block(@ps, &'self ast::blk), - node_item(@ps, @ast::item), - node_expr(@ps, @ast::expr), - node_pat(@ps, @ast::pat), + node_item(@ps, &'self ast::item), + node_expr(@ps, &'self ast::expr), + node_pat(@ps, &'self ast::pat), } pub struct pp_ann { pre: @fn(ann_node), @@ -106,7 +106,7 @@ pub static default_columns: uint = 78u; pub fn print_crate(cm: @CodeMap, intr: @ident_interner, span_diagnostic: @diagnostic::span_handler, - crate: @ast::crate, + crate: &ast::crate, filename: @str, in: @io::Reader, out: @io::Writer, @@ -136,21 +136,21 @@ pub fn print_crate(cm: @CodeMap, print_crate_(s, crate); } -pub fn print_crate_(s: @ps, crate: @ast::crate) { +pub fn print_crate_(s: @ps, crate: &ast::crate) { print_mod(s, &crate.node.module, crate.node.attrs); print_remaining_comments(s); eof(s.s); } -pub fn ty_to_str(ty: @ast::Ty, intr: @ident_interner) -> ~str { +pub fn ty_to_str(ty: &ast::Ty, intr: @ident_interner) -> ~str { to_str(ty, print_type, intr) } -pub fn pat_to_str(pat: @ast::pat, intr: @ident_interner) -> ~str { +pub fn pat_to_str(pat: &ast::pat, intr: @ident_interner) -> ~str { to_str(pat, print_irrefutable_pat, intr) } -pub fn expr_to_str(e: @ast::expr, intr: @ident_interner) -> ~str { +pub fn expr_to_str(e: &ast::expr, intr: @ident_interner) -> ~str { to_str(e, print_expr, intr) } @@ -158,19 +158,19 @@ pub fn lifetime_to_str(e: &ast::Lifetime, intr: @ident_interner) -> ~str { to_str(e, print_lifetime, intr) } -pub fn tt_to_str(tt: ast::token_tree, intr: @ident_interner) -> ~str { - to_str(&tt, print_tt, intr) +pub fn tt_to_str(tt: &ast::token_tree, intr: @ident_interner) -> ~str { + to_str(tt, print_tt, intr) } pub fn tts_to_str(tts: &[ast::token_tree], intr: @ident_interner) -> ~str { - to_str(tts, print_tts, intr) + to_str(&tts, print_tts, intr) } pub fn stmt_to_str(s: &ast::stmt, intr: @ident_interner) -> ~str { to_str(s, print_stmt, intr) } -pub fn item_to_str(i: @ast::item, intr: @ident_interner) -> ~str { +pub fn item_to_str(i: &ast::item, intr: @ident_interner) -> ~str { to_str(i, print_item, intr) } @@ -179,7 +179,7 @@ pub fn generics_to_str(generics: &ast::Generics, to_str(generics, print_generics, intr) } -pub fn path_to_str(p: @ast::Path, intr: @ident_interner) -> ~str { +pub fn path_to_str(p: &ast::Path, intr: @ident_interner) -> ~str { to_str(p, |a,b| print_path(a, b, false), intr) } @@ -208,11 +208,11 @@ pub fn block_to_str(blk: &ast::blk, intr: @ident_interner) -> ~str { } } -pub fn meta_item_to_str(mi: @ast::meta_item, intr: @ident_interner) -> ~str { +pub fn meta_item_to_str(mi: &ast::meta_item, intr: @ident_interner) -> ~str { to_str(mi, print_meta_item, intr) } -pub fn attribute_to_str(attr: ast::attribute, intr: @ident_interner) -> ~str { +pub fn attribute_to_str(attr: &ast::attribute, intr: @ident_interner) -> ~str { to_str(attr, print_attribute, intr) } @@ -314,30 +314,30 @@ pub fn synth_comment(s: @ps, text: ~str) { word(s.s, "*/"); } -pub fn commasep(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN)) { +pub fn commasep(s: @ps, b: breaks, elts: &[T], op: &fn(@ps, &T)) { box(s, 0u, b); let mut first = true; for elts.iter().advance |elt| { if first { first = false; } else { word_space(s, ","); } - op(s, copy *elt); + op(s, elt); } end(s); } -pub fn commasep_cmnt(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN), - get_span: &fn(IN) -> codemap::span) { +pub fn commasep_cmnt(s: @ps, b: breaks, elts: &[T], op: &fn(@ps, &T), + get_span: &fn(&T) -> codemap::span) { box(s, 0u, b); let len = elts.len(); let mut i = 0u; for elts.iter().advance |elt| { - maybe_print_comment(s, get_span(copy *elt).hi); - op(s, copy *elt); + maybe_print_comment(s, get_span(elt).hi); + op(s, elt); i += 1u; if i < len { word(s.s, ","); - maybe_print_trailing_comment(s, get_span(copy *elt), - Some(get_span(copy elts[i]).hi)); + maybe_print_trailing_comment(s, get_span(elt), + Some(get_span(&elts[i]).hi)); space_if_not_bol(s); } } @@ -345,14 +345,13 @@ pub fn commasep_cmnt(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN), } pub fn commasep_exprs(s: @ps, b: breaks, exprs: &[@ast::expr]) { - fn expr_span(expr: @ast::expr) -> codemap::span { return expr.span; } - commasep_cmnt(s, b, exprs, print_expr, expr_span); + commasep_cmnt(s, b, exprs, |p, &e| print_expr(p, e), |e| e.span); } pub fn print_mod(s: @ps, _mod: &ast::_mod, attrs: &[ast::attribute]) { print_inner_attributes(s, attrs); for _mod.view_items.iter().advance |vitem| { - print_view_item(s, *vitem); + print_view_item(s, vitem); } for _mod.items.iter().advance |item| { print_item(s, *item); } } @@ -361,19 +360,19 @@ pub fn print_foreign_mod(s: @ps, nmod: &ast::foreign_mod, attrs: &[ast::attribute]) { print_inner_attributes(s, attrs); for nmod.view_items.iter().advance |vitem| { - print_view_item(s, *vitem); + print_view_item(s, vitem); } for nmod.items.iter().advance |item| { print_foreign_item(s, *item); } } -pub fn print_opt_lifetime(s: @ps, lifetime: Option<@ast::Lifetime>) { +pub fn print_opt_lifetime(s: @ps, lifetime: &Option) { for lifetime.iter().advance |l| { - print_lifetime(s, *l); + print_lifetime(s, l); nbsp(s); } } -pub fn print_type(s: @ps, ty: @ast::Ty) { +pub fn print_type(s: @ps, ty: &ast::Ty) { maybe_print_comment(s, ty.span.lo); ibox(s, 0u); match ty.node { @@ -392,7 +391,7 @@ pub fn print_type(s: @ps, ty: @ast::Ty) { word(s.s, "]"); } ast::ty_ptr(ref mt) => { word(s.s, "*"); print_mt(s, mt); } - ast::ty_rptr(lifetime, ref mt) => { + ast::ty_rptr(ref lifetime, ref mt) => { word(s.s, "&"); print_opt_lifetime(s, lifetime); print_mt(s, mt); @@ -408,18 +407,18 @@ pub fn print_type(s: @ps, ty: @ast::Ty) { ast::ty_bare_fn(f) => { let generics = ast::Generics {lifetimes: copy f.lifetimes, ty_params: opt_vec::Empty}; - print_ty_fn(s, Some(f.abis), None, None, + print_ty_fn(s, Some(f.abis), None, &None, f.purity, ast::Many, &f.decl, None, &None, Some(&generics), None); } ast::ty_closure(f) => { let generics = ast::Generics {lifetimes: copy f.lifetimes, ty_params: opt_vec::Empty}; - print_ty_fn(s, None, Some(f.sigil), f.region, + print_ty_fn(s, None, Some(f.sigil), &f.region, f.purity, f.onceness, &f.decl, None, &f.bounds, Some(&generics), None); } - ast::ty_path(path, bounds, _) => print_bounded_path(s, path, bounds), + ast::ty_path(ref path, ref bounds, _) => print_bounded_path(s, path, bounds), ast::ty_fixed_length_vec(ref mt, v) => { word(s.s, "["); match mt.mutbl { @@ -443,7 +442,7 @@ pub fn print_type(s: @ps, ty: @ast::Ty) { end(s); } -pub fn print_foreign_item(s: @ps, item: @ast::foreign_item) { +pub fn print_foreign_item(s: @ps, item: &ast::foreign_item) { hardbreak_if_not_bol(s); maybe_print_comment(s, item.span.lo); print_outer_attributes(s, item.attrs); @@ -455,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"); @@ -470,14 +469,14 @@ pub fn print_foreign_item(s: @ps, item: @ast::foreign_item) { } } -pub fn print_item(s: @ps, item: @ast::item) { +pub fn print_item(s: @ps, item: &ast::item) { hardbreak_if_not_bol(s); maybe_print_comment(s, item.span.lo); print_outer_attributes(s, item.attrs); 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"); @@ -531,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")); @@ -560,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, 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); @@ -568,12 +567,12 @@ pub fn print_item(s: @ps, item: @ast::item) { } match opt_trait { - Some(t) => { + &Some(ref t) => { print_trait_ref(s, t); space(s.s); word_space(s, "for"); } - None => () + &None => () }; print_type(s, ty); @@ -600,7 +599,7 @@ pub fn print_item(s: @ps, item: @ast::item) { if i != 0 { word_space(s, "+"); } - print_path(s, trait_.path, false); + print_path(s, &trait_.path, false); } } word(s.s, " "); @@ -610,7 +609,7 @@ pub fn print_item(s: @ps, item: @ast::item) { } bclose(s, item.span); } - ast::item_mac(codemap::spanned { node: ast::mac_invoc_tt(pth, ref tts), + ast::item_mac(codemap::spanned { node: ast::mac_invoc_tt(ref pth, ref tts), _}) => { print_visibility(s, item.vis); print_path(s, pth, false); @@ -618,7 +617,7 @@ pub fn print_item(s: @ps, item: @ast::item) { print_ident(s, item.ident); cbox(s, indent_unit); popen(s); - print_tts(s, *tts); + print_tts(s, &(tts.as_slice())); pclose(s); end(s); } @@ -627,7 +626,7 @@ pub fn print_item(s: @ps, item: @ast::item) { } fn print_trait_ref(s: @ps, t: &ast::trait_ref) { - print_path(s, t.path, false); + print_path(s, &t.path, false); } pub fn print_enum_def(s: @ps, enum_definition: &ast::enum_def, @@ -681,7 +680,7 @@ pub fn print_visibility(s: @ps, vis: ast::visibility) { } pub fn print_struct(s: @ps, - struct_def: @ast::struct_def, + struct_def: &ast::struct_def, generics: &ast::Generics, ident: ast::ident, span: codemap::span) { @@ -695,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); } } } @@ -719,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, ","); } } @@ -738,7 +737,7 @@ pub fn print_struct(s: @ps, /// expression arguments as expressions). It can be done! I think. pub fn print_tt(s: @ps, tt: &ast::token_tree) { match *tt { - ast::tt_delim(ref tts) => print_tts(s, *tts), + ast::tt_delim(ref tts) => print_tts(s, &(tts.as_slice())), ast::tt_tok(_, ref tk) => { word(s.s, parse::token::to_str(s.intr, tk)); } @@ -759,7 +758,7 @@ pub fn print_tt(s: @ps, tt: &ast::token_tree) { } } -pub fn print_tts(s: @ps, tts: &[ast::token_tree]) { +pub fn print_tts(s: @ps, tts: & &[ast::token_tree]) { ibox(s, 0); for tts.iter().enumerate().advance |(i, tt)| { if i != 0 { @@ -777,8 +776,8 @@ pub fn print_variant(s: @ps, v: &ast::variant) { print_ident(s, v.node.name); if !args.is_empty() { popen(s); - fn print_variant_arg(s: @ps, arg: ast::variant_arg) { - print_type(s, arg.ty); + fn print_variant_arg(s: @ps, arg: &ast::variant_arg) { + print_type(s, &arg.ty); } commasep(s, consistent, *args, print_variant_arg); pclose(s); @@ -804,7 +803,7 @@ pub fn print_ty_method(s: @ps, m: &ast::ty_method) { hardbreak_if_not_bol(s); maybe_print_comment(s, m.span.lo); print_outer_attributes(s, m.attrs); - print_ty_fn(s, None, None, None, m.purity, ast::Many, + print_ty_fn(s, None, None, &None, m.purity, ast::Many, &m.decl, Some(m.ident), &None, Some(&m.generics), Some(/*bad*/ copy m.explicit_self.node)); word(s.s, ";"); @@ -817,7 +816,7 @@ pub fn print_trait_method(s: @ps, m: &ast::trait_method) { } } -pub fn print_method(s: @ps, meth: @ast::method) { +pub fn print_method(s: @ps, meth: &ast::method) { hardbreak_if_not_bol(s); maybe_print_comment(s, meth.span.lo); print_outer_attributes(s, meth.attrs); @@ -832,7 +831,7 @@ pub fn print_outer_attributes(s: @ps, attrs: &[ast::attribute]) { let mut count = 0; for attrs.iter().advance |attr| { match attr.node.style { - ast::attr_outer => { print_attribute(s, *attr); count += 1; } + ast::attr_outer => { print_attribute(s, attr); count += 1; } _ => {/* fallthrough */ } } } @@ -844,7 +843,7 @@ pub fn print_inner_attributes(s: @ps, attrs: &[ast::attribute]) { for attrs.iter().advance |attr| { match attr.node.style { ast::attr_inner => { - print_attribute(s, *attr); + print_attribute(s, attr); if !attr.node.is_sugared_doc { word(s.s, ";"); } @@ -856,11 +855,11 @@ pub fn print_inner_attributes(s: @ps, attrs: &[ast::attribute]) { if count > 0 { hardbreak_if_not_bol(s); } } -pub fn print_attribute(s: @ps, attr: ast::attribute) { +pub fn print_attribute(s: @ps, attr: &ast::attribute) { hardbreak_if_not_bol(s); maybe_print_comment(s, attr.span.lo); if attr.node.is_sugared_doc { - let meta = attr::attr_meta(attr); + let meta = attr::attr_meta(*attr); let comment = attr::get_meta_item_value_str(meta).get(); word(s.s, comment); } else { @@ -947,7 +946,7 @@ pub fn print_possibly_embedded_block_(s: @ps, print_inner_attributes(s, attrs); - for blk.node.view_items.iter().advance |vi| { print_view_item(s, *vi); } + for blk.node.view_items.iter().advance |vi| { print_view_item(s, vi); } for blk.node.stmts.iter().advance |st| { print_stmt(s, *st); } @@ -963,7 +962,7 @@ pub fn print_possibly_embedded_block_(s: @ps, (s.ann.post)(ann_node); } -pub fn print_if(s: @ps, test: @ast::expr, blk: &ast::blk, +pub fn print_if(s: @ps, test: &ast::expr, blk: &ast::blk, elseopt: Option<@ast::expr>, chk: bool) { head(s, "if"); if chk { word_nbsp(s, "check"); } @@ -1005,11 +1004,11 @@ pub fn print_if(s: @ps, test: @ast::expr, blk: &ast::blk, pub fn print_mac(s: @ps, m: &ast::mac) { match m.node { - ast::mac_invoc_tt(pth, ref tts) => { + ast::mac_invoc_tt(ref pth, ref tts) => { print_path(s, pth, false); word(s.s, "!"); popen(s); - print_tts(s, *tts); + print_tts(s, &tts.as_slice()); pclose(s); } } @@ -1021,7 +1020,7 @@ pub fn print_vstore(s: @ps, t: ast::vstore) { ast::vstore_fixed(None) => word(s.s, "_"), ast::vstore_uniq => word(s.s, "~"), ast::vstore_box => word(s.s, "@"), - ast::vstore_slice(r) => { + ast::vstore_slice(ref r) => { word(s.s, "&"); print_opt_lifetime(s, r); } @@ -1088,15 +1087,15 @@ pub fn print_call_post(s: @ps, } } -pub fn print_expr(s: @ps, expr: @ast::expr) { - fn print_field(s: @ps, field: ast::field) { +pub fn print_expr(s: @ps, expr: &ast::expr) { + fn print_field(s: @ps, field: &ast::field) { ibox(s, indent_unit); print_ident(s, field.node.ident); word_space(s, ":"); print_expr(s, field.node.expr); end(s); } - fn get_span(field: ast::field) -> codemap::span { return field.span; } + fn get_span(field: &ast::field) -> codemap::span { return field.span; } maybe_print_comment(s, expr.span.lo); ibox(s, indent_unit); @@ -1134,7 +1133,7 @@ pub fn print_expr(s: @ps, expr: @ast::expr) { end(s); } - ast::expr_struct(path, ref fields, wth) => { + ast::expr_struct(ref path, ref fields, wth) => { print_path(s, path, true); word(s.s, "{"); commasep_cmnt(s, consistent, (*fields), print_field, get_span); @@ -1199,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"); @@ -1359,7 +1358,7 @@ pub fn print_expr(s: @ps, expr: @ast::expr) { print_expr(s, index); word(s.s, "]"); } - ast::expr_path(path) => print_path(s, path, true), + ast::expr_path(ref path) => print_path(s, path, true), ast::expr_self => word(s.s, "self"), ast::expr_break(opt_ident) => { word(s.s, "break"); @@ -1434,15 +1433,15 @@ pub fn print_expr(s: @ps, expr: @ast::expr) { end(s); } -pub fn print_local_decl(s: @ps, loc: @ast::local) { +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); } } } -pub fn print_decl(s: @ps, decl: @ast::decl) { +pub fn print_decl(s: @ps, decl: &ast::decl) { maybe_print_comment(s, decl.span.lo); match decl.node { ast::decl_local(ref loc) => { @@ -1454,7 +1453,7 @@ pub fn print_decl(s: @ps, decl: @ast::decl) { word_nbsp(s, "mut"); } - fn print_local(s: @ps, loc: @ast::local) { + fn print_local(s: @ps, loc: &ast::local) { ibox(s, indent_unit); print_local_decl(s, loc); end(s); @@ -1479,14 +1478,14 @@ pub fn print_ident(s: @ps, ident: ast::ident) { word(s.s, ident_to_str(&ident)); } -pub fn print_for_decl(s: @ps, loc: @ast::local, coll: @ast::expr) { +pub fn print_for_decl(s: @ps, loc: &ast::local, coll: &ast::expr) { print_local_decl(s, loc); space(s.s); word_space(s, "in"); print_expr(s, coll); } -fn print_path_(s: @ps, path: @ast::Path, colons_before_params: bool, +fn print_path_(s: @ps, path: &ast::Path, colons_before_params: bool, opt_bounds: &Option>) { maybe_print_comment(s, path.span.lo); if path.global { word(s.s, "::"); } @@ -1505,7 +1504,7 @@ fn print_path_(s: @ps, path: @ast::Path, colons_before_params: bool, word(s.s, "<"); for path.rp.iter().advance |r| { - print_lifetime(s, *r); + print_lifetime(s, r); if !path.types.is_empty() { word_space(s, ","); } @@ -1518,24 +1517,24 @@ fn print_path_(s: @ps, path: @ast::Path, colons_before_params: bool, } } -pub fn print_path(s: @ps, path: @ast::Path, colons_before_params: bool) { +pub fn print_path(s: @ps, path: &ast::Path, colons_before_params: bool) { print_path_(s, path, colons_before_params, &None) } -pub fn print_bounded_path(s: @ps, path: @ast::Path, +pub fn print_bounded_path(s: @ps, path: &ast::Path, bounds: &Option>) { print_path_(s, path, false, bounds) } -pub fn print_irrefutable_pat(s: @ps, pat: @ast::pat) { +pub fn print_irrefutable_pat(s: @ps, pat: &ast::pat) { print_pat(s, pat, false) } -pub fn print_refutable_pat(s: @ps, pat: @ast::pat) { +pub fn print_refutable_pat(s: @ps, pat: &ast::pat) { print_pat(s, pat, true) } -pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) { +pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) { maybe_print_comment(s, pat.span.lo); let ann_node = node_pat(s, pat); (s.ann.pre)(ann_node); @@ -1543,7 +1542,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) { is that it doesn't matter */ match pat.node { ast::pat_wild => word(s.s, "_"), - ast::pat_ident(binding_mode, path, sub) => { + ast::pat_ident(binding_mode, ref path, sub) => { if refutable { match binding_mode { ast::bind_by_ref(mutbl) => { @@ -1562,7 +1561,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) { None => () } } - ast::pat_enum(path, ref args_) => { + ast::pat_enum(ref path, ref args_) => { print_path(s, path, true); match *args_ { None => word(s.s, "(*)"), @@ -1570,23 +1569,23 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) { if !args.is_empty() { popen(s); commasep(s, inconsistent, *args, - |s, p| print_pat(s, p, refutable)); + |s, &p| print_pat(s, p, refutable)); pclose(s); } else { } } } } - ast::pat_struct(path, ref fields, etc) => { + ast::pat_struct(ref path, ref fields, etc) => { print_path(s, path, true); word(s.s, "{"); - fn print_field(s: @ps, f: ast::field_pat, refutable: bool) { + fn print_field(s: @ps, f: &ast::field_pat, refutable: bool) { cbox(s, indent_unit); print_ident(s, f.ident); word_space(s, ":"); print_pat(s, f.pat, refutable); end(s); } - fn get_span(f: ast::field_pat) -> codemap::span { return f.pat.span; } + fn get_span(f: &ast::field_pat) -> codemap::span { return f.pat.span; } commasep_cmnt(s, consistent, *fields, |s, f| print_field(s,f,refutable), get_span); @@ -1598,7 +1597,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) { } ast::pat_tup(ref elts) => { popen(s); - commasep(s, inconsistent, *elts, |s, p| print_pat(s, p, refutable)); + commasep(s, inconsistent, *elts, |s, &p| print_pat(s, p, refutable)); if elts.len() == 1 { word(s.s, ","); } @@ -1625,7 +1624,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) { } ast::pat_vec(ref before, slice, ref after) => { word(s.s, "["); - do commasep(s, inconsistent, *before) |s, p| { + do commasep(s, inconsistent, *before) |s, &p| { print_pat(s, p, refutable); } for slice.iter().advance |&p| { @@ -1634,7 +1633,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) { print_pat(s, p, refutable); if !after.is_empty() { word_space(s, ","); } } - do commasep(s, inconsistent, *after) |s, p| { + do commasep(s, inconsistent, *after) |s, &p| { print_pat(s, p, refutable); } word(s.s, "]"); @@ -1643,8 +1642,8 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) { (s.ann.post)(ann_node); } -pub fn explicit_self_to_str(explicit_self: ast::explicit_self_, intr: @ident_interner) -> ~str { - to_str(explicit_self, |a, b| { print_explicit_self(a, b); () }, intr) +pub fn explicit_self_to_str(explicit_self: &ast::explicit_self_, intr: @ident_interner) -> ~str { + to_str(explicit_self, |a, &b| { print_explicit_self(a, b); () }, intr) } // Returns whether it printed anything @@ -1653,7 +1652,7 @@ pub fn print_explicit_self(s: @ps, explicit_self: ast::explicit_self_) -> bool { ast::sty_static => { return false; } ast::sty_value => { word(s.s, "self"); } ast::sty_uniq => { word(s.s, "~self"); } - ast::sty_region(lt, m) => { + ast::sty_region(ref lt, m) => { word(s.s, "&"); print_opt_lifetime(s, lt); print_mutability(s, m); @@ -1694,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); @@ -1712,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); } } } @@ -1727,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); } } @@ -1748,7 +1747,7 @@ pub fn print_bounds(s: @ps, bounds: &OptVec, } match *bound { - TraitTyParamBound(tref) => print_trait_ref(s, tref), + TraitTyParamBound(ref tref) => print_trait_ref(s, tref), RegionTyParamBound => word(s.s, "'static"), } } @@ -1774,7 +1773,7 @@ pub fn print_generics(s: @ps, generics: &ast::Generics) { let idx = idx - generics.lifetimes.len(); let param = generics.ty_params.get(idx); print_ident(s, param.ident); - print_bounds(s, param.bounds, false); + print_bounds(s, ¶m.bounds, false); } } @@ -1784,12 +1783,12 @@ pub fn print_generics(s: @ps, generics: &ast::Generics) { } commasep(s, inconsistent, ints, - |s, i| print_item(s, generics, i)); + |s, &i| print_item(s, generics, i)); word(s.s, ">"); } } -pub fn print_meta_item(s: @ps, item: @ast::meta_item) { +pub fn print_meta_item(s: @ps, item: &ast::meta_item) { ibox(s, indent_unit); match item.node { ast::meta_word(name) => word(s.s, name), @@ -1804,8 +1803,8 @@ pub fn print_meta_item(s: @ps, item: @ast::meta_item) { commasep( s, consistent, - /* FIXME (#2543) */ copy *items, - print_meta_item + items.as_slice(), + |p, &i| print_meta_item(p, i) ); pclose(s); } @@ -1813,9 +1812,9 @@ pub fn print_meta_item(s: @ps, item: @ast::meta_item) { end(s); } -pub fn print_view_path(s: @ps, vp: @ast::view_path) { +pub fn print_view_path(s: @ps, vp: &ast::view_path) { match vp.node { - ast::view_path_simple(ident, path, _) => { + ast::view_path_simple(ident, ref path, _) => { if path.idents[path.idents.len()-1u] != ident { print_ident(s, ident); space(s.s); @@ -1824,12 +1823,12 @@ pub fn print_view_path(s: @ps, vp: @ast::view_path) { print_path(s, path, false); } - ast::view_path_glob(path, _) => { + ast::view_path_glob(ref path, _) => { print_path(s, path, false); word(s.s, "::*"); } - ast::view_path_list(path, ref idents, _) => { + ast::view_path_list(ref path, ref idents, _) => { print_path(s, path, false); word(s.s, "::{"); do commasep(s, inconsistent, (*idents)) |s, w| { @@ -1841,10 +1840,10 @@ pub fn print_view_path(s: @ps, vp: @ast::view_path) { } pub fn print_view_paths(s: @ps, vps: &[@ast::view_path]) { - commasep(s, inconsistent, vps, print_view_path); + commasep(s, inconsistent, vps, |p, &vp| print_view_path(p, vp)); } -pub fn print_view_item(s: @ps, item: @ast::view_item) { +pub fn print_view_item(s: @ps, item: &ast::view_item) { hardbreak_if_not_bol(s); maybe_print_comment(s, item.span.lo); print_outer_attributes(s, item.attrs); @@ -1855,7 +1854,7 @@ pub fn print_view_item(s: @ps, item: @ast::view_item) { print_ident(s, id); if !mta.is_empty() { popen(s); - commasep(s, consistent, *mta, print_meta_item); + commasep(s, consistent, *mta, |p, &i| print_meta_item(p, i)); pclose(s); } } @@ -1883,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"); @@ -1892,7 +1891,7 @@ pub fn print_arg(s: @ps, input: ast::arg) { ast::ty_infer => print_irrefutable_pat(s, input.pat), _ => { match input.pat.node { - ast::pat_ident(_, path, _) if + ast::pat_ident(_, ref path, _) if path.idents.len() == 1 && path.idents[0] == parse::token::special_idents::invalid => { // Do nothing. @@ -1903,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); @@ -1912,7 +1911,7 @@ pub fn print_arg(s: @ps, input: ast::arg) { pub fn print_ty_fn(s: @ps, opt_abis: Option, opt_sigil: Option, - opt_region: Option<@ast::Lifetime>, + opt_region: &Option, purity: ast::purity, onceness: ast::Onceness, decl: &ast::fn_decl, @@ -1945,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); @@ -1959,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); } } @@ -2003,7 +2002,7 @@ pub fn print_remaining_comments(s: @ps) { } } -pub fn print_literal(s: @ps, lit: @ast::lit) { +pub fn print_literal(s: @ps, lit: &ast::lit) { maybe_print_comment(s, lit.span.lo); match next_lit(s, lit.span.lo) { Some(ref ltrl) => { @@ -2056,7 +2055,7 @@ pub fn print_literal(s: @ps, lit: @ast::lit) { } } -pub fn lit_to_str(l: @ast::lit) -> ~str { +pub fn lit_to_str(l: &ast::lit) -> ~str { return to_str(l, print_literal, parse::token::mk_fake_ident_interner()); } @@ -2139,10 +2138,10 @@ pub fn print_string(s: @ps, st: &str) { word(s.s, "\""); } -pub fn to_str(t: T, f: @fn(@ps, T), intr: @ident_interner) -> ~str { +pub fn to_str(t: &T, f: &fn(@ps, &T), intr: @ident_interner) -> ~str { do io::with_str_writer |wr| { let s = rust_printer(wr, intr); - f(s, copy t); + f(s, t); eof(s.s); } } @@ -2273,7 +2272,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 5bde51ad70fa2..b2d9d49f0ee77 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -72,7 +72,7 @@ pub fn generics_of_fn(fk: &fn_kind) -> Generics { pub struct Visitor { visit_mod: @fn(&_mod, span, node_id, (E, vt)), - visit_view_item: @fn(@view_item, (E, vt)), + visit_view_item: @fn(&view_item, (E, vt)), visit_foreign_item: @fn(@foreign_item, (E, vt)), visit_item: @fn(@item, (E, vt)), visit_local: @fn(@local, (E, vt)), @@ -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)), @@ -123,7 +123,7 @@ pub fn visit_crate(c: &crate, (e, v): (E, vt)) { } pub fn visit_mod(m: &_mod, _sp: span, _id: node_id, (e, v): (E, vt)) { - for m.view_items.iter().advance |vi| { (v.visit_view_item)(*vi, (copy e, v)); } + for m.view_items.iter().advance |vi| { (v.visit_view_item)(vi, (copy e, v)); } for m.items.iter().advance |i| { (v.visit_item)(*i, (copy e, v)); } } @@ -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)) @@ -139,12 +139,12 @@ pub fn visit_local(loc: &local, (e, v): (E, vt)) { } fn visit_trait_ref(tref: &ast::trait_ref, (e, v): (E, vt)) { - visit_path(tref.path, (e, v)); + visit_path(&tref.path, (e, v)); } 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)); } @@ -166,10 +166,10 @@ pub fn visit_item(i: &item, (e, v): (E, vt)) { } item_mod(ref m) => (v.visit_mod)(m, i.span, i.id, (e, v)), item_foreign_mod(ref nm) => { - for nm.view_items.iter().advance |vi| { (v.visit_view_item)(*vi, (copy e, v)); } + 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,9 +181,9 @@ 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| { + for traits.iter().advance |p| { visit_trait_ref(p, (copy e, v)); } (v.visit_ty)(ty, (copy e, v)); @@ -197,7 +197,7 @@ pub fn visit_item(i: &item, (e, v): (E, vt)) { } item_trait(ref generics, ref traits, ref methods) => { (v.visit_generics)(generics, (copy e, v)); - for traits.iter().advance |p| { visit_path(p.path, (copy e, v)); } + for traits.iter().advance |p| { visit_path(&p.path, (copy e, v)); } for methods.iter().advance |m| { (v.visit_trait_method)(m, (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,27 +232,27 @@ 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(p, bounds, _) => { + ty_path(ref p, ref bounds, _) => { visit_path(p, (copy e, v)); do bounds.map |bounds| { visit_ty_param_bounds(bounds, (copy e, v)); @@ -267,12 +267,12 @@ 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)) { match p.node { - pat_enum(path, ref children) => { + pat_enum(ref path, ref children) => { visit_path(path, (copy e, v)); for children.iter().advance |children| { for children.iter().advance |child| { @@ -280,7 +280,7 @@ pub fn visit_pat(p: &pat, (e, v): (E, vt)) { } } } - pat_struct(path, ref fields, _) => { + pat_struct(ref path, ref fields, _) => { visit_path(path, (copy e, v)); for fields.iter().advance |f| { (v.visit_pat)(f.pat, (copy e, v)); @@ -294,7 +294,7 @@ pub fn visit_pat(p: &pat, (e, v): (E, vt)) { pat_box(inner) | pat_uniq(inner) | pat_region(inner) => { (v.visit_pat)(inner, (e, v)) }, - pat_ident(_, path, ref inner) => { + pat_ident(_, ref path, ref inner) => { visit_path(path, (copy e, v)); for inner.iter().advance |subpat| { (v.visit_pat)(*subpat, (copy e, v)) @@ -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)); } } @@ -336,7 +336,7 @@ pub fn visit_ty_param_bounds(bounds: &OptVec, (e, v): (E, vt)) { for bounds.iter().advance |bound| { match *bound { - TraitTyParamBound(ty) => visit_trait_ref(ty, (copy e, v)), + TraitTyParamBound(ref ty) => visit_trait_ref(ty, (copy e, v)), RegionTyParamBound => {} } } @@ -344,16 +344,16 @@ pub fn visit_ty_param_bounds(bounds: &OptVec, pub fn visit_generics(generics: &Generics, (e, v): (E, vt)) { for generics.ty_params.iter().advance |tp| { - visit_ty_param_bounds(tp.bounds, (copy e, v)); + visit_ty_param_bounds(&tp.bounds, (copy e, v)); } } 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,12 +409,12 @@ 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)) { for b.node.view_items.iter().advance |vi| { - (v.visit_view_item)(*vi, (copy e, v)); + (v.visit_view_item)(vi, (copy e, v)); } for b.node.stmts.iter().advance |s| { (v.visit_stmt)(*s, (copy e, v)); @@ -458,7 +458,7 @@ pub fn visit_expr(ex: @expr, (e, v): (E, vt)) { (v.visit_expr)(element, (copy e, v)); (v.visit_expr)(count, (copy e, v)); } - expr_struct(p, ref flds, base) => { + expr_struct(ref p, ref flds, base) => { visit_path(p, (copy e, v)); for flds.iter().advance |f| { (v.visit_expr)(f.node.expr, (copy e, v)); @@ -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,14 +527,14 @@ 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) => { (v.visit_expr)(a, (copy e, v)); (v.visit_expr)(b, (copy e, v)); } - expr_path(p) => visit_path(p, (copy e, v)), + expr_path(ref p) => visit_path(p, (copy e, v)), expr_self => (), expr_break(_) => (), expr_again(_) => (), @@ -568,7 +568,7 @@ pub fn visit_arm(a: &arm, (e, v): (E, vt)) { pub struct SimpleVisitor { visit_mod: @fn(&_mod, span, node_id), - visit_view_item: @fn(@view_item), + visit_view_item: @fn(&view_item), visit_foreign_item: @fn(@foreign_item), visit_item: @fn(@item), visit_local: @fn(@local), @@ -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 { @@ -629,7 +629,7 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { f(m, sp, id); visit_mod(m, sp, id, (e, v)); } - fn v_view_item(f: @fn(@view_item), vi: @view_item, (e, v): ((), vt<()>)) { + fn v_view_item(f: @fn(&view_item), vi: &view_item, (e, v): ((), vt<()>)) { f(vi); visit_view_item(vi, (e, v)); } @@ -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);