Struct rustfmt_nightly::visitor::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 inclusifs.

§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 ) -> Option<String>

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, unsafety: Unsafe, 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> !DynSend for FmtVisitor<'a>

§

impl<'a> !DynSync for FmtVisitor<'a>

§

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> Aligned for T

source§

const ALIGN: Alignment = _

Alignment of Self.
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, R> CollectAndApply<T, R> for T

source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

§

impl<T> Filterable for T

§

fn filterable( self, filter_name: &'static str ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. 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> 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<P> IntoQueryParam<P> for P

source§

impl<T> MaybeResult<T> for T

§

type Error = !

source§

fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

source§

fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

§

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> Same for T

§

type Output = T

Should always be Self
source§

impl<'tcx, T> ToPredicate<'tcx, T> for T

source§

fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> T

source§

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

§

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

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<Tcx, T> Value<Tcx> for T
where Tcx: DepContext,

source§

default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed ) -> T

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
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
source§

impl<'a, T> Captures<'a> for T
where T: ?Sized,

source§

impl<'a, T> Captures<'a> for T
where T: ?Sized,

§

impl<T> ErasedDestructor for T
where T: 'static,

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