@@ -29,16 +29,15 @@ pub struct UnmatchedBrace {
2929}
3030
3131pub 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 ,
3737 /// Stop reading src at this index.
38- crate end_src_index : usize ,
38+ end_src_index : usize ,
3939 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.
4241 src : Lrc < String > ,
4342 override_span : Option < Span > ,
4443}
@@ -56,8 +55,8 @@ impl<'a> StringReader<'a> {
5655
5756 StringReader {
5857 sess,
58+ start_pos : source_file. start_pos ,
5959 pos : source_file. start_pos ,
60- source_file,
6160 end_src_index : src. len ( ) ,
6261 src,
6362 fatal_errs : Vec :: new ( ) ,
@@ -108,12 +107,12 @@ impl<'a> StringReader<'a> {
108107 let text: & str = & self . src [ start_src_index..self . end_src_index ] ;
109108
110109 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 ) ;
112111 return Ok ( Token :: new ( token:: Eof , span) ) ;
113112 }
114113
115114 {
116- let is_beginning_of_file = self . pos == self . source_file . start_pos ;
115+ let is_beginning_of_file = self . pos == self . start_pos ;
117116 if is_beginning_of_file {
118117 if let Some ( shebang_len) = rustc_lexer:: strip_shebang ( text) {
119118 let start = self . pos ;
@@ -533,7 +532,7 @@ impl<'a> StringReader<'a> {
533532
534533 #[ inline]
535534 fn src_index ( & self , pos : BytePos ) -> usize {
536- ( pos - self . source_file . start_pos ) . to_usize ( )
535+ ( pos - self . start_pos ) . to_usize ( )
537536 }
538537
539538 /// Slice of the source text from `start` up to but excluding `self.pos`,
0 commit comments