@@ -15,6 +15,7 @@ use rustc_middle::ty::visit::TypeVisitable;
1515use rustc_middle:: ty:: { self , Ty , TypeSuperVisitable , TypeVisitor } ;
1616use rustc_span:: def_id:: LocalDefId ;
1717use rustc_span:: source_map:: Span ;
18+ use rustc_span:: sym;
1819use rustc_target:: spec:: abi:: Abi ;
1920use rustc_trait_selection:: traits;
2021use rustc_trait_selection:: traits:: error_reporting:: ArgKind ;
@@ -288,21 +289,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
288289 let trait_def_id = projection. trait_def_id ( tcx) ;
289290
290291 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+
293296 if !is_fn && !is_gen {
294297 debug ! ( "not fn or generator" ) ;
295298 return None ;
296299 }
297300
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 ;
306306 }
307307
308308 let input_tys = if is_fn {
0 commit comments