@@ -1195,12 +1195,16 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
11951195 }
11961196 ty:: AssocKind :: Fn => {
11971197 let fn_data = if let hir:: TraitItemKind :: Fn ( m_sig, m) = & ast_item. kind {
1198- let param_names = match * m {
1199- hir:: TraitFn :: Required ( ref names) => self . encode_fn_param_names ( names) ,
1200- hir:: TraitFn :: Provided ( body) => self . encode_fn_param_names_for_body ( body) ,
1198+ match * m {
1199+ hir:: TraitFn :: Required ( ref names) => {
1200+ record ! ( self . tables. fn_arg_names[ def_id] <- * names)
1201+ }
1202+ hir:: TraitFn :: Provided ( body) => {
1203+ record ! ( self . tables. fn_arg_names[ def_id] <- self . tcx. hir( ) . body_param_names( body) )
1204+ }
12011205 } ;
12021206 record ! ( self . tables. asyncness[ def_id] <- m_sig. header. asyncness) ;
1203- FnData { constness : hir:: Constness :: NotConst , param_names }
1207+ FnData { constness : hir:: Constness :: NotConst }
12041208 } else {
12051209 bug ! ( )
12061210 } ;
@@ -1262,14 +1266,14 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
12621266 ty:: AssocKind :: Fn => {
12631267 let fn_data = if let hir:: ImplItemKind :: Fn ( ref sig, body) = ast_item. kind {
12641268 record ! ( self . tables. asyncness[ def_id] <- sig. header. asyncness) ;
1269+ record ! ( self . tables. fn_arg_names[ def_id] <- self . tcx. hir( ) . body_param_names( body) ) ;
12651270 FnData {
12661271 // Can be inside `impl const Trait`, so using sig.header.constness is not reliable
12671272 constness : if self . tcx . is_const_fn_raw ( def_id) {
12681273 hir:: Constness :: Const
12691274 } else {
12701275 hir:: Constness :: NotConst
12711276 } ,
1272- param_names : self . encode_fn_param_names_for_body ( body) ,
12731277 }
12741278 } else {
12751279 bug ! ( )
@@ -1294,14 +1298,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
12941298 }
12951299 }
12961300
1297- fn encode_fn_param_names_for_body ( & mut self , body_id : hir:: BodyId ) -> Lazy < [ Ident ] > {
1298- self . lazy ( self . tcx . hir ( ) . body_param_names ( body_id) )
1299- }
1300-
1301- fn encode_fn_param_names ( & mut self , param_names : & [ Ident ] ) -> Lazy < [ Ident ] > {
1302- self . lazy ( param_names. iter ( ) )
1303- }
1304-
13051301 fn encode_mir ( & mut self ) {
13061302 if self . is_proc_macro {
13071303 return ;
@@ -1405,10 +1401,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14051401 }
14061402 hir:: ItemKind :: Fn ( ref sig, .., body) => {
14071403 record ! ( self . tables. asyncness[ def_id] <- sig. header. asyncness) ;
1408- let data = FnData {
1409- constness : sig. header . constness ,
1410- param_names : self . encode_fn_param_names_for_body ( body) ,
1411- } ;
1404+ record ! ( self . tables. fn_arg_names[ def_id] <- self . tcx. hir( ) . body_param_names( body) ) ;
1405+ let data = FnData { constness : sig. header . constness } ;
14121406
14131407 EntryKind :: Fn ( self . lazy ( data) )
14141408 }
@@ -1874,13 +1868,13 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
18741868 match nitem. kind {
18751869 hir:: ForeignItemKind :: Fn ( _, ref names, _) => {
18761870 record ! ( self . tables. asyncness[ def_id] <- hir:: IsAsync :: NotAsync ) ;
1871+ record ! ( self . tables. fn_arg_names[ def_id] <- * names) ;
18771872 let data = FnData {
18781873 constness : if self . tcx . is_const_fn_raw ( def_id) {
18791874 hir:: Constness :: Const
18801875 } else {
18811876 hir:: Constness :: NotConst
18821877 } ,
1883- param_names : self . encode_fn_param_names ( names) ,
18841878 } ;
18851879 record ! ( self . tables. kind[ def_id] <- EntryKind :: ForeignFn ( self . lazy( data) ) ) ;
18861880 }
0 commit comments