pub trait FnPtrDiscriminatorSource<'tcx>: Sized {
// Required method
fn discriminator_input(
self,
tcx: TyCtxt<'tcx>,
) -> Option<FnPtrTypeDiscriminatorInput<'tcx>>;
}Expand description
Types that can serve as a source for function pointer type discrimination.
This trait abstracts over the different compiler representations from which
a function signature can be obtained. Implementations construct the
canonical FnPtrTypeDiscriminatorInput consumed by the discriminator
computation.
This is intended primarily for ergonomic use at call sites, allowing code
to compute discriminators directly from an Instance, Ty, or FnSig
without manually constructing the intermediate representation.
Required Methods§
fn discriminator_input( self, tcx: TyCtxt<'tcx>, ) -> Option<FnPtrTypeDiscriminatorInput<'tcx>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<'tcx> FnPtrDiscriminatorSource<'tcx> for FnSig<'tcx>
Enables discriminator computation directly from instantiated function signatures.
The signature is assumed to already be instantiated and normalized.
impl<'tcx> FnPtrDiscriminatorSource<'tcx> for Instance<'tcx>
Enables discriminator computation directly from monomorphized function instances.
The instance’s signature is instantiated using its generic arguments and normalized before constructing the canonical discriminator input.
impl<'tcx> FnPtrDiscriminatorSource<'tcx> for Ty<'tcx>
Enables discriminator computation directly from Rust function types.
Accepts both:
FnPtr: actual function pointer typesFnDef: function items
FnDef is only accepted for convenience; the discriminator is still computed from the instantiated function signature.