@@ -1498,11 +1498,18 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1498
1498
// check upstream for type errors and don't add the obligations to
1499
1499
// begin with in those cases.
1500
1500
if self . tcx . lang_items ( ) . sized_trait ( ) == Some ( trait_ref. def_id ( ) ) {
1501
- self . emit_inference_failure_err ( body_id, span, subst, ErrorCode :: E0282 ) . emit ( ) ;
1501
+ self . emit_inference_failure_err ( body_id, span, subst, vec ! [ ] , ErrorCode :: E0282 )
1502
+ . emit ( ) ;
1502
1503
return ;
1503
1504
}
1504
- let mut err =
1505
- self . emit_inference_failure_err ( body_id, span, subst, ErrorCode :: E0283 ) ;
1505
+ let impl_candidates = self . find_similar_impl_candidates ( trait_ref) ;
1506
+ let mut err = self . emit_inference_failure_err (
1507
+ body_id,
1508
+ span,
1509
+ subst,
1510
+ impl_candidates,
1511
+ ErrorCode :: E0283 ,
1512
+ ) ;
1506
1513
err. note ( & format ! ( "cannot satisfy `{}`" , predicate) ) ;
1507
1514
if let ObligationCauseCode :: ItemObligation ( def_id) = obligation. cause . code {
1508
1515
self . suggest_fully_qualified_path ( & mut err, def_id, span, trait_ref. def_id ( ) ) ;
@@ -1566,7 +1573,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1566
1573
return ;
1567
1574
}
1568
1575
1569
- self . emit_inference_failure_err ( body_id, span, arg, ErrorCode :: E0282 )
1576
+ self . emit_inference_failure_err ( body_id, span, arg, vec ! [ ] , ErrorCode :: E0282 )
1570
1577
}
1571
1578
1572
1579
ty:: PredicateKind :: Subtype ( data) => {
@@ -1577,7 +1584,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1577
1584
let SubtypePredicate { a_is_expected : _, a, b } = data;
1578
1585
// both must be type variables, or the other would've been instantiated
1579
1586
assert ! ( a. is_ty_var( ) && b. is_ty_var( ) ) ;
1580
- self . emit_inference_failure_err ( body_id, span, a. into ( ) , ErrorCode :: E0282 )
1587
+ self . emit_inference_failure_err ( body_id, span, a. into ( ) , vec ! [ ] , ErrorCode :: E0282 )
1581
1588
}
1582
1589
ty:: PredicateKind :: Projection ( data) => {
1583
1590
let trait_ref = bound_predicate. rebind ( data) . to_poly_trait_ref ( self . tcx ) ;
@@ -1592,6 +1599,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1592
1599
body_id,
1593
1600
span,
1594
1601
self_ty. into ( ) ,
1602
+ vec ! [ ] ,
1595
1603
ErrorCode :: E0284 ,
1596
1604
) ;
1597
1605
err. note ( & format ! ( "cannot satisfy `{}`" , predicate) ) ;
0 commit comments