Trait rustc_trait_selection::infer::InferCtxtExt

source ·
pub trait InferCtxtExt<'tcx> {
    // Required methods
    fn can_eq<T: ToTrace<'tcx>>(
        &self,
        param_env: ParamEnv<'tcx>,
        a: T,
        b: T,
    ) -> bool;
    fn type_is_copy_modulo_regions(
        &self,
        param_env: ParamEnv<'tcx>,
        ty: Ty<'tcx>,
    ) -> bool;
    fn type_is_sized_modulo_regions(
        &self,
        param_env: ParamEnv<'tcx>,
        ty: Ty<'tcx>,
    ) -> bool;
    fn type_implements_trait(
        &self,
        trait_def_id: DefId,
        params: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
        param_env: ParamEnv<'tcx>,
    ) -> EvaluationResult;
    fn type_implements_trait_shallow(
        &self,
        trait_def_id: DefId,
        ty: Ty<'tcx>,
        param_env: ParamEnv<'tcx>,
    ) -> Option<Vec<FulfillmentError<'tcx>>>;
}

Required Methods§

source

fn can_eq<T: ToTrace<'tcx>>( &self, param_env: ParamEnv<'tcx>, a: T, b: T, ) -> bool

source

fn type_is_copy_modulo_regions( &self, param_env: ParamEnv<'tcx>, ty: Ty<'tcx>, ) -> bool

source

fn type_is_sized_modulo_regions( &self, param_env: ParamEnv<'tcx>, ty: Ty<'tcx>, ) -> bool

source

fn type_implements_trait( &self, trait_def_id: DefId, params: impl IntoIterator<Item: Into<GenericArg<'tcx>>>, param_env: ParamEnv<'tcx>, ) -> EvaluationResult

Check whether a ty implements given trait(trait_def_id) without side-effects.

The inputs are:

  • the def-id of the trait
  • the type parameters of the trait, including the self-type
  • the parameter environment

Invokes evaluate_obligation, so in the event that evaluating Ty: Trait causes overflow, EvaluatedToAmbigStackDependent will be returned.

source

fn type_implements_trait_shallow( &self, trait_def_id: DefId, ty: Ty<'tcx>, param_env: ParamEnv<'tcx>, ) -> Option<Vec<FulfillmentError<'tcx>>>

Returns Some if a type implements a trait shallowly, without side-effects, along with any errors that would have been reported upon further obligation processing.

  • If this returns Some([]), then the trait holds modulo regions.
  • If this returns Some([errors..]), then the trait has an impl for the self type, but some nested obligations do not hold.
  • If this returns None, no implementation that applies could be found.

FIXME(-Znext-solver): Due to the recursive nature of the new solver, this will probably only ever return Some([]) or None.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx>