diff options
| author | James Miller <bladeon@gmail.com> | 2013-07-06 16:57:11 +1200 |
|---|---|---|
| committer | James Miller <bladeon@gmail.com> | 2013-07-07 22:51:10 +1200 |
| commit | 47eca2113c5c55a4ffbb8c11a38c8ca7a79a1d72 (patch) | |
| tree | 264e2191016cfc1b83d7a79169a3f6bc19706c1e /src/libsyntax/ext | |
| parent | 46a1f54666dbeb9a926c75b380f62571963cbacc (diff) | |
| download | rust-47eca2113c5c55a4ffbb8c11a38c8ca7a79a1d72.tar.gz rust-47eca2113c5c55a4ffbb8c11a38c8ca7a79a1d72.zip | |
De-share ast::Ty
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/build.rs | 103 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/ty.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/ast_builder.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/check.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/pipec.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/proto.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 10 |
8 files changed, 77 insertions, 78 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 0388115d7ef..73220ec2881 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -39,31 +39,30 @@ pub trait AstBuilder { global: bool, idents: ~[ast::ident], rp: Option<ast::Lifetime>, - types: ~[@ast::Ty]) + types: ~[ast::Ty]) -> ast::Path; // types - fn ty_mt(&self, ty: @ast::Ty, mutbl: ast::mutability) -> ast::mt; + fn ty_mt(&self, ty: ast::Ty, mutbl: ast::mutability) -> ast::mt; - fn ty(&self, span: span, ty: ast::ty_) -> @ast::Ty; - fn ty_path(&self, ast::Path, Option<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, + 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; + mutbl: ast::mutability) -> ast::Ty; + fn ty_uniq(&self, span: span, ty: ast::Ty) -> ast::Ty; + fn ty_box(&self, span: span, ty: ast::Ty, mutbl: ast::mutability) -> ast::Ty; - fn ty_option(&self, ty: @ast::Ty) -> @ast::Ty; - fn ty_infer(&self, sp: span) -> @ast::Ty; - fn ty_nil(&self) -> @ast::Ty; + fn ty_option(&self, ty: ast::Ty) -> ast::Ty; + fn ty_infer(&self, sp: span) -> ast::Ty; + fn ty_nil(&self) -> ast::Ty; - fn ty_vars(&self, ty_params: &OptVec<ast::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 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; @@ -167,25 +166,25 @@ pub trait AstBuilder { fn item(&self, span: span, name: ident, attrs: ~[ast::attribute], node: ast::item_) -> @ast::item; - fn arg(&self, span: span, name: ident, ty: @ast::Ty) -> ast::arg; + fn arg(&self, span: span, name: ident, ty: ast::Ty) -> ast::arg; // XXX unused self - fn fn_decl(&self, inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl; + fn fn_decl(&self, inputs: ~[ast::arg], output: ast::Ty) -> ast::fn_decl; fn item_fn_poly(&self, span: span, name: ident, inputs: ~[ast::arg], - output: @ast::Ty, + output: ast::Ty, generics: Generics, body: ast::blk) -> @ast::item; fn item_fn(&self, span: span, name: ident, inputs: ~[ast::arg], - output: @ast::Ty, + output: ast::Ty, body: ast::blk) -> @ast::item; - fn variant(&self, span: span, name: ident, tys: ~[@ast::Ty]) -> ast::variant; + fn variant(&self, span: span, name: ident, tys: ~[ast::Ty]) -> ast::variant; fn item_enum_poly(&self, span: span, name: ident, @@ -207,9 +206,9 @@ pub trait AstBuilder { fn item_ty_poly(&self, span: span, name: ident, - ty: @ast::Ty, + ty: ast::Ty, generics: Generics) -> @ast::item; - fn item_ty(&self, span: span, name: ident, ty: @ast::Ty) -> @ast::item; + fn item_ty(&self, span: span, name: ident, ty: ast::Ty) -> @ast::item; fn attribute(&self, sp: span, mi: @ast::meta_item) -> ast::attribute; @@ -239,7 +238,7 @@ impl AstBuilder for @ExtCtxt { global: bool, idents: ~[ast::ident], rp: Option<ast::Lifetime>, - types: ~[@ast::Ty]) + types: ~[ast::Ty]) -> ast::Path { ast::Path { span: sp, @@ -250,15 +249,15 @@ impl AstBuilder for @ExtCtxt { } } - fn ty_mt(&self, ty: @ast::Ty, mutbl: ast::mutability) -> ast::mt { + fn ty_mt(&self, ty: ast::Ty, mutbl: ast::mutability) -> ast::mt { ast::mt { - ty: ty, + ty: ~ty, mutbl: mutbl } } - fn ty(&self, span: span, ty: ast::ty_) -> @ast::Ty { - @ast::Ty { + fn ty(&self, span: span, ty: ast::ty_) -> ast::Ty { + ast::Ty { id: self.next_id(), span: span, node: ty @@ -266,7 +265,7 @@ impl AstBuilder for @ExtCtxt { } fn ty_path(&self, path: ast::Path, bounds: Option<OptVec<ast::TyParamBound>>) - -> @ast::Ty { + -> ast::Ty { self.ty(path.span, ast::ty_path(path, bounds, self.next_id())) } @@ -274,28 +273,28 @@ impl AstBuilder for @ExtCtxt { // Might need to take bounds as an argument in the future, if you ever want // to generate a bounded existential trait type. fn ty_ident(&self, span: span, ident: ast::ident) - -> @ast::Ty { + -> ast::Ty { self.ty_path(self.path_ident(span, ident), None) } fn ty_rptr(&self, span: span, - ty: @ast::Ty, + ty: ast::Ty, lifetime: Option<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, @@ -308,20 +307,20 @@ impl AstBuilder for @ExtCtxt { ~[ ty ]), None) } - fn ty_field_imm(&self, span: span, name: ident, ty: @ast::Ty) -> ast::ty_field { + fn ty_field_imm(&self, span: span, name: ident, ty: ast::Ty) -> ast::ty_field { respan(span, ast::ty_field_ { ident: name, - mt: ast::mt { ty: ty, mutbl: ast::m_imm }, + mt: ast::mt { ty: ~ty, mutbl: ast::m_imm }, }) } - fn ty_infer(&self, span: span) -> @ast::Ty { + fn ty_infer(&self, span: span) -> ast::Ty { self.ty(span, ast::ty_infer) } - fn ty_nil(&self) -> @ast::Ty { - @ast::Ty { + fn ty_nil(&self) -> ast::Ty { + ast::Ty { id: self.next_id(), node: ast::ty_nil, span: dummy_sp(), @@ -335,12 +334,12 @@ impl AstBuilder for @ExtCtxt { // these are strange, and probably shouldn't be used outside of // pipes. Specifically, the global version possible generates // incorrect code. - fn ty_vars(&self, ty_params: &OptVec<ast::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))) @@ -642,7 +641,7 @@ impl AstBuilder for @ExtCtxt { self.lambda1(span, self.blk(span, stmts, None), ident) } - fn arg(&self, span: span, ident: ast::ident, ty: @ast::Ty) -> ast::arg { + fn arg(&self, span: span, ident: ast::ident, ty: ast::Ty) -> ast::arg { let arg_pat = self.pat_ident(span, ident); ast::arg { is_mutbl: false, @@ -653,7 +652,7 @@ impl AstBuilder for @ExtCtxt { } // XXX unused self - fn fn_decl(&self, inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl { + fn fn_decl(&self, inputs: ~[ast::arg], output: ast::Ty) -> ast::fn_decl { ast::fn_decl { inputs: inputs, output: output, @@ -677,7 +676,7 @@ impl AstBuilder for @ExtCtxt { span: span, name: ident, inputs: ~[ast::arg], - output: @ast::Ty, + output: ast::Ty, generics: Generics, body: ast::blk) -> @ast::item { self.item(span, @@ -694,7 +693,7 @@ impl AstBuilder for @ExtCtxt { span: span, name: ident, inputs: ~[ast::arg], - output: @ast::Ty, + output: ast::Ty, body: ast::blk ) -> @ast::item { self.item_fn_poly( @@ -706,10 +705,10 @@ impl AstBuilder for @ExtCtxt { body) } - fn variant(&self, span: span, name: ident, tys: ~[@ast::Ty]) -> ast::variant { - let args = do tys.map |ty| { - ast::variant_arg { ty: *ty, id: self.next_id() } - }; + fn variant(&self, span: span, name: ident, tys: ~[ast::Ty]) -> ast::variant { + let args = tys.consume_iter().transform(|ty| { + ast::variant_arg { ty: ty, id: self.next_id() } + }).collect(); respan(span, ast::variant_ { @@ -773,12 +772,12 @@ impl AstBuilder for @ExtCtxt { ) } - fn item_ty_poly(&self, span: span, name: ident, ty: @ast::Ty, + fn item_ty_poly(&self, span: span, name: ident, ty: ast::Ty, generics: Generics) -> @ast::item { self.item(span, name, ~[], ast::item_ty(ty, generics)) } - fn item_ty(&self, span: span, name: ident, ty: @ast::Ty) -> @ast::item { + fn item_ty(&self, span: span, name: ident, ty: ast::Ty) -> @ast::item { self.item_ty_poly(span, name, ty, ast_util::empty_generics()) } diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 10282cb6f0a..01769482d08 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -456,7 +456,7 @@ impl<'self> MethodDef<'self> { } fn get_ret_ty(&self, cx: @ExtCtxt, span: span, - generics: &Generics, type_ident: ident) -> @ast::Ty { + generics: &Generics, type_ident: ident) -> ast::Ty { self.ret_ty.to_ty(cx, span, type_ident, generics) } @@ -466,7 +466,7 @@ impl<'self> MethodDef<'self> { fn split_self_nonself_args(&self, cx: @ExtCtxt, span: span, type_ident: ident, generics: &Generics) - -> (ast::explicit_self, ~[@expr], ~[@expr], ~[(ident, @ast::Ty)]) { + -> (ast::explicit_self, ~[@expr], ~[@expr], ~[(ident, ast::Ty)]) { let mut self_args = ~[]; let mut nonself_args = ~[]; @@ -514,7 +514,7 @@ impl<'self> MethodDef<'self> { type_ident: ident, generics: &Generics, explicit_self: ast::explicit_self, - arg_types: ~[(ident, @ast::Ty)], + arg_types: ~[(ident, ast::Ty)], body: @expr) -> @ast::method { // create the generics that aren't for Self let fn_generics = self.generics.to_generics(cx, span, type_ident, generics); diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index c820371714b..255bc6c9877 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -61,7 +61,7 @@ impl<'self> Path<'self> { span: span, self_ty: ident, self_generics: &Generics) - -> @ast::Ty { + -> ast::Ty { cx.ty_path(self.to_path(cx, span, self_ty, self_generics), None) } pub fn to_path(&self, @@ -122,7 +122,7 @@ impl<'self> Ty<'self> { span: span, self_ty: ident, self_generics: &Generics) - -> @ast::Ty { + -> ast::Ty { match *self { Ptr(ref ty, ref ptr) => { let raw_ty = ty.to_ty(cx, span, self_ty, self_generics); diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index 58838b0c40b..a4873e6e34b 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -42,19 +42,19 @@ pub fn path_global(ids: ~[ident], span: span) -> ast::Path { } pub trait append_types { - fn add_ty(&self, ty: @ast::Ty) -> ast::Path; - fn add_tys(&self, tys: ~[@ast::Ty]) -> ast::Path; + fn add_ty(&self, ty: ast::Ty) -> ast::Path; + fn add_tys(&self, tys: ~[ast::Ty]) -> ast::Path; } impl append_types for ast::Path { - fn add_ty(&self, ty: @ast::Ty) -> ast::Path { + fn add_ty(&self, ty: ast::Ty) -> ast::Path { ast::Path { types: vec::append_one(copy self.types, ty), .. copy *self } } - fn add_tys(&self, tys: ~[@ast::Ty]) -> ast::Path { + fn add_tys(&self, tys: ~[ast::Ty]) -> ast::Path { ast::Path { types: vec::append(copy self.types, tys), .. copy *self diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs index 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 57174f216fe..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,7 +56,7 @@ impl gen_send for message { next.generics.ty_params.len()); let arg_names = vec::from_fn(tys.len(), |i| cx.ident_of("x_"+i.to_str())); let args_ast: ~[ast::arg] = arg_names.iter().zip(tys.iter()) - .transform(|(n, t)| cx.arg(span, *n, *t)).collect(); + .transform(|(n, t)| cx.arg(span, copy *n, copy *t)).collect(); let pipe_ty = cx.ty_path( path(~[this.data_name()], span) @@ -137,7 +137,7 @@ impl gen_send for message { let arg_names = vec::from_fn(tys.len(), |i| "x_" + i.to_str()); let args_ast: ~[ast::arg] = arg_names.iter().zip(tys.iter()) - .transform(|(n, t)| cx.arg(span, cx.ident_of(*n), *t)).collect(); + .transform(|(&n, t)| cx.arg(span, cx.ident_of(n), copy *t)).collect(); let args_ast = vec::append( ~[cx.arg(span, @@ -189,7 +189,7 @@ impl gen_send for message { } } - fn to_ty(&mut self, cx: @ExtCtxt) -> @ast::Ty { + fn to_ty(&mut self, cx: @ExtCtxt) -> ast::Ty { cx.ty_path(path(~[cx.ident_of(self.name())], self.span()) .add_tys(cx.ty_vars(&self.get_generics().ty_params)), None) } @@ -369,7 +369,7 @@ impl gen_init for protocol { }) } - fn buffer_ty_path(&self, cx: @ExtCtxt) -> @ast::Ty { + fn buffer_ty_path(&self, cx: @ExtCtxt) -> ast::Ty { let mut params: OptVec<ast::TyParam> = opt_vec::Empty; for self.states.iter().advance |s| { for s.generics.ty_params.iter().advance |tp| { diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index f3d7158de52..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,7 +96,7 @@ impl state_ { } /// Returns the type that is used for the messages. - pub fn to_ty(&self, cx: @ExtCtxt) -> @ast::Ty { + pub fn to_ty(&self, cx: @ExtCtxt) -> ast::Ty { cx.ty_path (path(~[cx.ident_of(self.name)],self.span).add_tys( cx.ty_vars(&self.generics.ty_params)), None) @@ -206,7 +206,7 @@ impl protocol_ { pub trait visitor<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()) } |
