@@ -18,7 +18,7 @@ use rustc_span::def_id::LocalDefId;
1818use rustc_span:: { DUMMY_SP , Span } ;
1919use rustc_trait_selection:: error_reporting:: traits:: ArgKind ;
2020use rustc_trait_selection:: traits;
21- use rustc_type_ir:: ClosureKind ;
21+ use rustc_type_ir:: { ClosureKind , Upcast as _ } ;
2222use tracing:: { debug, instrument, trace} ;
2323
2424use super :: { CoroutineTypes , Expectation , FnCtxt , check_fn} ;
@@ -312,16 +312,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
312312 . iter_instantiated_copied ( self . tcx , args)
313313 . map ( |( c, s) | ( c. as_predicate ( ) , s) ) ,
314314 ) ,
315- ty:: Dynamic ( object_type, ..) => {
316- let sig = object_type. projection_bounds ( ) . find_map ( |pb| {
317- let pb = pb. with_self_ty ( self . tcx , self . tcx . types . trait_object_dummy_self ) ;
318- self . deduce_sig_from_projection ( None , closure_kind, pb)
319- } ) ;
320- let kind = object_type
321- . principal_def_id ( )
322- . and_then ( |did| self . tcx . fn_trait_kind_from_def_id ( did) ) ;
323- ( sig, kind)
324- }
315+ ty:: Dynamic ( data, ..) => self . deduce_closure_signature_from_predicates (
316+ expected_ty,
317+ closure_kind,
318+ data. iter ( ) . map ( |bound| {
319+ (
320+ bound
321+ . with_self_ty ( self . tcx , self . tcx . types . trait_object_dummy_self )
322+ . upcast ( self . tcx ) ,
323+ DUMMY_SP ,
324+ )
325+ } ) ,
326+ ) ,
325327 ty:: Infer ( ty:: TyVar ( vid) ) => self . deduce_closure_signature_from_predicates (
326328 Ty :: new_var ( self . tcx , self . root_var ( vid) ) ,
327329 closure_kind,
0 commit comments