Trait rustc_middle::ty::print::pretty::PrettyPrinter

source ·
pub trait PrettyPrinter<'tcx>: Printer<'tcx> + Write {
Show 35 methods // Required methods fn generic_delimiters( &mut self, f: impl FnOnce(&mut Self) -> Result<(), PrintError>, ) -> Result<(), PrintError>; fn should_print_region(&self, region: Region<'tcx>) -> bool; // Provided methods fn print_value_path( &mut self, def_id: DefId, args: &'tcx [GenericArg<'tcx>], ) -> Result<(), PrintError> { ... } fn in_binder<T>( &mut self, value: &Binder<'tcx, T>, ) -> Result<(), PrintError> where T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>> { ... } fn wrap_binder<T, F: FnOnce(&T, &mut Self) -> Result<(), Error>>( &mut self, value: &Binder<'tcx, T>, f: F, ) -> Result<(), PrintError> where T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>> { ... } fn comma_sep<T>( &mut self, elems: impl Iterator<Item = T>, ) -> Result<(), PrintError> where T: Print<'tcx, Self> { ... } fn typed_value( &mut self, f: impl FnOnce(&mut Self) -> Result<(), PrintError>, t: impl FnOnce(&mut Self) -> Result<(), PrintError>, conversion: &str, ) -> Result<(), PrintError> { ... } fn parenthesized( &mut self, f: impl FnOnce(&mut Self) -> Result<(), PrintError>, ) -> Result<(), PrintError> { ... } fn maybe_parenthesized( &mut self, f: impl FnOnce(&mut Self) -> Result<(), PrintError>, parenthesized: bool, ) -> Result<(), PrintError> { ... } fn reset_type_limit(&mut self) { ... } fn try_print_visible_def_path( &mut self, def_id: DefId, ) -> Result<bool, PrintError> { ... } fn force_print_trimmed_def_path( &mut self, def_id: DefId, ) -> Result<bool, PrintError> { ... } fn try_print_trimmed_def_path( &mut self, def_id: DefId, ) -> Result<bool, PrintError> { ... } fn try_print_visible_def_path_recur( &mut self, def_id: DefId, callers: &mut Vec<DefId>, ) -> Result<bool, PrintError> { ... } fn pretty_path_qualified( &mut self, self_ty: Ty<'tcx>, trait_ref: Option<TraitRef<'tcx>>, ) -> Result<(), PrintError> { ... } fn pretty_path_append_impl( &mut self, print_prefix: impl FnOnce(&mut Self) -> Result<(), PrintError>, self_ty: Ty<'tcx>, trait_ref: Option<TraitRef<'tcx>>, ) -> Result<(), PrintError> { ... } fn pretty_print_type(&mut self, ty: Ty<'tcx>) -> Result<(), PrintError> { ... } fn pretty_print_opaque_impl_type( &mut self, def_id: DefId, args: GenericArgsRef<'tcx>, ) -> Result<(), PrintError> { ... } fn insert_trait_and_projection( &mut self, trait_ref: PolyTraitRef<'tcx>, polarity: PredicatePolarity, proj_ty: Option<(DefId, Binder<'tcx, Term<'tcx>>)>, traits: &mut FxIndexMap<(PolyTraitRef<'tcx>, PredicatePolarity), FxIndexMap<DefId, Binder<'tcx, Term<'tcx>>>>, fn_traits: &mut FxIndexMap<PolyTraitRef<'tcx>, OpaqueFnEntry<'tcx>>, ) { ... } fn pretty_print_inherent_projection( &mut self, alias_ty: AliasTerm<'tcx>, ) -> Result<(), PrintError> { ... } fn ty_infer_name(&self, _: TyVid) -> Option<Symbol> { ... } fn const_infer_name(&self, _: ConstVid) -> Option<Symbol> { ... } fn pretty_print_dyn_existential( &mut self, predicates: &'tcx List<PolyExistentialPredicate<'tcx>>, ) -> Result<(), PrintError> { ... } fn pretty_fn_sig( &mut self, inputs: &[Ty<'tcx>], c_variadic: bool, output: Ty<'tcx>, ) -> Result<(), PrintError> { ... } fn pretty_print_const( &mut self, ct: Const<'tcx>, print_ty: bool, ) -> Result<(), PrintError> { ... } fn pretty_print_const_expr( &mut self, expr: Expr<'tcx>, print_ty: bool, ) -> Result<(), PrintError> { ... } fn pretty_print_const_scalar( &mut self, scalar: Scalar, ty: Ty<'tcx>, ) -> Result<(), PrintError> { ... } fn pretty_print_const_scalar_ptr( &mut self, ptr: Pointer, ty: Ty<'tcx>, ) -> Result<(), PrintError> { ... } fn pretty_print_const_scalar_int( &mut self, int: ScalarInt, ty: Ty<'tcx>, print_ty: bool, ) -> Result<(), PrintError> { ... } fn pretty_print_const_pointer<Prov: Provenance>( &mut self, _: Pointer<Prov>, ty: Ty<'tcx>, ) -> Result<(), PrintError> { ... } fn pretty_print_byte_str( &mut self, byte_str: &'tcx [u8], ) -> Result<(), PrintError> { ... } fn pretty_print_const_valtree( &mut self, valtree: ValTree<'tcx>, ty: Ty<'tcx>, print_ty: bool, ) -> Result<(), PrintError> { ... } fn pretty_closure_as_impl( &mut self, closure: ClosureArgs<TyCtxt<'tcx>>, ) -> Result<(), PrintError> { ... } fn pretty_print_bound_constness( &mut self, trait_ref: TraitRef<'tcx>, ) -> Result<(), PrintError> { ... } fn should_print_verbose(&self) -> bool { ... }
}
Expand description

Trait for printers that pretty-print using fmt::Write to the printer.

Required Methods§

source

fn generic_delimiters( &mut self, f: impl FnOnce(&mut Self) -> Result<(), PrintError>, ) -> Result<(), PrintError>

Prints <...> around what f prints.

source

fn should_print_region(&self, region: Region<'tcx>) -> bool

Returns true if the region should be printed in optional positions, e.g., &'a T or dyn Tr + 'b. This is typically the case for all non-'_ regions.

Provided Methods§

source

fn print_value_path( &mut self, def_id: DefId, args: &'tcx [GenericArg<'tcx>], ) -> Result<(), PrintError>

Like print_def_path but for value paths.

source

fn in_binder<T>(&mut self, value: &Binder<'tcx, T>) -> Result<(), PrintError>
where T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,

source

fn wrap_binder<T, F: FnOnce(&T, &mut Self) -> Result<(), Error>>( &mut self, value: &Binder<'tcx, T>, f: F, ) -> Result<(), PrintError>
where T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,

source

fn comma_sep<T>( &mut self, elems: impl Iterator<Item = T>, ) -> Result<(), PrintError>
where T: Print<'tcx, Self>,

Prints comma-separated elements.

source

fn typed_value( &mut self, f: impl FnOnce(&mut Self) -> Result<(), PrintError>, t: impl FnOnce(&mut Self) -> Result<(), PrintError>, conversion: &str, ) -> Result<(), PrintError>

Prints {f: t} or {f as t} depending on the cast argument

source

fn parenthesized( &mut self, f: impl FnOnce(&mut Self) -> Result<(), PrintError>, ) -> Result<(), PrintError>

Prints (...) around what f prints.

source

fn maybe_parenthesized( &mut self, f: impl FnOnce(&mut Self) -> Result<(), PrintError>, parenthesized: bool, ) -> Result<(), PrintError>

Prints (...) around what f prints if parenthesized is true, otherwise just prints f.

source

fn reset_type_limit(&mut self)

source

fn try_print_visible_def_path( &mut self, def_id: DefId, ) -> Result<bool, PrintError>

If possible, this returns a global path resolving to def_id that is visible from at least one local module, and returns true. If the crate defining def_id is declared with an extern crate, the path is guaranteed to use the extern crate.

source

fn force_print_trimmed_def_path( &mut self, def_id: DefId, ) -> Result<bool, PrintError>

source

fn try_print_trimmed_def_path( &mut self, def_id: DefId, ) -> Result<bool, PrintError>

Try to see if this path can be trimmed to a unique symbol name.

source

fn try_print_visible_def_path_recur( &mut self, def_id: DefId, callers: &mut Vec<DefId>, ) -> Result<bool, PrintError>

Does the work of try_print_visible_def_path, building the full definition path recursively before attempting to post-process it into the valid and visible version that accounts for re-exports.

This method should only be called by itself or try_print_visible_def_path.

callers is a chain of visible_parent’s leading to def_id, to support cycle detection during recursion.

This method returns false if we can’t print the visible path, so print_def_path can fall back on the item’s real definition path.

source

fn pretty_path_qualified( &mut self, self_ty: Ty<'tcx>, trait_ref: Option<TraitRef<'tcx>>, ) -> Result<(), PrintError>

source

fn pretty_path_append_impl( &mut self, print_prefix: impl FnOnce(&mut Self) -> Result<(), PrintError>, self_ty: Ty<'tcx>, trait_ref: Option<TraitRef<'tcx>>, ) -> Result<(), PrintError>

source

fn pretty_print_type(&mut self, ty: Ty<'tcx>) -> Result<(), PrintError>

source

fn pretty_print_opaque_impl_type( &mut self, def_id: DefId, args: GenericArgsRef<'tcx>, ) -> Result<(), PrintError>

source

fn insert_trait_and_projection( &mut self, trait_ref: PolyTraitRef<'tcx>, polarity: PredicatePolarity, proj_ty: Option<(DefId, Binder<'tcx, Term<'tcx>>)>, traits: &mut FxIndexMap<(PolyTraitRef<'tcx>, PredicatePolarity), FxIndexMap<DefId, Binder<'tcx, Term<'tcx>>>>, fn_traits: &mut FxIndexMap<PolyTraitRef<'tcx>, OpaqueFnEntry<'tcx>>, )

Insert the trait ref and optionally a projection type associated with it into either the traits map or fn_traits map, depending on if the trait is in the Fn* family of traits.

source

fn pretty_print_inherent_projection( &mut self, alias_ty: AliasTerm<'tcx>, ) -> Result<(), PrintError>

source

fn ty_infer_name(&self, _: TyVid) -> Option<Symbol>

source

fn const_infer_name(&self, _: ConstVid) -> Option<Symbol>

source

fn pretty_print_dyn_existential( &mut self, predicates: &'tcx List<PolyExistentialPredicate<'tcx>>, ) -> Result<(), PrintError>

source

fn pretty_fn_sig( &mut self, inputs: &[Ty<'tcx>], c_variadic: bool, output: Ty<'tcx>, ) -> Result<(), PrintError>

source

fn pretty_print_const( &mut self, ct: Const<'tcx>, print_ty: bool, ) -> Result<(), PrintError>

source

fn pretty_print_const_expr( &mut self, expr: Expr<'tcx>, print_ty: bool, ) -> Result<(), PrintError>

source

fn pretty_print_const_scalar( &mut self, scalar: Scalar, ty: Ty<'tcx>, ) -> Result<(), PrintError>

source

fn pretty_print_const_scalar_ptr( &mut self, ptr: Pointer, ty: Ty<'tcx>, ) -> Result<(), PrintError>

source

fn pretty_print_const_scalar_int( &mut self, int: ScalarInt, ty: Ty<'tcx>, print_ty: bool, ) -> Result<(), PrintError>

source

fn pretty_print_const_pointer<Prov: Provenance>( &mut self, _: Pointer<Prov>, ty: Ty<'tcx>, ) -> Result<(), PrintError>

This is overridden for MIR printing because we only want to hide alloc ids from users, not from MIR where it is actually useful.

source

fn pretty_print_byte_str( &mut self, byte_str: &'tcx [u8], ) -> Result<(), PrintError>

source

fn pretty_print_const_valtree( &mut self, valtree: ValTree<'tcx>, ty: Ty<'tcx>, print_ty: bool, ) -> Result<(), PrintError>

source

fn pretty_closure_as_impl( &mut self, closure: ClosureArgs<TyCtxt<'tcx>>, ) -> Result<(), PrintError>

source

fn pretty_print_bound_constness( &mut self, trait_ref: TraitRef<'tcx>, ) -> Result<(), PrintError>

source

fn should_print_verbose(&self) -> bool

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx>