rustc_parse::lexer

Struct StringReader

Source
struct StringReader<'psess, 'src> {
    psess: &'psess ParseSess,
    start_pos: BytePos,
    pos: BytePos,
    src: &'src str,
    cursor: Cursor<'src>,
    override_span: Option<Span>,
    nbsp_is_whitespace: bool,
    last_lifetime: Option<Span>,
}

Fields§

§psess: &'psess ParseSess§start_pos: BytePos

Initial position, read-only.

§pos: BytePos

The absolute offset within the source_map of the current character.

§src: &'src str

Source text to tokenize.

§cursor: Cursor<'src>

Cursor for getting lexer tokens.

§override_span: Option<Span>§nbsp_is_whitespace: bool

When a “unknown start of token: \u{a0}” has already been emitted earlier in this file, it’s safe to treat further occurrences of the non-breaking space character as whitespace.

§last_lifetime: Option<Span>

Track the Span for the leading ' of the last lifetime. Used for diagnostics to detect possible typo where " was meant.

Implementations§

Source§

impl<'psess, 'src> StringReader<'psess, 'src>

Source

fn dcx(&self) -> DiagCtxtHandle<'psess>

Source

fn mk_sp(&self, lo: BytePos, hi: BytePos) -> Span

Source

fn next_token(&mut self) -> (Token, bool)

Returns the next token, paired with a bool indicating if the token was preceded by whitespace.

Source

fn ident(&self, start: BytePos) -> TokenKind

Source

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.

Source

fn cook_doc_comment( &self, content_start: BytePos, content: &str, comment_kind: CommentKind, doc_style: DocStyle, ) -> TokenKind

Source

fn cook_lexer_literal( &self, start: BytePos, end: BytePos, kind: LiteralKind, ) -> (LitKind, Symbol)

Source

fn src_index(&self, pos: BytePos) -> usize

Source

fn str_from(&self, start: BytePos) -> &'src str

Slice of the source text from start up to but excluding self.pos, meaning the slice does not include the character self.ch.

Source

fn symbol_from_to(&self, start: BytePos, end: BytePos) -> Symbol

As symbol_from, with an explicit endpoint.

Source

fn str_from_to(&self, start: BytePos, end: BytePos) -> &'src str

Slice of the source text spanning from start up to but excluding end.

Source

fn str_from_to_end(&self, start: BytePos) -> &'src str

Slice of the source text spanning from start until the end

Source

fn report_raw_str_error(&self, start: BytePos, prefix_len: u32) -> !

Source

fn report_non_started_raw_string(&self, start: BytePos, bad_char: char) -> !

Source

fn report_unterminated_raw_string( &self, start: BytePos, n_hashes: u32, possible_offset: Option<u32>, found_terminators: u32, ) -> !

Source

fn report_unterminated_block_comment( &self, start: BytePos, doc_style: Option<DocStyle>, )

Source

fn report_unknown_prefix(&self, start: BytePos)

Source

fn maybe_report_guarded_str( &mut self, start: BytePos, str_before: &'src str, ) -> TokenKind

Detect guarded string literal syntax

RFC 3598 reserved this syntax for future use. As of Rust 2024, using this syntax produces an error. In earlier editions, however, it only results in an (allowed by default) lint, and is treated as separate tokens.

Source

fn report_too_many_hashes(&self, start: BytePos, num: u32) -> !

Source

fn cook_common( &self, kind: LitKind, mode: Mode, start: BytePos, end: BytePos, prefix_len: u32, postfix_len: u32, unescape: fn(_: &str, _: Mode, _: &mut dyn FnMut(Range<usize>, Result<(), EscapeError>)), ) -> (LitKind, Symbol)

Source

fn cook_unicode( &self, kind: LitKind, mode: Mode, start: BytePos, end: BytePos, prefix_len: u32, postfix_len: u32, ) -> (LitKind, Symbol)

Source

fn cook_mixed( &self, kind: LitKind, mode: Mode, start: BytePos, end: BytePos, prefix_len: u32, postfix_len: u32, ) -> (LitKind, Symbol)

Auto Trait Implementations§

§

impl<'psess, 'src> !DynSend for StringReader<'psess, 'src>

§

impl<'psess, 'src> !DynSync for StringReader<'psess, 'src>

§

impl<'psess, 'src> Freeze for StringReader<'psess, 'src>

§

impl<'psess, 'src> !RefUnwindSafe for StringReader<'psess, 'src>

§

impl<'psess, 'src> !Send for StringReader<'psess, 'src>

§

impl<'psess, 'src> !Sync for StringReader<'psess, 'src>

§

impl<'psess, 'src> Unpin for StringReader<'psess, 'src>

§

impl<'psess, 'src> !UnwindSafe for StringReader<'psess, 'src>

Blanket Implementations§

Source§

impl<T> Aligned for T

Source§

const ALIGN: Alignment = _

Alignment of Self.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, R> CollectAndApply<T, R> for T

§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

Source§

impl<T> Filterable for T

Source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

§

fn upcast(self, interner: I) -> U

§

impl<I, T> UpcastFrom<I, T> for T

§

fn upcast_from(from: T, _tcx: I) -> T

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<'a, T> Captures<'a> for T
where T: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

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: 88 bytes