1 use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
2 use crate::traits::query::dropck_outlives::{DropckOutlivesResult, trivial_dropck_outlives};
3 use crate::traits::query::Fallible;
4 use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
6 #[derive(Copy, Clone, Debug, TypeFoldable, Lift)]
7 pub struct DropckOutlives<'tcx> {
11 impl<'tcx> DropckOutlives<'tcx> {
12 pub fn new(dropped_ty: Ty<'tcx>) -> Self {
13 DropckOutlives { dropped_ty }
17 impl super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
18 type QueryResponse = DropckOutlivesResult<'tcx>;
22 key: &ParamEnvAnd<'tcx, Self>,
23 ) -> Option<Self::QueryResponse> {
24 if trivial_dropck_outlives(tcx, key.value.dropped_ty) {
25 Some(DropckOutlivesResult::default())
33 canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
34 ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self::QueryResponse>> {
35 // Subtle: note that we are not invoking
36 // `infcx.at(...).dropck_outlives(...)` here, but rather the
37 // underlying `dropck_outlives` query. This same underlying
38 // query is also used by the
39 // `infcx.at(...).dropck_outlives(...)` fn. Avoiding the
40 // wrapper means we don't need an infcx in this code, which is
41 // good because the interface doesn't give us one (so that we
42 // know we are not registering any subregion relations or
45 // FIXME convert to the type expected by the `dropck_outlives`
46 // query. This should eventually be fixed by changing the
47 // *underlying query*.
48 let canonicalized = canonicalized.unchecked_map(|ParamEnvAnd { param_env, value }| {
49 let DropckOutlives { dropped_ty } = value;
50 param_env.and(dropped_ty)
53 tcx.dropck_outlives(canonicalized)
57 impl_stable_hash_for! {
58 struct DropckOutlives<'tcx> { dropped_ty }