[][src]Trait rustc_ap_rustc_ast_pretty::pprust::state::PrintState

pub trait PrintState<'a>: Deref<Target = Printer> + DerefMut {
    pub fn insert_extra_parens(&self) -> bool;
pub fn comments(&mut self) -> &mut Option<Comments<'a>>;
pub fn print_ident(&mut self, ident: Ident);
pub fn print_generic_args(
        &mut self,
        args: &GenericArgs,
        colons_before_params: bool
    ); pub fn strsep<T, F>(
        &mut self,
        sep: &'static str,
        space_before: bool,
        b: Breaks,
        elts: &[T],
        op: F
    )
    where
        F: FnMut(&mut Self, &T)
, { ... }
pub fn commasep<T, F>(&mut self, b: Breaks, elts: &[T], op: F)
    where
        F: FnMut(&mut Self, &T)
, { ... }
pub fn maybe_print_comment(&mut self, pos: BytePos) { ... }
pub fn print_comment(&mut self, cmnt: &Comment) { ... }
pub fn next_comment(&mut self) -> Option<Comment> { ... }
pub fn print_literal(&mut self, lit: &Lit) { ... }
pub fn print_string(&mut self, st: &str, style: StrStyle) { ... }
pub fn print_symbol(&mut self, sym: Symbol, style: StrStyle) { ... }
pub fn print_inner_attributes(&mut self, attrs: &[Attribute]) { ... }
pub fn print_inner_attributes_no_trailing_hardbreak(
        &mut self,
        attrs: &[Attribute]
    ) { ... }
pub fn print_outer_attributes(&mut self, attrs: &[Attribute]) { ... }
pub fn print_inner_attributes_inline(&mut self, attrs: &[Attribute]) { ... }
pub fn print_outer_attributes_inline(&mut self, attrs: &[Attribute]) { ... }
pub fn print_either_attributes(
        &mut self,
        attrs: &[Attribute],
        kind: AttrStyle,
        is_inline: bool,
        trailing_hardbreak: bool
    ) { ... }
pub fn print_attribute(&mut self, attr: &Attribute) { ... }
pub fn print_attribute_inline(&mut self, attr: &Attribute, is_inline: bool) { ... }
pub fn print_attr_item(&mut self, item: &AttrItem, span: Span) { ... }
pub fn print_meta_list_item(&mut self, item: &NestedMetaItem) { ... }
pub fn print_meta_item(&mut self, item: &MetaItem) { ... }
pub fn print_tt(&mut self, tt: &TokenTree, convert_dollar_crate: bool) { ... }
pub fn print_tts(&mut self, tts: &TokenStream, convert_dollar_crate: bool) { ... }
pub 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
    ) { ... }
pub fn print_path(
        &mut self,
        path: &Path,
        colons_before_params: bool,
        depth: usize
    ) { ... }
pub fn print_path_segment(
        &mut self,
        segment: &PathSegment,
        colons_before_params: bool
    ) { ... }
pub fn head<S: Into<Cow<'static, str>>>(&mut self, w: S) { ... }
pub fn bopen(&mut self) { ... }
pub fn bclose_maybe_open(&mut self, span: Span, close_box: bool) { ... }
pub fn bclose(&mut self, span: Span) { ... }
pub fn break_offset_if_not_bol(&mut self, n: usize, off: isize) { ... }
pub fn nonterminal_to_string(&self, nt: &Nonterminal) -> String { ... }
pub fn token_kind_to_string(&self, tok: &TokenKind) -> String { ... }
pub fn token_kind_to_string_ext(
        &self,
        tok: &TokenKind,
        convert_dollar_crate: Option<Span>
    ) -> String { ... }
pub fn token_to_string(&self, token: &Token) -> String { ... }
pub fn token_to_string_ext(
        &self,
        token: &Token,
        convert_dollar_crate: bool
    ) -> String { ... }
pub fn ty_to_string(&self, ty: &Ty) -> String { ... }
pub fn bounds_to_string(&self, bounds: &[GenericBound]) -> String { ... }
pub fn pat_to_string(&self, pat: &Pat) -> String { ... }
pub fn expr_to_string(&self, e: &Expr) -> String { ... }
pub fn tt_to_string(&self, tt: &TokenTree) -> String { ... }
pub fn tts_to_string(&self, tokens: &TokenStream) -> String { ... }
pub fn stmt_to_string(&self, stmt: &Stmt) -> String { ... }
pub fn item_to_string(&self, i: &Item) -> String { ... }
pub fn generic_params_to_string(
        &self,
        generic_params: &[GenericParam]
    ) -> String { ... }
pub fn path_to_string(&self, p: &Path) -> String { ... }
pub fn path_segment_to_string(&self, p: &PathSegment) -> String { ... }
pub fn vis_to_string(&self, v: &Visibility) -> String { ... }
pub fn block_to_string(&self, blk: &Block) -> String { ... }
pub fn meta_list_item_to_string(&self, li: &NestedMetaItem) -> String { ... }
pub fn attr_item_to_string(&self, ai: &AttrItem) -> String { ... }
pub fn attribute_to_string(&self, attr: &Attribute) -> String { ... }
pub fn param_to_string(&self, arg: &Param) -> String { ... }
pub fn to_string(&self, f: impl FnOnce(&mut State<'_>)) -> String { ... } }

Required methods

pub fn insert_extra_parens(&self) -> bool[src]

pub fn comments(&mut self) -> &mut Option<Comments<'a>>[src]

pub fn print_ident(&mut self, ident: Ident)[src]

pub fn print_generic_args(
    &mut self,
    args: &GenericArgs,
    colons_before_params: bool
)
[src]

Loading content...

Provided methods

pub 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]

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

pub fn maybe_print_comment(&mut self, pos: BytePos)[src]

pub fn print_comment(&mut self, cmnt: &Comment)[src]

pub fn next_comment(&mut self) -> Option<Comment>[src]

pub fn print_literal(&mut self, lit: &Lit)[src]

pub fn print_string(&mut self, st: &str, style: StrStyle)[src]

pub fn print_symbol(&mut self, sym: Symbol, style: StrStyle)[src]

pub fn print_inner_attributes(&mut self, attrs: &[Attribute])[src]

pub fn print_inner_attributes_no_trailing_hardbreak(
    &mut self,
    attrs: &[Attribute]
)
[src]

pub fn print_outer_attributes(&mut self, attrs: &[Attribute])[src]

pub fn print_inner_attributes_inline(&mut self, attrs: &[Attribute])[src]

pub fn print_outer_attributes_inline(&mut self, attrs: &[Attribute])[src]

pub fn print_either_attributes(
    &mut self,
    attrs: &[Attribute],
    kind: AttrStyle,
    is_inline: bool,
    trailing_hardbreak: bool
)
[src]

pub fn print_attribute(&mut self, attr: &Attribute)[src]

pub fn print_attribute_inline(&mut self, attr: &Attribute, is_inline: bool)[src]

pub fn print_attr_item(&mut self, item: &AttrItem, span: Span)[src]

pub fn print_meta_list_item(&mut self, item: &NestedMetaItem)[src]

pub fn print_meta_item(&mut self, item: &MetaItem)[src]

pub 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.

pub fn print_tts(&mut self, tts: &TokenStream, convert_dollar_crate: bool)[src]

pub 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]

pub fn print_path(
    &mut self,
    path: &Path,
    colons_before_params: bool,
    depth: usize
)
[src]

pub fn print_path_segment(
    &mut self,
    segment: &PathSegment,
    colons_before_params: bool
)
[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 break_offset_if_not_bol(&mut self, n: usize, off: isize)[src]

pub fn nonterminal_to_string(&self, nt: &Nonterminal) -> String[src]

pub fn token_kind_to_string(&self, tok: &TokenKind) -> String[src]

Print the token kind precisely, without converting $crate into its respective crate name.

pub fn token_kind_to_string_ext(
    &self,
    tok: &TokenKind,
    convert_dollar_crate: Option<Span>
) -> String
[src]

pub fn token_to_string(&self, token: &Token) -> String[src]

Print the token precisely, without converting $crate into its respective crate name.

pub fn token_to_string_ext(
    &self,
    token: &Token,
    convert_dollar_crate: bool
) -> String
[src]

pub fn ty_to_string(&self, ty: &Ty) -> String[src]

pub fn bounds_to_string(&self, bounds: &[GenericBound]) -> String[src]

pub fn pat_to_string(&self, pat: &Pat) -> String[src]

pub fn expr_to_string(&self, e: &Expr) -> String[src]

pub fn tt_to_string(&self, tt: &TokenTree) -> String[src]

pub fn tts_to_string(&self, tokens: &TokenStream) -> String[src]

pub fn stmt_to_string(&self, stmt: &Stmt) -> String[src]

pub fn item_to_string(&self, i: &Item) -> String[src]

pub fn generic_params_to_string(
    &self,
    generic_params: &[GenericParam]
) -> String
[src]

pub fn path_to_string(&self, p: &Path) -> String[src]

pub fn path_segment_to_string(&self, p: &PathSegment) -> String[src]

pub fn vis_to_string(&self, v: &Visibility) -> String[src]

pub fn block_to_string(&self, blk: &Block) -> String[src]

pub fn meta_list_item_to_string(&self, li: &NestedMetaItem) -> String[src]

pub fn attr_item_to_string(&self, ai: &AttrItem) -> String[src]

pub fn attribute_to_string(&self, attr: &Attribute) -> String[src]

pub fn param_to_string(&self, arg: &Param) -> String[src]

pub fn to_string(&self, f: impl FnOnce(&mut State<'_>)) -> String[src]

Loading content...

Implementors

impl<'a> PrintState<'a> for State<'a>[src]

Loading content...