@@ -1503,11 +1503,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1503
1503
// avoid inundating the user with unnecessary errors, but we now
1504
1504
// check upstream for type errors and don't add the obligations to
1505
1505
// begin with in those cases.
1506
- if self . tcx . lang_items ( ) . sized_trait ( ) == Some ( data. trait_ref . def_id ) {
1507
- self . emit_inference_failure_err ( body_id, span, subst, ErrorCode :: E0282 , & [ ] )
1508
- . delay_as_bug ( ) ;
1509
- return ;
1510
- }
1506
+ let is_sized = self . tcx . lang_items ( ) . sized_trait ( ) == Some ( data. trait_ref . def_id ) ;
1507
+
1511
1508
// Try to find possible types that would satisfy the bounds in the type param to
1512
1509
// give an appropriate turbofish suggestion.
1513
1510
let turbofish_suggestions =
@@ -1516,11 +1513,12 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1516
1513
body_id,
1517
1514
span,
1518
1515
subst,
1519
- ErrorCode :: E0283 ,
1516
+ if is_sized { ErrorCode :: E0282 } else { ErrorCode :: E0283 } ,
1520
1517
& turbofish_suggestions,
1521
1518
) ;
1522
- err. note ( & format ! ( "cannot satisfy `{}`" , predicate) ) ;
1523
-
1519
+ if !is_sized {
1520
+ err. note ( & format ! ( "cannot satisfy `{}`" , predicate) ) ;
1521
+ }
1524
1522
if let ObligationCauseCode :: ItemObligation ( def_id) = obligation. cause . code {
1525
1523
self . suggest_fully_qualified_path (
1526
1524
& mut err,
@@ -1600,6 +1598,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1600
1598
}
1601
1599
}
1602
1600
}
1601
+ if is_sized {
1602
+ err. emit ( ) ;
1603
+ return ;
1604
+ }
1603
1605
err
1604
1606
}
1605
1607
0 commit comments