@@ -57,13 +57,13 @@ impl LexError {
5757}
5858
5959impl TokenStream {
60- pub fn new ( ) -> Self {
60+ pub ( crate ) fn new ( ) -> Self {
6161 TokenStream {
6262 inner : RcVecBuilder :: new ( ) . build ( ) ,
6363 }
6464 }
6565
66- pub fn is_empty ( & self ) -> bool {
66+ pub ( crate ) fn is_empty ( & self ) -> bool {
6767 self . inner . len ( ) == 0
6868 }
6969
@@ -125,23 +125,23 @@ pub(crate) struct TokenStreamBuilder {
125125}
126126
127127impl TokenStreamBuilder {
128- pub fn new ( ) -> Self {
128+ pub ( crate ) fn new ( ) -> Self {
129129 TokenStreamBuilder {
130130 inner : RcVecBuilder :: new ( ) ,
131131 }
132132 }
133133
134- pub fn with_capacity ( cap : usize ) -> Self {
134+ pub ( crate ) fn with_capacity ( cap : usize ) -> Self {
135135 TokenStreamBuilder {
136136 inner : RcVecBuilder :: with_capacity ( cap) ,
137137 }
138138 }
139139
140- pub fn push_token_from_parser ( & mut self , tt : TokenTree ) {
140+ pub ( crate ) fn push_token_from_parser ( & mut self , tt : TokenTree ) {
141141 self . inner . push ( tt) ;
142142 }
143143
144- pub fn build ( self ) -> TokenStream {
144+ pub ( crate ) fn build ( self ) -> TokenStream {
145145 TokenStream {
146146 inner : self . inner . build ( ) ,
147147 }
@@ -303,11 +303,11 @@ pub(crate) struct SourceFile {
303303#[ cfg( procmacro2_semver_exempt) ]
304304impl SourceFile {
305305 /// Get the path to this source file as a string.
306- pub fn path ( & self ) -> PathBuf {
306+ pub ( crate ) fn path ( & self ) -> PathBuf {
307307 self . path . clone ( )
308308 }
309309
310- pub fn is_real ( & self ) -> bool {
310+ pub ( crate ) fn is_real ( & self ) -> bool {
311311 false
312312 }
313313}
@@ -509,37 +509,37 @@ pub(crate) struct Span {
509509
510510impl Span {
511511 #[ cfg( not( span_locations) ) ]
512- pub fn call_site ( ) -> Self {
512+ pub ( crate ) fn call_site ( ) -> Self {
513513 Span { }
514514 }
515515
516516 #[ cfg( span_locations) ]
517- pub fn call_site ( ) -> Self {
517+ pub ( crate ) fn call_site ( ) -> Self {
518518 Span { lo : 0 , hi : 0 }
519519 }
520520
521- pub fn mixed_site ( ) -> Self {
521+ pub ( crate ) fn mixed_site ( ) -> Self {
522522 Span :: call_site ( )
523523 }
524524
525525 #[ cfg( procmacro2_semver_exempt) ]
526- pub fn def_site ( ) -> Self {
526+ pub ( crate ) fn def_site ( ) -> Self {
527527 Span :: call_site ( )
528528 }
529529
530- pub fn resolved_at ( & self , _other : Span ) -> Span {
530+ pub ( crate ) fn resolved_at ( & self , _other : Span ) -> Span {
531531 // Stable spans consist only of line/column information, so
532532 // `resolved_at` and `located_at` only select which span the
533533 // caller wants line/column information from.
534534 * self
535535 }
536536
537- pub fn located_at ( & self , other : Span ) -> Span {
537+ pub ( crate ) fn located_at ( & self , other : Span ) -> Span {
538538 other
539539 }
540540
541541 #[ cfg( procmacro2_semver_exempt) ]
542- pub fn source_file ( & self ) -> SourceFile {
542+ pub ( crate ) fn source_file ( & self ) -> SourceFile {
543543 #[ cfg( fuzzing) ]
544544 return SourceFile {
545545 path : PathBuf :: from ( "<unspecified>" ) ,
@@ -554,7 +554,7 @@ impl Span {
554554 }
555555
556556 #[ cfg( span_locations) ]
557- pub fn byte_range ( & self ) -> Range < usize > {
557+ pub ( crate ) fn byte_range ( & self ) -> Range < usize > {
558558 #[ cfg( fuzzing) ]
559559 return 0 ..0 ;
560560
@@ -569,7 +569,7 @@ impl Span {
569569 }
570570
571571 #[ cfg( span_locations) ]
572- pub fn start ( & self ) -> LineColumn {
572+ pub ( crate ) fn start ( & self ) -> LineColumn {
573573 #[ cfg( fuzzing) ]
574574 return LineColumn { line : 0 , column : 0 } ;
575575
@@ -582,7 +582,7 @@ impl Span {
582582 }
583583
584584 #[ cfg( span_locations) ]
585- pub fn end ( & self ) -> LineColumn {
585+ pub ( crate ) fn end ( & self ) -> LineColumn {
586586 #[ cfg( fuzzing) ]
587587 return LineColumn { line : 0 , column : 0 } ;
588588
@@ -595,12 +595,12 @@ impl Span {
595595 }
596596
597597 #[ cfg( not( span_locations) ) ]
598- pub fn join ( & self , _other : Span ) -> Option < Span > {
598+ pub ( crate ) fn join ( & self , _other : Span ) -> Option < Span > {
599599 Some ( Span { } )
600600 }
601601
602602 #[ cfg( span_locations) ]
603- pub fn join ( & self , other : Span ) -> Option < Span > {
603+ pub ( crate ) fn join ( & self , other : Span ) -> Option < Span > {
604604 #[ cfg( fuzzing) ]
605605 return {
606606 let _ = other;
@@ -622,12 +622,12 @@ impl Span {
622622 }
623623
624624 #[ cfg( not( span_locations) ) ]
625- pub fn source_text ( & self ) -> Option < String > {
625+ pub ( crate ) fn source_text ( & self ) -> Option < String > {
626626 None
627627 }
628628
629629 #[ cfg( span_locations) ]
630- pub fn source_text ( & self ) -> Option < String > {
630+ pub ( crate ) fn source_text ( & self ) -> Option < String > {
631631 #[ cfg( fuzzing) ]
632632 return None ;
633633
@@ -704,35 +704,35 @@ pub(crate) struct Group {
704704}
705705
706706impl Group {
707- pub fn new ( delimiter : Delimiter , stream : TokenStream ) -> Self {
707+ pub ( crate ) fn new ( delimiter : Delimiter , stream : TokenStream ) -> Self {
708708 Group {
709709 delimiter,
710710 stream,
711711 span : Span :: call_site ( ) ,
712712 }
713713 }
714714
715- pub fn delimiter ( & self ) -> Delimiter {
715+ pub ( crate ) fn delimiter ( & self ) -> Delimiter {
716716 self . delimiter
717717 }
718718
719- pub fn stream ( & self ) -> TokenStream {
719+ pub ( crate ) fn stream ( & self ) -> TokenStream {
720720 self . stream . clone ( )
721721 }
722722
723- pub fn span ( & self ) -> Span {
723+ pub ( crate ) fn span ( & self ) -> Span {
724724 self . span
725725 }
726726
727- pub fn span_open ( & self ) -> Span {
727+ pub ( crate ) fn span_open ( & self ) -> Span {
728728 self . span . first_byte ( )
729729 }
730730
731- pub fn span_close ( & self ) -> Span {
731+ pub ( crate ) fn span_close ( & self ) -> Span {
732732 self . span . last_byte ( )
733733 }
734734
735- pub fn set_span ( & mut self , span : Span ) {
735+ pub ( crate ) fn set_span ( & mut self , span : Span ) {
736736 self . span = span;
737737 }
738738}
@@ -783,12 +783,12 @@ pub(crate) struct Ident {
783783
784784impl Ident {
785785 #[ track_caller]
786- pub fn new_checked ( string : & str , span : Span ) -> Self {
786+ pub ( crate ) fn new_checked ( string : & str , span : Span ) -> Self {
787787 validate_ident ( string) ;
788788 Ident :: new_unchecked ( string, span)
789789 }
790790
791- pub fn new_unchecked ( string : & str , span : Span ) -> Self {
791+ pub ( crate ) fn new_unchecked ( string : & str , span : Span ) -> Self {
792792 Ident {
793793 sym : Box :: from ( string) ,
794794 span,
@@ -797,24 +797,24 @@ impl Ident {
797797 }
798798
799799 #[ 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 {
801801 validate_ident_raw ( string) ;
802802 Ident :: new_raw_unchecked ( string, span)
803803 }
804804
805- pub fn new_raw_unchecked ( string : & str , span : Span ) -> Self {
805+ pub ( crate ) fn new_raw_unchecked ( string : & str , span : Span ) -> Self {
806806 Ident {
807807 sym : Box :: from ( string) ,
808808 span,
809809 raw : true ,
810810 }
811811 }
812812
813- pub fn span ( & self ) -> Span {
813+ pub ( crate ) fn span ( & self ) -> Span {
814814 self . span
815815 }
816816
817- pub fn set_span ( & mut self , span : Span ) {
817+ pub ( crate ) fn set_span ( & mut self , span : Span ) {
818818 self . span = span;
819819 }
820820}
@@ -928,15 +928,15 @@ pub(crate) struct Literal {
928928
929929macro_rules! suffixed_numbers {
930930 ( $( $name: ident => $kind: ident, ) * ) => ( $(
931- pub fn $name( n: $kind) -> Literal {
931+ pub ( crate ) fn $name( n: $kind) -> Literal {
932932 Literal :: _new( format!( concat!( "{}" , stringify!( $kind) ) , n) )
933933 }
934934 ) * )
935935}
936936
937937macro_rules! unsuffixed_numbers {
938938 ( $( $name: ident => $kind: ident, ) * ) => ( $(
939- pub fn $name( n: $kind) -> Literal {
939+ pub ( crate ) fn $name( n: $kind) -> Literal {
940940 Literal :: _new( n. to_string( ) )
941941 }
942942 ) * )
@@ -987,31 +987,31 @@ impl Literal {
987987 isize_unsuffixed => isize ,
988988 }
989989
990- pub fn f32_unsuffixed ( f : f32 ) -> Literal {
990+ pub ( crate ) fn f32_unsuffixed ( f : f32 ) -> Literal {
991991 let mut s = f. to_string ( ) ;
992992 if !s. contains ( '.' ) {
993993 s. push_str ( ".0" ) ;
994994 }
995995 Literal :: _new ( s)
996996 }
997997
998- pub fn f64_unsuffixed ( f : f64 ) -> Literal {
998+ pub ( crate ) fn f64_unsuffixed ( f : f64 ) -> Literal {
999999 let mut s = f. to_string ( ) ;
10001000 if !s. contains ( '.' ) {
10011001 s. push_str ( ".0" ) ;
10021002 }
10031003 Literal :: _new ( s)
10041004 }
10051005
1006- pub fn string ( string : & str ) -> Literal {
1006+ pub ( crate ) fn string ( string : & str ) -> Literal {
10071007 let mut repr = String :: with_capacity ( string. len ( ) + 2 ) ;
10081008 repr. push ( '"' ) ;
10091009 escape_utf8 ( string, & mut repr) ;
10101010 repr. push ( '"' ) ;
10111011 Literal :: _new ( repr)
10121012 }
10131013
1014- pub fn character ( ch : char ) -> Literal {
1014+ pub ( crate ) fn character ( ch : char ) -> Literal {
10151015 let mut repr = String :: new ( ) ;
10161016 repr. push ( '\'' ) ;
10171017 if ch == '"' {
@@ -1024,7 +1024,7 @@ impl Literal {
10241024 Literal :: _new ( repr)
10251025 }
10261026
1027- pub fn byte_character ( byte : u8 ) -> Literal {
1027+ pub ( crate ) fn byte_character ( byte : u8 ) -> Literal {
10281028 let mut repr = "b'" . to_string ( ) ;
10291029 #[ allow( clippy:: match_overlapping_arm) ]
10301030 match byte {
@@ -1043,7 +1043,7 @@ impl Literal {
10431043 Literal :: _new ( repr)
10441044 }
10451045
1046- pub fn byte_string ( bytes : & [ u8 ] ) -> Literal {
1046+ pub ( crate ) fn byte_string ( bytes : & [ u8 ] ) -> Literal {
10471047 let mut repr = "b\" " . to_string ( ) ;
10481048 let mut bytes = bytes. iter ( ) ;
10491049 while let Some ( & b) = bytes. next ( ) {
@@ -1069,7 +1069,7 @@ impl Literal {
10691069 Literal :: _new ( repr)
10701070 }
10711071
1072- pub fn c_string ( string : & CStr ) -> Literal {
1072+ pub ( crate ) fn c_string ( string : & CStr ) -> Literal {
10731073 let mut repr = "c\" " . to_string ( ) ;
10741074 let mut bytes = string. to_bytes ( ) ;
10751075 while !bytes. is_empty ( ) {
@@ -1097,15 +1097,15 @@ impl Literal {
10971097 Literal :: _new ( repr)
10981098 }
10991099
1100- pub fn span ( & self ) -> Span {
1100+ pub ( crate ) fn span ( & self ) -> Span {
11011101 self . span
11021102 }
11031103
1104- pub fn set_span ( & mut self , span : Span ) {
1104+ pub ( crate ) fn set_span ( & mut self , span : Span ) {
11051105 self . span = span;
11061106 }
11071107
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 > {
11091109 #[ cfg( not( span_locations) ) ]
11101110 {
11111111 let _ = range;
0 commit comments