diff options
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 76 | ||||
| -rw-r--r-- | src/libsyntax/ast_map.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 197 | ||||
| -rw-r--r-- | src/libsyntax/ext/concat_idents.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic.rs | 21 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/ty.rs | 25 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/log_syntax.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/ast_builder.rs | 26 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/check.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/pipec.rs | 39 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/proto.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 110 | ||||
| -rw-r--r-- | src/libsyntax/opt_vec.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 30 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 140 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 241 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 88 |
23 files changed, 532 insertions, 526 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 2603cbb2dd7..8c37c1510cf 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<Lifetime>, + 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<TyParamBound> + bounds: OptVec<TyParamBound> } #[deriving(Eq, Encodable, Decodable,IterBytes)] @@ -219,7 +219,7 @@ pub type blk = spanned<blk_>; #[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<uint>), // [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<Lifetime>) // &'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<mac_>; #[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<lit_>; @@ -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<Lifetime>, lifetimes: OptVec<Lifetime>, 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<Lifetime>, mt), ty_closure(@TyClosure), ty_bare_fn(@TyBareFn), - ty_tup(~[@Ty]), - ty_path(@Path, @Option<OptVec<TyParamBound>>, node_id), // for #7264; see above + ty_tup(~[Ty]), + ty_path(Path, Option<OptVec<TyParamBound>>, 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<Lifetime>, 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<trait_ref>, // (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 3abbe397054..59020e9d183 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 ce8e24fd444..565f181ab85 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 ad14b567b96..56868874916 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 2c1b4cfc591..73220ec2881 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<ast::Lifetime>, + 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<OptVec<ast::TyParamBound>>) -> @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<OptVec<ast::TyParamBound>>) -> 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::TyParam>) -> ~[@ast::Ty]; - fn ty_vars_global(&self, ty_params: &OptVec<ast::TyParam>) -> ~[@ast::Ty]; - fn ty_field_imm(&self, span: span, name: ident, ty: @ast::Ty) -> ast::ty_field; + 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::TyParam>) -> ~[ast::Ty]; + fn ty_vars_global(&self, ty_params: &OptVec<ast::TyParam>) -> ~[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::TyParamBound>) -> ast::TyParam; + fn typaram(&self, id: ast::ident, bounds: OptVec<ast::TyParamBound>) -> 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<ast::Lifetime>, + 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<OptVec<ast::TyParamBound>>) - -> @ast::Ty { + fn ty_path(&self, path: ast::Path, bounds: Option<OptVec<ast::TyParamBound>>) + -> 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<ast::Lifetime>, 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::TyParamBound>) -> ast::TyParam { + fn typaram(&self, id: ast::ident, bounds: OptVec<ast::TyParamBound>) -> 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::TyParam>) -> ~[@ast::Ty] { + fn ty_vars(&self, ty_params: &OptVec<ast::TyParam>) -> ~[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::TyParam>) -> ~[@ast::Ty] { + fn ty_vars_global(&self, ty_params: &OptVec<ast::TyParam>) -> ~[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 7df8874076e..900668df117 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 0e4fc9d96fa..01769482d08 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 e210853bfb4..255bc6c9877 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<ast::Lifetime> { 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<PtrTy>) 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 2b18ede8879..940bd5ef61c 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 5b789cbc26c..9e6776363a8 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 1af6e7810a5..a4873e6e34b 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 8c2898737a3..adf10215cb5 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<next_state>) { match next { Some(ref next_state) => { diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 0e24725ea99..98fc9aa6178 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<ast::TyParam> = 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<ast::TyParam> = 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 0525c666478..2fe8456c274 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<next_state>); +pub struct message(@str, span, ~[ast::Ty], state, Option<next_state>); 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<next_state>) { 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<Tproto, Tstate, Tmessage> { 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<next_state>) -> Tmessage; } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index db1902753a3..c550e3382a2 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 80dd0c7247b..6de504c66fd 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 96d7685353b..c36b717ea00 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<TyParam>, fld: @ast_fold) -> OptVec<TyParam> { - 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 8e2da3d6eb1..ba3b72ec194 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<T> { @@ -58,6 +58,13 @@ impl<T> OptVec<T> { } } + fn map_consume<U>(self, op: &fn(T) -> U) -> OptVec<U> { + 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 67ae695508b..75d1f35bf38 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -370,7 +370,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, @@ -382,7 +382,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, @@ -432,7 +432,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, @@ -448,7 +448,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")], @@ -469,7 +469,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")], @@ -486,19 +486,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")], @@ -523,19 +523,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")], @@ -546,7 +546,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 @@ -565,7 +565,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 f496af92f93..2f79f60fb60 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] } @@ -637,7 +645,7 @@ impl Parser { // parse a ty_closure type pub fn parse_ty_closure(&self, sigil: ast::Sigil, - region: Option<@ast::Lifetime>) + region: Option<ast::Lifetime>) -> ty_ { /* @@ -815,7 +823,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 } } @@ -826,7 +834,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, @@ -838,13 +846,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) @@ -857,7 +865,7 @@ impl Parser { let pos = self.span.lo; ( return_val, - @Ty { + Ty { id: self.get_id(), node: ty_nil, span: mk_sp(pos, pos), @@ -869,7 +877,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; @@ -959,14 +967,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 ~ @@ -976,7 +984,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)); } @@ -985,7 +993,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) { @@ -1107,7 +1115,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), @@ -1217,10 +1225,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, @@ -1228,7 +1236,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); @@ -1254,7 +1262,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 @@ -1279,7 +1287,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)")); @@ -1287,22 +1295,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::<t1,t2> - 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<OptVec<TyParamBound>>) { + pub fn parse_type_path(&self) -> (ast::Path, Option<OptVec<TyParamBound>>) { 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 @@ -1313,17 +1321,17 @@ impl Parser { } /// parses 0 or 1 lifetime - pub fn parse_opt_lifetime(&self) -> Option<@ast::Lifetime> { + pub fn parse_opt_lifetime(&self) -> Option<ast::Lifetime> { 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 } @@ -1454,7 +1462,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) @@ -1464,7 +1472,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) } @@ -2206,7 +2214,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 @@ -2817,7 +2825,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), @@ -3204,7 +3212,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 "<T>" and "<T:>". - 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 } } @@ -3226,7 +3234,7 @@ impl Parser { // parse a generic use site fn parse_generic_values( - &self) -> (OptVec<ast::Lifetime>, ~[@Ty]) + &self) -> (OptVec<ast::Lifetime>, ~[Ty]) { if !self.eat(&token::LT) { (opt_vec::Empty, ~[]) @@ -3236,7 +3244,7 @@ impl Parser { } fn parse_generic_values_after_lt( - &self) -> (OptVec<ast::Lifetime>, ~[@Ty]) + &self) -> (OptVec<ast::Lifetime>, ~[Ty]) { let lifetimes = self.parse_lifetimes(); let result = self.parse_seq_to_gt( @@ -3334,14 +3342,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) @@ -3446,7 +3454,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 { @@ -3556,9 +3564,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 }) } @@ -3599,15 +3607,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)), @@ -4091,7 +4099,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, @@ -4164,9 +4172,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(), }); } @@ -4325,7 +4333,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, @@ -4575,7 +4583,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, @@ -4605,7 +4613,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, @@ -4617,7 +4625,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, @@ -4633,7 +4641,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, @@ -4673,7 +4681,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() @@ -4686,7 +4694,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) } @@ -4704,7 +4712,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 a50fa416832..09d6ecb40fc 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 5e685d85f95..b545c56778e 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<IN: Copy>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN)) { +pub fn commasep<T>(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<IN: Copy>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN), - get_span: &fn(IN) -> codemap::span) { +pub fn commasep_cmnt<T>(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<IN: Copy>(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<ast::Lifetime>) { 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<OptVec<ast::TyParamBound>>) { 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<OptVec<ast::TyParamBound>>) { 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<ast::TyParamBound>, } 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<AbiSet>, opt_sigil: Option<ast::Sigil>, - opt_region: Option<@ast::Lifetime>, + opt_region: &Option<ast::Lifetime>, 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: Copy>(t: T, f: @fn(@ps, T), intr: @ident_interner) -> ~str { +pub fn to_str<T>(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 5bde51ad70f..b2d9d49f0ee 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<E> { visit_mod: @fn(&_mod, span, node_id, (E, vt<E>)), - visit_view_item: @fn(@view_item, (E, vt<E>)), + visit_view_item: @fn(&view_item, (E, vt<E>)), visit_foreign_item: @fn(@foreign_item, (E, vt<E>)), visit_item: @fn(@item, (E, vt<E>)), visit_local: @fn(@local, (E, vt<E>)), @@ -83,7 +83,7 @@ pub struct Visitor<E> { visit_decl: @fn(@decl, (E, vt<E>)), visit_expr: @fn(@expr, (E, vt<E>)), visit_expr_post: @fn(@expr, (E, vt<E>)), - visit_ty: @fn(@Ty, (E, vt<E>)), + visit_ty: @fn(&Ty, (E, vt<E>)), visit_generics: @fn(&Generics, (E, vt<E>)), visit_fn: @fn(&fn_kind, &fn_decl, &blk, span, node_id, (E, vt<E>)), visit_ty_method: @fn(&ty_method, (E, vt<E>)), @@ -123,7 +123,7 @@ pub fn visit_crate<E: Copy>(c: &crate, (e, v): (E, vt<E>)) { } pub fn visit_mod<E: Copy>(m: &_mod, _sp: span, _id: node_id, (e, v): (E, vt<E>)) { - 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<E>(_vi: &view_item, (_e, _v): (E, vt<E>)) { } pub fn visit_local<E: Copy>(loc: &local, (e, v): (E, vt<E>)) { (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<E: Copy>(loc: &local, (e, v): (E, vt<E>)) { } fn visit_trait_ref<E: Copy>(tref: &ast::trait_ref, (e, v): (E, vt<E>)) { - visit_path(tref.path, (e, v)); + visit_path(&tref.path, (e, v)); } pub fn visit_item<E: Copy>(i: &item, (e, v): (E, vt<E>)) { 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<E: Copy>(i: &item, (e, v): (E, vt<E>)) { } 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<E: Copy>(i: &item, (e, v): (E, vt<E>)) { (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<E: Copy>(i: &item, (e, v): (E, vt<E>)) { } 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<E: Copy>(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<E>(_t: &Ty, (_e,_v): (E, vt<E>)) {} pub fn visit_ty<E: Copy>(t: &Ty, (e, v): (E, vt<E>)) { 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<E: Copy>(t: &Ty, (e, v): (E, vt<E>)) { } pub fn visit_path<E: Copy>(p: &Path, (e, v): (E, vt<E>)) { - 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<E: Copy>(p: &pat, (e, v): (E, vt<E>)) { 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<E: Copy>(p: &pat, (e, v): (E, vt<E>)) { } } } - 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<E: Copy>(p: &pat, (e, v): (E, vt<E>)) { 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<E: Copy>(ni: &foreign_item, (e, v): (E, vt<E>)) { 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<E: Copy>(bounds: &OptVec<TyParamBound>, (e, v): (E, vt<E>)) { 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<E: Copy>(bounds: &OptVec<TyParamBound>, pub fn visit_generics<E: Copy>(generics: &Generics, (e, v): (E, vt<E>)) { 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<E: Copy>(fd: &fn_decl, (e, v): (E, vt<E>)) { 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<E: Copy>(fk: &fn_kind, decl: &fn_decl, body: &blk, _sp: span, } pub fn visit_ty_method<E: Copy>(m: &ty_method, (e, v): (E, vt<E>)) { - 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<E: Copy>(m: &trait_method, (e, v): (E, vt<E>)) { @@ -409,12 +409,12 @@ pub fn visit_struct_def<E: Copy>( } pub fn visit_struct_field<E: Copy>(sf: &struct_field, (e, v): (E, vt<E>)) { - (v.visit_ty)(sf.node.ty, (e, v)); + (v.visit_ty)(&sf.node.ty, (e, v)); } pub fn visit_block<E: Copy>(b: &blk, (e, v): (E, vt<E>)) { 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<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) { (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<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) { 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<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) { 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<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) { 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<E: Copy>(a: &arm, (e, v): (E, vt<E>)) { 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); |
