Struct FmtCtx

Source
pub struct FmtCtx<'a> {
    pub translated: Option<&'a TranslatedCrate>,
    pub generics: BindingStack<Cow<'a, GenericParams>>,
    pub locals: Option<&'a Locals>,
    pub indent_level: usize,
}
Expand description

Context for formatting.

Fields§

§translated: Option<&'a TranslatedCrate>§generics: BindingStack<Cow<'a, GenericParams>>

Generics form a stack, where each binder introduces a new level. For DeBruijn indices to work, we keep the innermost parameters at the start of the vector.

§locals: Option<&'a Locals>§indent_level: usize

Implementations§

Source§

impl<'a> FmtCtx<'a>

Source

pub fn new() -> Self

Source

pub fn get_item( &self, id: AnyTransId, ) -> Result<AnyTransItem<'_>, Option<&Name>>

Source

pub fn format_decl_id(&self, id: impl Into<AnyTransId>) -> String

Print the whole definition.

Source

fn reborrow<'b>(&'b self) -> FmtCtx<'b>

Trait Implementations§

Source§

impl<'c> AstFormatter for FmtCtx<'c>

Source§

type Reborrow<'a> = FmtCtx<'a> where Self: 'a

Source§

fn get_crate(&self) -> Option<&TranslatedCrate>

Source§

fn set_generics<'a>(&'a self, generics: &'a GenericParams) -> Self::Reborrow<'a>

Source§

fn set_locals<'a>(&'a self, locals: &'a Locals) -> Self::Reborrow<'a>

Source§

fn push_binder<'a>( &'a self, new_params: Cow<'a, GenericParams>, ) -> Self::Reborrow<'a>

Source§

fn increase_indent<'a>(&'a self) -> Self::Reborrow<'a>

Source§

fn indent(&self) -> String

Source§

fn format_local_id(&self, f: &mut Formatter<'_>, id: LocalId) -> Result

Source§

fn format_bound_var<Id: Idx + Display, T>( &self, f: &mut Formatter<'_>, var: DeBruijnVar<Id>, var_prefix: &str, fmt_var: impl Fn(&T) -> Option<String>, ) -> Result
where GenericParams: HasVectorOf<Id, Output = T>,

Source§

fn push_bound_regions<'a>( &'a self, regions: &'a Vector<RegionId, RegionVar>, ) -> Self::Reborrow<'a>

Source§

fn format_enum_variant( &self, f: &mut Formatter<'_>, type_id: TypeDeclId, variant_id: VariantId, ) -> Result

Source§

fn format_field_name( &self, f: &mut Formatter<'_>, type_id: TypeDeclId, opt_variant_id: Option<VariantId>, field_id: FieldId, ) -> Result

Source§

impl<'a> Default for FmtCtx<'a>

Source§

fn default() -> FmtCtx<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for FmtCtx<'a>

§

impl<'a> RefUnwindSafe for FmtCtx<'a>

§

impl<'a> Send for FmtCtx<'a>

§

impl<'a> Sync for FmtCtx<'a>

§

impl<'a> Unpin for FmtCtx<'a>

§

impl<'a> UnwindSafe for FmtCtx<'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
§

impl<I, T> ExtractContext<I, ()> for T

§

fn extract_context(self, _original_input: I)

Given the context attached to a nom error, and given the original input to the nom parser, extract more the useful context information. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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<I> RecreateContext<I> for I

§

fn recreate_context(_original_input: I, tail: I) -> I

Given the original input, as well as the context reported by nom, recreate a context in the original string where the error occurred. 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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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