pub struct LeanPrinter(/* private fields */);Expand description
The Lean printer
Implementations§
Source§impl LeanPrinter
impl LeanPrinter
Sourcepub fn printable_item(item: &Item) -> bool
pub fn printable_item(item: &Item) -> bool
A filter for items blacklisted by the Lean backend : returns false if the item is definitely not printable, but might return true on unsupported items
Sourcepub fn render_id(&self, id: &GlobalId) -> String
pub fn render_id(&self, id: &GlobalId) -> String
Render a global id using the Rendering strategy of the Lean printer. Works for both concrete and projector ids. TODO: https://github.com/cryspen/hax/issues/1660
Sourcepub fn escape(&self, id: String) -> String
pub fn escape(&self, id: String) -> String
Escapes local identifiers (prefixing reserved keywords with an underscore). TODO: This should be treated directly in the name rendering engine, see https://github.com/cryspen/hax/issues/1630
Sourcepub fn render_last(&self, id: &GlobalId) -> String
pub fn render_last(&self, id: &GlobalId) -> String
Renders the last, most local part of an id. Used for named arguments of constructors.
Source§impl LeanPrinter
impl LeanPrinter
Sourcepub fn arguments<A: 'static + Clone, D>(
&self,
fields: &[(GlobalId, D)],
is_record: &bool,
) -> DocBuilder<A>where
D: ToDocument<Self, A>,
pub fn arguments<A: 'static + Clone, D>(
&self,
fields: &[(GlobalId, D)],
is_record: &bool,
) -> DocBuilder<A>where
D: ToDocument<Self, A>,
Prints arguments a variant or constructor of struct, using named or unamed arguments based
on the is_record flag. Used for both expressions and patterns
Trait Implementations§
Source§impl Clone for LeanPrinter
impl Clone for LeanPrinter
Source§fn clone(&self) -> LeanPrinter
fn clone(&self) -> LeanPrinter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for LeanPrinter
impl Default for LeanPrinter
Source§fn default() -> LeanPrinter
fn default() -> LeanPrinter
Source§impl HasContextualSpan for LeanPrinter
impl HasContextualSpan for LeanPrinter
Source§impl HasLinkedItemGraph for LeanPrinter
impl HasLinkedItemGraph for LeanPrinter
Source§fn linked_item_graph(&self) -> &LinkedItemGraph
fn linked_item_graph(&self) -> &LinkedItemGraph
LinkedItemGraph.Source§fn with_linked_item_graph(self, graph: Rc<LinkedItemGraph>) -> Self
fn with_linked_item_graph(self, graph: Rc<LinkedItemGraph>) -> Self
LinkedItemGraph.Source§impl<A: 'static + Clone> PrettyAst<A> for LeanPrinter
impl<A: 'static + Clone> PrettyAst<A> for LeanPrinter
Source§fn todo_document(&self, message: &str, issue_id: Option<u32>) -> DocBuilder<A>
fn todo_document(&self, message: &str, issue_id: Option<u32>) -> DocBuilder<A>
Produce a non-panicking placeholder document. In general, prefer the use of the helper macro [todo_document!].
Source§fn generics(&self, generics: &Generics) -> DocBuilder<A>
👎Deprecated: Do not call this method directly. Use ToDocument::to_document instead, so annotations/spans are preserved correctly.
fn generics(&self, generics: &Generics) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.Render generics, adding a space after each parameter
Source§const NAME: &'static str = "Lean"
const NAME: &'static str = "Lean"
PrettyAst.
Useful for diagnostics and debugging.Source§fn module(&self, module: &Module) -> DocBuilder<A>
fn module(&self, module: &Module) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn global_id(&self, global_id: &GlobalId) -> DocBuilder<A>
fn global_id(&self, global_id: &GlobalId) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn generic_constraint(&self, _: &GenericConstraint) -> DocBuilder<A>
fn generic_constraint(&self, _: &GenericConstraint) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn generic_param(&self, generic_param: &GenericParam) -> DocBuilder<A>
fn generic_param(&self, generic_param: &GenericParam) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn generic_value(&self, generic_value: &GenericValue) -> DocBuilder<A>
fn generic_value(&self, generic_value: &GenericValue) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn expr(&self, _: &Expr) -> DocBuilder<A>
fn expr(&self, _: &Expr) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn arm(&self, arm: &Arm) -> DocBuilder<A>
fn arm(&self, arm: &Arm) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn pat(&self, pat: &Pat) -> DocBuilder<A>
fn pat(&self, pat: &Pat) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn ty(&self, ty: &Ty) -> DocBuilder<A>
fn ty(&self, ty: &Ty) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn literal(&self, literal: &Literal) -> DocBuilder<A>
fn literal(&self, literal: &Literal) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn local_id(&self, local_id: &LocalId) -> DocBuilder<A>
fn local_id(&self, local_id: &LocalId) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn spanned_ty(&self, spanned_ty: &SpannedTy) -> DocBuilder<A>
fn spanned_ty(&self, spanned_ty: &SpannedTy) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn primitive_ty(&self, primitive_ty: &PrimitiveTy) -> DocBuilder<A>
fn primitive_ty(&self, primitive_ty: &PrimitiveTy) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn int_kind(&self, int_kind: &IntKind) -> DocBuilder<A>
fn int_kind(&self, int_kind: &IntKind) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn float_kind(&self, float_kind: &FloatKind) -> DocBuilder<A>
fn float_kind(&self, float_kind: &FloatKind) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn quote_content(&self, quote_content: &QuoteContent) -> DocBuilder<A>
fn quote_content(&self, quote_content: &QuoteContent) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn quote(&self, quote: &Quote) -> DocBuilder<A>
fn quote(&self, quote: &Quote) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn param(&self, param: &Param) -> DocBuilder<A>
fn param(&self, param: &Param) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn item(&self, item: &Item) -> DocBuilder<A>
fn item(&self, item: &Item) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn impl_item(&self, _: &ImplItem) -> DocBuilder<A>
fn impl_item(&self, _: &ImplItem) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn impl_ident(&self, _: &ImplIdent) -> DocBuilder<A>
fn impl_ident(&self, _: &ImplIdent) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn trait_goal(&self, _: &TraitGoal) -> DocBuilder<A>
fn trait_goal(&self, _: &TraitGoal) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn variant(&self, _: &Variant) -> DocBuilder<A>
fn variant(&self, _: &Variant) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn symbol(&self, symbol: &Symbol) -> DocBuilder<A>
fn symbol(&self, symbol: &Symbol) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn metadata(&self, _: &Metadata) -> DocBuilder<A>
fn metadata(&self, _: &Metadata) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn lhs(&self, _lhs: &Lhs) -> DocBuilder<A>
fn lhs(&self, _lhs: &Lhs) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn safety_kind(&self, _safety_kind: &SafetyKind) -> DocBuilder<A>
fn safety_kind(&self, _safety_kind: &SafetyKind) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn binding_mode(&self, _binding_mode: &BindingMode) -> DocBuilder<A>
fn binding_mode(&self, _binding_mode: &BindingMode) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn region(&self, _region: &Region) -> DocBuilder<A>
fn region(&self, _region: &Region) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn dyn_trait_goal(&self, _dyn_trait_goal: &DynTraitGoal) -> DocBuilder<A>
fn dyn_trait_goal(&self, _dyn_trait_goal: &DynTraitGoal) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn attribute(&self, _: &Attribute) -> DocBuilder<A>
fn attribute(&self, _: &Attribute) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn borrow_kind(&self, _borrow_kind: &BorrowKind) -> DocBuilder<A>
fn borrow_kind(&self, _borrow_kind: &BorrowKind) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn guard(&self, _guard: &Guard) -> DocBuilder<A>
fn guard(&self, _guard: &Guard) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn projection_predicate(
&self,
projection_predicate: &ProjectionPredicate,
) -> DocBuilder<A>
fn projection_predicate( &self, projection_predicate: &ProjectionPredicate, ) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn error_node(&self, _error_node: &ErrorNode) -> DocBuilder<A>
fn error_node(&self, _error_node: &ErrorNode) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn impl_expr(&self, _impl_expr: &ImplExpr) -> DocBuilder<A>
fn impl_expr(&self, _impl_expr: &ImplExpr) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn emit_diagnostic(&self, kind: Kind)
fn emit_diagnostic(&self, kind: Kind)
Source§fn unimplemented_method(
&self,
method: &str,
ast: FragmentRef<'_>,
) -> DocBuilder<A>
fn unimplemented_method( &self, method: &str, ast: FragmentRef<'_>, ) -> DocBuilder<A>
Source§fn trait_item(&self, trait_item: &TraitItem) -> DocBuilder<A>
fn trait_item(&self, trait_item: &TraitItem) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn generic_param_kind(
&self,
generic_param_kind: &GenericParamKind,
) -> DocBuilder<A>
fn generic_param_kind( &self, generic_param_kind: &GenericParamKind, ) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn item_kind(&self, item_kind: &ItemKind) -> DocBuilder<A>
fn item_kind(&self, item_kind: &ItemKind) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn resugared_expr_kind(
&self,
resugared_expr_kind: &ResugaredExprKind,
) -> DocBuilder<A>
fn resugared_expr_kind( &self, resugared_expr_kind: &ResugaredExprKind, ) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn resugared_ty_kind(
&self,
resugared_ty_kind: &ResugaredTyKind,
) -> DocBuilder<A>
fn resugared_ty_kind( &self, resugared_ty_kind: &ResugaredTyKind, ) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn resugared_pat_kind(
&self,
resugared_pat_kind: &ResugaredPatKind,
) -> DocBuilder<A>
fn resugared_pat_kind( &self, resugared_pat_kind: &ResugaredPatKind, ) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn resugared_impl_item_kind(
&self,
resugared_impl_item_kind: &ResugaredImplItemKind,
) -> DocBuilder<A>
fn resugared_impl_item_kind( &self, resugared_impl_item_kind: &ResugaredImplItemKind, ) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn resugared_trait_item_kind(
&self,
resugared_trait_item_kind: &ResugaredTraitItemKind,
) -> DocBuilder<A>
fn resugared_trait_item_kind( &self, resugared_trait_item_kind: &ResugaredTraitItemKind, ) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§fn resugared_item_kind(
&self,
resugared_item_kind: &ResugaredItemKind,
) -> DocBuilder<A>
fn resugared_item_kind( &self, resugared_item_kind: &ResugaredItemKind, ) -> DocBuilder<A>
ToDocument::to_document instead, so annotations/spans are preserved correctly.ToDocument::to_document instead, so annotations/spans are preserved correctly.Source§impl Printer for LeanPrinter
impl Printer for LeanPrinter
Source§fn resugaring_phases() -> Vec<Box<dyn Resugaring>>
fn resugaring_phases() -> Vec<Box<dyn Resugaring>>
Source§impl RenderView for LeanPrinter
impl RenderView for LeanPrinter
Source§fn separator(&self) -> &str
fn separator(&self) -> &str
"::"). Read moreSource§fn render_path_segment(&self, chunk: &PathSegment) -> Vec<String>
fn render_path_segment(&self, chunk: &PathSegment) -> Vec<String>
PathSegment into a vector of display atoms. Read moreSource§fn render_unnamed_path_segment_payload(
&self,
unnamed: UnnamedPathSegmentPayload,
) -> Symbol
fn render_unnamed_path_segment_payload( &self, unnamed: UnnamedPathSegmentPayload, ) -> Symbol
Source§fn render_path_segment_payload(&self, payload: PathSegmentPayload) -> Symbol
fn render_path_segment_payload(&self, payload: PathSegmentPayload) -> Symbol
Source§fn rendered_to_strings(
&self,
rendered: Rendered,
) -> impl Iterator<Item = String>
fn rendered_to_strings( &self, rendered: Rendered, ) -> impl Iterator<Item = String>
Source§fn rendered_to_string(&self, rendered: Rendered) -> String
fn rendered_to_string(&self, rendered: Rendered) -> String
Source§impl<A: 'static + Clone> ToDocument<LeanPrinter, A> for (Vec<GenericParam>, &TraitItem)
impl<A: 'static + Clone> ToDocument<LeanPrinter, A> for (Vec<GenericParam>, &TraitItem)
Source§fn to_document(&self, printer: &LeanPrinter) -> DocBuilder<A>
fn to_document(&self, printer: &LeanPrinter) -> DocBuilder<A>
Source§impl<A: 'static + Clone> ToDocument<LeanPrinter, A> for Vec<Param>
Render parameters, adding a line after each parameter
impl<A: 'static + Clone> ToDocument<LeanPrinter, A> for Vec<Param>
Render parameters, adding a line after each parameter
Source§fn to_document(&self, printer: &LeanPrinter) -> DocBuilder<A>
fn to_document(&self, printer: &LeanPrinter) -> DocBuilder<A>
Auto Trait Implementations§
impl Freeze for LeanPrinter
impl RefUnwindSafe for LeanPrinter
impl !Send for LeanPrinter
impl !Sync for LeanPrinter
impl Unpin for LeanPrinter
impl UnwindSafe for LeanPrinter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<A, P> PrettyAstExt<A> for P
impl<A, P> PrettyAstExt<A> for P
Source§fn nil(&self) -> DocBuilder<A>
fn nil(&self) -> DocBuilder<A>
pretty::DocAllocator::nil.Source§fn fail(&self) -> DocBuilder<A>
fn fail(&self) -> DocBuilder<A>
pretty::DocAllocator::fail. Read moreSource§fn hardline(&self) -> DocBuilder<A>
fn hardline(&self) -> DocBuilder<A>
pretty::DocAllocator::hardline.Source§fn space(&self) -> DocBuilder<A>
fn space(&self) -> DocBuilder<A>
pretty::DocAllocator::space.Source§fn line(&self) -> DocBuilder<A>
fn line(&self) -> DocBuilder<A>
\n but behaves like space once grouped onto a single line.
Mirrors pretty::DocAllocator::line.Source§fn line_(&self) -> DocBuilder<A>
fn line_(&self) -> DocBuilder<A>
line but collapses to nil if grouped on a single line.
Mirrors pretty::DocAllocator::line_.Source§fn softline(&self) -> DocBuilder<A>
fn softline(&self) -> DocBuilder<A>
space when the document fits the page, otherwise behaves like line.
Mirrors pretty::DocAllocator::softline.Source§fn softline_(&self) -> DocBuilder<A>
fn softline_(&self) -> DocBuilder<A>
nil when the document fits the page, otherwise behaves like line_.
Mirrors pretty::DocAllocator::softline_.Source§fn as_string<U: Display>(&self, data: U) -> DocBuilder<A>
fn as_string<U: Display>(&self, data: U) -> DocBuilder<A>
Source§fn text<'a>(&self, data: impl Into<Cow<'a, str>>) -> DocBuilder<A>
fn text<'a>(&self, data: impl Into<Cow<'a, str>>) -> DocBuilder<A>
pretty::DocAllocator::text. Read moreSource§fn concat<I>(&self, docs: I) -> DocBuilder<A>
fn concat<I>(&self, docs: I) -> DocBuilder<A>
pretty::DocAllocator::concat.Source§fn intersperse<I, S>(&self, docs: I, separator: S) -> DocBuilder<A>where
I::Item: ToDocumentOwned<Self, A>,
I: IntoIterator,
S: ToDocumentOwned<Self, A> + Clone,
A: Clone,
fn intersperse<I, S>(&self, docs: I, separator: S) -> DocBuilder<A>where
I::Item: ToDocumentOwned<Self, A>,
I: IntoIterator,
S: ToDocumentOwned<Self, A> + Clone,
A: Clone,
separator between every pair.
Mirrors pretty::DocAllocator::intersperse. Read more