23
23
24
24
pub use self :: Code :: * ;
25
25
26
- use ast_map :: { self , Node } ;
26
+ use front :: map :: { self , Node } ;
27
27
use syntax:: abi;
28
- use syntax:: ast:: { Block , FnDecl , NodeId } ;
29
- use syntax:: ast;
28
+ use rustc_front:: hir:: { Block , FnDecl } ;
29
+ use syntax:: ast:: { NodeId , Ident } ;
30
+ use rustc_front:: hir as ast;
30
31
use syntax:: codemap:: Span ;
31
- use syntax :: visit:: FnKind ;
32
+ use rustc_front :: visit:: FnKind ;
32
33
33
34
/// An FnLikeNode is a Node that is like a fn, in that it has a decl
34
35
/// and a body (as well as a NodeId, a span, etc).
@@ -40,7 +41,7 @@ use syntax::visit::FnKind;
40
41
///
41
42
/// To construct one, use the `Code::from_node` function.
42
43
#[ derive( Copy , Clone ) ]
43
- pub struct FnLikeNode < ' a > { node : ast_map :: Node < ' a > }
44
+ pub struct FnLikeNode < ' a > { node : map :: Node < ' a > }
44
45
45
46
/// MaybeFnLike wraps a method that indicates if an object
46
47
/// corresponds to some FnLikeNode.
@@ -86,7 +87,7 @@ pub enum Code<'a> {
86
87
}
87
88
88
89
impl < ' a > Code < ' a > {
89
- pub fn id ( & self ) -> ast :: NodeId {
90
+ pub fn id ( & self ) -> NodeId {
90
91
match * self {
91
92
FnLikeCode ( node) => node. id ( ) ,
92
93
BlockCode ( block) => block. id ,
@@ -95,7 +96,7 @@ impl<'a> Code<'a> {
95
96
96
97
/// Attempts to construct a Code from presumed FnLike or Block node input.
97
98
pub fn from_node ( node : Node ) -> Option < Code > {
98
- if let ast_map :: NodeBlock ( block) = node {
99
+ if let map :: NodeBlock ( block) = node {
99
100
Some ( BlockCode ( block) )
100
101
} else {
101
102
FnLikeNode :: from_node ( node) . map ( |fn_like| FnLikeCode ( fn_like) )
@@ -106,15 +107,15 @@ impl<'a> Code<'a> {
106
107
/// These are all the components one can extract from a fn item for
107
108
/// use when implementing FnLikeNode operations.
108
109
struct ItemFnParts < ' a > {
109
- ident : ast :: Ident ,
110
+ ident : Ident ,
110
111
decl : & ' a ast:: FnDecl ,
111
112
unsafety : ast:: Unsafety ,
112
113
constness : ast:: Constness ,
113
114
abi : abi:: Abi ,
114
115
vis : ast:: Visibility ,
115
116
generics : & ' a ast:: Generics ,
116
117
body : & ' a Block ,
117
- id : ast :: NodeId ,
118
+ id : NodeId ,
118
119
span : Span
119
120
}
120
121
@@ -137,10 +138,10 @@ impl<'a> FnLikeNode<'a> {
137
138
/// Attempts to construct a FnLikeNode from presumed FnLike node input.
138
139
pub fn from_node ( node : Node ) -> Option < FnLikeNode > {
139
140
let fn_like = match node {
140
- ast_map :: NodeItem ( item) => item. is_fn_like ( ) ,
141
- ast_map :: NodeTraitItem ( tm) => tm. is_fn_like ( ) ,
142
- ast_map :: NodeImplItem ( _) => true ,
143
- ast_map :: NodeExpr ( e) => e. is_fn_like ( ) ,
141
+ map :: NodeItem ( item) => item. is_fn_like ( ) ,
142
+ map :: NodeTraitItem ( tm) => tm. is_fn_like ( ) ,
143
+ map :: NodeImplItem ( _) => true ,
144
+ map :: NodeExpr ( e) => e. is_fn_like ( ) ,
144
145
_ => false
145
146
} ;
146
147
if fn_like {
@@ -202,7 +203,7 @@ impl<'a> FnLikeNode<'a> {
202
203
fn handle < A , I , M , C > ( self , item_fn : I , method : M , closure : C ) -> A where
203
204
I : FnOnce ( ItemFnParts < ' a > ) -> A ,
204
205
M : FnOnce ( NodeId ,
205
- ast :: Ident ,
206
+ Ident ,
206
207
& ' a ast:: MethodSig ,
207
208
Option < ast:: Visibility > ,
208
209
& ' a ast:: Block ,
@@ -211,7 +212,7 @@ impl<'a> FnLikeNode<'a> {
211
212
C : FnOnce ( ClosureParts < ' a > ) -> A ,
212
213
{
213
214
match self . node {
214
- ast_map :: NodeItem ( i) => match i. node {
215
+ map :: NodeItem ( i) => match i. node {
215
216
ast:: ItemFn ( ref decl, unsafety, constness, abi, ref generics, ref block) =>
216
217
item_fn ( ItemFnParts {
217
218
id : i. id ,
@@ -227,13 +228,13 @@ impl<'a> FnLikeNode<'a> {
227
228
} ) ,
228
229
_ => panic ! ( "item FnLikeNode that is not fn-like" ) ,
229
230
} ,
230
- ast_map :: NodeTraitItem ( ti) => match ti. node {
231
+ map :: NodeTraitItem ( ti) => match ti. node {
231
232
ast:: MethodTraitItem ( ref sig, Some ( ref body) ) => {
232
233
method ( ti. id , ti. ident , sig, None , body, ti. span )
233
234
}
234
235
_ => panic ! ( "trait method FnLikeNode that is not fn-like" ) ,
235
236
} ,
236
- ast_map :: NodeImplItem ( ii) => {
237
+ map :: NodeImplItem ( ii) => {
237
238
match ii. node {
238
239
ast:: MethodImplItem ( ref sig, ref body) => {
239
240
method ( ii. id , ii. ident , sig, Some ( ii. vis ) , body, ii. span )
@@ -243,7 +244,7 @@ impl<'a> FnLikeNode<'a> {
243
244
}
244
245
}
245
246
}
246
- ast_map :: NodeExpr ( e) => match e. node {
247
+ map :: NodeExpr ( e) => match e. node {
247
248
ast:: ExprClosure ( _, ref decl, ref block) =>
248
249
closure ( ClosureParts :: new ( & * * decl, & * * block, e. id , e. span ) ) ,
249
250
_ => panic ! ( "expr FnLikeNode that is not fn-like" ) ,
0 commit comments