@@ -702,18 +702,6 @@ impl SyntaxErrorKind {
702
702
}
703
703
}
704
704
705
- pub ( super ) trait ErrorStyle {
706
- fn empty ( ) -> Self ;
707
- fn error_prefix < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a ;
708
- fn error_message < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a ;
709
- fn error_position_hint < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a ;
710
- fn error_underline < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a ;
711
- fn error_underline_message < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a ;
712
- fn line_numbers < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a ;
713
- fn note_prefix < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a ;
714
- fn suggestion < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a ;
715
- }
716
-
717
705
#[ cfg( feature = "color" ) ]
718
706
mod colored {
719
707
use super :: { fmt_parse_error, ParseError } ;
@@ -761,10 +749,8 @@ mod colored {
761
749
suggestion : suggestion_color,
762
750
}
763
751
}
764
- }
765
752
766
- impl super :: ErrorStyle for OwoColorsErrorStyle {
767
- fn empty ( ) -> Self {
753
+ pub ( crate ) fn empty ( ) -> Self {
768
754
let empty_style = owo_colors:: Style :: new ( ) ;
769
755
Self {
770
756
error_prefix : empty_style,
@@ -778,42 +764,42 @@ mod colored {
778
764
}
779
765
}
780
766
781
- fn error_prefix < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
767
+ pub ( crate ) fn error_prefix < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
782
768
use owo_colors:: OwoColorize ;
783
769
target. style ( self . error_prefix )
784
770
}
785
771
786
- fn error_message < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
772
+ pub ( crate ) fn error_message < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
787
773
use owo_colors:: OwoColorize ;
788
774
target. style ( self . error_message )
789
775
}
790
776
791
- fn error_position_hint < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
777
+ pub ( crate ) fn error_position_hint < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
792
778
use owo_colors:: OwoColorize ;
793
779
target. style ( self . error_position_hint )
794
780
}
795
781
796
- fn error_underline < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
782
+ pub ( crate ) fn error_underline < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
797
783
use owo_colors:: OwoColorize ;
798
784
target. style ( self . error_underline )
799
785
}
800
786
801
- fn error_underline_message < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
787
+ pub ( crate ) fn error_underline_message < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
802
788
use owo_colors:: OwoColorize ;
803
789
target. style ( self . error_underline_message )
804
790
}
805
791
806
- fn line_numbers < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
792
+ pub ( crate ) fn line_numbers < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
807
793
use owo_colors:: OwoColorize ;
808
794
target. style ( self . line_numbers )
809
795
}
810
796
811
- fn note_prefix < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
797
+ pub ( crate ) fn note_prefix < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
812
798
use owo_colors:: OwoColorize ;
813
799
target. style ( self . note_prefix )
814
800
}
815
801
816
- fn suggestion < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
802
+ pub ( crate ) fn suggestion < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
817
803
use owo_colors:: OwoColorize ;
818
804
target. style ( self . suggestion )
819
805
}
@@ -827,40 +813,50 @@ mod plain {
827
813
#[ derive( Clone ) ]
828
814
pub ( super ) struct PlainErrorStyle ;
829
815
830
- impl super :: ErrorStyle for PlainErrorStyle {
831
- fn empty ( ) -> Self {
816
+ impl PlainErrorStyle {
817
+ pub ( crate ) fn empty ( ) -> Self {
832
818
Self
833
819
}
834
820
835
- fn error_prefix < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
821
+ // We want to keep the same function signature as for the colored version, so `&self` must be here.
822
+ // We could use a trait, but returning `impl trait` in traits would bump MSRV to 1.75.
823
+ #[ allow( clippy:: unused_self) ]
824
+ pub ( crate ) fn error_prefix < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
836
825
target
837
826
}
838
827
839
- fn error_message < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
828
+ #[ allow( clippy:: unused_self) ]
829
+ pub ( crate ) fn error_message < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
840
830
target
841
831
}
842
832
843
- fn error_position_hint < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
833
+ #[ allow( clippy:: unused_self) ]
834
+ pub ( crate ) fn error_position_hint < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
844
835
target
845
836
}
846
837
847
- fn error_underline < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
838
+ #[ allow( clippy:: unused_self) ]
839
+ pub ( crate ) fn error_underline < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
848
840
target
849
841
}
850
842
851
- fn error_underline_message < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
843
+ #[ allow( clippy:: unused_self) ]
844
+ pub ( crate ) fn error_underline_message < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
852
845
target
853
846
}
854
847
855
- fn line_numbers < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
848
+ #[ allow( clippy:: unused_self) ]
849
+ pub ( crate ) fn line_numbers < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
856
850
target
857
851
}
858
852
859
- fn note_prefix < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
853
+ #[ allow( clippy:: unused_self) ]
854
+ pub ( crate ) fn note_prefix < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
860
855
target
861
856
}
862
857
863
- fn suggestion < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
858
+ #[ allow( clippy:: unused_self) ]
859
+ pub ( crate ) fn suggestion < ' a , D : Display > ( & self , target : & ' a D ) -> impl Display + ' a {
864
860
target
865
861
}
866
862
}
0 commit comments