@@ -245,63 +245,6 @@ fn resolve_associated_item<'tcx>(
245245 span : tcx. def_span ( trait_item_id) ,
246246 } )
247247 }
248- } else if Some ( trait_ref. def_id ) == lang_items. future_trait ( ) {
249- let ty:: Coroutine ( coroutine_def_id, args) = * rcvr_args. type_at ( 0 ) . kind ( ) else {
250- bug ! ( )
251- } ;
252- if Some ( trait_item_id) == tcx. lang_items ( ) . future_poll_fn ( ) {
253- // `Future::poll` is generated by the compiler.
254- Some ( Instance { def : ty:: InstanceDef :: Item ( coroutine_def_id) , args : args } )
255- } else {
256- // All other methods are default methods of the `Future` trait.
257- // (this assumes that `ImplSource::Builtin` is only used for methods on `Future`)
258- debug_assert ! ( tcx. defaultness( trait_item_id) . has_value( ) ) ;
259- Some ( Instance :: new ( trait_item_id, rcvr_args) )
260- }
261- } else if Some ( trait_ref. def_id ) == lang_items. iterator_trait ( ) {
262- let ty:: Coroutine ( coroutine_def_id, args) = * rcvr_args. type_at ( 0 ) . kind ( ) else {
263- bug ! ( )
264- } ;
265- if Some ( trait_item_id) == tcx. lang_items ( ) . next_fn ( ) {
266- // `Iterator::next` is generated by the compiler.
267- Some ( Instance { def : ty:: InstanceDef :: Item ( coroutine_def_id) , args } )
268- } else {
269- // All other methods are default methods of the `Iterator` trait.
270- // (this assumes that `ImplSource::Builtin` is only used for methods on `Iterator`)
271- debug_assert ! ( tcx. defaultness( trait_item_id) . has_value( ) ) ;
272- Some ( Instance :: new ( trait_item_id, rcvr_args) )
273- }
274- } else if Some ( trait_ref. def_id ) == lang_items. async_iterator_trait ( ) {
275- let ty:: Coroutine ( coroutine_def_id, args) = * rcvr_args. type_at ( 0 ) . kind ( ) else {
276- bug ! ( )
277- } ;
278-
279- if cfg ! ( debug_assertions) && tcx. item_name ( trait_item_id) != sym:: poll_next {
280- span_bug ! (
281- tcx. def_span( coroutine_def_id) ,
282- "no definition for `{trait_ref}::{}` for built-in coroutine type" ,
283- tcx. item_name( trait_item_id)
284- )
285- }
286-
287- // `AsyncIterator::poll_next` is generated by the compiler.
288- Some ( Instance { def : ty:: InstanceDef :: Item ( coroutine_def_id) , args } )
289- } else if Some ( trait_ref. def_id ) == lang_items. coroutine_trait ( ) {
290- let ty:: Coroutine ( coroutine_def_id, args) = * rcvr_args. type_at ( 0 ) . kind ( ) else {
291- bug ! ( )
292- } ;
293- if cfg ! ( debug_assertions) && tcx. item_name ( trait_item_id) != sym:: resume {
294- // For compiler developers who'd like to add new items to `Coroutine`,
295- // you either need to generate a shim body, or perhaps return
296- // `InstanceDef::Item` pointing to a trait default method body if
297- // it is given a default implementation by the trait.
298- span_bug ! (
299- tcx. def_span( coroutine_def_id) ,
300- "no definition for `{trait_ref}::{}` for built-in coroutine type" ,
301- tcx. item_name( trait_item_id)
302- )
303- }
304- Some ( Instance { def : ty:: InstanceDef :: Item ( coroutine_def_id) , args } )
305248 } else if tcx. fn_trait_kind_from_def_id ( trait_ref. def_id ) . is_some ( ) {
306249 // FIXME: This doesn't check for malformed libcore that defines, e.g.,
307250 // `trait Fn { fn call_once(&self) { .. } }`. This is mostly for extension
@@ -334,7 +277,7 @@ fn resolve_associated_item<'tcx>(
334277 ) ,
335278 }
336279 } else {
337- None
280+ Instance :: try_resolve_item_for_coroutine ( tcx , trait_item_id , trait_id , rcvr_args )
338281 }
339282 }
340283 traits:: ImplSource :: Param ( ..)
0 commit comments