File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -861,7 +861,16 @@ pub(crate) struct ComparisonInterpretedAsGeneric {
861861 #[ label( "interpreted as generic arguments" ) ]
862862 pub args : Span ,
863863 #[ subdiagnostic]
864- pub suggestion : ComparisonOrShiftInterpretedAsGenericSugg ,
864+ pub suggestion : ComparisonInterpretedAsGenericSugg ,
865+ }
866+
867+ #[ derive( Subdiagnostic ) ]
868+ #[ multipart_suggestion( "try comparing the cast value" , applicability = "machine-applicable" ) ]
869+ pub ( crate ) struct ComparisonInterpretedAsGenericSugg {
870+ #[ suggestion_part( code = "(" ) ]
871+ pub left : Span ,
872+ #[ suggestion_part( code = ")" ) ]
873+ pub right : Span ,
865874}
866875
867876#[ derive( Diagnostic ) ]
@@ -874,12 +883,12 @@ pub(crate) struct ShiftInterpretedAsGeneric {
874883 #[ label( "interpreted as generic arguments" ) ]
875884 pub args : Span ,
876885 #[ subdiagnostic]
877- pub suggestion : ComparisonOrShiftInterpretedAsGenericSugg ,
886+ pub suggestion : ShiftInterpretedAsGenericSugg ,
878887}
879888
880889#[ derive( Subdiagnostic ) ]
881- #[ multipart_suggestion( "BROKEN " , applicability = "machine-applicable" ) ]
882- pub ( crate ) struct ComparisonOrShiftInterpretedAsGenericSugg {
890+ #[ multipart_suggestion( "try shifting the cast value " , applicability = "machine-applicable" ) ]
891+ pub ( crate ) struct ShiftInterpretedAsGenericSugg {
883892 #[ suggestion_part( code = "(" ) ]
884893 pub left : Span ,
885894 #[ suggestion_part( code = ")" ) ]
Original file line number Diff line number Diff line change @@ -727,25 +727,26 @@ impl<'a> Parser<'a> {
727727 ) ;
728728
729729 let args_span = self . look_ahead ( 1 , |t| t. span ) . to ( span_after_type) ;
730- let suggestion = errors:: ComparisonOrShiftInterpretedAsGenericSugg {
731- left : expr. span . shrink_to_lo ( ) ,
732- right : expr. span . shrink_to_hi ( ) ,
733- } ;
734-
735730 match self . token . kind {
736731 token:: Lt => {
737732 self . dcx ( ) . emit_err ( errors:: ComparisonInterpretedAsGeneric {
738733 comparison : self . token . span ,
739734 r#type : path,
740735 args : args_span,
741- suggestion,
736+ suggestion : errors:: ComparisonInterpretedAsGenericSugg {
737+ left : expr. span . shrink_to_lo ( ) ,
738+ right : expr. span . shrink_to_hi ( ) ,
739+ } ,
742740 } )
743741 }
744742 token:: Shl => self . dcx ( ) . emit_err ( errors:: ShiftInterpretedAsGeneric {
745743 shift : self . token . span ,
746744 r#type : path,
747745 args : args_span,
748- suggestion,
746+ suggestion : errors:: ShiftInterpretedAsGenericSugg {
747+ left : expr. span . shrink_to_lo ( ) ,
748+ right : expr. span . shrink_to_hi ( ) ,
749+ } ,
749750 } ) ,
750751 _ => {
751752 // We can end up here even without `<` being the next token, for
You can’t perform that action at this time.
0 commit comments