Struct rustc_ast_pretty::pprust::state::State [−][src]
Fields
s: Printer
comments: Option<Comments<'a>>
ann: &'a (dyn PpAnn + 'a)
Implementations
pub(crate) 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,
fn print_item_const(
&mut self,
ident: Ident,
mutbl: Option<Mutability>,
ty: &Ty,
body: Option<&Expr>,
vis: &Visibility,
defaultness: Defaultness
)
fn print_associated_type(
&mut self,
ident: Ident,
generics: &Generics,
bounds: &GenericBounds,
ty: Option<&Ty>,
vis: &Visibility,
defaultness: Defaultness
)
Pretty-prints an item.
pub(crate) fn print_enum_def(
&mut self,
enum_definition: &EnumDef,
generics: &Generics,
ident: Ident,
span: Span,
visibility: &Visibility
)
pub(crate) fn print_struct(
&mut self,
struct_def: &VariantData,
generics: &Generics,
ident: Ident,
span: Span,
print_finalizer: bool
)
pub(crate) 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.
fn print_expr_struct(
&mut self,
qself: &Option<QSelf>,
path: &Path,
fields: &[ExprField],
rest: &StructRest
)
fn print_fn_full(
&mut self,
sig: &FnSig,
name: Ident,
generics: &Generics,
vis: &Visibility,
defaultness: Defaultness,
body: Option<&Block>,
attrs: &[Attribute]
)
pub(crate) fn print_fn(
&mut self,
decl: &FnDecl,
header: FnHeader,
name: Option<Ident>,
generics: &Generics
)
pub(crate) fn print_ty_fn(
&mut self,
ext: Extern,
unsafety: Unsafe,
decl: &FnDecl,
name: Option<Ident>,
generic_params: &[GenericParam]
)
Methods from Deref<Target = Printer>
Be very careful with this!
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: 224 bytes