Struct syntex_syntax::print::pprust::State [] [src]

pub struct State<'a> {
    pub s: Printer<'a>,
    // some fields omitted
}

Fields

s

Methods

impl<'a> State<'a>

fn new_from_input(cm: &'a CodeMap, span_diagnostic: &SpanHandler, filename: String, input: &mut Read, out: Box<Write + 'a>, ann: &'a PpAnn, is_expanded: bool) -> State<'a>

fn new(cm: &'a CodeMap, out: Box<Write + 'a>, ann: &'a PpAnn, comments: Option<Vec<Comment>>, literals: Option<Vec<Literal>>) -> State<'a>

impl<'a> State<'a>

fn cbox(&mut self, u: usize) -> Result<()>

fn word_nbsp(&mut self, w: &str) -> Result<()>

fn head(&mut self, w: &str) -> Result<()>

fn bopen(&mut self) -> Result<()>

fn bclose_(&mut self, span: Span, indented: usize) -> Result<()>

fn bclose_maybe_open(&mut self, span: Span, indented: usize, close_box: bool) -> Result<()>

fn bclose(&mut self, span: Span) -> Result<()>

fn in_cbox(&self) -> bool

fn break_offset_if_not_bol(&mut self, n: usize, off: isize) -> Result<()>

fn synth_comment(&mut self, text: String) -> Result<()>

fn commasep_cmnt<T, F, G>(&mut self, b: Breaks, elts: &[T], op: F, get_span: G) -> Result<()> where F: FnMut(&mut State, &T) -> Result<()>, G: FnMut(&T) -> Span

fn commasep_exprs(&mut self, b: Breaks, exprs: &[P<Expr>]) -> Result<()>

fn print_mod(&mut self, _mod: &Mod, attrs: &[Attribute]) -> Result<()>

fn print_foreign_mod(&mut self, nmod: &ForeignMod, attrs: &[Attribute]) -> Result<()>

fn print_opt_lifetime(&mut self, lifetime: &Option<Lifetime>) -> Result<()>

fn print_type(&mut self, ty: &Ty) -> Result<()>

fn print_foreign_item(&mut self, item: &ForeignItem) -> Result<()>

fn print_item(&mut self, item: &Item) -> Result<()>

Pretty-print an item

fn print_enum_def(&mut self, enum_definition: &EnumDef, generics: &Generics, ident: Ident, span: Span, visibility: Visibility) -> Result<()>

fn print_variants(&mut self, variants: &[P<Variant>], span: Span) -> Result<()>

fn print_visibility(&mut self, vis: Visibility) -> Result<()>

fn print_struct(&mut self, struct_def: &VariantData, generics: &Generics, ident: Ident, span: Span, print_finalizer: bool) -> Result<()>

fn print_tt(&mut self, tt: &TokenTree) -> Result<()>

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.

fn print_tts(&mut self, tts: &[TokenTree]) -> Result<()>

fn print_variant(&mut self, v: &Variant) -> Result<()>

fn print_method_sig(&mut self, ident: Ident, m: &MethodSig, vis: Visibility) -> Result<()>

fn print_trait_item(&mut self, ti: &TraitItem) -> Result<()>

fn print_impl_item(&mut self, ii: &ImplItem) -> Result<()>

fn print_stmt(&mut self, st: &Stmt) -> Result<()>

fn print_block(&mut self, blk: &Block) -> Result<()>

fn print_block_unclosed(&mut self, blk: &Block) -> Result<()>

fn print_block_unclosed_with_attrs(&mut self, blk: &Block, attrs: &[Attribute]) -> Result<()>

fn print_block_unclosed_indent(&mut self, blk: &Block, indented: usize) -> Result<()>

fn print_block_with_attrs(&mut self, blk: &Block, attrs: &[Attribute]) -> Result<()>

fn print_block_maybe_unclosed(&mut self, blk: &Block, indented: usize, attrs: &[Attribute], close_box: bool) -> Result<()>

fn print_if(&mut self, test: &Expr, blk: &Block, elseopt: Option<&Expr>) -> Result<()>

fn print_if_let(&mut self, pat: &Pat, expr: &Expr, blk: &Block, elseopt: Option<&Expr>) -> Result<()>

fn print_mac(&mut self, m: &Mac, delim: DelimToken) -> Result<()>

fn check_expr_bin_needs_paren(&mut self, sub_expr: &Expr, binop: BinOp) -> bool

fn print_expr_maybe_paren(&mut self, expr: &Expr) -> Result<()>

fn print_expr(&mut self, expr: &Expr) -> Result<()>

fn print_local_decl(&mut self, loc: &Local) -> Result<()>

fn print_decl(&mut self, decl: &Decl) -> Result<()>

fn print_ident(&mut self, ident: Ident) -> Result<()>

fn print_usize(&mut self, i: usize) -> Result<()>

fn print_name(&mut self, name: Name) -> Result<()>

fn print_for_decl(&mut self, loc: &Local, coll: &Expr) -> Result<()>

fn print_pat(&mut self, pat: &Pat) -> Result<()>

fn print_fn(&mut self, decl: &FnDecl, unsafety: Unsafety, constness: Constness, abi: Abi, name: Option<Ident>, generics: &Generics, opt_explicit_self: Option<&ExplicitSelf_>, vis: Visibility) -> Result<()>

fn print_fn_args(&mut self, decl: &FnDecl, opt_explicit_self: Option<&ExplicitSelf_>) -> Result<()>

fn print_fn_args_and_ret(&mut self, decl: &FnDecl, opt_explicit_self: Option<&ExplicitSelf_>) -> Result<()>

fn print_fn_block_args(&mut self, decl: &FnDecl) -> Result<()>

fn print_capture_clause(&mut self, capture_clause: CaptureClause) -> Result<()>

fn print_bounds(&mut self, prefix: &str, bounds: &[TyParamBound]) -> Result<()>

fn print_lifetime(&mut self, lifetime: &Lifetime) -> Result<()>

fn print_lifetime_def(&mut self, lifetime: &LifetimeDef) -> Result<()>

fn print_generics(&mut self, generics: &Generics) -> Result<()>

fn print_ty_param(&mut self, param: &TyParam) -> Result<()>

fn print_where_clause(&mut self, where_clause: &WhereClause) -> Result<()>

fn print_view_path(&mut self, vp: &ViewPath) -> Result<()>

fn print_mutability(&mut self, mutbl: Mutability) -> Result<()>

fn print_mt(&mut self, mt: &MutTy) -> Result<()>

fn print_arg(&mut self, input: &Arg) -> Result<()>

fn print_fn_output(&mut self, decl: &FnDecl) -> Result<()>

fn print_ty_fn(&mut self, abi: Abi, unsafety: Unsafety, decl: &FnDecl, name: Option<Ident>, generics: &Generics, opt_explicit_self: Option<&ExplicitSelf_>) -> Result<()>

fn maybe_print_trailing_comment(&mut self, span: Span, next_pos: Option<BytePos>) -> Result<()>

fn print_remaining_comments(&mut self) -> Result<()>

fn print_opt_abi_and_extern_if_nondefault(&mut self, opt_abi: Option<Abi>) -> Result<()>

fn print_extern_opt_abi(&mut self, opt_abi: Option<Abi>) -> Result<()>

fn print_fn_header_info(&mut self, unsafety: Unsafety, constness: Constness, abi: Abi, vis: Visibility) -> Result<()>

fn print_unsafety(&mut self, s: Unsafety) -> Result<()>

Trait Implementations

impl<'a> PrintState<'a> for State<'a>

fn writer(&mut self) -> &mut Printer<'a>

fn boxes(&mut self) -> &mut Vec<Breaks>

fn comments(&mut self) -> &mut Option<Vec<Comment>>

fn cur_cmnt_and_lit(&mut self) -> &mut CurrentCommentAndLiteral

fn literals(&self) -> &Option<Vec<Literal>>

fn word_space(&mut self, w: &str) -> Result<()>

fn popen(&mut self) -> Result<()>

fn pclose(&mut self) -> Result<()>

fn is_begin(&mut self) -> bool

fn is_end(&mut self) -> bool

fn is_bol(&mut self) -> bool

fn hardbreak_if_not_bol(&mut self) -> Result<()>

fn rbox(&mut self, u: usize, b: Breaks) -> Result<()>

fn ibox(&mut self, u: usize) -> Result<()>

fn end(&mut self) -> Result<()>

fn commasep<T, F>(&mut self, b: Breaks, elts: &[T], op: F) -> Result<()> where F: FnMut(&mut Self, &T) -> Result<()>

fn next_lit(&mut self, pos: BytePos) -> Option<Literal>

fn maybe_print_comment(&mut self, pos: BytePos) -> Result<()>

fn print_comment(&mut self, cmnt: &Comment) -> Result<()>

fn next_comment(&mut self) -> Option<Comment>

fn print_literal(&mut self, lit: &Lit) -> Result<()>

fn print_string(&mut self, st: &str, style: StrStyle) -> Result<()>

fn print_inner_attributes(&mut self, attrs: &[Attribute]) -> Result<()>

fn print_inner_attributes_no_trailing_hardbreak(&mut self, attrs: &[Attribute]) -> Result<()>

fn print_outer_attributes(&mut self, attrs: &[Attribute]) -> Result<()>

fn print_inner_attributes_inline(&mut self, attrs: &[Attribute]) -> Result<()>

fn print_outer_attributes_inline(&mut self, attrs: &[Attribute]) -> Result<()>

fn print_either_attributes(&mut self, attrs: &[Attribute], kind: AttrStyle, is_inline: bool, trailing_hardbreak: bool) -> Result<()>

fn print_attribute(&mut self, attr: &Attribute) -> Result<()>

fn print_attribute_inline(&mut self, attr: &Attribute, is_inline: bool) -> Result<()>

fn print_meta_item(&mut self, item: &MetaItem) -> Result<()>

fn space_if_not_bol(&mut self) -> Result<()>

fn nbsp(&mut self) -> Result<()>