Struct rustfmt_nightly::visitor::FmtVisitor [−][src]
pub(crate) struct FmtVisitor<'a> {Show 14 fields
parent_context: Option<&'a RewriteContext<'a>>,
pub(crate) parse_sess: &'a ParseSess,
pub(crate) buffer: String,
pub(crate) last_pos: BytePos,
pub(crate) block_indent: Indent,
pub(crate) config: &'a Config,
pub(crate) is_if_else_block: bool,
pub(crate) snippet_provider: &'a SnippetProvider,
pub(crate) line_number: usize,
pub(crate) skipped_range: Rc<RefCell<Vec<(usize, usize)>>>,
pub(crate) macro_rewrite_failure: bool,
pub(crate) report: FormatReport,
pub(crate) skip_context: SkipContext,
pub(crate) is_macro_def: bool,
}
Fields
parent_context: Option<&'a RewriteContext<'a>>
parse_sess: &'a ParseSess
buffer: String
last_pos: BytePos
block_indent: Indent
config: &'a Config
is_if_else_block: bool
snippet_provider: &'a SnippetProvider
line_number: usize
skipped_range: Rc<RefCell<Vec<(usize, usize)>>>
List of 1-based line ranges which were annotated with skip Both bounds are inclusifs.
macro_rewrite_failure: bool
report: FormatReport
skip_context: SkipContext
is_macro_def: bool
Implementations
pub(crate) fn rewrite_fn_before_block(
&mut self,
indent: Indent,
ident: Ident,
fn_sig: &FnSig<'_>,
span: Span
) -> Option<(String, FnBraceStyle)>
pub(crate) fn rewrite_required_fn(
&mut self,
indent: Indent,
ident: Ident,
sig: &FnSig,
generics: &Generics,
span: Span
) -> Option<String>
pub(crate) fn single_line_fn(
&self,
fn_str: &str,
block: &Block,
inner_attrs: Option<&[Attribute]>
) -> Option<String>
pub(crate) fn visit_enum(
&mut self,
ident: Ident,
vis: &Visibility,
enum_def: &EnumDef,
generics: &Generics,
span: Span
)
fn format_variant_list(
&mut self,
enum_def: &EnumDef,
body_lo: BytePos,
body_hi: BytePos
) -> Option<String>
fn format_missing_inner<F: Fn(&mut FmtVisitor<'_>, &str, &str)>(
&mut self,
end: BytePos,
process_last_snippet: F
)
fn write_snippet<F>(&mut self, span: Span, process_last_snippet: F) where
F: Fn(&mut FmtVisitor<'_>, &str, &str),
fn write_snippet_inner<F>(
&mut self,
big_snippet: &str,
old_snippet: &str,
big_diff: usize,
span: Span,
process_last_snippet: F
) where
F: Fn(&mut FmtVisitor<'_>, &str, &str),
fn process_comment(
&mut self,
status: &mut SnippetStatus,
snippet: &str,
big_snippet: &str,
offset: usize,
subslice: &str
)
fn process_missing_code(
&mut self,
status: &mut SnippetStatus,
snippet: &str,
subslice: &str,
offset: usize,
file_name: &FileName
)
fn walk_reorderable_or_regroupable_items(
&mut self,
items: &[&Item],
item_kind: ReorderableItemKind,
in_group: bool
) -> usize
fn walk_reorderable_or_regroupable_items(
&mut self,
items: &[&Item],
item_kind: ReorderableItemKind,
in_group: bool
) -> usize
Format items with the same item kind and reorder them, regroup them, or
both. If in_group
is true
, then the items separated by an empty line
will not be reordered together.
Visits and format the given items. Items are reordered If they are consecutive and reorderable.
Remove spaces between the opening brace and the first statement or the inner attribute of the block.
pub(crate) fn visit_block(
&mut self,
b: &Block,
inner_attrs: Option<&[Attribute]>,
has_braces: bool
)
pub(crate) fn visit_fn(
&mut self,
fk: FnKind<'_>,
generics: &Generics,
fd: &FnDecl,
s: Span,
defaultness: Defaultness,
inner_attrs: Option<&[Attribute]>
)
pub(crate) fn push_skipped_with_span(
&mut self,
attrs: &[Attribute],
item_span: Span,
main_span: Span
)
pub(crate) fn from_parse_sess(
parse_session: &'a ParseSess,
config: &'a Config,
snippet_provider: &'a SnippetProvider,
report: FormatReport
) -> FmtVisitor<'a>
fn format_mod(
&mut self,
mod_kind: &ModKind,
unsafety: Unsafe,
vis: &Visibility,
s: Span,
ident: Ident,
attrs: &[Attribute]
)
pub(crate) fn with_context<F>(&mut self, f: F) -> Option<String> where
F: Fn(&RewriteContext<'_>) -> Option<String>,
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for FmtVisitor<'a>
impl<'a> !Send for FmtVisitor<'a>
impl<'a> !Sync for FmtVisitor<'a>
impl<'a> Unpin for FmtVisitor<'a>
impl<'a> !UnwindSafe for FmtVisitor<'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: 176 bytes