rustfmt_nightly::visitor

Struct FmtVisitor

Source
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>

Source

pub(crate) fn format_import(&mut self, item: &Item, tree: &UseTree)

Source§

impl<'a> FmtVisitor<'a>

Source

fn format_item(&mut self, item: &Item<'_>)

Source

fn format_body_element(&mut self, element: &BodyElement<'_>)

Source

pub(crate) fn format_foreign_mod(&mut self, fm: &ForeignMod, span: Span)

Source

fn format_foreign_item(&mut self, item: &ForeignItem)

Source

pub(crate) fn rewrite_fn_before_block( &mut self, indent: Indent, ident: Ident, fn_sig: &FnSig<'_>, span: Span, ) -> Option<(String, FnBraceStyle)>

Source

pub(crate) fn rewrite_required_fn( &mut self, indent: Indent, ident: Ident, sig: &FnSig, vis: &Visibility, generics: &Generics, span: Span, ) -> Result<String, RewriteError>

Source

pub(crate) fn single_line_fn( &self, fn_str: &str, block: &Block, inner_attrs: Option<&[Attribute]>, ) -> Option<String>

Source

pub(crate) fn visit_static(&mut self, static_parts: &StaticParts<'_>)

Source

pub(crate) fn visit_struct(&mut self, struct_parts: &StructParts<'_>)

Source

pub(crate) fn visit_enum( &mut self, ident: Ident, vis: &Visibility, enum_def: &EnumDef, generics: &Generics, span: Span, )

Source

fn format_variant_list( &mut self, enum_def: &EnumDef, body_lo: BytePos, body_hi: BytePos, ) -> Option<String>

Source

fn format_variant( &self, field: &Variant, one_line_width: usize, pad_discrim_ident_to: usize, ) -> Option<String>

Source

fn visit_impl_items(&mut self, items: &[P<AssocItem>])

Source§

impl<'a> FmtVisitor<'a>

Source

fn output_at_start(&self) -> bool

Source

pub(crate) fn format_missing(&mut self, end: BytePos)

Source

pub(crate) fn format_missing_with_indent(&mut self, end: BytePos)

Source

pub(crate) fn format_missing_no_indent(&mut self, end: BytePos)

Source

fn format_missing_indent(&mut self, end: BytePos, should_indent: bool)

Source

fn format_missing_inner<F: Fn(&mut FmtVisitor<'_>, &str, &str)>( &mut self, end: BytePos, process_last_snippet: F, )

Source

fn push_vertical_spaces(&mut self, newline_count: usize)

Source

fn write_snippet<F>(&mut self, span: Span, process_last_snippet: F)
where F: Fn(&mut FmtVisitor<'_>, &str, &str),

Source

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),

Source

fn process_comment( &mut self, status: &mut SnippetStatus, snippet: &str, big_snippet: &str, offset: usize, subslice: &str, )

Source

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>

Source

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.

Source

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>

Source

fn set_parent_context(&mut self, context: &'a RewriteContext<'_>)

Source

pub(crate) fn shape(&self) -> Shape

Source

fn next_span(&self, hi: BytePos) -> Span

Source

fn visit_stmt(&mut self, stmt: &Stmt<'_>, include_empty_semi: bool)

Source

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.

Source

pub(crate) fn visit_block( &mut self, b: &Block, inner_attrs: Option<&[Attribute]>, has_braces: bool, )

Source

fn close_block(&mut self, span: Span, unindent_comment: bool)

Source

fn unindent_comment_on_closing_brace(&self, b: &Block) -> bool

Source

pub(crate) fn visit_fn( &mut self, fk: FnKind<'_>, fd: &FnDecl, s: Span, defaultness: Defaultness, inner_attrs: Option<&[Attribute]>, )

Source

pub(crate) fn visit_item(&mut self, item: &Item)

Source

fn visit_ty_alias_kind( &mut self, ty_kind: &TyAlias, visitor_kind: &ItemVisitorKind<'_>, span: Span, )

Source

fn visit_assoc_item(&mut self, visitor_kind: &ItemVisitorKind<'_>)

Source

pub(crate) fn visit_trait_item(&mut self, ti: &AssocItem)

Source

pub(crate) fn visit_impl_item(&mut self, ii: &AssocItem)

Source

fn visit_mac(&mut self, mac: &MacCall, ident: Option<Ident>, pos: MacroPosition)

Source

pub(crate) fn push_str(&mut self, s: &str)

Source

fn push_rewrite_inner(&mut self, span: Span, rewrite: Option<String>)

Source

pub(crate) fn push_rewrite(&mut self, span: Span, rewrite: Option<String>)

Source

pub(crate) fn push_skipped_with_span( &mut self, attrs: &[Attribute], item_span: Span, main_span: Span, )

Source

pub(crate) fn from_context(ctx: &'a RewriteContext<'_>) -> FmtVisitor<'a>

Source

pub(crate) fn from_psess( psess: &'a ParseSess, config: &'a Config, snippet_provider: &'a SnippetProvider, report: FormatReport, ) -> FmtVisitor<'a>

Source

pub(crate) fn opt_snippet(&'b self, span: Span) -> Option<&'a str>

Source

pub(crate) fn snippet(&'b self, span: Span) -> &'a str

Source

pub(crate) fn visit_attrs( &mut self, attrs: &[Attribute], style: AttrStyle, ) -> bool

Source

fn is_unknown_rustfmt_attr(&self, segments: &[PathSegment]) -> bool

Source

fn walk_mod_items(&mut self, items: &[P<Item>])

Source

fn walk_stmts(&mut self, stmts: &[Stmt<'_>], include_current_empty_semi: bool)

Source

fn walk_block_stmts(&mut self, b: &Block)

Source

fn format_mod( &mut self, mod_kind: &ModKind, safety: Safety, vis: &Visibility, s: Span, ident: Ident, attrs: &[Attribute], )

Source

pub(crate) fn format_separate_mod(&mut self, m: &Module<'_>, end_pos: BytePos)

Source

pub(crate) fn skip_empty_lines(&mut self, end_pos: BytePos)

Source

pub(crate) fn with_context<F>(&mut self, f: F) -> Option<String>
where F: Fn(&RewriteContext<'_>) -> Option<String>,

Source

pub(crate) fn get_context(&self) -> RewriteContext<'_>

Trait Implementations§

Source§

impl<'a> Drop for FmtVisitor<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more

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