rustc_middle::ty::print::pretty

Struct FmtPrinter

Source
pub struct FmtPrinter<'a, 'tcx>(Box<FmtPrinterData<'a, 'tcx>>);

Tuple Fields§

§0: Box<FmtPrinterData<'a, 'tcx>>

Implementations§

Source§

impl<'a, 'tcx> FmtPrinter<'a, 'tcx>

Source

pub fn new(tcx: TyCtxt<'tcx>, ns: Namespace) -> Self

Source

pub fn print_string( tcx: TyCtxt<'tcx>, ns: Namespace, f: impl FnOnce(&mut Self) -> Result<(), PrintError>, ) -> Result<String, PrintError>

Source

pub fn new_with_limit( tcx: TyCtxt<'tcx>, ns: Namespace, type_length_limit: Limit, ) -> Self

Source

pub fn into_buffer(self) -> String

Source§

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

Source

pub fn pretty_print_region(&mut self, region: Region<'tcx>) -> Result<(), Error>

Source§

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

Source

pub fn name_all_regions<T>( &mut self, value: &Binder<'tcx, T>, ) -> Result<(T, UnordMap<BoundRegion, Region<'tcx>>), Error>
where T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,

Source

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

Source

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

Source

fn prepare_region_info<T>(&mut self, value: &Binder<'tcx, T>)
where T: TypeVisitable<TyCtxt<'tcx>>,

Trait Implementations§

Source§

impl<'a, 'tcx> Deref for FmtPrinter<'a, 'tcx>

Source§

type Target = FmtPrinterData<'a, 'tcx>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for FmtPrinter<'_, '_>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

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

Source§

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

Source§

fn reset_type_limit(&mut self)

Source§

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

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, C: FnOnce(&T, &mut Self) -> Result<(), PrintError>>( &mut self, value: &Binder<'tcx, T>, f: C, ) -> Result<(), PrintError>
where T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,

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 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.
Source§

fn pretty_print_const_pointer<Prov: Provenance>( &mut self, p: 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 comma_sep<T>( &mut self, elems: impl Iterator<Item = T>, ) -> Result<(), PrintError>
where T: Print<'tcx, Self>,

Prints comma-separated elements.
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 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. Read more
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_pred: PolyTraitPredicate<'tcx>, proj_ty: Option<(DefId, Binder<'tcx, Term<'tcx>>)>, traits: &mut FxIndexMap<PolyTraitPredicate<'tcx>, FxIndexMap<DefId, Binder<'tcx, Term<'tcx>>>>, fn_traits: &mut FxIndexMap<(Binder<'tcx, &'tcx List<Ty<'tcx>>>, bool), 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 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_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, constness: BoundConstness, ) -> Result<(), PrintError>

Source§

fn should_print_verbose(&self) -> bool

Source§

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

Source§

fn tcx<'a>(&'a self) -> TyCtxt<'tcx>

Source§

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

Source§

fn print_region(&mut self, region: Region<'tcx>) -> Result<(), PrintError>

Source§

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

Source§

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

Source§

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

Source§

fn path_crate(&mut self, cnum: CrateNum) -> Result<(), PrintError>

Source§

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

Source§

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

Source§

fn path_append( &mut self, print_prefix: impl FnOnce(&mut Self) -> Result<(), PrintError>, disambiguated_data: &DisambiguatedDefPathData, ) -> Result<(), PrintError>

Source§

fn path_generic_args( &mut self, print_prefix: impl FnOnce(&mut Self) -> Result<(), PrintError>, args: &[GenericArg<'tcx>], ) -> Result<(), PrintError>

Source§

fn print_impl_path( &mut self, impl_def_id: DefId, args: &'tcx [GenericArg<'tcx>], self_ty: Ty<'tcx>, trait_ref: Option<TraitRef<'tcx>>, ) -> Result<(), PrintError>

Source§

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

Source§

fn default_print_impl_path( &mut self, impl_def_id: DefId, _args: &'tcx [GenericArg<'tcx>], self_ty: Ty<'tcx>, impl_trait_ref: Option<TraitRef<'tcx>>, ) -> Result<(), PrintError>

Source§

impl Write for FmtPrinter<'_, '_>

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations§

§

impl<'a, 'tcx> !DynSend for FmtPrinter<'a, 'tcx>

§

impl<'a, 'tcx> !DynSync for FmtPrinter<'a, 'tcx>

§

impl<'a, 'tcx> Freeze for FmtPrinter<'a, 'tcx>

§

impl<'a, 'tcx> !RefUnwindSafe for FmtPrinter<'a, 'tcx>

§

impl<'a, 'tcx> !Send for FmtPrinter<'a, 'tcx>

§

impl<'a, 'tcx> !Sync for FmtPrinter<'a, 'tcx>

§

impl<'a, 'tcx> Unpin for FmtPrinter<'a, 'tcx>

§

impl<'a, 'tcx> !UnwindSafe for FmtPrinter<'a, 'tcx>

Blanket Implementations§

Source§

impl<T> Aligned for T

Source§

const ALIGN: Alignment

Alignment of Self.
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
Source§

impl<T, R> CollectAndApply<T, R> for T

Source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

Source§

type Output = R

Source§

impl<T> Filterable for T

Source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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<P> IntoQueryParam<P> for P

Source§

impl<T> MaybeResult<T> for T

Source§

type Error = !

Source§

fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

Source§

fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

Source§

fn upcast(self, interner: I) -> U

Source§

impl<I, T> UpcastFrom<I, T> for T

Source§

fn upcast_from(from: T, _tcx: I) -> T

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<Tcx, T> Value<Tcx> for T
where Tcx: DepContext,

Source§

default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<'a, T> Captures<'a> for T
where T: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 8 bytes