pub(crate) struct FmtVisitor<'a> {Show 14 fields
parent_context: Option<&'a RewriteContext<'a>>,
pub(crate) psess: &'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>>
§psess: &'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 inclusive.
macro_rewrite_failure: bool
§report: FormatReport
§skip_context: SkipContext
§is_macro_def: bool
Implementations§
source§impl<'a> FmtVisitor<'a>
impl<'a> FmtVisitor<'a>
pub(crate) fn format_import(&mut self, item: &Item, tree: &UseTree)
source§impl<'a> FmtVisitor<'a>
impl<'a> FmtVisitor<'a>
fn format_item(&mut self, item: &Item<'_>)
fn format_body_element(&mut self, element: &BodyElement<'_>)
pub(crate) fn format_foreign_mod(&mut self, fm: &ForeignMod, span: Span)
fn format_foreign_item(&mut self, item: &ForeignItem)
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, vis: &Visibility, generics: &Generics, span: Span, ) -> Result<String, RewriteError>
pub(crate) fn single_line_fn( &self, fn_str: &str, block: &Block, inner_attrs: Option<&[Attribute]>, ) -> Option<String>
pub(crate) fn visit_static(&mut self, static_parts: &StaticParts<'_>)
pub(crate) fn visit_struct(&mut self, struct_parts: &StructParts<'_>)
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_variant( &self, field: &Variant, one_line_width: usize, pad_discrim_ident_to: usize, ) -> Option<String>
fn visit_impl_items(&mut self, items: &[P<AssocItem>])
source§impl<'a> FmtVisitor<'a>
impl<'a> FmtVisitor<'a>
fn output_at_start(&self) -> bool
pub(crate) fn format_missing(&mut self, end: BytePos)
pub(crate) fn format_missing_with_indent(&mut self, end: BytePos)
pub(crate) fn format_missing_no_indent(&mut self, end: BytePos)
fn format_missing_indent(&mut self, end: BytePos, should_indent: bool)
fn format_missing_inner<F: Fn(&mut FmtVisitor<'_>, &str, &str)>( &mut self, end: BytePos, process_last_snippet: F, )
fn push_vertical_spaces(&mut self, newline_count: usize)
fn write_snippet<F>(&mut self, span: Span, process_last_snippet: F)
fn write_snippet_inner<F>( &mut self, big_snippet: &str, old_snippet: &str, big_diff: usize, span: Span, process_last_snippet: F, )
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, )
source§impl<'b, 'a: 'b> FmtVisitor<'a>
impl<'b, 'a: 'b> FmtVisitor<'a>
sourcefn 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.
sourcepub(crate) fn visit_items_with_reordering(&mut self, items: &[&Item])
pub(crate) fn visit_items_with_reordering(&mut self, items: &[&Item])
Visits and format the given items. Items are reordered If they are consecutive and reorderable.
source§impl<'b, 'a: 'b> FmtVisitor<'a>
impl<'b, 'a: 'b> FmtVisitor<'a>
fn set_parent_context(&mut self, context: &'a RewriteContext<'_>)
pub(crate) fn shape(&self) -> Shape
fn next_span(&self, hi: BytePos) -> Span
fn visit_stmt(&mut self, stmt: &Stmt<'_>, include_empty_semi: bool)
sourcefn trim_spaces_after_opening_brace(
&mut self,
b: &Block,
inner_attrs: Option<&[Attribute]>,
)
fn trim_spaces_after_opening_brace( &mut self, b: &Block, inner_attrs: Option<&[Attribute]>, )
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, )
fn close_block(&mut self, span: Span, unindent_comment: bool)
fn unindent_comment_on_closing_brace(&self, b: &Block) -> bool
pub(crate) fn visit_fn( &mut self, fk: FnKind<'_>, fd: &FnDecl, s: Span, defaultness: Defaultness, inner_attrs: Option<&[Attribute]>, )
pub(crate) fn visit_item(&mut self, item: &Item)
fn visit_ty_alias_kind( &mut self, ty_kind: &TyAlias, visitor_kind: &ItemVisitorKind<'_>, span: Span, )
fn visit_assoc_item(&mut self, visitor_kind: &ItemVisitorKind<'_>)
pub(crate) fn visit_trait_item(&mut self, ti: &AssocItem)
pub(crate) fn visit_impl_item(&mut self, ii: &AssocItem)
fn visit_mac(&mut self, mac: &MacCall, ident: Option<Ident>, pos: MacroPosition)
pub(crate) fn push_str(&mut self, s: &str)
fn push_rewrite_inner(&mut self, span: Span, rewrite: Option<String>)
pub(crate) fn push_rewrite(&mut self, span: Span, rewrite: Option<String>)
pub(crate) fn push_skipped_with_span( &mut self, attrs: &[Attribute], item_span: Span, main_span: Span, )
pub(crate) fn from_context(ctx: &'a RewriteContext<'_>) -> FmtVisitor<'a>
pub(crate) fn from_psess( psess: &'a ParseSess, config: &'a Config, snippet_provider: &'a SnippetProvider, report: FormatReport, ) -> FmtVisitor<'a>
pub(crate) fn opt_snippet(&'b self, span: Span) -> Option<&'a str>
pub(crate) fn snippet(&'b self, span: Span) -> &'a str
pub(crate) fn visit_attrs( &mut self, attrs: &[Attribute], style: AttrStyle, ) -> bool
fn is_unknown_rustfmt_attr(&self, segments: &[PathSegment]) -> bool
fn walk_mod_items(&mut self, items: &[P<Item>])
fn walk_stmts(&mut self, stmts: &[Stmt<'_>], include_current_empty_semi: bool)
fn walk_block_stmts(&mut self, b: &Block)
fn format_mod( &mut self, mod_kind: &ModKind, safety: Safety, vis: &Visibility, s: Span, ident: Ident, attrs: &[Attribute], )
pub(crate) fn format_separate_mod(&mut self, m: &Module<'_>, end_pos: BytePos)
pub(crate) fn skip_empty_lines(&mut self, end_pos: BytePos)
pub(crate) fn with_context<F>(&mut self, f: F) -> Option<String>
pub(crate) fn get_context(&self) -> RewriteContext<'_>
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for FmtVisitor<'a>
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
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