@@ -194,21 +194,18 @@ fn resolve_associated_item<'tcx>(
194
194
} )
195
195
}
196
196
traits:: ImplSource :: Future ( future_data) => {
197
- if cfg ! ( debug_assertions) && tcx. item_name ( trait_item_id) != sym:: poll {
198
- // For compiler developers who'd like to add new items to `Future`,
199
- // you either need to generate a shim body, or perhaps return
200
- // `InstanceDef::Item` pointing to a trait default method body if
201
- // it is given a default implementation by the trait.
202
- span_bug ! (
203
- tcx. def_span( future_data. generator_def_id) ,
204
- "no definition for `{trait_ref}::{}` for built-in async generator type" ,
205
- tcx. item_name( trait_item_id)
206
- )
197
+ if Some ( trait_item_id) == tcx. lang_items ( ) . future_poll_fn ( ) {
198
+ // `Future::poll` is generated by the compiler.
199
+ Some ( Instance {
200
+ def : ty:: InstanceDef :: Item ( future_data. generator_def_id ) ,
201
+ substs : future_data. substs ,
202
+ } )
203
+ } else {
204
+ // All other methods are default methods of the `Future` trait.
205
+ // (this assumes that `ImplSource::Future` is only used for methods on `Future`)
206
+ debug_assert ! ( tcx. impl_defaultness( trait_item_id) . has_value( ) ) ;
207
+ Some ( Instance :: new ( trait_item_id, rcvr_substs) )
207
208
}
208
- Some ( Instance {
209
- def : ty:: InstanceDef :: Item ( future_data. generator_def_id ) ,
210
- substs : future_data. substs ,
211
- } )
212
209
}
213
210
traits:: ImplSource :: Closure ( closure_data) => {
214
211
if cfg ! ( debug_assertions)
0 commit comments