@@ -1503,11 +1503,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
15031503 // avoid inundating the user with unnecessary errors, but we now
15041504 // check upstream for type errors and don't add the obligations to
15051505 // 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+
15111508 // Try to find possible types that would satisfy the bounds in the type param to
15121509 // give an appropriate turbofish suggestion.
15131510 let turbofish_suggestions =
@@ -1516,11 +1513,12 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
15161513 body_id,
15171514 span,
15181515 subst,
1519- ErrorCode :: E0283 ,
1516+ if is_sized { ErrorCode :: E0282 } else { ErrorCode :: E0283 } ,
15201517 & turbofish_suggestions,
15211518 ) ;
1522- err. note ( & format ! ( "cannot satisfy `{}`" , predicate) ) ;
1523-
1519+ if !is_sized {
1520+ err. note ( & format ! ( "cannot satisfy `{}`" , predicate) ) ;
1521+ }
15241522 if let ObligationCauseCode :: ItemObligation ( def_id) = obligation. cause . code {
15251523 self . suggest_fully_qualified_path (
15261524 & mut err,
@@ -1600,6 +1598,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
16001598 }
16011599 }
16021600 }
1601+ if is_sized {
1602+ err. emit ( ) ;
1603+ return ;
1604+ }
16031605 err
16041606 }
16051607
0 commit comments