rustc_ast_pretty::pp

Struct Printer

Source
pub struct Printer {
    out: String,
    space: isize,
    buf: RingBuffer<BufEntry>,
    left_total: isize,
    right_total: isize,
    scan_stack: VecDeque<usize>,
    print_stack: Vec<PrintFrame>,
    indent: usize,
    pending_indentation: isize,
    last_printed: Option<Token>,
}

Fields§

§out: String§space: isize

Number of spaces left on line

§buf: RingBuffer<BufEntry>

Ring-buffer of tokens and calculated sizes

§left_total: isize

Running size of stream “…left”

§right_total: isize

Running size of stream “…right”

§scan_stack: VecDeque<usize>

Pseudo-stack, really a ring too. Holds the primary-ring-buffers index of the Begin that started the current block, possibly with the most recent Break after that Begin (if there is any) on top of it. Stuff is flushed off the bottom as it becomes irrelevant due to the primary ring-buffer advancing.

§print_stack: Vec<PrintFrame>

Stack of blocks-in-progress being flushed by print

§indent: usize

Level of indentation of current line

§pending_indentation: isize

Buffered indentation to avoid writing trailing whitespace

§last_printed: Option<Token>

The token most recently popped from the left boundary of the ring-buffer for printing

Implementations§

Source§

impl Printer

Source

pub fn word_space<W: Into<Cow<'static, str>>>(&mut self, w: W)

Source

pub fn popen(&mut self)

Source

pub fn pclose(&mut self)

Source

pub fn hardbreak_if_not_bol(&mut self)

Source

pub fn space_if_not_bol(&mut self)

Source

pub fn nbsp(&mut self)

Source

pub fn word_nbsp<S: Into<Cow<'static, str>>>(&mut self, w: S)

Source

pub fn synth_comment(&mut self, text: impl Into<Cow<'static, str>>)

Synthesizes a comment that was not textually present in the original source file.

Source§

impl Printer

Source

pub fn rbox(&mut self, indent: isize, breaks: Breaks)

“raw box”

Source

pub fn ibox(&mut self, indent: isize)

Inconsistent breaking box

Source

pub fn cbox(&mut self, indent: isize)

Consistent breaking box

Source

pub fn visual_align(&mut self)

Source

pub fn break_offset(&mut self, n: usize, off: isize)

Source

pub fn end(&mut self)

Source

pub fn eof(self) -> String

Source

pub fn word<S: Into<Cow<'static, str>>>(&mut self, wrd: S)

Source

fn spaces(&mut self, n: usize)

Source

pub fn zerobreak(&mut self)

Source

pub fn space(&mut self)

Source

pub fn hardbreak(&mut self)

Source

pub fn is_beginning_of_line(&self) -> bool

Source

pub(crate) fn hardbreak_tok_offset(off: isize) -> Token

Source

pub fn trailing_comma(&mut self)

Source

pub fn trailing_comma_or_space(&mut self)

Source§

impl Printer

Source

pub fn new() -> Self

Source

pub(crate) fn last_token(&self) -> Option<&Token>

Source

pub(crate) fn last_token_still_buffered(&self) -> Option<&Token>

Source

pub(crate) fn replace_last_token_still_buffered(&mut self, token: Token)

Be very careful with this!

Source

fn scan_eof(&mut self)

Source

fn scan_begin(&mut self, token: BeginToken)

Source

fn scan_end(&mut self)

Source

fn scan_break(&mut self, token: BreakToken)

Source

fn scan_string(&mut self, string: Cow<'static, str>)

Source

pub(crate) fn offset(&mut self, offset: isize)

Source

fn check_stream(&mut self)

Source

fn advance_left(&mut self)

Source

fn check_stack(&mut self, depth: usize)

Source

fn get_top(&self) -> PrintFrame

Source

fn print_begin(&mut self, token: BeginToken, size: isize)

Source

fn print_end(&mut self)

Source

fn print_break(&mut self, token: BreakToken, size: isize)

Source

fn print_string(&mut self, string: &str)

Auto Trait Implementations§

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
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.
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,

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