Skip to content

Commit c18c194

Browse files
authored
Rollup merge of #59671 - matklad:lexer, r=eddyb
Make some of lexer's API private Lexer is a `pub` type, so it feels wrong that its fields are just pub (I guess it wasn't exported initially), so let's minimize visibility. Context: I am looking into extracting rust-lexer into a library, which can be shared by rust-analyzer and rustc. I hope that a simple interface like `fn next_token(src: &str) -> (TokenKind, usize)` would work, but to try this out I need to understand what is the current API of the lexer.
2 parents 05c31ba + 1763aea commit c18c194

File tree

1 file changed

+8
-8
lines changed
  • src/libsyntax/parse/lexer

1 file changed

+8
-8
lines changed

src/libsyntax/parse/lexer/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ pub struct UnmatchedBrace {
4343
}
4444

4545
pub struct StringReader<'a> {
46-
pub sess: &'a ParseSess,
46+
crate sess: &'a ParseSess,
4747
/// The absolute offset within the source_map of the next character to read
48-
pub next_pos: BytePos,
48+
crate next_pos: BytePos,
4949
/// The absolute offset within the source_map of the current character
50-
pub pos: BytePos,
50+
crate pos: BytePos,
5151
/// The current character (which has been read from self.pos)
52-
pub ch: Option<char>,
53-
pub source_file: Lrc<syntax_pos::SourceFile>,
52+
crate ch: Option<char>,
53+
crate source_file: Lrc<syntax_pos::SourceFile>,
5454
/// Stop reading src at this index.
55-
pub end_src_index: usize,
55+
crate end_src_index: usize,
5656
// cached:
5757
peek_tok: token::Token,
5858
peek_span: Span,
@@ -126,7 +126,7 @@ impl<'a> StringReader<'a> {
126126
}
127127

128128
/// Immutably extract string if found at current position with given delimiters
129-
pub fn peek_delimited(&self, from_ch: char, to_ch: char) -> Option<String> {
129+
fn peek_delimited(&self, from_ch: char, to_ch: char) -> Option<String> {
130130
let mut pos = self.pos;
131131
let mut idx = self.src_index(pos);
132132
let mut ch = char_at(&self.src, idx);
@@ -191,7 +191,7 @@ impl<'a> StringReader<'a> {
191191
self.fatal_span(self.peek_span, m)
192192
}
193193

194-
pub fn emit_fatal_errors(&mut self) {
194+
crate fn emit_fatal_errors(&mut self) {
195195
for err in &mut self.fatal_errs {
196196
err.emit();
197197
}

0 commit comments

Comments
 (0)