@@ -57,13 +57,13 @@ impl LexError {
57
57
}
58
58
59
59
impl TokenStream {
60
- pub fn new ( ) -> Self {
60
+ pub ( crate ) fn new ( ) -> Self {
61
61
TokenStream {
62
62
inner : RcVecBuilder :: new ( ) . build ( ) ,
63
63
}
64
64
}
65
65
66
- pub fn is_empty ( & self ) -> bool {
66
+ pub ( crate ) fn is_empty ( & self ) -> bool {
67
67
self . inner . len ( ) == 0
68
68
}
69
69
@@ -125,23 +125,23 @@ pub(crate) struct TokenStreamBuilder {
125
125
}
126
126
127
127
impl TokenStreamBuilder {
128
- pub fn new ( ) -> Self {
128
+ pub ( crate ) fn new ( ) -> Self {
129
129
TokenStreamBuilder {
130
130
inner : RcVecBuilder :: new ( ) ,
131
131
}
132
132
}
133
133
134
- pub fn with_capacity ( cap : usize ) -> Self {
134
+ pub ( crate ) fn with_capacity ( cap : usize ) -> Self {
135
135
TokenStreamBuilder {
136
136
inner : RcVecBuilder :: with_capacity ( cap) ,
137
137
}
138
138
}
139
139
140
- pub fn push_token_from_parser ( & mut self , tt : TokenTree ) {
140
+ pub ( crate ) fn push_token_from_parser ( & mut self , tt : TokenTree ) {
141
141
self . inner . push ( tt) ;
142
142
}
143
143
144
- pub fn build ( self ) -> TokenStream {
144
+ pub ( crate ) fn build ( self ) -> TokenStream {
145
145
TokenStream {
146
146
inner : self . inner . build ( ) ,
147
147
}
@@ -303,11 +303,11 @@ pub(crate) struct SourceFile {
303
303
#[ cfg( procmacro2_semver_exempt) ]
304
304
impl SourceFile {
305
305
/// Get the path to this source file as a string.
306
- pub fn path ( & self ) -> PathBuf {
306
+ pub ( crate ) fn path ( & self ) -> PathBuf {
307
307
self . path . clone ( )
308
308
}
309
309
310
- pub fn is_real ( & self ) -> bool {
310
+ pub ( crate ) fn is_real ( & self ) -> bool {
311
311
false
312
312
}
313
313
}
@@ -509,37 +509,37 @@ pub(crate) struct Span {
509
509
510
510
impl Span {
511
511
#[ cfg( not( span_locations) ) ]
512
- pub fn call_site ( ) -> Self {
512
+ pub ( crate ) fn call_site ( ) -> Self {
513
513
Span { }
514
514
}
515
515
516
516
#[ cfg( span_locations) ]
517
- pub fn call_site ( ) -> Self {
517
+ pub ( crate ) fn call_site ( ) -> Self {
518
518
Span { lo : 0 , hi : 0 }
519
519
}
520
520
521
- pub fn mixed_site ( ) -> Self {
521
+ pub ( crate ) fn mixed_site ( ) -> Self {
522
522
Span :: call_site ( )
523
523
}
524
524
525
525
#[ cfg( procmacro2_semver_exempt) ]
526
- pub fn def_site ( ) -> Self {
526
+ pub ( crate ) fn def_site ( ) -> Self {
527
527
Span :: call_site ( )
528
528
}
529
529
530
- pub fn resolved_at ( & self , _other : Span ) -> Span {
530
+ pub ( crate ) fn resolved_at ( & self , _other : Span ) -> Span {
531
531
// Stable spans consist only of line/column information, so
532
532
// `resolved_at` and `located_at` only select which span the
533
533
// caller wants line/column information from.
534
534
* self
535
535
}
536
536
537
- pub fn located_at ( & self , other : Span ) -> Span {
537
+ pub ( crate ) fn located_at ( & self , other : Span ) -> Span {
538
538
other
539
539
}
540
540
541
541
#[ cfg( procmacro2_semver_exempt) ]
542
- pub fn source_file ( & self ) -> SourceFile {
542
+ pub ( crate ) fn source_file ( & self ) -> SourceFile {
543
543
#[ cfg( fuzzing) ]
544
544
return SourceFile {
545
545
path : PathBuf :: from ( "<unspecified>" ) ,
@@ -554,7 +554,7 @@ impl Span {
554
554
}
555
555
556
556
#[ cfg( span_locations) ]
557
- pub fn byte_range ( & self ) -> Range < usize > {
557
+ pub ( crate ) fn byte_range ( & self ) -> Range < usize > {
558
558
#[ cfg( fuzzing) ]
559
559
return 0 ..0 ;
560
560
@@ -569,7 +569,7 @@ impl Span {
569
569
}
570
570
571
571
#[ cfg( span_locations) ]
572
- pub fn start ( & self ) -> LineColumn {
572
+ pub ( crate ) fn start ( & self ) -> LineColumn {
573
573
#[ cfg( fuzzing) ]
574
574
return LineColumn { line : 0 , column : 0 } ;
575
575
@@ -582,7 +582,7 @@ impl Span {
582
582
}
583
583
584
584
#[ cfg( span_locations) ]
585
- pub fn end ( & self ) -> LineColumn {
585
+ pub ( crate ) fn end ( & self ) -> LineColumn {
586
586
#[ cfg( fuzzing) ]
587
587
return LineColumn { line : 0 , column : 0 } ;
588
588
@@ -595,12 +595,12 @@ impl Span {
595
595
}
596
596
597
597
#[ cfg( not( span_locations) ) ]
598
- pub fn join ( & self , _other : Span ) -> Option < Span > {
598
+ pub ( crate ) fn join ( & self , _other : Span ) -> Option < Span > {
599
599
Some ( Span { } )
600
600
}
601
601
602
602
#[ cfg( span_locations) ]
603
- pub fn join ( & self , other : Span ) -> Option < Span > {
603
+ pub ( crate ) fn join ( & self , other : Span ) -> Option < Span > {
604
604
#[ cfg( fuzzing) ]
605
605
return {
606
606
let _ = other;
@@ -622,12 +622,12 @@ impl Span {
622
622
}
623
623
624
624
#[ cfg( not( span_locations) ) ]
625
- pub fn source_text ( & self ) -> Option < String > {
625
+ pub ( crate ) fn source_text ( & self ) -> Option < String > {
626
626
None
627
627
}
628
628
629
629
#[ cfg( span_locations) ]
630
- pub fn source_text ( & self ) -> Option < String > {
630
+ pub ( crate ) fn source_text ( & self ) -> Option < String > {
631
631
#[ cfg( fuzzing) ]
632
632
return None ;
633
633
@@ -704,35 +704,35 @@ pub(crate) struct Group {
704
704
}
705
705
706
706
impl Group {
707
- pub fn new ( delimiter : Delimiter , stream : TokenStream ) -> Self {
707
+ pub ( crate ) fn new ( delimiter : Delimiter , stream : TokenStream ) -> Self {
708
708
Group {
709
709
delimiter,
710
710
stream,
711
711
span : Span :: call_site ( ) ,
712
712
}
713
713
}
714
714
715
- pub fn delimiter ( & self ) -> Delimiter {
715
+ pub ( crate ) fn delimiter ( & self ) -> Delimiter {
716
716
self . delimiter
717
717
}
718
718
719
- pub fn stream ( & self ) -> TokenStream {
719
+ pub ( crate ) fn stream ( & self ) -> TokenStream {
720
720
self . stream . clone ( )
721
721
}
722
722
723
- pub fn span ( & self ) -> Span {
723
+ pub ( crate ) fn span ( & self ) -> Span {
724
724
self . span
725
725
}
726
726
727
- pub fn span_open ( & self ) -> Span {
727
+ pub ( crate ) fn span_open ( & self ) -> Span {
728
728
self . span . first_byte ( )
729
729
}
730
730
731
- pub fn span_close ( & self ) -> Span {
731
+ pub ( crate ) fn span_close ( & self ) -> Span {
732
732
self . span . last_byte ( )
733
733
}
734
734
735
- pub fn set_span ( & mut self , span : Span ) {
735
+ pub ( crate ) fn set_span ( & mut self , span : Span ) {
736
736
self . span = span;
737
737
}
738
738
}
@@ -783,12 +783,12 @@ pub(crate) struct Ident {
783
783
784
784
impl Ident {
785
785
#[ track_caller]
786
- pub fn new_checked ( string : & str , span : Span ) -> Self {
786
+ pub ( crate ) fn new_checked ( string : & str , span : Span ) -> Self {
787
787
validate_ident ( string) ;
788
788
Ident :: new_unchecked ( string, span)
789
789
}
790
790
791
- pub fn new_unchecked ( string : & str , span : Span ) -> Self {
791
+ pub ( crate ) fn new_unchecked ( string : & str , span : Span ) -> Self {
792
792
Ident {
793
793
sym : Box :: from ( string) ,
794
794
span,
@@ -797,24 +797,24 @@ impl Ident {
797
797
}
798
798
799
799
#[ track_caller]
800
- pub fn new_raw_checked ( string : & str , span : Span ) -> Self {
800
+ pub ( crate ) fn new_raw_checked ( string : & str , span : Span ) -> Self {
801
801
validate_ident_raw ( string) ;
802
802
Ident :: new_raw_unchecked ( string, span)
803
803
}
804
804
805
- pub fn new_raw_unchecked ( string : & str , span : Span ) -> Self {
805
+ pub ( crate ) fn new_raw_unchecked ( string : & str , span : Span ) -> Self {
806
806
Ident {
807
807
sym : Box :: from ( string) ,
808
808
span,
809
809
raw : true ,
810
810
}
811
811
}
812
812
813
- pub fn span ( & self ) -> Span {
813
+ pub ( crate ) fn span ( & self ) -> Span {
814
814
self . span
815
815
}
816
816
817
- pub fn set_span ( & mut self , span : Span ) {
817
+ pub ( crate ) fn set_span ( & mut self , span : Span ) {
818
818
self . span = span;
819
819
}
820
820
}
@@ -928,15 +928,15 @@ pub(crate) struct Literal {
928
928
929
929
macro_rules! suffixed_numbers {
930
930
( $( $name: ident => $kind: ident, ) * ) => ( $(
931
- pub fn $name( n: $kind) -> Literal {
931
+ pub ( crate ) fn $name( n: $kind) -> Literal {
932
932
Literal :: _new( format!( concat!( "{}" , stringify!( $kind) ) , n) )
933
933
}
934
934
) * )
935
935
}
936
936
937
937
macro_rules! unsuffixed_numbers {
938
938
( $( $name: ident => $kind: ident, ) * ) => ( $(
939
- pub fn $name( n: $kind) -> Literal {
939
+ pub ( crate ) fn $name( n: $kind) -> Literal {
940
940
Literal :: _new( n. to_string( ) )
941
941
}
942
942
) * )
@@ -987,31 +987,31 @@ impl Literal {
987
987
isize_unsuffixed => isize ,
988
988
}
989
989
990
- pub fn f32_unsuffixed ( f : f32 ) -> Literal {
990
+ pub ( crate ) fn f32_unsuffixed ( f : f32 ) -> Literal {
991
991
let mut s = f. to_string ( ) ;
992
992
if !s. contains ( '.' ) {
993
993
s. push_str ( ".0" ) ;
994
994
}
995
995
Literal :: _new ( s)
996
996
}
997
997
998
- pub fn f64_unsuffixed ( f : f64 ) -> Literal {
998
+ pub ( crate ) fn f64_unsuffixed ( f : f64 ) -> Literal {
999
999
let mut s = f. to_string ( ) ;
1000
1000
if !s. contains ( '.' ) {
1001
1001
s. push_str ( ".0" ) ;
1002
1002
}
1003
1003
Literal :: _new ( s)
1004
1004
}
1005
1005
1006
- pub fn string ( string : & str ) -> Literal {
1006
+ pub ( crate ) fn string ( string : & str ) -> Literal {
1007
1007
let mut repr = String :: with_capacity ( string. len ( ) + 2 ) ;
1008
1008
repr. push ( '"' ) ;
1009
1009
escape_utf8 ( string, & mut repr) ;
1010
1010
repr. push ( '"' ) ;
1011
1011
Literal :: _new ( repr)
1012
1012
}
1013
1013
1014
- pub fn character ( ch : char ) -> Literal {
1014
+ pub ( crate ) fn character ( ch : char ) -> Literal {
1015
1015
let mut repr = String :: new ( ) ;
1016
1016
repr. push ( '\'' ) ;
1017
1017
if ch == '"' {
@@ -1024,7 +1024,7 @@ impl Literal {
1024
1024
Literal :: _new ( repr)
1025
1025
}
1026
1026
1027
- pub fn byte_character ( byte : u8 ) -> Literal {
1027
+ pub ( crate ) fn byte_character ( byte : u8 ) -> Literal {
1028
1028
let mut repr = "b'" . to_string ( ) ;
1029
1029
#[ allow( clippy:: match_overlapping_arm) ]
1030
1030
match byte {
@@ -1043,7 +1043,7 @@ impl Literal {
1043
1043
Literal :: _new ( repr)
1044
1044
}
1045
1045
1046
- pub fn byte_string ( bytes : & [ u8 ] ) -> Literal {
1046
+ pub ( crate ) fn byte_string ( bytes : & [ u8 ] ) -> Literal {
1047
1047
let mut repr = "b\" " . to_string ( ) ;
1048
1048
let mut bytes = bytes. iter ( ) ;
1049
1049
while let Some ( & b) = bytes. next ( ) {
@@ -1069,7 +1069,7 @@ impl Literal {
1069
1069
Literal :: _new ( repr)
1070
1070
}
1071
1071
1072
- pub fn c_string ( string : & CStr ) -> Literal {
1072
+ pub ( crate ) fn c_string ( string : & CStr ) -> Literal {
1073
1073
let mut repr = "c\" " . to_string ( ) ;
1074
1074
let mut bytes = string. to_bytes ( ) ;
1075
1075
while !bytes. is_empty ( ) {
@@ -1097,15 +1097,15 @@ impl Literal {
1097
1097
Literal :: _new ( repr)
1098
1098
}
1099
1099
1100
- pub fn span ( & self ) -> Span {
1100
+ pub ( crate ) fn span ( & self ) -> Span {
1101
1101
self . span
1102
1102
}
1103
1103
1104
- pub fn set_span ( & mut self , span : Span ) {
1104
+ pub ( crate ) fn set_span ( & mut self , span : Span ) {
1105
1105
self . span = span;
1106
1106
}
1107
1107
1108
- pub fn subspan < R : RangeBounds < usize > > ( & self , range : R ) -> Option < Span > {
1108
+ pub ( crate ) fn subspan < R : RangeBounds < usize > > ( & self , range : R ) -> Option < Span > {
1109
1109
#[ cfg( not( span_locations) ) ]
1110
1110
{
1111
1111
let _ = range;
0 commit comments