1 use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
2 use crate::traits::query::Fallible;
3 use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
5 #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, TypeFoldable, Lift)]
6 pub struct Subtype<'tcx> {
11 impl<'tcx> Subtype<'tcx> {
12 pub fn new(sub: Ty<'tcx>, sup: Ty<'tcx>) -> Self {
20 impl<'tcx> super::QueryTypeOp<'tcx> for Subtype<'tcx> {
21 type QueryResponse = ();
23 fn try_fast_path(_tcx: TyCtxt<'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<()> {
24 if key.value.sub == key.value.sup {
33 canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
34 ) -> Fallible<CanonicalizedQueryResponse<'tcx, ()>> {
35 tcx.type_op_subtype(canonicalized)
39 impl_stable_hash_for! {
40 struct Subtype<'tcx> { sub, sup }