Struct rustc_hir_pretty::State [−][src]
pub struct State<'a> {
pub s: Printer,
comments: Option<Comments<'a>>,
attrs: &'a dyn Fn(HirId) -> &'a [Attribute],
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
pub fn commasep_cmnt<T, F, G>(
&mut self,
b: Breaks,
elts: &[T],
op: F,
get_span: G
) where
F: FnMut(&mut State<'_>, &T),
G: FnMut(&T) -> Span,
pub(crate) fn print_associated_const(
&mut self,
ident: Ident,
ty: &Ty<'_>,
default: Option<BodyId>,
vis: &Visibility<'_>
)
pub(crate) fn print_associated_type(
&mut self,
ident: Ident,
generics: &Generics<'_>,
bounds: Option<GenericBounds<'_>>,
ty: Option<&Ty<'_>>
)
pub(crate) fn print_item_type(
&mut self,
item: &Item<'_>,
generics: &Generics<'_>,
inner: impl Fn(&mut Self)
)
Pretty-print an item
pub fn print_enum_def(
&mut self,
enum_definition: &EnumDef<'_>,
generics: &Generics<'_>,
name: Symbol,
span: Span,
visibility: &Visibility<'_>
)
pub fn print_struct(
&mut self,
struct_def: &VariantData<'_>,
generics: &Generics<'_>,
name: Symbol,
span: Span,
print_finalizer: bool
)
pub fn print_method_sig(
&mut self,
ident: Ident,
m: &FnSig<'_>,
generics: &Generics<'_>,
vis: &Visibility<'_>,
arg_names: &[Ident],
body_id: Option<BodyId>
)
pub fn print_block_maybe_unclosed(
&mut self,
blk: &Block<'_>,
attrs: &[Attribute],
close_box: bool
)
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.
pub(crate) fn print_expr_struct(
&mut self,
qpath: &QPath<'_>,
fields: &[ExprField<'_>],
wth: &Option<&Expr<'_>>
)
pub(crate) fn print_expr_addr_of(
&mut self,
kind: BorrowKind,
mutability: Mutability,
expr: &Expr<'_>
)
pub(crate) fn print_generic_args(
&mut self,
generic_args: &GenericArgs<'_>,
infer_args: bool,
colons_before_params: bool
)
pub fn print_fn(
&mut self,
decl: &FnDecl<'_>,
header: FnHeader,
name: Option<Symbol>,
generics: &Generics<'_>,
vis: &Visibility<'_>,
arg_names: &[Ident],
body_id: Option<BodyId>
)
pub fn print_bounds<'b>(
&mut self,
prefix: &'static str,
bounds: impl IntoIterator<Item = &'b GenericBound<'b>>
)
Trait Implementations
fn strsep<T, F>(
&mut self,
sep: &'static str,
space_before: bool,
b: Breaks,
elts: &[T],
op: F
) where
F: FnMut(&mut Self, &T),
fn print_either_attributes(
&mut self,
attrs: &[Attribute],
kind: AttrStyle,
is_inline: bool,
trailing_hardbreak: bool
)
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
fn print_mac_common(
&mut self,
header: Option<MacHeader<'_>>,
has_bang: bool,
ident: Option<Ident>,
delim: DelimToken,
tts: &TokenStream,
convert_dollar_crate: bool,
span: Span
)
fn print_mac_def(
&mut self,
macro_def: &MacroDef,
ident: &Ident,
sp: &Span,
print_visibility: impl FnOnce(&mut Self)
)
Print the token kind precisely, without converting $crate
into its respective crate name.
fn token_kind_to_string_ext(
&self,
tok: &TokenKind,
convert_dollar_crate: Option<Span>
) -> Cow<'static, str>
Print the token precisely, without converting $crate
into its respective crate name.
Auto Trait Implementations
impl<'a> !RefUnwindSafe for State<'a>
impl<'a> !UnwindSafe for State<'a>
Blanket Implementations
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: 240 bytes