@@ -14,7 +14,7 @@ use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
14
14
use rustc_middle:: ty:: GenericArgs ;
15
15
use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeSuperVisitable , TypeVisitor } ;
16
16
use rustc_span:: def_id:: LocalDefId ;
17
- use rustc_span:: { sym , Span } ;
17
+ use rustc_span:: Span ;
18
18
use rustc_target:: spec:: abi:: Abi ;
19
19
use rustc_trait_selection:: traits;
20
20
use rustc_trait_selection:: traits:: error_reporting:: ArgKind ;
@@ -347,36 +347,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
347
347
let tcx = self . tcx ;
348
348
349
349
let trait_def_id = projection. trait_def_id ( tcx) ;
350
-
351
- let is_fn = tcx. is_fn_trait ( trait_def_id) ;
352
-
353
- let coroutine_trait = tcx. lang_items ( ) . coroutine_trait ( ) ;
354
- let is_gen = coroutine_trait == Some ( trait_def_id) ;
355
-
356
- if !is_fn && !is_gen {
357
- debug ! ( "not fn or coroutine" ) ;
358
- return None ;
359
- }
360
-
361
- // Check that we deduce the signature from the `<_ as std::ops::Coroutine>::Return`
362
- // associated item and not yield.
363
- if is_gen && self . tcx . associated_item ( projection. projection_def_id ( ) ) . name != sym:: Return {
364
- debug ! ( "not `Return` assoc item of `Coroutine`" ) ;
350
+ // For now, we only do signature deduction based off of the `Fn` traits.
351
+ if !tcx. is_fn_trait ( trait_def_id) {
365
352
return None ;
366
353
}
367
354
368
- let input_tys = if is_fn {
369
- let arg_param_ty = projection. skip_binder ( ) . projection_ty . args . type_at ( 1 ) ;
370
- let arg_param_ty = self . resolve_vars_if_possible ( arg_param_ty) ;
371
- debug ! ( ?arg_param_ty) ;
355
+ let arg_param_ty = projection. skip_binder ( ) . projection_ty . args . type_at ( 1 ) ;
356
+ let arg_param_ty = self . resolve_vars_if_possible ( arg_param_ty) ;
357
+ debug ! ( ?arg_param_ty) ;
372
358
373
- match arg_param_ty. kind ( ) {
374
- & ty:: Tuple ( tys) => tys,
375
- _ => return None ,
376
- }
377
- } else {
378
- // Coroutines with a `()` resume type may be defined with 0 or 1 explicit arguments,
379
- // else they must have exactly 1 argument. For now though, just give up in this case.
359
+ let ty:: Tuple ( input_tys) = * arg_param_ty. kind ( ) else {
380
360
return None ;
381
361
} ;
382
362
0 commit comments