Struct rustc_hir_pretty::State

source ·
pub struct State<'a> {
    pub s: Printer,
    pub(crate) comments: Option<Comments<'a>>,
    pub(crate) attrs: &'a dyn Fn(HirId) -> &'a [Attribute],
    pub(crate) ann: &'a (dyn PpAnn + 'a),
}

Fields§

§s: Printer§comments: Option<Comments<'a>>§attrs: &'a dyn Fn(HirId) -> &'a [Attribute]§ann: &'a (dyn PpAnn + 'a)

Implementations§

Pretty-print an item

source

pub(crate) fn print_call_post(&mut self, args: &[Expr<'_>])

Prints an expr using syntax that’s acceptable in a condition position, such as the cond in if cond { ... }.

Prints expr or (expr) when needs_par holds.

Print a let pat = expr expression.

Trait Implementations§

The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
This doesn’t deserve to be called “pretty” printing, but it should be meaning-preserving. A quick hack that might help would be to look at the spans embedded in the TTs to decide where to put spaces and newlines. But it’d be better to parse these according to the grammar of the appropriate macro, transcribe back into the grammar we just parsed from, and then pretty-print the resulting AST nodes (so, e.g., we print expression arguments as expressions). It can be done! I think. Read more
Print the token kind precisely, without converting $crate into its respective crate name.
Print the token precisely, without converting $crate into its respective crate name.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

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