@@ -51,16 +51,16 @@ pub struct StringReader<'a> {
51
51
pub ch : Option < char > ,
52
52
pub filemap : Lrc < syntax_pos:: FileMap > ,
53
53
/// Stop reading src at this index.
54
- pub end_src_index : usize ,
54
+ end_src_index : usize ,
55
55
/// Whether to record new-lines and multibyte chars in filemap.
56
56
/// This is only necessary the first time a filemap is lexed.
57
57
/// If part of a filemap is being re-lexed, this should be set to false.
58
- pub save_new_lines_and_multibyte : bool ,
58
+ save_new_lines_and_multibyte : bool ,
59
59
// cached:
60
60
peek_tok : token:: Token ,
61
61
peek_span : Span ,
62
62
peek_span_src_raw : Span ,
63
- pub fatal_errs : Vec < DiagnosticBuilder < ' a > > ,
63
+ fatal_errs : Vec < DiagnosticBuilder < ' a > > ,
64
64
// cache a direct reference to the source text, so that we don't have to
65
65
// retrieve it via `self.filemap.src.as_ref().unwrap()` all the time.
66
66
src : Lrc < String > ,
@@ -70,7 +70,7 @@ pub struct StringReader<'a> {
70
70
/// The raw source span which *does not* take `override_span` into account
71
71
span_src_raw : Span ,
72
72
open_braces : Vec < ( token:: DelimToken , Span ) > ,
73
- pub override_span : Option < Span > ,
73
+ crate override_span : Option < Span > ,
74
74
}
75
75
76
76
impl < ' a > StringReader < ' a > {
@@ -163,11 +163,9 @@ impl<'a> StringReader<'a> {
163
163
sp : self . peek_span ,
164
164
}
165
165
}
166
- }
167
166
168
- impl < ' a > StringReader < ' a > {
169
167
/// For comments.rs, which hackily pokes into next_pos and ch
170
- pub fn new_raw ( sess : & ' a ParseSess , filemap : Lrc < syntax_pos:: FileMap > ,
168
+ fn new_raw ( sess : & ' a ParseSess , filemap : Lrc < syntax_pos:: FileMap > ,
171
169
override_span : Option < Span > ) -> Self {
172
170
let mut sr = StringReader :: new_raw_internal ( sess, filemap, override_span) ;
173
171
sr. bump ( ) ;
@@ -240,17 +238,17 @@ impl<'a> StringReader<'a> {
240
238
sr
241
239
}
242
240
243
- pub fn ch_is ( & self , c : char ) -> bool {
241
+ fn ch_is ( & self , c : char ) -> bool {
244
242
self . ch == Some ( c)
245
243
}
246
244
247
245
/// Report a fatal lexical error with a given span.
248
- pub fn fatal_span ( & self , sp : Span , m : & str ) -> FatalError {
246
+ fn fatal_span ( & self , sp : Span , m : & str ) -> FatalError {
249
247
self . sess . span_diagnostic . span_fatal ( sp, m)
250
248
}
251
249
252
250
/// Report a lexical error with a given span.
253
- pub fn err_span ( & self , sp : Span , m : & str ) {
251
+ fn err_span ( & self , sp : Span , m : & str ) {
254
252
self . sess . span_diagnostic . span_err ( sp, m)
255
253
}
256
254
@@ -375,7 +373,7 @@ impl<'a> StringReader<'a> {
375
373
/// Calls `f` with a string slice of the source text spanning from `start`
376
374
/// up to but excluding `self.pos`, meaning the slice does not include
377
375
/// the character `self.ch`.
378
- pub fn with_str_from < T , F > ( & self , start : BytePos , f : F ) -> T
376
+ fn with_str_from < T , F > ( & self , start : BytePos , f : F ) -> T
379
377
where F : FnOnce ( & str ) -> T
380
378
{
381
379
self . with_str_from_to ( start, self . pos , f)
@@ -384,13 +382,13 @@ impl<'a> StringReader<'a> {
384
382
/// Create a Name from a given offset to the current offset, each
385
383
/// adjusted 1 towards each other (assumes that on either side there is a
386
384
/// single-byte delimiter).
387
- pub fn name_from ( & self , start : BytePos ) -> ast:: Name {
385
+ fn name_from ( & self , start : BytePos ) -> ast:: Name {
388
386
debug ! ( "taking an ident from {:?} to {:?}" , start, self . pos) ;
389
387
self . with_str_from ( start, Symbol :: intern)
390
388
}
391
389
392
390
/// As name_from, with an explicit endpoint.
393
- pub fn name_from_to ( & self , start : BytePos , end : BytePos ) -> ast:: Name {
391
+ fn name_from_to ( & self , start : BytePos , end : BytePos ) -> ast:: Name {
394
392
debug ! ( "taking an ident from {:?} to {:?}" , start, end) ;
395
393
self . with_str_from_to ( start, end, Symbol :: intern)
396
394
}
@@ -454,7 +452,7 @@ impl<'a> StringReader<'a> {
454
452
455
453
/// Advance the StringReader by one character. If a newline is
456
454
/// discovered, add it to the FileMap's list of line start offsets.
457
- pub fn bump ( & mut self ) {
455
+ crate fn bump ( & mut self ) {
458
456
let next_src_index = self . src_index ( self . next_pos ) ;
459
457
if next_src_index < self . end_src_index {
460
458
let next_ch = char_at ( & self . src , next_src_index) ;
@@ -481,7 +479,7 @@ impl<'a> StringReader<'a> {
481
479
}
482
480
}
483
481
484
- pub fn nextch ( & self ) -> Option < char > {
482
+ fn nextch ( & self ) -> Option < char > {
485
483
let next_src_index = self . src_index ( self . next_pos ) ;
486
484
if next_src_index < self . end_src_index {
487
485
Some ( char_at ( & self . src , next_src_index) )
@@ -490,11 +488,11 @@ impl<'a> StringReader<'a> {
490
488
}
491
489
}
492
490
493
- pub fn nextch_is ( & self , c : char ) -> bool {
491
+ fn nextch_is ( & self , c : char ) -> bool {
494
492
self . nextch ( ) == Some ( c)
495
493
}
496
494
497
- pub fn nextnextch ( & self ) -> Option < char > {
495
+ fn nextnextch ( & self ) -> Option < char > {
498
496
let next_src_index = self . src_index ( self . next_pos ) ;
499
497
if next_src_index < self . end_src_index {
500
498
let next_next_src_index =
@@ -506,7 +504,7 @@ impl<'a> StringReader<'a> {
506
504
None
507
505
}
508
506
509
- pub fn nextnextch_is ( & self , c : char ) -> bool {
507
+ fn nextnextch_is ( & self , c : char ) -> bool {
510
508
self . nextnextch ( ) == Some ( c)
511
509
}
512
510
@@ -1732,7 +1730,7 @@ impl<'a> StringReader<'a> {
1732
1730
1733
1731
// This tests the character for the unicode property 'PATTERN_WHITE_SPACE' which
1734
1732
// is guaranteed to be forward compatible. http://unicode.org/reports/tr31/#R3
1735
- pub fn is_pattern_whitespace ( c : Option < char > ) -> bool {
1733
+ crate fn is_pattern_whitespace ( c : Option < char > ) -> bool {
1736
1734
c. map_or ( false , Pattern_White_Space )
1737
1735
}
1738
1736
@@ -1747,14 +1745,14 @@ fn is_dec_digit(c: Option<char>) -> bool {
1747
1745
in_range ( c, '0' , '9' )
1748
1746
}
1749
1747
1750
- pub fn is_doc_comment ( s : & str ) -> bool {
1748
+ fn is_doc_comment ( s : & str ) -> bool {
1751
1749
let res = ( s. starts_with ( "///" ) && * s. as_bytes ( ) . get ( 3 ) . unwrap_or ( & b' ' ) != b'/' ) ||
1752
1750
s. starts_with ( "//!" ) ;
1753
1751
debug ! ( "is {:?} a doc comment? {}" , s, res) ;
1754
1752
res
1755
1753
}
1756
1754
1757
- pub fn is_block_doc_comment ( s : & str ) -> bool {
1755
+ fn is_block_doc_comment ( s : & str ) -> bool {
1758
1756
// Prevent `/**/` from being parsed as a doc comment
1759
1757
let res = ( ( s. starts_with ( "/**" ) && * s. as_bytes ( ) . get ( 3 ) . unwrap_or ( & b' ' ) != b'*' ) ||
1760
1758
s. starts_with ( "/*!" ) ) && s. len ( ) >= 5 ;
0 commit comments