rustc_trait_selection/traits/query/type_op/
outlives.rs1use rustc_middle::traits::query::{DropckOutlivesResult, NoSolution};
2use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
3use rustc_span::Span;
4
5use crate::infer::canonical::{CanonicalQueryInput, CanonicalQueryResponse};
6use crate::traits::ObligationCtxt;
7use crate::traits::query::dropck_outlives::{
8 compute_dropck_outlives_inner, trivial_dropck_outlives,
9};
10use crate::traits::query::type_op::DropckOutlives;
11
12impl<'tcx> super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
13 type QueryResponse = DropckOutlivesResult<'tcx>;
14
15 fn try_fast_path(
16 tcx: TyCtxt<'tcx>,
17 key: &ParamEnvAnd<'tcx, Self>,
18 ) -> Option<Self::QueryResponse> {
19 trivial_dropck_outlives(tcx, key.value.dropped_ty).then(DropckOutlivesResult::default)
20 }
21
22 fn perform_query(
23 tcx: TyCtxt<'tcx>,
24 canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>,
25 ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> {
26 tcx.dropck_outlives(canonicalized)
27 }
28
29 fn perform_locally_with_next_solver(
30 ocx: &ObligationCtxt<'_, 'tcx>,
31 key: ParamEnvAnd<'tcx, Self>,
32 span: Span,
33 ) -> Result<Self::QueryResponse, NoSolution> {
34 compute_dropck_outlives_inner(ocx, key.param_env.and(key.value), span)
35 }
36}