rustc_trait_selection::traits::query::type_op

Trait QueryTypeOp

Source
pub trait QueryTypeOp<'tcx>:
    Debug
    + Copy
    + TypeFoldable<TyCtxt<'tcx>>
    + 'tcx {
    type QueryResponse: TypeFoldable<TyCtxt<'tcx>>;

    // Required methods
    fn try_fast_path(
        tcx: TyCtxt<'tcx>,
        key: &ParamEnvAnd<'tcx, Self>,
    ) -> Option<Self::QueryResponse>;
    fn perform_query(
        tcx: TyCtxt<'tcx>,
        canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>,
    ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution>;
    fn perform_locally_with_next_solver(
        ocx: &ObligationCtxt<'_, 'tcx>,
        key: ParamEnvAnd<'tcx, Self>,
    ) -> Result<Self::QueryResponse, NoSolution>;

    // Provided method
    fn fully_perform_into(
        query_key: ParamEnvAnd<'tcx, Self>,
        infcx: &InferCtxt<'tcx>,
        output_query_region_constraints: &mut QueryRegionConstraints<'tcx>,
        span: Span,
    ) -> Result<(Self::QueryResponse, Option<CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>>, PredicateObligations<'tcx>, Certainty), NoSolution> { ... }
}
Expand description

“Query type ops” are type ops that are implemented using a canonical query. The Self type here contains the kernel of information needed to do the operation – TypeOp is actually implemented for ParamEnvAnd<Self>, since we always need to bring along a parameter environment as well. For query type-ops, we will first canonicalize the key and then invoke the query on the tcx, which produces the resulting query region constraints.

Required Associated Types§

Required Methods§

Source

fn try_fast_path( tcx: TyCtxt<'tcx>, key: &ParamEnvAnd<'tcx, Self>, ) -> Option<Self::QueryResponse>

Give query the option for a simple fast path that never actually hits the tcx cache lookup etc. Return Some(r) with a final result or None to do the full path.

Source

fn perform_query( tcx: TyCtxt<'tcx>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>, ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution>

Performs the actual query with the canonicalized key – the real work happens here. This method is not given an infcx because it shouldn’t need one – and if it had access to one, it might do things like invoke sub_regions, which would be bad, because it would create subregion relationships that are not captured in the return value.

Source

fn perform_locally_with_next_solver( ocx: &ObligationCtxt<'_, 'tcx>, key: ParamEnvAnd<'tcx, Self>, ) -> Result<Self::QueryResponse, NoSolution>

In the new trait solver, we already do caching in the solver itself, so there’s no need to canonicalize and cache via the query system. Additionally, even if we were to canonicalize, we’d still need to make sure to feed it predefined opaque types and the defining anchor and that would require duplicating all of the tcx queries. Instead, just perform these ops locally.

Provided Methods§

Source

fn fully_perform_into( query_key: ParamEnvAnd<'tcx, Self>, infcx: &InferCtxt<'tcx>, output_query_region_constraints: &mut QueryRegionConstraints<'tcx>, span: Span, ) -> Result<(Self::QueryResponse, Option<CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>>, PredicateObligations<'tcx>, Certainty), NoSolution>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'tcx> QueryTypeOp<'tcx> for AscribeUserType<'tcx>

Source§

impl<'tcx> QueryTypeOp<'tcx> for DropckOutlives<'tcx>

Source§

impl<'tcx> QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx>

Source§

impl<'tcx> QueryTypeOp<'tcx> for ProvePredicate<'tcx>

Source§

impl<'tcx, T> QueryTypeOp<'tcx> for Normalize<T>
where T: Normalizable<'tcx> + 'tcx,