@@ -29,16 +29,15 @@ pub struct UnmatchedBrace {
29
29
}
30
30
31
31
pub struct StringReader < ' a > {
32
- crate sess : & ' a ParseSess ,
33
- /// The absolute offset within the source_map of the current character
34
- crate pos : BytePos ,
35
- /// The current character (which has been read from self.pos)
36
- crate source_file : Lrc < syntax_pos :: SourceFile > ,
32
+ sess : & ' a ParseSess ,
33
+ /// Initial position, read-only.
34
+ start_pos : BytePos ,
35
+ /// The absolute offset within the source_map of the current character.
36
+ pos : BytePos ,
37
37
/// Stop reading src at this index.
38
- crate end_src_index : usize ,
38
+ end_src_index : usize ,
39
39
fatal_errs : Vec < DiagnosticBuilder < ' a > > ,
40
- // cache a direct reference to the source text, so that we don't have to
41
- // retrieve it via `self.source_file.src.as_ref().unwrap()` all the time.
40
+ /// Source text to tokenize.
42
41
src : Lrc < String > ,
43
42
override_span : Option < Span > ,
44
43
}
@@ -56,8 +55,8 @@ impl<'a> StringReader<'a> {
56
55
57
56
StringReader {
58
57
sess,
58
+ start_pos : source_file. start_pos ,
59
59
pos : source_file. start_pos ,
60
- source_file,
61
60
end_src_index : src. len ( ) ,
62
61
src,
63
62
fatal_errs : Vec :: new ( ) ,
@@ -108,12 +107,12 @@ impl<'a> StringReader<'a> {
108
107
let text: & str = & self . src [ start_src_index..self . end_src_index ] ;
109
108
110
109
if text. is_empty ( ) {
111
- let span = self . mk_sp ( self . source_file . end_pos , self . source_file . end_pos ) ;
110
+ let span = self . mk_sp ( self . pos , self . pos ) ;
112
111
return Ok ( Token :: new ( token:: Eof , span) ) ;
113
112
}
114
113
115
114
{
116
- let is_beginning_of_file = self . pos == self . source_file . start_pos ;
115
+ let is_beginning_of_file = self . pos == self . start_pos ;
117
116
if is_beginning_of_file {
118
117
if let Some ( shebang_len) = rustc_lexer:: strip_shebang ( text) {
119
118
let start = self . pos ;
@@ -534,7 +533,7 @@ impl<'a> StringReader<'a> {
534
533
535
534
#[ inline]
536
535
fn src_index ( & self , pos : BytePos ) -> usize {
537
- ( pos - self . source_file . start_pos ) . to_usize ( )
536
+ ( pos - self . start_pos ) . to_usize ( )
538
537
}
539
538
540
539
/// Slice of the source text from `start` up to but excluding `self.pos`,
0 commit comments