Trait rustc_middle::ty::print::Printer
source · pub trait Printer<'tcx>: Sized {
type Error;
type Path;
type Region;
type Type;
type DynExistential;
type Const;
Show 14 methods
// Required methods
fn tcx<'a>(&'a self) -> TyCtxt<'tcx>;
fn print_region(
self,
region: Region<'tcx>
) -> Result<Self::Region, Self::Error>;
fn print_type(self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error>;
fn print_dyn_existential(
self,
predicates: &'tcx List<PolyExistentialPredicate<'tcx>>
) -> Result<Self::DynExistential, Self::Error>;
fn print_const(self, ct: Const<'tcx>) -> Result<Self::Const, Self::Error>;
fn path_crate(self, cnum: CrateNum) -> Result<Self::Path, Self::Error>;
fn path_qualified(
self,
self_ty: Ty<'tcx>,
trait_ref: Option<TraitRef<'tcx>>
) -> Result<Self::Path, Self::Error>;
fn path_append_impl(
self,
print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
disambiguated_data: &DisambiguatedDefPathData,
self_ty: Ty<'tcx>,
trait_ref: Option<TraitRef<'tcx>>
) -> Result<Self::Path, Self::Error>;
fn path_append(
self,
print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
disambiguated_data: &DisambiguatedDefPathData
) -> Result<Self::Path, Self::Error>;
fn path_generic_args(
self,
print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
args: &[GenericArg<'tcx>]
) -> Result<Self::Path, Self::Error>;
// Provided methods
fn print_def_path(
self,
def_id: DefId,
args: &'tcx [GenericArg<'tcx>]
) -> Result<Self::Path, Self::Error> { ... }
fn print_impl_path(
self,
impl_def_id: DefId,
args: &'tcx [GenericArg<'tcx>],
self_ty: Ty<'tcx>,
trait_ref: Option<TraitRef<'tcx>>
) -> Result<Self::Path, Self::Error> { ... }
fn default_print_def_path(
self,
def_id: DefId,
args: &'tcx [GenericArg<'tcx>]
) -> Result<Self::Path, Self::Error> { ... }
fn default_print_impl_path(
self,
impl_def_id: DefId,
_args: &'tcx [GenericArg<'tcx>],
self_ty: Ty<'tcx>,
impl_trait_ref: Option<TraitRef<'tcx>>
) -> Result<Self::Path, Self::Error> { ... }
}
Expand description
Interface for outputting user-facing “type-system entities”
(paths, types, lifetimes, constants, etc.) as a side-effect
(e.g. formatting, like PrettyPrinter
implementors do) or by
constructing some alternative representation (e.g. an AST),
which the associated types allow passing through the methods.
For pretty-printing/formatting in particular, see PrettyPrinter
.