fn implemented_method<'tcx>(
tcx: TyCtxt<'tcx>,
instance: Instance<'tcx>,
) -> Option<(EarlyBinder<'tcx, TraitRef<'tcx>>, DefId, DefId)>Expand description
Determines if an instance represents a trait method implementation and returns the necessary information for type erasure.
This function handles two main cases:
-
Implementation in an
implblock: When the instance represents a concrete implementation of a trait method in animplblock, it extracts the trait reference, method ID, and trait ID from the implementation. The method ID is obtained from thetrait_item_def_idfield of the associated item, which points to the original trait method definition. -
Provided method in a
traitblock or syntheticshim: When the instance represents a default implementation provided in the trait definition itself or a synthetic shim, it uses the instance’s owndef_idas the method ID and determines the trait ID from the associated item.