@@ -5,29 +5,29 @@ pub(crate) mod printf {
55
66 /// Represents a single `printf`-style substitution.
77 #[ derive( Clone , PartialEq , Debug ) ]
8- pub enum Substitution < ' a > {
8+ pub ( crate ) enum Substitution < ' a > {
99 /// A formatted output substitution with its internal byte offset.
1010 Format ( Format < ' a > ) ,
1111 /// A literal `%%` escape, with its start and end indices.
1212 Escape ( ( usize , usize ) ) ,
1313 }
1414
1515 impl < ' a > Substitution < ' a > {
16- pub fn as_str ( & self ) -> & str {
16+ pub ( crate ) fn as_str ( & self ) -> & str {
1717 match self {
1818 Substitution :: Format ( fmt) => fmt. span ,
1919 Substitution :: Escape ( _) => "%%" ,
2020 }
2121 }
2222
23- pub fn position ( & self ) -> InnerSpan {
23+ pub ( crate ) fn position ( & self ) -> InnerSpan {
2424 match self {
2525 Substitution :: Format ( fmt) => fmt. position ,
2626 & Substitution :: Escape ( ( start, end) ) => InnerSpan :: new ( start, end) ,
2727 }
2828 }
2929
30- pub fn set_position ( & mut self , start : usize , end : usize ) {
30+ pub ( crate ) fn set_position ( & mut self , start : usize , end : usize ) {
3131 match self {
3232 Substitution :: Format ( fmt) => fmt. position = InnerSpan :: new ( start, end) ,
3333 Substitution :: Escape ( pos) => * pos = ( start, end) ,
@@ -38,7 +38,7 @@ pub(crate) mod printf {
3838 ///
3939 /// This ignores cases where the substitution does not have an exact equivalent, or where
4040 /// the substitution would be unnecessary.
41- pub fn translate ( & self ) -> Result < String , Option < String > > {
41+ pub ( crate ) fn translate ( & self ) -> Result < String , Option < String > > {
4242 match self {
4343 Substitution :: Format ( fmt) => fmt. translate ( ) ,
4444 Substitution :: Escape ( _) => Err ( None ) ,
@@ -48,31 +48,31 @@ pub(crate) mod printf {
4848
4949 #[ derive( Clone , PartialEq , Debug ) ]
5050 /// A single `printf`-style formatting directive.
51- pub struct Format < ' a > {
51+ pub ( crate ) struct Format < ' a > {
5252 /// The entire original formatting directive.
53- pub span : & ' a str ,
53+ span : & ' a str ,
5454 /// The (1-based) parameter to be converted.
55- pub parameter : Option < u16 > ,
55+ parameter : Option < u16 > ,
5656 /// Formatting flags.
57- pub flags : & ' a str ,
57+ flags : & ' a str ,
5858 /// Minimum width of the output.
59- pub width : Option < Num > ,
59+ width : Option < Num > ,
6060 /// Precision of the conversion.
61- pub precision : Option < Num > ,
61+ precision : Option < Num > ,
6262 /// Length modifier for the conversion.
63- pub length : Option < & ' a str > ,
63+ length : Option < & ' a str > ,
6464 /// Type of parameter being converted.
65- pub type_ : & ' a str ,
65+ type_ : & ' a str ,
6666 /// Byte offset for the start and end of this formatting directive.
67- pub position : InnerSpan ,
67+ position : InnerSpan ,
6868 }
6969
7070 impl Format < ' _ > {
7171 /// Translate this directive into an equivalent Rust formatting directive.
7272 ///
7373 /// Returns `Err` in cases where the `printf` directive does not have an exact Rust
7474 /// equivalent, rather than guessing.
75- pub fn translate ( & self ) -> Result < String , Option < String > > {
75+ pub ( crate ) fn translate ( & self ) -> Result < String , Option < String > > {
7676 use std:: fmt:: Write ;
7777
7878 let ( c_alt, c_zero, c_left, c_plus) = {
@@ -249,7 +249,7 @@ pub(crate) mod printf {
249249
250250 /// A general number used in a `printf` formatting directive.
251251 #[ derive( Copy , Clone , PartialEq , Debug ) ]
252- pub enum Num {
252+ enum Num {
253253 // The range of these values is technically bounded by `NL_ARGMAX`... but, at least for GNU
254254 // libc, it apparently has no real fixed limit. A `u16` is used here on the basis that it
255255 // is *vanishingly* unlikely that *anyone* is going to try formatting something wider, or
@@ -288,12 +288,12 @@ pub(crate) mod printf {
288288 }
289289
290290 /// Returns an iterator over all substitutions in a given string.
291- pub fn iter_subs ( s : & str , start_pos : usize ) -> Substitutions < ' _ > {
291+ pub ( crate ) fn iter_subs ( s : & str , start_pos : usize ) -> Substitutions < ' _ > {
292292 Substitutions { s, pos : start_pos }
293293 }
294294
295295 /// Iterator over substitutions in a string.
296- pub struct Substitutions < ' a > {
296+ pub ( crate ) struct Substitutions < ' a > {
297297 s : & ' a str ,
298298 pos : usize ,
299299 }
@@ -327,7 +327,7 @@ pub(crate) mod printf {
327327 }
328328
329329 /// Parse the next substitution from the input string.
330- pub fn parse_next_substitution ( s : & str ) -> Option < ( Substitution < ' _ > , & str ) > {
330+ fn parse_next_substitution ( s : & str ) -> Option < ( Substitution < ' _ > , & str ) > {
331331 use self :: State :: * ;
332332
333333 let at = {
@@ -615,38 +615,38 @@ pub(crate) mod printf {
615615 mod tests;
616616}
617617
618- pub mod shell {
618+ pub ( crate ) mod shell {
619619 use rustc_span:: InnerSpan ;
620620
621621 use super :: strcursor:: StrCursor as Cur ;
622622
623623 #[ derive( Clone , PartialEq , Debug ) ]
624- pub enum Substitution < ' a > {
624+ pub ( crate ) enum Substitution < ' a > {
625625 Ordinal ( u8 , ( usize , usize ) ) ,
626626 Name ( & ' a str , ( usize , usize ) ) ,
627627 Escape ( ( usize , usize ) ) ,
628628 }
629629
630630 impl Substitution < ' _ > {
631- pub fn as_str ( & self ) -> String {
631+ pub ( crate ) fn as_str ( & self ) -> String {
632632 match self {
633633 Substitution :: Ordinal ( n, _) => format ! ( "${n}" ) ,
634634 Substitution :: Name ( n, _) => format ! ( "${n}" ) ,
635635 Substitution :: Escape ( _) => "$$" . into ( ) ,
636636 }
637637 }
638638
639- pub fn position ( & self ) -> InnerSpan {
639+ pub ( crate ) fn position ( & self ) -> InnerSpan {
640640 let ( Self :: Ordinal ( _, pos) | Self :: Name ( _, pos) | Self :: Escape ( pos) ) = self ;
641641 InnerSpan :: new ( pos. 0 , pos. 1 )
642642 }
643643
644- pub fn set_position ( & mut self , start : usize , end : usize ) {
644+ fn set_position ( & mut self , start : usize , end : usize ) {
645645 let ( Self :: Ordinal ( _, pos) | Self :: Name ( _, pos) | Self :: Escape ( pos) ) = self ;
646646 * pos = ( start, end) ;
647647 }
648648
649- pub fn translate ( & self ) -> Result < String , Option < String > > {
649+ pub ( crate ) fn translate ( & self ) -> Result < String , Option < String > > {
650650 match self {
651651 Substitution :: Ordinal ( n, _) => Ok ( format ! ( "{{{}}}" , n) ) ,
652652 Substitution :: Name ( n, _) => Ok ( format ! ( "{{{}}}" , n) ) ,
@@ -656,12 +656,12 @@ pub mod shell {
656656 }
657657
658658 /// Returns an iterator over all substitutions in a given string.
659- pub fn iter_subs ( s : & str , start_pos : usize ) -> Substitutions < ' _ > {
659+ pub ( crate ) fn iter_subs ( s : & str , start_pos : usize ) -> Substitutions < ' _ > {
660660 Substitutions { s, pos : start_pos }
661661 }
662662
663663 /// Iterator over substitutions in a string.
664- pub struct Substitutions < ' a > {
664+ pub ( crate ) struct Substitutions < ' a > {
665665 s : & ' a str ,
666666 pos : usize ,
667667 }
@@ -683,7 +683,7 @@ pub mod shell {
683683 }
684684
685685 /// Parse the next substitution from the input string.
686- pub fn parse_next_substitution ( s : & str ) -> Option < ( Substitution < ' _ > , & str ) > {
686+ fn parse_next_substitution ( s : & str ) -> Option < ( Substitution < ' _ > , & str ) > {
687687 let at = {
688688 let start = s. find ( '$' ) ?;
689689 match s[ start + 1 ..] . chars ( ) . next ( ) ? {
@@ -743,24 +743,24 @@ pub mod shell {
743743}
744744
745745mod strcursor {
746- pub struct StrCursor < ' a > {
746+ pub ( crate ) struct StrCursor < ' a > {
747747 s : & ' a str ,
748748 pub at : usize ,
749749 }
750750
751751 impl < ' a > StrCursor < ' a > {
752- pub fn new_at ( s : & ' a str , at : usize ) -> StrCursor < ' a > {
752+ pub ( crate ) fn new_at ( s : & ' a str , at : usize ) -> StrCursor < ' a > {
753753 StrCursor { s, at }
754754 }
755755
756- pub fn at_next_cp ( mut self ) -> Option < StrCursor < ' a > > {
756+ pub ( crate ) fn at_next_cp ( mut self ) -> Option < StrCursor < ' a > > {
757757 match self . try_seek_right_cp ( ) {
758758 true => Some ( self ) ,
759759 false => None ,
760760 }
761761 }
762762
763- pub fn next_cp ( mut self ) -> Option < ( char , StrCursor < ' a > ) > {
763+ pub ( crate ) fn next_cp ( mut self ) -> Option < ( char , StrCursor < ' a > ) > {
764764 let cp = self . cp_after ( ) ?;
765765 self . seek_right ( cp. len_utf8 ( ) ) ;
766766 Some ( ( cp, self ) )
@@ -770,11 +770,11 @@ mod strcursor {
770770 & self . s [ 0 ..self . at ]
771771 }
772772
773- pub fn slice_after ( & self ) -> & ' a str {
773+ pub ( crate ) fn slice_after ( & self ) -> & ' a str {
774774 & self . s [ self . at ..]
775775 }
776776
777- pub fn slice_between ( & self , until : StrCursor < ' a > ) -> Option < & ' a str > {
777+ pub ( crate ) fn slice_between ( & self , until : StrCursor < ' a > ) -> Option < & ' a str > {
778778 if !str_eq_literal ( self . s , until. s ) {
779779 None
780780 } else {
0 commit comments