@@ -688,12 +688,26 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
688688 let msg = "`match` arms have incompatible types" ;
689689 err. span_label ( outer_error_span, msg) ;
690690 if let Some ( ( sp, boxed) ) = semi_span {
691- if matches ! ( boxed, StatementAsExpression :: NeedsBoxing ) {
692- err. span_suggestion_verbose (
691+ if let ( StatementAsExpression :: NeedsBoxing , [ .., prior_arm] ) =
692+ ( boxed, & prior_arms[ ..] )
693+ {
694+ err. multipart_suggestion (
695+ "consider removing this semicolon and boxing the expressions" ,
696+ vec ! [
697+ ( prior_arm. shrink_to_lo( ) , "Box::new(" . to_string( ) ) ,
698+ ( prior_arm. shrink_to_hi( ) , ")" . to_string( ) ) ,
699+ ( arm_span. shrink_to_lo( ) , "Box::new(" . to_string( ) ) ,
700+ ( arm_span. shrink_to_hi( ) , ")" . to_string( ) ) ,
701+ ( sp, String :: new( ) ) ,
702+ ] ,
703+ Applicability :: HasPlaceholders ,
704+ ) ;
705+ } else if matches ! ( boxed, StatementAsExpression :: NeedsBoxing ) {
706+ err. span_suggestion_short (
693707 sp,
694- "consider removing this semicolon and boxing the expression " ,
708+ "consider removing this semicolon and boxing the expressions " ,
695709 String :: new ( ) ,
696- Applicability :: HasPlaceholders ,
710+ Applicability :: MachineApplicable ,
697711 ) ;
698712 } else {
699713 err. span_suggestion_short (
@@ -727,11 +741,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
727741 }
728742 if let Some ( ( sp, boxed) ) = semicolon {
729743 if matches ! ( boxed, StatementAsExpression :: NeedsBoxing ) {
730- err. span_suggestion_verbose (
731- sp,
744+ err. multipart_suggestion (
732745 "consider removing this semicolon and boxing the expression" ,
733- String :: new ( ) ,
734- Applicability :: HasPlaceholders ,
746+ vec ! [
747+ ( then. shrink_to_lo( ) , "Box::new(" . to_string( ) ) ,
748+ ( then. shrink_to_hi( ) , ")" . to_string( ) ) ,
749+ ( else_sp. shrink_to_lo( ) , "Box::new(" . to_string( ) ) ,
750+ ( else_sp. shrink_to_hi( ) , ")" . to_string( ) ) ,
751+ ( sp, String :: new( ) ) ,
752+ ] ,
753+ Applicability :: MachineApplicable ,
735754 ) ;
736755 } else {
737756 err. span_suggestion_short (
0 commit comments