diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2015-03-11 23:38:58 +0200 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2015-03-11 23:39:16 +0200 |
| commit | 9da918548d77182ca64f375fb6da24036d5ad60c (patch) | |
| tree | f04e278a2ffe86f73f9499fa6d23e4dd14faa3c6 /src/libsyntax/ast_map | |
| parent | ce10fa8d12cb20d9eee59fffeeaadfcca8badf4a (diff) | |
| download | rust-9da918548d77182ca64f375fb6da24036d5ad60c.tar.gz rust-9da918548d77182ca64f375fb6da24036d5ad60c.zip | |
syntax: move MethMac to MacImplItem and combine {Provided,Required}Method into MethodTraitItem.
Diffstat (limited to 'src/libsyntax/ast_map')
| -rw-r--r-- | src/libsyntax/ast_map/blocks.rs | 28 | ||||
| -rw-r--r-- | src/libsyntax/ast_map/mod.rs | 22 |
2 files changed, 26 insertions, 24 deletions
diff --git a/src/libsyntax/ast_map/blocks.rs b/src/libsyntax/ast_map/blocks.rs index 345ccf902cd..16a339cdcb5 100644 --- a/src/libsyntax/ast_map/blocks.rs +++ b/src/libsyntax/ast_map/blocks.rs @@ -28,7 +28,6 @@ use ast::{Block, FnDecl, NodeId}; use ast; use ast_map::{Node}; use ast_map; -use ast_util::PostExpansionMethod; use codemap::Span; use visit; @@ -65,7 +64,7 @@ impl MaybeFnLike for ast::Item { impl MaybeFnLike for ast::TraitItem { fn is_fn_like(&self) -> bool { - match self.node { ast::ProvidedMethod(_) => true, _ => false, } + match self.node { ast::MethodTraitItem(_, Some(_)) => true, _ => false, } } } @@ -156,25 +155,25 @@ impl<'a> FnLikeNode<'a> { pub fn body(self) -> &'a Block { self.handle(|i: ItemFnParts<'a>| &*i.body, - |_, _, m: &'a ast::Method, _| m.pe_body(), + |_, _, _: &'a ast::MethodSig, body: &'a ast::Block, _| body, |c: ClosureParts<'a>| c.body) } pub fn decl(self) -> &'a FnDecl { self.handle(|i: ItemFnParts<'a>| &*i.decl, - |_, _, m: &'a ast::Method, _| &m.pe_sig().decl, + |_, _, sig: &'a ast::MethodSig, _, _| &sig.decl, |c: ClosureParts<'a>| c.decl) } pub fn span(self) -> Span { self.handle(|i: ItemFnParts| i.span, - |_, _, _: &'a ast::Method, span| span, + |_, _, _: &'a ast::MethodSig, _, span| span, |c: ClosureParts| c.span) } pub fn id(self) -> NodeId { self.handle(|i: ItemFnParts| i.id, - |id, _, _: &'a ast::Method, _| id, + |id, _, _: &'a ast::MethodSig, _, _| id, |c: ClosureParts| c.id) } @@ -185,15 +184,15 @@ impl<'a> FnLikeNode<'a> { let closure = |_: ClosureParts| { visit::FkFnBlock }; - let method = |_, ident, m: &'a ast::Method, _| { - visit::FkMethod(ident, m) + let method = |_, ident, sig: &'a ast::MethodSig, _, _| { + visit::FkMethod(ident, sig) }; self.handle(item, method, closure) } fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A where I: FnOnce(ItemFnParts<'a>) -> A, - M: FnOnce(NodeId, ast::Ident, &'a ast::Method, Span) -> A, + M: FnOnce(NodeId, ast::Ident, &'a ast::MethodSig, &'a ast::Block, Span) -> A, C: FnOnce(ClosureParts<'a>) -> A, { match self.node { @@ -206,13 +205,18 @@ impl<'a> FnLikeNode<'a> { _ => panic!("item FnLikeNode that is not fn-like"), }, ast_map::NodeTraitItem(ti) => match ti.node { - ast::ProvidedMethod(ref m) => method(ti.id, ti.ident, m, ti.span), + ast::MethodTraitItem(ref sig, Some(ref body)) => { + method(ti.id, ti.ident, sig, body, ti.span) + } _ => panic!("trait method FnLikeNode that is not fn-like"), }, ast_map::NodeImplItem(ii) => { match ii.node { - ast::MethodImplItem(ref m) => method(ii.id, ii.ident, m, ii.span), - ast::TypeImplItem(_) => { + ast::MethodImplItem(ref sig, ref body) => { + method(ii.id, ii.ident, sig, body, ii.span) + } + ast::TypeImplItem(_) | + ast::MacImplItem(_) => { panic!("impl method FnLikeNode that is not fn-like") } } diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index 606c6b640df..48bb044cb18 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -929,16 +929,10 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String { } Some(NodeImplItem(ii)) => { match ii.node { - MethodImplItem(ref m) => { - match *m { - MethDecl(..) => - format!("method {} in {}{}", - token::get_ident(ii.ident), - map.path_to_string(id), id_str), - MethMac(ref mac) => - format!("method macro {}{}", - pprust::mac_to_string(mac), id_str) - } + MethodImplItem(..) => { + format!("method {} in {}{}", + token::get_ident(ii.ident), + map.path_to_string(id), id_str) } TypeImplItem(_) => { format!("assoc type {} in {}{}", @@ -946,13 +940,17 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String { map.path_to_string(id), id_str) } + MacImplItem(ref mac) => { + format!("method macro {}{}", + pprust::mac_to_string(mac), id_str) + } } } Some(NodeTraitItem(ti)) => { let kind = match ti.node { - RequiredMethod(_) => "required method", - ProvidedMethod(_) => "provided method", + MethodTraitItem(..) => "trait method", TypeTraitItem(..) => "assoc type", +// ConstTraitItem(..) => "assoc constant" }; format!("{} {} in {}{}", |
