@@ -194,16 +194,115 @@ fn resolve_core_macro(
194194
195195impl LangItems {
196196 fn resolve_manually ( & mut self , db : & dyn DefDatabase ) {
197- ( || {
198- let into_future_into_future = self . IntoFutureIntoFuture ?;
199- let ItemContainerId :: TraitId ( into_future) = into_future_into_future. loc ( db) . container
200- else {
201- return None ;
197+ let parent_trait =
198+ |lang_item : & mut Option < TraitId > , def : Option < FunctionId > | match def?. loc ( db) . container
199+ {
200+ ItemContainerId :: TraitId ( trait_) => {
201+ * lang_item = Some ( trait_) ;
202+ Some ( trait_)
203+ }
204+ _ => None ,
205+ } ;
206+ let assoc_types =
207+ |trait_ : TraitId , assoc_types : & mut [ ( & mut Option < TypeAliasId > , Symbol ) ] | {
208+ let trait_items = trait_. trait_items ( db) ;
209+ for ( assoc_type, name) in assoc_types {
210+ * * assoc_type =
211+ trait_items. associated_type_by_name ( & Name :: new_symbol_root ( name. clone ( ) ) ) ;
212+ }
202213 } ;
203- self . IntoFuture = Some ( into_future) ;
204- self . IntoFutureOutput = into_future
205- . trait_items ( db)
206- . associated_type_by_name ( & Name :: new_symbol_root ( sym:: Output ) ) ;
214+ let methods = |trait_ : TraitId , assoc_types : & mut [ ( & mut Option < FunctionId > , Symbol ) ] | {
215+ let trait_items = trait_. trait_items ( db) ;
216+ for ( assoc_type, name) in assoc_types {
217+ * * assoc_type = trait_items. method_by_name ( & Name :: new_symbol_root ( name. clone ( ) ) ) ;
218+ }
219+ } ;
220+ ( || {
221+ let into_future = parent_trait ( & mut self . IntoFuture , self . IntoFutureIntoFuture ) ?;
222+ assoc_types ( into_future, & mut [ ( & mut self . IntoFutureOutput , sym:: Output ) ] ) ;
223+ Some ( ( ) )
224+ } ) ( ) ;
225+
226+ ( || {
227+ let into_iterator = parent_trait ( & mut self . IntoIterator , self . IntoIterIntoIter ) ?;
228+ assoc_types (
229+ into_iterator,
230+ & mut [
231+ ( & mut self . IntoIteratorItem , sym:: Item ) ,
232+ ( & mut self . IntoIterIntoIterType , sym:: IntoIter ) ,
233+ ] ,
234+ ) ;
235+ Some ( ( ) )
236+ } ) ( ) ;
237+
238+ ( || {
239+ assoc_types ( self . Iterator ?, & mut [ ( & mut self . IteratorItem , sym:: Item ) ] ) ;
240+ Some ( ( ) )
241+ } ) ( ) ;
242+
243+ ( || {
244+ assoc_types ( self . AsyncIterator ?, & mut [ ( & mut self . AsyncIteratorItem , sym:: Item ) ] ) ;
245+ Some ( ( ) )
246+ } ) ( ) ;
247+
248+ for ( op_trait, op_method, op_method_name) in [
249+ ( self . Fn , & mut self . Fn_call , sym:: call) ,
250+ ( self . FnMut , & mut self . FnMut_call_mut , sym:: call_mut) ,
251+ ( self . FnOnce , & mut self . FnOnce_call_once , sym:: call_once) ,
252+ ( self . AsyncFn , & mut self . AsyncFn_async_call , sym:: async_call) ,
253+ ( self . AsyncFnMut , & mut self . AsyncFnMut_async_call_mut , sym:: async_call_mut) ,
254+ ( self . AsyncFnOnce , & mut self . AsyncFnOnce_async_call_once , sym:: async_call_once) ,
255+ ( self . Not , & mut self . Not_not , sym:: not) ,
256+ ( self . Neg , & mut self . Neg_neg , sym:: neg) ,
257+ ( self . Add , & mut self . Add_add , sym:: add) ,
258+ ( self . Mul , & mut self . Mul_mul , sym:: mul) ,
259+ ( self . Sub , & mut self . Sub_sub , sym:: sub) ,
260+ ( self . Div , & mut self . Div_div , sym:: div) ,
261+ ( self . Rem , & mut self . Rem_rem , sym:: rem) ,
262+ ( self . Shl , & mut self . Shl_shl , sym:: shl) ,
263+ ( self . Shr , & mut self . Shr_shr , sym:: shr) ,
264+ ( self . BitXor , & mut self . BitXor_bitxor , sym:: bitxor) ,
265+ ( self . BitOr , & mut self . BitOr_bitor , sym:: bitor) ,
266+ ( self . BitAnd , & mut self . BitAnd_bitand , sym:: bitand) ,
267+ ( self . AddAssign , & mut self . AddAssign_add_assign , sym:: add_assign) ,
268+ ( self . MulAssign , & mut self . MulAssign_mul_assign , sym:: mul_assign) ,
269+ ( self . SubAssign , & mut self . SubAssign_sub_assign , sym:: sub_assign) ,
270+ ( self . DivAssign , & mut self . DivAssign_div_assign , sym:: div_assign) ,
271+ ( self . RemAssign , & mut self . RemAssign_rem_assign , sym:: rem_assign) ,
272+ ( self . ShlAssign , & mut self . ShlAssign_shl_assign , sym:: shl_assign) ,
273+ ( self . ShrAssign , & mut self . ShrAssign_shr_assign , sym:: shr_assign) ,
274+ ( self . BitXorAssign , & mut self . BitXorAssign_bitxor_assign , sym:: bitxor_assign) ,
275+ ( self . BitOrAssign , & mut self . BitOrAssign_bitor_assign , sym:: bitor_assign) ,
276+ ( self . BitAndAssign , & mut self . BitAndAssign_bitand_assign , sym:: bitand_assign) ,
277+ ( self . Drop , & mut self . Drop_drop , sym:: drop) ,
278+ ( self . Debug , & mut self . Debug_fmt , sym:: fmt) ,
279+ ( self . Deref , & mut self . Deref_deref , sym:: deref) ,
280+ ( self . DerefMut , & mut self . DerefMut_deref_mut , sym:: deref_mut) ,
281+ ( self . Index , & mut self . Index_index , sym:: index) ,
282+ ( self . IndexMut , & mut self . IndexMut_index_mut , sym:: index_mut) ,
283+ ] {
284+ ( || {
285+ methods ( op_trait?, & mut [ ( op_method, op_method_name) ] ) ;
286+ Some ( ( ) )
287+ } ) ( ) ;
288+ }
289+ ( || {
290+ methods (
291+ self . PartialEq ?,
292+ & mut [ ( & mut self . PartialEq_eq , sym:: eq) , ( & mut self . PartialEq_ne , sym:: ne) ] ,
293+ ) ;
294+ Some ( ( ) )
295+ } ) ( ) ;
296+ ( || {
297+ methods (
298+ self . PartialOrd ?,
299+ & mut [
300+ ( & mut self . PartialOrd_le , sym:: le) ,
301+ ( & mut self . PartialOrd_lt , sym:: lt) ,
302+ ( & mut self . PartialOrd_ge , sym:: ge) ,
303+ ( & mut self . PartialOrd_gt , sym:: gt) ,
304+ ] ,
305+ ) ;
207306 Some ( ( ) )
208307 } ) ( ) ;
209308 }
@@ -567,6 +666,53 @@ language_item_table! { LangItems =>
567666 core:: clone, Clone , CloneDerive ;
568667
569668 @resolve_manually:
570- IntoFuture , TraitId ;
571- IntoFutureOutput , TypeAliasId ;
669+
670+ IntoFuture , TraitId ;
671+ IntoFutureOutput , TypeAliasId ;
672+ IntoIterator , TraitId ;
673+ IntoIteratorItem , TypeAliasId ;
674+ IntoIterIntoIterType , TypeAliasId ;
675+ IteratorItem , TypeAliasId ;
676+ AsyncIteratorItem , TypeAliasId ;
677+
678+ Fn_call , FunctionId ;
679+ FnMut_call_mut , FunctionId ;
680+ FnOnce_call_once , FunctionId ;
681+ AsyncFn_async_call , FunctionId ;
682+ AsyncFnMut_async_call_mut , FunctionId ;
683+ AsyncFnOnce_async_call_once , FunctionId ;
684+ Not_not , FunctionId ;
685+ Neg_neg , FunctionId ;
686+ Add_add , FunctionId ;
687+ Mul_mul , FunctionId ;
688+ Sub_sub , FunctionId ;
689+ Div_div , FunctionId ;
690+ Rem_rem , FunctionId ;
691+ Shl_shl , FunctionId ;
692+ Shr_shr , FunctionId ;
693+ BitXor_bitxor , FunctionId ;
694+ BitOr_bitor , FunctionId ;
695+ BitAnd_bitand , FunctionId ;
696+ AddAssign_add_assign , FunctionId ;
697+ MulAssign_mul_assign , FunctionId ;
698+ SubAssign_sub_assign , FunctionId ;
699+ DivAssign_div_assign , FunctionId ;
700+ RemAssign_rem_assign , FunctionId ;
701+ ShlAssign_shl_assign , FunctionId ;
702+ ShrAssign_shr_assign , FunctionId ;
703+ BitXorAssign_bitxor_assign , FunctionId ;
704+ BitOrAssign_bitor_assign , FunctionId ;
705+ BitAndAssign_bitand_assign , FunctionId ;
706+ PartialEq_eq , FunctionId ;
707+ PartialEq_ne , FunctionId ;
708+ PartialOrd_le , FunctionId ;
709+ PartialOrd_lt , FunctionId ;
710+ PartialOrd_ge , FunctionId ;
711+ PartialOrd_gt , FunctionId ;
712+ Drop_drop , FunctionId ;
713+ Debug_fmt , FunctionId ;
714+ Deref_deref , FunctionId ;
715+ DerefMut_deref_mut , FunctionId ;
716+ Index_index , FunctionId ;
717+ IndexMut_index_mut , FunctionId ;
572718}
0 commit comments