Skip to main content

## implemented_method

# Function implemented_method

Source

    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 `impl` block: When the instance represents a concrete implementation of a trait method in an `impl` block, it extracts the trait reference, method ID, and trait ID from the implementation. The method ID is obtained from the `trait_item_def_id` field of the associated item, which points to the original trait method definition.

- Provided method in a `trait` block or synthetic `shim`: When the instance represents a default implementation provided in the trait definition itself or a synthetic shim, it uses the instance’s own `def_id` as the method ID and determines the trait ID from the associated item.