pub struct HirFormatter<'a, 'db> {Show 16 fields
pub db: &'db dyn HirDatabase,
pub interner: DbInterner<'db>,
fmt: &'a mut dyn HirWrite,
buf: String,
curr_size: usize,
max_size: Option<usize>,
pub entity_limit: Option<usize>,
show_container_bounds: bool,
render_private_fields: bool,
omit_verbose_types: bool,
closure_style: ClosureStyle,
display_lifetimes: DisplayLifetime,
display_kind: DisplayKind,
display_target: DisplayTarget,
currently_formatting_bounds: FxHashSet<AliasTy<'db>>,
trait_bounds_need_parens: bool,
}Fields§
§db: &'db dyn HirDatabaseThe database handle
interner: DbInterner<'db>§fmt: &'a mut dyn HirWriteThe sink to write into
buf: StringA buffer to intercept writes with, this allows us to track the overall size of the formatted output.
curr_size: usizeThe current size of the formatted output.
max_size: Option<usize>Size from which we should truncate the output.
entity_limit: Option<usize>When rendering something that has a concept of “children” (like fields in a struct), this limits how many should be rendered.
show_container_bounds: boolWhen rendering functions, whether to show the constraint from the container
render_private_fields: bool§omit_verbose_types: bool§closure_style: ClosureStyle§display_lifetimes: DisplayLifetime§display_kind: DisplayKind§display_target: DisplayTarget§currently_formatting_bounds: FxHashSet<AliasTy<'db>>We can have recursive bounds like the following case:
where
T: Foo,
T::FooAssoc: Baz<<T::FooAssoc as Bar>::BarAssoc> + BarSo, record the projection types met while formatting bounds and prevent recursing into their bounds to avoid infinite loops.
trait_bounds_need_parens: boolWhether formatting impl Trait1 + Trait2 or dyn Trait1 + Trait2 needs parentheses around it,
for example when formatting &(impl Trait1 + Trait2).
Implementations§
Source§impl<'db> HirFormatter<'_, 'db>
impl<'db> HirFormatter<'_, 'db>
pub fn start_location_link(&mut self, location: ModuleDefId)
pub fn start_location_link_generic(&mut self, location: GenericParamId)
pub fn end_location_link(&mut self)
fn format_bounds_with<F: FnOnce(&mut Self) -> Result>( &mut self, target: AliasTy<'db>, format_bounds: F, ) -> Result
fn render_region(&self, lifetime: Region<'db>) -> bool
Source§impl<'db> HirFormatter<'_, 'db>
impl<'db> HirFormatter<'_, 'db>
pub fn krate(&self) -> Crate
pub fn edition(&self) -> Edition
pub fn lang_items(&self) -> &'db LangItems
pub fn write_joined<T: HirDisplay<'db>>( &mut self, iter: impl IntoIterator<Item = T>, sep: &str, ) -> Result
Sourcepub fn write_fmt(&mut self, args: Arguments<'_>) -> Result
pub fn write_fmt(&mut self, args: Arguments<'_>) -> Result
This allows using the write! macro directly with a HirFormatter.
pub fn write_str(&mut self, s: &str) -> Result
pub fn write_char(&mut self, c: char) -> Result
pub fn should_truncate(&self) -> bool
pub fn omit_verbose_types(&self) -> bool
pub fn show_container_bounds(&self) -> bool
pub fn render_private_fields(&self) -> bool
Auto Trait Implementations§
impl<'a, 'db> Freeze for HirFormatter<'a, 'db>
impl<'a, 'db> !RefUnwindSafe for HirFormatter<'a, 'db>
impl<'a, 'db> !Send for HirFormatter<'a, 'db>
impl<'a, 'db> !Sync for HirFormatter<'a, 'db>
impl<'a, 'db> Unpin for HirFormatter<'a, 'db>
impl<'a, 'db> UnsafeUnpin for HirFormatter<'a, 'db>
impl<'a, 'db> !UnwindSafe for HirFormatter<'a, 'db>
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
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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> ⓘ
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> ⓘ
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