Struct rustc_hir_pretty::State [−][src]
pub struct State<'a> {
pub s: Printer,
comments: Option<Comments<'a>>,
attrs: &'a BTreeMap<HirId, &'a [Attribute]>,
ann: &'a (dyn PpAnn + 'a),
}Fields
s: Printercomments: Option<Comments<'a>>attrs: &'a BTreeMap<HirId, &'a [Attribute]>ann: &'a (dyn PpAnn + 'a)Implementations
impl<'a> State<'a>[src]
impl<'a> State<'a>[src]pub fn print_node(&mut self, node: Node<'_>)[src]
impl<'a> State<'a>[src]
impl<'a> State<'a>[src]impl<'a> State<'a>[src]
impl<'a> State<'a>[src]pub fn cbox(&mut self, u: usize)[src]
pub fn nbsp(&mut self)[src]
pub fn word_nbsp<S: Into<Cow<'static, str>>>(&mut self, w: S)[src]
pub fn head<S: Into<Cow<'static, str>>>(&mut self, w: S)[src]
pub fn bopen(&mut self)[src]
pub fn bclose_maybe_open(&mut self, span: Span, close_box: bool)[src]
pub fn bclose(&mut self, span: Span)[src]
pub fn space_if_not_bol(&mut self)[src]
pub fn break_offset_if_not_bol(&mut self, n: usize, off: isize)[src]
pub fn synth_comment(&mut self, text: String)[src]
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, [src]
&mut self,
b: Breaks,
elts: &[T],
op: F,
get_span: G
) where
F: FnMut(&mut State<'_>, &T),
G: FnMut(&T) -> Span,
pub fn commasep_exprs(&mut self, b: Breaks, exprs: &[Expr<'_>])[src]
pub fn print_mod(&mut self, _mod: &Mod<'_>, attrs: &[Attribute])[src]
pub fn print_opt_lifetime(&mut self, lifetime: &Lifetime)[src]
pub fn print_type(&mut self, ty: &Ty<'_>)[src]
pub fn print_foreign_item(&mut self, item: &ForeignItem<'_>)[src]
pub(crate) fn print_associated_const(
&mut self,
ident: Ident,
ty: &Ty<'_>,
default: Option<BodyId>,
vis: &Visibility<'_>
)[src]
&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<'_>>
)[src]
&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)
)[src]
&mut self,
item: &Item<'_>,
generics: &Generics<'_>,
inner: impl Fn(&mut Self)
)
pub fn print_item(&mut self, item: &Item<'_>)[src]
pub fn print_item(&mut self, item: &Item<'_>)[src]Pretty-print an item
pub fn print_trait_ref(&mut self, t: &TraitRef<'_>)[src]
pub(crate) fn print_formal_generic_params(
&mut self,
generic_params: &[GenericParam<'_>]
)[src]
&mut self,
generic_params: &[GenericParam<'_>]
)
pub(crate) fn print_poly_trait_ref(&mut self, t: &PolyTraitRef<'_>)[src]
pub fn print_enum_def(
&mut self,
enum_definition: &EnumDef<'_>,
generics: &Generics<'_>,
name: Symbol,
span: Span,
visibility: &Visibility<'_>
)[src]
&mut self,
enum_definition: &EnumDef<'_>,
generics: &Generics<'_>,
name: Symbol,
span: Span,
visibility: &Visibility<'_>
)
pub fn print_variants(&mut self, variants: &[Variant<'_>], span: Span)[src]
pub fn print_visibility(&mut self, vis: &Visibility<'_>)[src]
pub fn print_defaultness(&mut self, defaultness: Defaultness)[src]
pub fn print_struct(
&mut self,
struct_def: &VariantData<'_>,
generics: &Generics<'_>,
name: Symbol,
span: Span,
print_finalizer: bool
)[src]
&mut self,
struct_def: &VariantData<'_>,
generics: &Generics<'_>,
name: Symbol,
span: Span,
print_finalizer: bool
)
pub fn print_variant(&mut self, v: &Variant<'_>)[src]
pub fn print_method_sig(
&mut self,
ident: Ident,
m: &FnSig<'_>,
generics: &Generics<'_>,
vis: &Visibility<'_>,
arg_names: &[Ident],
body_id: Option<BodyId>
)[src]
&mut self,
ident: Ident,
m: &FnSig<'_>,
generics: &Generics<'_>,
vis: &Visibility<'_>,
arg_names: &[Ident],
body_id: Option<BodyId>
)
pub fn print_trait_item(&mut self, ti: &TraitItem<'_>)[src]
pub fn print_impl_item(&mut self, ii: &ImplItem<'_>)[src]
pub fn print_local(&mut self, init: Option<&Expr<'_>>, decl: impl Fn(&mut Self))[src]
pub fn print_stmt(&mut self, st: &Stmt<'_>)[src]
pub fn print_block(&mut self, blk: &Block<'_>)[src]
pub fn print_block_unclosed(&mut self, blk: &Block<'_>)[src]
pub fn print_block_with_attrs(&mut self, blk: &Block<'_>, attrs: &[Attribute])[src]
pub fn print_block_maybe_unclosed(
&mut self,
blk: &Block<'_>,
attrs: &[Attribute],
close_box: bool
)[src]
&mut self,
blk: &Block<'_>,
attrs: &[Attribute],
close_box: bool
)
pub(crate) fn print_else(&mut self, els: Option<&Expr<'_>>)[src]
pub fn print_if(
&mut self,
test: &Expr<'_>,
blk: &Expr<'_>,
elseopt: Option<&Expr<'_>>
)[src]
&mut self,
test: &Expr<'_>,
blk: &Expr<'_>,
elseopt: Option<&Expr<'_>>
)
pub fn print_anon_const(&mut self, constant: &AnonConst)[src]
pub(crate) fn print_call_post(&mut self, args: &[Expr<'_>])[src]
pub fn print_expr_maybe_paren(&mut self, expr: &Expr<'_>, prec: i8)[src]
pub fn print_expr_as_cond(&mut self, expr: &Expr<'_>)[src]
pub fn print_expr_as_cond(&mut self, expr: &Expr<'_>)[src]Print an expr using syntax that’s acceptable in a condition position, such as the cond in
if cond { ... }.
pub(crate) fn print_expr_vec(&mut self, exprs: &[Expr<'_>])[src]
pub(crate) fn print_expr_anon_const(&mut self, anon_const: &AnonConst)[src]
pub(crate) fn print_expr_repeat(
&mut self,
element: &Expr<'_>,
count: &AnonConst
)[src]
&mut self,
element: &Expr<'_>,
count: &AnonConst
)
pub(crate) fn print_expr_struct(
&mut self,
qpath: &QPath<'_>,
fields: &[ExprField<'_>],
wth: &Option<&Expr<'_>>
)[src]
&mut self,
qpath: &QPath<'_>,
fields: &[ExprField<'_>],
wth: &Option<&Expr<'_>>
)
pub(crate) fn print_expr_tup(&mut self, exprs: &[Expr<'_>])[src]
pub(crate) fn print_expr_call(&mut self, func: &Expr<'_>, args: &[Expr<'_>])[src]
pub(crate) fn print_expr_method_call(
&mut self,
segment: &PathSegment<'_>,
args: &[Expr<'_>]
)[src]
&mut self,
segment: &PathSegment<'_>,
args: &[Expr<'_>]
)
pub(crate) fn print_expr_binary(
&mut self,
op: BinOp,
lhs: &Expr<'_>,
rhs: &Expr<'_>
)[src]
&mut self,
op: BinOp,
lhs: &Expr<'_>,
rhs: &Expr<'_>
)
pub(crate) fn print_expr_unary(&mut self, op: UnOp, expr: &Expr<'_>)[src]
pub(crate) fn print_expr_addr_of(
&mut self,
kind: BorrowKind,
mutability: Mutability,
expr: &Expr<'_>
)[src]
&mut self,
kind: BorrowKind,
mutability: Mutability,
expr: &Expr<'_>
)
pub(crate) fn print_literal(&mut self, lit: &Lit)[src]
pub fn print_expr(&mut self, expr: &Expr<'_>)[src]
pub fn print_local_decl(&mut self, loc: &Local<'_>)[src]
pub fn print_name(&mut self, name: Symbol)[src]
pub fn print_path(&mut self, path: &Path<'_>, colons_before_params: bool)[src]
pub fn print_path_segment(&mut self, segment: &PathSegment<'_>)[src]
pub fn print_qpath(&mut self, qpath: &QPath<'_>, colons_before_params: bool)[src]
pub(crate) fn print_generic_args(
&mut self,
generic_args: &GenericArgs<'_>,
infer_args: bool,
colons_before_params: bool
)[src]
&mut self,
generic_args: &GenericArgs<'_>,
infer_args: bool,
colons_before_params: bool
)
pub fn print_pat(&mut self, pat: &Pat<'_>)[src]
pub fn print_param(&mut self, arg: &Param<'_>)[src]
pub fn print_arm(&mut self, arm: &Arm<'_>)[src]
pub fn print_fn(
&mut self,
decl: &FnDecl<'_>,
header: FnHeader,
name: Option<Symbol>,
generics: &Generics<'_>,
vis: &Visibility<'_>,
arg_names: &[Ident],
body_id: Option<BodyId>
)[src]
&mut self,
decl: &FnDecl<'_>,
header: FnHeader,
name: Option<Symbol>,
generics: &Generics<'_>,
vis: &Visibility<'_>,
arg_names: &[Ident],
body_id: Option<BodyId>
)
pub(crate) fn print_closure_params(
&mut self,
decl: &FnDecl<'_>,
body_id: BodyId
)[src]
&mut self,
decl: &FnDecl<'_>,
body_id: BodyId
)
pub fn print_capture_clause(&mut self, capture_clause: CaptureBy)[src]
pub fn print_bounds<'b>(
&mut self,
prefix: &'static str,
bounds: impl IntoIterator<Item = &'b GenericBound<'b>>
)[src]
&mut self,
prefix: &'static str,
bounds: impl IntoIterator<Item = &'b GenericBound<'b>>
)
pub fn print_generic_params(&mut self, generic_params: &[GenericParam<'_>])[src]
pub fn print_generic_param(&mut self, param: &GenericParam<'_>)[src]
pub fn print_lifetime(&mut self, lifetime: &Lifetime)[src]
pub fn print_where_clause(&mut self, where_clause: &WhereClause<'_>)[src]
pub fn print_mutability(&mut self, mutbl: Mutability, print_const: bool)[src]
pub fn print_mt(&mut self, mt: &MutTy<'_>, print_const: bool)[src]
pub fn print_fn_output(&mut self, decl: &FnDecl<'_>)[src]
pub fn print_ty_fn(
&mut self,
abi: Abi,
unsafety: Unsafety,
decl: &FnDecl<'_>,
name: Option<Symbol>,
generic_params: &[GenericParam<'_>],
arg_names: &[Ident]
)[src]
&mut self,
abi: Abi,
unsafety: Unsafety,
decl: &FnDecl<'_>,
name: Option<Symbol>,
generic_params: &[GenericParam<'_>],
arg_names: &[Ident]
)
pub fn maybe_print_trailing_comment(
&mut self,
span: Span,
next_pos: Option<BytePos>
)[src]
&mut self,
span: Span,
next_pos: Option<BytePos>
)
pub fn print_remaining_comments(&mut self)[src]
pub fn print_fn_header_info(&mut self, header: FnHeader, vis: &Visibility<'_>)[src]
pub fn print_unsafety(&mut self, s: Unsafety)[src]
pub fn print_is_auto(&mut self, s: IsAuto)[src]
Trait Implementations
impl<'a> PrintState<'a> for State<'a>[src]
impl<'a> PrintState<'a> for State<'a>[src]fn comments(&mut self) -> &mut Option<Comments<'a>>[src]
fn print_ident(&mut self, ident: Ident)[src]
fn print_generic_args(&mut self, _: &GenericArgs, _colons_before_params: bool)[src]
fn strsep<T, F>(
&mut self,
sep: &'static str,
space_before: bool,
b: Breaks,
elts: &[T],
op: F
) where
F: FnMut(&mut Self, &T), [src]
&mut self,
sep: &'static str,
space_before: bool,
b: Breaks,
elts: &[T],
op: F
) where
F: FnMut(&mut Self, &T),
fn commasep<T, F>(&mut self, b: Breaks, elts: &[T], op: F) where
F: FnMut(&mut Self, &T), [src]
F: FnMut(&mut Self, &T),
fn maybe_print_comment(&mut self, pos: BytePos)[src]
fn print_comment(&mut self, cmnt: &Comment)[src]
fn next_comment(&mut self) -> Option<Comment>[src]
fn print_literal(&mut self, lit: &Lit)[src]
fn print_string(&mut self, st: &str, style: StrStyle)[src]
fn print_symbol(&mut self, sym: Symbol, style: StrStyle)[src]
fn print_inner_attributes(&mut self, attrs: &[Attribute])[src]
fn print_outer_attributes(&mut self, attrs: &[Attribute])[src]
fn print_inner_attributes_inline(&mut self, attrs: &[Attribute])[src]
fn print_outer_attributes_inline(&mut self, attrs: &[Attribute])[src]
fn print_either_attributes(
&mut self,
attrs: &[Attribute],
kind: AttrStyle,
is_inline: bool,
trailing_hardbreak: bool
)[src]
&mut self,
attrs: &[Attribute],
kind: AttrStyle,
is_inline: bool,
trailing_hardbreak: bool
)
fn print_attribute(&mut self, attr: &Attribute)[src]
fn print_attribute_inline(&mut self, attr: &Attribute, is_inline: bool)[src]
fn print_attr_item(&mut self, item: &AttrItem, span: Span)[src]
fn print_meta_list_item(&mut self, item: &NestedMetaItem)[src]
fn print_meta_item(&mut self, item: &MetaItem)[src]
fn print_tt(&mut self, tt: &TokenTree, convert_dollar_crate: bool)[src]
fn print_tt(&mut self, tt: &TokenTree, convert_dollar_crate: bool)[src]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_tts(&mut self, tts: &TokenStream, convert_dollar_crate: bool)[src]
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
)[src]
&mut self,
header: Option<MacHeader<'_>>,
has_bang: bool,
ident: Option<Ident>,
delim: DelimToken,
tts: &TokenStream,
convert_dollar_crate: bool,
span: Span
)
fn print_path(&mut self, path: &Path, colons_before_params: bool, depth: usize)[src]
fn print_path_segment(
&mut self,
segment: &PathSegment,
colons_before_params: bool
)[src]
&mut self,
segment: &PathSegment,
colons_before_params: bool
)
fn head<S>(&mut self, w: S) where
S: Into<Cow<'static, str>>, [src]
S: Into<Cow<'static, str>>,
fn bopen(&mut self)[src]
fn bclose_maybe_open(&mut self, span: Span, close_box: bool)[src]
fn bclose(&mut self, span: Span)[src]
fn break_offset_if_not_bol(&mut self, n: usize, off: isize)[src]
fn nonterminal_to_string(&self, nt: &Nonterminal) -> String[src]
fn token_kind_to_string(&self, tok: &TokenKind) -> String[src]
fn token_kind_to_string(&self, tok: &TokenKind) -> String[src]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>
) -> String[src]
&self,
tok: &TokenKind,
convert_dollar_crate: Option<Span>
) -> String
fn token_to_string(&self, token: &Token) -> String[src]
fn token_to_string(&self, token: &Token) -> String[src]Print the token precisely, without converting $crate into its respective crate name.
fn token_to_string_ext(
&self,
token: &Token,
convert_dollar_crate: bool
) -> String[src]
&self,
token: &Token,
convert_dollar_crate: bool
) -> String