Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup stale 'FIXME(#64197)' #72206

Merged
merged 1 commit into from
May 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc_expand/parse/lexer/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ fn t1() {
assert_eq!(string_reader.next_token(), token::Whitespace);
// Read another token.
let tok3 = string_reader.next_token();
assert_eq!(string_reader.pos.clone(), BytePos(28));
assert_eq!(string_reader.pos(), BytePos(28));
let tok4 = Token::new(mk_ident("main"), Span::with_root_ctxt(BytePos(24), BytePos(28)));
assert_eq!(tok3.kind, tok4.kind);
assert_eq!(tok3.span, tok4.span);

assert_eq!(string_reader.next_token(), token::OpenDelim(token::Paren));
assert_eq!(string_reader.pos.clone(), BytePos(29))
assert_eq!(string_reader.pos(), BytePos(29))
})
}

Expand Down
7 changes: 5 additions & 2 deletions src/librustc_parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ pub struct StringReader<'a> {
/// Initial position, read-only.
start_pos: BytePos,
/// The absolute offset within the source_map of the current character.
// FIXME(#64197): `pub` is needed by tests for now.
pub pos: BytePos,
pos: BytePos,
/// Stop reading src at this index.
end_src_index: usize,
/// Source text to tokenize.
Expand Down Expand Up @@ -436,6 +435,10 @@ impl<'a> StringReader<'a> {
}
}

pub fn pos(&self) -> BytePos {
self.pos
}

#[inline]
fn src_index(&self, pos: BytePos) -> usize {
(pos - self.start_pos).to_usize()
Expand Down