1212//! for the `Code` associated with a particular NodeId.
1313
1414use crate :: hir:: map:: Map ;
15- use rustc_ast:: Attribute ;
1615use rustc_hir as hir;
1716use rustc_hir:: intravisit:: FnKind ;
1817use rustc_hir:: { Expr , FnDecl , Node } ;
@@ -105,7 +104,6 @@ struct ItemFnParts<'a> {
105104 body : hir:: BodyId ,
106105 id : hir:: HirId ,
107106 span : Span ,
108- attrs : & ' a [ Attribute ] ,
109107}
110108
111109/// These are all the components one can extract from a closure expr
@@ -115,18 +113,11 @@ struct ClosureParts<'a> {
115113 body : hir:: BodyId ,
116114 id : hir:: HirId ,
117115 span : Span ,
118- attrs : & ' a [ Attribute ] ,
119116}
120117
121118impl < ' a > ClosureParts < ' a > {
122- fn new (
123- d : & ' a FnDecl < ' a > ,
124- b : hir:: BodyId ,
125- id : hir:: HirId ,
126- s : Span ,
127- attrs : & ' a [ Attribute ] ,
128- ) -> Self {
129- ClosureParts { decl : d, body : b, id, span : s, attrs }
119+ fn new ( d : & ' a FnDecl < ' a > , b : hir:: BodyId , id : hir:: HirId , s : Span ) -> Self {
120+ ClosureParts { decl : d, body : b, id, span : s }
130121 }
131122}
132123
@@ -146,31 +137,31 @@ impl<'a> FnLikeNode<'a> {
146137 pub fn body ( self ) -> hir:: BodyId {
147138 self . handle (
148139 |i : ItemFnParts < ' a > | i. body ,
149- |_, _, _: & ' a hir:: FnSig < ' a > , _, body : hir:: BodyId , _, _ | body,
140+ |_, _, _: & ' a hir:: FnSig < ' a > , _, body : hir:: BodyId , _| body,
150141 |c : ClosureParts < ' a > | c. body ,
151142 )
152143 }
153144
154145 pub fn decl ( self ) -> & ' a FnDecl < ' a > {
155146 self . handle (
156147 |i : ItemFnParts < ' a > | & * i. decl ,
157- |_, _, sig : & ' a hir:: FnSig < ' a > , _, _, _, _ | & sig. decl ,
148+ |_, _, sig : & ' a hir:: FnSig < ' a > , _, _, _| & sig. decl ,
158149 |c : ClosureParts < ' a > | c. decl ,
159150 )
160151 }
161152
162153 pub fn span ( self ) -> Span {
163154 self . handle (
164155 |i : ItemFnParts < ' _ > | i. span ,
165- |_, _, _: & ' a hir:: FnSig < ' a > , _, _, span, _ | span,
156+ |_, _, _: & ' a hir:: FnSig < ' a > , _, _, span| span,
166157 |c : ClosureParts < ' _ > | c. span ,
167158 )
168159 }
169160
170161 pub fn id ( self ) -> hir:: HirId {
171162 self . handle (
172163 |i : ItemFnParts < ' _ > | i. id ,
173- |id, _, _: & ' a hir:: FnSig < ' a > , _, _, _, _ | id,
164+ |id, _, _: & ' a hir:: FnSig < ' a > , _, _, _| id,
174165 |c : ClosureParts < ' _ > | c. id ,
175166 )
176167 }
@@ -189,12 +180,11 @@ impl<'a> FnLikeNode<'a> {
189180
190181 pub fn kind ( self ) -> FnKind < ' a > {
191182 let item = |p : ItemFnParts < ' a > | -> FnKind < ' a > {
192- FnKind :: ItemFn ( p. ident , p. generics , p. header , p. vis , p. attrs )
193- } ;
194- let closure = |c : ClosureParts < ' a > | FnKind :: Closure ( c. attrs ) ;
195- let method = |_, ident : Ident , sig : & ' a hir:: FnSig < ' a > , vis, _, _, attrs| {
196- FnKind :: Method ( ident, sig, vis, attrs)
183+ FnKind :: ItemFn ( p. ident , p. generics , p. header , p. vis )
197184 } ;
185+ let closure = |_: ClosureParts < ' a > | FnKind :: Closure ;
186+ let method =
187+ |_, ident : Ident , sig : & ' a hir:: FnSig < ' a > , vis, _, _| FnKind :: Method ( ident, sig, vis) ;
198188 self . handle ( item, method, closure)
199189 }
200190
@@ -208,7 +198,6 @@ impl<'a> FnLikeNode<'a> {
208198 Option < & ' a hir:: Visibility < ' a > > ,
209199 hir:: BodyId ,
210200 Span ,
211- & ' a [ Attribute ] ,
212201 ) -> A ,
213202 C : FnOnce ( ClosureParts < ' a > ) -> A ,
214203 {
@@ -221,27 +210,26 @@ impl<'a> FnLikeNode<'a> {
221210 body : block,
222211 vis : & i. vis ,
223212 span : i. span ,
224- attrs : & i. attrs ,
225213 header : sig. header ,
226214 generics,
227215 } ) ,
228216 _ => bug ! ( "item FnLikeNode that is not fn-like" ) ,
229217 } ,
230218 Node :: TraitItem ( ti) => match ti. kind {
231219 hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Provided ( body) ) => {
232- method ( ti. hir_id ( ) , ti. ident , sig, None , body, ti. span , & ti . attrs )
220+ method ( ti. hir_id ( ) , ti. ident , sig, None , body, ti. span )
233221 }
234222 _ => bug ! ( "trait method FnLikeNode that is not fn-like" ) ,
235223 } ,
236224 Node :: ImplItem ( ii) => match ii. kind {
237225 hir:: ImplItemKind :: Fn ( ref sig, body) => {
238- method ( ii. hir_id ( ) , ii. ident , sig, Some ( & ii. vis ) , body, ii. span , & ii . attrs )
226+ method ( ii. hir_id ( ) , ii. ident , sig, Some ( & ii. vis ) , body, ii. span )
239227 }
240228 _ => bug ! ( "impl method FnLikeNode that is not fn-like" ) ,
241229 } ,
242230 Node :: Expr ( e) => match e. kind {
243231 hir:: ExprKind :: Closure ( _, ref decl, block, _fn_decl_span, _gen) => {
244- closure ( ClosureParts :: new ( & decl, block, e. hir_id , e. span , & e . attrs ) )
232+ closure ( ClosureParts :: new ( & decl, block, e. hir_id , e. span ) )
245233 }
246234 _ => bug ! ( "expr FnLikeNode that is not fn-like" ) ,
247235 } ,
0 commit comments