Struct rustc_parse::lexer::StringReader
source · [−]struct StringReader<'a> {
sess: &'a ParseSess,
start_pos: BytePos,
pos: BytePos,
end_src_index: usize,
src: &'a str,
override_span: Option<Span>,
}Fields
sess: &'a ParseSessstart_pos: BytePosInitial position, read-only.
pos: BytePosThe absolute offset within the source_map of the current character.
end_src_index: usizeStop reading src at this index.
src: &'a strSource text to tokenize.
override_span: Option<Span>Implementations
sourceimpl<'a> StringReader<'a>
impl<'a> StringReader<'a>
pub(super) fn into_token_trees(
self
) -> (PResult<'a, TokenStream>, Vec<UnmatchedBrace>)
sourceimpl<'a> StringReader<'a>
impl<'a> StringReader<'a>
fn mk_sp(&self, lo: BytePos, hi: BytePos) -> Span
sourcefn next_token(&mut self) -> (Spacing, Token)
fn next_token(&mut self) -> (Spacing, Token)
Returns the next token, and info about preceding whitespace, if any.
sourcefn fatal_span(&self, sp: Span, m: &str) -> FatalError
fn fatal_span(&self, sp: Span, m: &str) -> FatalError
Report a fatal lexical error with a given span.
sourcefn fatal_span_(&self, from_pos: BytePos, to_pos: BytePos, m: &str) -> FatalError
fn fatal_span_(&self, from_pos: BytePos, to_pos: BytePos, m: &str) -> FatalError
Report a fatal error spanning [from_pos, to_pos).
sourcefn err_span_(&self, from_pos: BytePos, to_pos: BytePos, m: &str)
fn err_span_(&self, from_pos: BytePos, to_pos: BytePos, m: &str)
Report a lexical error spanning [from_pos, to_pos).
fn struct_fatal_span_char(
&self,
from_pos: BytePos,
to_pos: BytePos,
m: &str,
c: char
) -> DiagnosticBuilder<'a>
sourcefn lint_unicode_text_flow(&self, start: BytePos)
fn lint_unicode_text_flow(&self, start: BytePos)
Detect usages of Unicode codepoints changing the direction of the text on screen and loudly complain about it.
sourcefn cook_lexer_token(
&self,
token: TokenKind,
start: BytePos
) -> Option<TokenKind>
fn cook_lexer_token(
&self,
token: TokenKind,
start: BytePos
) -> Option<TokenKind>
Turns simple rustc_lexer::TokenKind enum into a rich
rustc_ast::TokenKind. This turns strings into interned
symbols and runs additional validation.
fn cook_doc_comment(
&self,
content_start: BytePos,
content: &str,
comment_kind: CommentKind,
doc_style: DocStyle
) -> TokenKind
fn cook_lexer_literal(
&self,
start: BytePos,
suffix_start: BytePos,
kind: LiteralKind
) -> (LitKind, Symbol)
fn src_index(&self, pos: BytePos) -> usize
sourcefn str_from(&self, start: BytePos) -> &str
fn str_from(&self, start: BytePos) -> &str
Slice of the source text from start up to but excluding self.pos,
meaning the slice does not include the character self.ch.
sourcefn symbol_from_to(&self, start: BytePos, end: BytePos) -> Symbol
fn symbol_from_to(&self, start: BytePos, end: BytePos) -> Symbol
As symbol_from, with an explicit endpoint.
sourcefn str_from_to(&self, start: BytePos, end: BytePos) -> &str
fn str_from_to(&self, start: BytePos, end: BytePos) -> &str
Slice of the source text spanning from start up to but excluding end.
fn report_raw_str_error(&self, start: BytePos, opt_err: Option<RawStrError>)
fn report_non_started_raw_string(&self, start: BytePos, bad_char: char) -> !
fn report_unterminated_raw_string(
&self,
start: BytePos,
n_hashes: usize,
possible_offset: Option<usize>,
found_terminators: usize
) -> !
fn report_unknown_prefix(&self, start: BytePos)
sourcefn report_too_many_hashes(&self, start: BytePos, found: usize) -> !
fn report_too_many_hashes(&self, start: BytePos, found: usize) -> !
Note: It was decided to not add a test case, because it would be too big. https://github.com/rust-lang/rust/pull/50296#issuecomment-392135180
fn validate_literal_escape(
&self,
mode: Mode,
content_start: BytePos,
content_end: BytePos,
prefix_len: u32,
postfix_len: u32
)
fn validate_int_literal(
&self,
base: Base,
content_start: BytePos,
content_end: BytePos
)
Auto Trait Implementations
impl<'a> !RefUnwindSafe for StringReader<'a>
impl<'a> !Send for StringReader<'a>
impl<'a> !Sync for StringReader<'a>
impl<'a> Unpin for StringReader<'a>
impl<'a> !UnwindSafe for StringReader<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 56 bytes