File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
compiler/rustc_typeck/src/check Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -391,6 +391,30 @@ fn compare_predicate_entailment<'tcx>(
391
391
return Err ( diag. emit ( ) ) ;
392
392
}
393
393
394
+ // Check that an impl's fn return satisfies the bounds of the
395
+ // FIXME(RPITIT): Generalize this to nested impl traits
396
+ if let ty:: Projection ( proj) = tcx. fn_sig ( trait_m. def_id ) . skip_binder ( ) . output ( ) . kind ( )
397
+ && tcx. def_kind ( proj. item_def_id ) == DefKind :: ImplTraitPlaceholder
398
+ {
399
+ let return_span = tcx. hir ( ) . fn_decl_by_hir_id ( impl_m_hir_id) . unwrap ( ) . output . span ( ) ;
400
+
401
+ for ( predicate, span) in tcx
402
+ . bound_explicit_item_bounds ( proj. item_def_id )
403
+ . transpose_iter ( )
404
+ . map ( |pred| pred. map_bound ( |pred| * pred) . subst ( tcx, trait_to_placeholder_substs) )
405
+ {
406
+ ocx. register_obligation ( traits:: Obligation :: new (
407
+ traits:: ObligationCause :: new (
408
+ return_span,
409
+ impl_m_hir_id,
410
+ ObligationCauseCode :: BindingObligation ( proj. item_def_id , span) ,
411
+ ) ,
412
+ param_env,
413
+ predicate,
414
+ ) ) ;
415
+ }
416
+ }
417
+
394
418
// Check that all obligations are satisfied by the implementation's
395
419
// version.
396
420
let errors = ocx. select_all_or_error ( ) ;
You can’t perform that action at this time.
0 commit comments