@@ -15,6 +15,7 @@ use rustc_middle::ty::visit::TypeVisitable;
15
15
use rustc_middle:: ty:: { self , Ty , TypeSuperVisitable , TypeVisitor } ;
16
16
use rustc_span:: def_id:: LocalDefId ;
17
17
use rustc_span:: source_map:: Span ;
18
+ use rustc_span:: sym;
18
19
use rustc_target:: spec:: abi:: Abi ;
19
20
use rustc_trait_selection:: traits;
20
21
use rustc_trait_selection:: traits:: error_reporting:: ArgKind ;
@@ -288,21 +289,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
288
289
let trait_def_id = projection. trait_def_id ( tcx) ;
289
290
290
291
let is_fn = tcx. is_fn_trait ( trait_def_id) ;
291
- let gen_trait = tcx. require_lang_item ( LangItem :: Generator , cause_span) ;
292
- let is_gen = gen_trait == trait_def_id;
292
+
293
+ let gen_trait = tcx. lang_items ( ) . gen_trait ( ) ;
294
+ let is_gen = gen_trait == Some ( trait_def_id) ;
295
+
293
296
if !is_fn && !is_gen {
294
297
debug ! ( "not fn or generator" ) ;
295
298
return None ;
296
299
}
297
300
298
- if is_gen {
299
- // Check that we deduce the signature from the `<_ as std::ops::Generator>::Return`
300
- // associated item and not yield.
301
- let return_assoc_item = self . tcx . associated_item_def_ids ( gen_trait) [ 1 ] ;
302
- if return_assoc_item != projection. projection_def_id ( ) {
303
- debug ! ( "not return assoc item of generator" ) ;
304
- return None ;
305
- }
301
+ // Check that we deduce the signature from the `<_ as std::ops::Generator>::Return`
302
+ // associated item and not yield.
303
+ if is_gen && self . tcx . associated_item ( projection. projection_def_id ( ) ) . name != sym:: Return {
304
+ debug ! ( "not `Return` assoc item of `Generator`" ) ;
305
+ return None ;
306
306
}
307
307
308
308
let input_tys = if is_fn {
0 commit comments