charon_lib::pretty::formatter

Struct FmtCtx

source
pub struct FmtCtx<'a> {
    pub translated: Option<&'a TranslatedCrate>,
    pub generics: VecDeque<Cow<'a, GenericParams>>,
    pub locals: Option<&'a Vector<VarId, Var>>,
}
Expand description

For formatting.

Note that we use the ULLBC definitions, even when formatting LLBC definitions. It doesn’t really matter, as all we use is the name of the definitions.

Remark: we take shared borrows to the top-level declarations, but clone the generics, because we may dive into different contexts and may need to update those. We can think of a smarter way of doing this, but for now it is simple and efficient enough.

Fields§

§translated: Option<&'a TranslatedCrate>§generics: VecDeque<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 Vector<VarId, Var>>

Implementations§

source§

impl<'a> FmtCtx<'a>

source

pub fn new() -> Self

source

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

source

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

source

fn format_any_decl(&self, id: AnyTransId) -> String

Trait Implementations§

source§

impl<'a> DeclFormatter<FunDeclId> for FmtCtx<'a>

source§

impl<'a> DeclFormatter<GlobalDeclId> for FmtCtx<'a>

source§

impl<'a> DeclFormatter<TraitDeclId> for FmtCtx<'a>

source§

impl<'a> DeclFormatter<TraitImplId> for FmtCtx<'a>

source§

impl<'a> DeclFormatter<TypeDeclId> for FmtCtx<'a>

source§

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

source§

fn default() -> FmtCtx<'a>

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

impl<'a> Formatter<&Block> for FmtCtx<'a>

source§

impl<'a> Formatter<&FunDecl> for FmtCtx<'a>

source§

impl<'a> Formatter<&FunSig> for FmtCtx<'a>

source§

impl<'a> Formatter<&GExprBody<Block>> for FmtCtx<'a>

source§

impl<'a> Formatter<&GExprBody<Vector<BlockId, BlockData>>> for FmtCtx<'a>

source§

impl<'a> Formatter<&GlobalDecl> for FmtCtx<'a>

source§

impl<'a> Formatter<&ImplElem> for FmtCtx<'a>

source§

impl<'a> Formatter<&RegionVar> for FmtCtx<'a>

source§

impl<'a> Formatter<&TraitDecl> for FmtCtx<'a>

source§

impl<'a> Formatter<&TraitImpl> for FmtCtx<'a>

source§

impl<'a> Formatter<&Ty> for FmtCtx<'a>

source§

fn format_object(&self, x: &Ty) -> String

source§

impl<'a> Formatter<&TypeDecl> for FmtCtx<'a>

source§

impl<'a> Formatter<&Vector<BlockId, BlockData>> for FmtCtx<'a>

source§

impl<'a> Formatter<(DeBruijnId, RegionId)> for FmtCtx<'a>

source§

fn format_object(&self, (grid, id): (DeBruijnId, RegionId)) -> String

source§

impl<'a> Formatter<(TypeDeclId, Option<VariantId>, FieldId)> for FmtCtx<'a>

For struct/enum values: retrieve a field name

source§

impl<'a> Formatter<(TypeDeclId, VariantId)> for FmtCtx<'a>

For enum values: List::Cons

source§

impl<'a> Formatter<AnyTransId> for FmtCtx<'a>

source§

impl<'a> Formatter<BodyId> for FmtCtx<'a>

source§

impl<'a> Formatter<ConstGenericVarId> for FmtCtx<'a>

source§

impl<'a> Formatter<FunDeclId> for FmtCtx<'a>

source§

impl<'a> Formatter<GlobalDeclId> for FmtCtx<'a>

source§

impl<'a> Formatter<TraitClauseId> for FmtCtx<'a>

source§

impl<'a> Formatter<TraitDeclId> for FmtCtx<'a>

source§

impl<'a> Formatter<TraitImplId> for FmtCtx<'a>

source§

impl<'a> Formatter<TypeDeclId> for FmtCtx<'a>

source§

impl<'a> Formatter<TypeVarId> for FmtCtx<'a>

source§

impl<'a> Formatter<VarId> for FmtCtx<'a>

source§

impl<'a, 'b> PushBoundRegions<'a> for FmtCtx<'b>

source§

type C = FmtCtx<'a>

source§

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

source§

impl<'a, 'b> SetGenerics<'a> for FmtCtx<'b>

source§

type C = FmtCtx<'a>

source§

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

source§

impl<'a, 'b> SetLocals<'a> for FmtCtx<'b>

source§

type C = FmtCtx<'a>

source§

fn set_locals(&'a self, locals: &'a Vector<VarId, Var>) -> Self::C

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

impl<C> IntoFormatter for C
where C: AstFormatter,

source§

type C = C

source§

fn into_fmt(self) -> <C as IntoFormatter>::C

§

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