Skip to main content

rustc_type_ir/solve/
mod.rs

1pub mod inspect;
2
3use std::convert::Infallible;
4use std::fmt::Debug;
5use std::hash::Hash;
6
7use derive_where::derive_where;
8#[cfg(feature = "nightly")]
9use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash, StableHash_NoContext};
10use rustc_type_ir_macros::{
11    GenericTypeVisitable, Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic,
12};
13use thin_vec::ThinVec;
14use tracing::debug;
15
16use crate::inherent::*;
17use crate::lang_items::SolverTraitLangItem;
18use crate::region_constraint::RegionConstraint;
19use crate::{
20    self as ty, Canonical, CantBeErased, Const, ConstVid, FloatVid, GenericArgKind, InferConst,
21    IntVid, Interner, TermKind, TyVid, TypingMode, Upcast,
22};
23
24pub type CanonicalInputData<I> =
25    ty::CanonicalQueryInput<I, QueryInput<I, <I as Interner>::Predicate>>;
26pub type CanonicalResponse<I> = Canonical<I, Response<I>>;
27/// The result of evaluating a canonical query.
28///
29/// FIXME: We use a different type than the existing canonical queries. This is because
30/// we need to add a `Certainty` for `overflow` and may want to restructure this code without
31/// having to worry about changes to currently used code. Once we've made progress on this
32/// solver, merge the two responses again.
33pub type QueryResult<I> = Result<CanonicalResponse<I>, NoSolution>;
34pub type QueryResultOrRerunNonErased<I> = Result<CanonicalResponse<I>, NoSolutionOrRerunNonErased>;
35
36#[derive(#[automatically_derived]
impl ::core::marker::Copy for NoSolution { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for NoSolution { }
#[automatically_derived]
impl ::core::clone::Clone for NoSolution {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for NoSolution {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "NoSolution")
    }
}Debug, #[automatically_derived]
impl ::core::hash::Hash for NoSolution {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {}
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for NoSolution { }
#[automatically_derived]
impl ::core::cmp::PartialEq for NoSolution {
    #[inline]
    fn eq(&self, other: &Self) -> bool { true }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for NoSolution { }Eq)]
37#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for NoSolution {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self { NoSolution => {} }
            }
        }
    };StableHash))]
38pub struct NoSolution;
39
40pub trait RerunResultExt<T> {
41    fn map_err_to_rerun(self) -> Result<Result<T, NoSolution>, RerunNonErased>;
42}
43
44impl<T> RerunResultExt<T> for Result<T, NoSolutionOrRerunNonErased> {
45    fn map_err_to_rerun(self) -> Result<Result<T, NoSolution>, RerunNonErased> {
46        match self {
47            Ok(i) => Ok(Ok(i)),
48            Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution)) => Ok(Err(NoSolution)),
49            Err(NoSolutionOrRerunNonErased::RerunNonErased(e)) => Err(e),
50        }
51    }
52}
53
54/// A bit like [`NoSolution`], but for functions that normally cannot fail *unless* they accessed
55/// opaues. (See [`TypingMode::ErasedNotCoherence`]). Getting `OpaquesAccessed` doesn't mean there
56/// truly is no solution. It just means that we want to bail out of the current query as fast as
57/// possible, possibly by returning `NoSolution` if that's fastest. This is okay because when you get
58/// `OpaquesAccessed` we're guaranteed that we're going to retry this query in the original typing
59/// mode to get the correct answer.
60#[derive(#[automatically_derived]
impl ::core::marker::Copy for RerunNonErased { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for RerunNonErased { }
#[automatically_derived]
impl ::core::clone::Clone for RerunNonErased {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<()>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for RerunNonErased {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "RerunNonErased",
            &&self.0)
    }
}Debug, #[automatically_derived]
impl ::core::hash::Hash for RerunNonErased {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for RerunNonErased { }
#[automatically_derived]
impl ::core::cmp::PartialEq for RerunNonErased {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for RerunNonErased {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<()>;
    }
}Eq)]
61#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            RerunNonErased {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    RerunNonErased(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash))]
62pub struct RerunNonErased(());
63
64#[derive(#[automatically_derived]
impl ::core::marker::Copy for NoSolutionOrRerunNonErased { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for NoSolutionOrRerunNonErased { }
#[automatically_derived]
impl ::core::clone::Clone for NoSolutionOrRerunNonErased {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<NoSolution>;
        let _: ::core::clone::AssertParamIsClone<RerunNonErased>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for NoSolutionOrRerunNonErased {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::NoSolution(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "NoSolution", &__self_0),
            Self::RerunNonErased(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "RerunNonErased", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::hash::Hash for NoSolutionOrRerunNonErased {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::NoSolution(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            Self::RerunNonErased(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
        }
    }
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for NoSolutionOrRerunNonErased { }
#[automatically_derived]
impl ::core::cmp::PartialEq for NoSolutionOrRerunNonErased {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::NoSolution(__self_0), Self::NoSolution(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::RerunNonErased(__self_0),
                    Self::RerunNonErased(__arg1_0)) => __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for NoSolutionOrRerunNonErased {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<NoSolution>;
        let _: ::core::cmp::AssertParamIsEq<RerunNonErased>;
    }
}Eq)]
65#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            NoSolutionOrRerunNonErased {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    NoSolutionOrRerunNonErased::NoSolution(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    NoSolutionOrRerunNonErased::RerunNonErased(ref __binding_0)
                        => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash))]
66pub enum NoSolutionOrRerunNonErased {
67    NoSolution(NoSolution),
68    RerunNonErased(RerunNonErased),
69}
70
71impl From<NoSolution> for NoSolutionOrRerunNonErased {
72    fn from(value: NoSolution) -> Self {
73        Self::NoSolution(value)
74    }
75}
76
77impl From<RerunNonErased> for NoSolutionOrRerunNonErased {
78    fn from(value: RerunNonErased) -> Self {
79        Self::RerunNonErased(value)
80    }
81}
82
83/// A small set of up to 3 `Copy` elements, used as an optimization in [`RerunCondition`].
84/// The entire set can be `Copy`ed because of this requirement.
85///
86/// Set properties maintained using [`union`](SmallCopySet::union), which deduplicates values.
87#[derive(#[automatically_derived]
impl<T: ::core::marker::Copy + Copy + Debug + Hash + Eq> ::core::marker::Copy
    for SmallCopySet<T> {
}Copy, #[automatically_derived]
impl<T: ::core::clone::Clone + Copy + Debug + Hash + Eq> ::core::clone::Clone
    for SmallCopySet<T> {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            Self::Empty => SmallCopySet::Empty,
            Self::One(__self_0) =>
                SmallCopySet::One(::core::clone::Clone::clone(__self_0)),
            Self::Two(__self_0) =>
                SmallCopySet::Two(::core::clone::Clone::clone(__self_0)),
            Self::Three(__self_0) =>
                SmallCopySet::Three(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone, #[automatically_derived]
impl<T: ::core::fmt::Debug + Copy + Debug + Hash + Eq> ::core::fmt::Debug for
    SmallCopySet<T> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Empty => ::core::fmt::Formatter::write_str(f, "Empty"),
            Self::One(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "One",
                    &__self_0),
            Self::Two(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Two",
                    &__self_0),
            Self::Three(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Three",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<T: ::core::hash::Hash + Copy + Debug + Hash + Eq> ::core::hash::Hash for
    SmallCopySet<T> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::One(__self_0) => ::core::hash::Hash::hash(__self_0, state),
            Self::Two(__self_0) => ::core::hash::Hash::hash(__self_0, state),
            Self::Three(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, #[automatically_derived]
impl<T: ::core::cmp::PartialEq + Copy + Debug + Hash + Eq>
    ::core::marker::StructuralPartialEq for SmallCopySet<T> {
}
#[automatically_derived]
impl<T: ::core::cmp::PartialEq + Copy + Debug + Hash + Eq>
    ::core::cmp::PartialEq for SmallCopySet<T> {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::One(__self_0), Self::One(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::Two(__self_0), Self::Two(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::Three(__self_0), Self::Three(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl<T: ::core::cmp::Eq + Copy + Debug + Hash + Eq> ::core::cmp::Eq for
    SmallCopySet<T> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<[T; 1]>;
        let _: ::core::cmp::AssertParamIsEq<[T; 2]>;
        let _: ::core::cmp::AssertParamIsEq<[T; 3]>;
    }
}Eq)]
88#[derive(const _: () =
    {
        impl<T: Copy + Debug + Hash + Eq, I> ::rustc_type_ir::TypeVisitable<I>
            for SmallCopySet<T> where I: Interner,
            [T; 1]: ::rustc_type_ir::TypeVisitable<I>,
            [T; 2]: ::rustc_type_ir::TypeVisitable<I>,
            [T; 3]: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    SmallCopySet::Empty => {}
                    SmallCopySet::One(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    SmallCopySet::Two(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    SmallCopySet::Three(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        impl<T: Copy + Debug + Hash + Eq, I> ::rustc_type_ir::TypeFoldable<I>
            for SmallCopySet<T> where I: Interner,
            T: ::rustc_type_ir::TypeFoldable<I>,
            [T; 1]: ::rustc_type_ir::TypeFoldable<I>,
            [T; 2]: ::rustc_type_ir::TypeFoldable<I>,
            [T; 3]: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        SmallCopySet::Empty => { SmallCopySet::Empty }
                        SmallCopySet::One(__binding_0) => {
                            SmallCopySet::One(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                        SmallCopySet::Two(__binding_0) => {
                            SmallCopySet::Two(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                        SmallCopySet::Three(__binding_0) => {
                            SmallCopySet::Three(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    SmallCopySet::Empty => { SmallCopySet::Empty }
                    SmallCopySet::One(__binding_0) => {
                        SmallCopySet::One(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                    SmallCopySet::Two(__binding_0) => {
                        SmallCopySet::Two(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                    SmallCopySet::Three(__binding_0) => {
                        SmallCopySet::Three(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        unsafe impl<T: Copy + Debug + Hash + Eq, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for SmallCopySet<T>
            where [T; 1]: ::rustc_type_ir::GenericTypeVisitable<__V>,
            [T; 2]: ::rustc_type_ir::GenericTypeVisitable<__V>,
            [T; 3]: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    SmallCopySet::Empty => {}
                    SmallCopySet::One(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    SmallCopySet::Two(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    SmallCopySet::Three(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable)]
89#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<T: Copy + Debug + Hash + Eq>
            ::rustc_data_structures::stable_hash::StableHash for
            SmallCopySet<T> where
            [T; 1]: ::rustc_data_structures::stable_hash::StableHash,
            [T; 2]: ::rustc_data_structures::stable_hash::StableHash,
            [T; 3]: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    SmallCopySet::Empty => {}
                    SmallCopySet::One(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    SmallCopySet::Two(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    SmallCopySet::Three(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
90pub enum SmallCopySet<T: Copy + Debug + Hash + Eq> {
91    Empty,
92    One([T; 1]),
93    Two([T; 2]),
94    Three([T; 3]),
95}
96
97impl<T: Copy + Debug + Hash + Eq> SmallCopySet<T> {
98    fn empty() -> Self {
99        Self::Empty
100    }
101
102    fn new(first: T) -> Self {
103        Self::One([first])
104    }
105
106    /// Computes the union of two lists. Duplicates are removed.
107    ///
108    /// Since the set can hold at most 3 elements, returns `None` if the resulting set cannot be
109    /// represented.
110    ///
111    /// In the context of [`RerunCondition`], this means we fall back to rerunning unconditionally.
112    /// This can be beneficial, since at some point, tracking all the conditions under which a query
113    /// has to be rerun becomes slower than just rerunning unconditionally. This is especially so,
114    /// since as long as rerun conditions are tracked, we keep executing the current query. As soon as
115    /// we cannot track anymore, and unconditionally rerun, we also abort the current query.
116    /// By at some point opting to abort early, we may save a lot of time skipping further work
117    /// that will have to likely be redone anyway.
118    ///
119    /// note that *not* all cases are handled. you can union two lists of two elements with equal
120    /// elements, and still get `none` back. checking for all cases is more work than just rerunning
121    /// in some cases.
122    fn union(self, other: Self) -> Option<Self> {
123        match (self, other) {
124            (Self::Empty, other) | (other, Self::Empty) => Some(other),
125
126            (Self::One([a]), Self::One([b])) if a == b => Some(Self::One([a])),
127            (Self::One([a]), Self::One([b])) => Some(Self::Two([a, b])),
128            (Self::One([a]), Self::Two([b, c])) | (Self::Two([a, b]), Self::One([c]))
129                if a == b && b == c =>
130            {
131                Some(Self::One([a]))
132            }
133            (Self::One([a]), Self::Two([b, c])) | (Self::Two([a, b]), Self::One([c])) if a == b => {
134                Some(Self::Two([a, c]))
135            }
136            (Self::One([a]), Self::Two([b, c])) | (Self::Two([a, b]), Self::One([c])) if a == c => {
137                Some(Self::Two([a, b]))
138            }
139            (Self::One([a]), Self::Two([b, c])) | (Self::Two([a, b]), Self::One([c])) if b == c => {
140                Some(Self::Two([a, b]))
141            }
142            (Self::One([a]), Self::Two([b, c])) | (Self::Two([a, b]), Self::One([c])) => {
143                Some(Self::Three([a, b, c]))
144            }
145            // There are some more cases we could handle, like 2 + 2 => 3 if there's one duplicate,
146            // But the check seems to be more expensive than the gain. Even then, the difference is
147            // tiny, and could just be noise. Not worth it regardless.
148            _ => None,
149        }
150    }
151}
152
153impl<T: Copy + Debug + Hash + Eq> AsRef<[T]> for SmallCopySet<T> {
154    fn as_ref(&self) -> &[T] {
155        match self {
156            Self::Empty => &[],
157            Self::One(l) => l,
158            Self::Two(l) => l,
159            Self::Three(l) => l,
160        }
161    }
162}
163
164/// Information about how we accessed opaque types
165/// This is what the trait solver does when each states is encountered:
166///
167/// |                         | bail? | rerun goal?                                                                                                          |
168/// | ----------------------- | ----- | -------------------------------------------------------------------------------------------------------------------- |
169/// | never                   | no    | no                                                                                                                   |
170/// | always                  | yes   | yes                                                                                                                  |
171/// | [defid in storage]      | no    | only if any of the defids in the list is in the opaque type storage OR if TypingMode::PostAnalysis                   |
172/// | opaque with hidden type | no    | only if any of the opaques in the opaque type storage has a hidden type in this list AND if TypingMode::Typeck       |
173///
174/// - "bail" is implemented with [`should_bail`](Self::should_bail).
175///   If true, we're abandoning our attempt to canonicalize in [`TypingMode::ErasedNotCoherence`],
176///   and should try to return as soon as possible to waste as little time as possible.
177///   A rerun will be attempted in the original typing mode.
178///
179/// - Rerun goal is implemented with `should_rerun_after_erased_canonicalization`, on the `EvalCtxt`.
180///
181/// Some variant names contain an `Or` here. They rerun when any of the two conditions applies
182#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for RerunCondition<I> where I: Interner
    {
}
#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for RerunCondition<I> where I: Interner
    {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for RerunCondition<I> where I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            RerunCondition::Never =>
                ::core::fmt::Formatter::write_str(__f, "Never"),
            RerunCondition::AnyOpaqueHasInferAsHidden =>
                ::core::fmt::Formatter::write_str(__f,
                    "AnyOpaqueHasInferAsHidden"),
            RerunCondition::OpaqueInStorage(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "OpaqueInStorage");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(ref __field_0)
                => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f,
                        "OpaqueInStorageOrAnyOpaqueHasInferAsHidden");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            RerunCondition::Always =>
                ::core::fmt::Formatter::write_str(__f, "Always"),
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for RerunCondition<I> where I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            RerunCondition::Never => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
            }
            RerunCondition::AnyOpaqueHasInferAsHidden => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
            }
            RerunCondition::OpaqueInStorage(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(ref __field_0)
                => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            RerunCondition::Always => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for RerunCondition<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        if ::core::mem::discriminant(self) ==
                ::core::mem::discriminant(__other) {
            match (self, __other) {
                (RerunCondition::OpaqueInStorage(ref __field_0),
                    RerunCondition::OpaqueInStorage(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(ref __field_0),
                    RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(ref __other_field_0))
                    =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                _ => true,
            }
        } else { false }
    }
}
const _: () =
    {
        trait DeriveWhereAssertEq {
            fn assert(&self);
        }
        impl<I: Interner> DeriveWhereAssertEq for RerunCondition<I> where
            I: Interner {
            fn assert(&self) {
                struct __AssertEq<__T: ::core::cmp::Eq +
                    ?::core::marker::Sized>(::core::marker::PhantomData<__T>);
                let _: __AssertEq<SmallCopySet<I::LocalDefId>>;
                let _: __AssertEq<SmallCopySet<I::LocalDefId>>;
            }
        }
    };
#[automatically_derived]
impl<I: Interner> ::core::cmp::Eq for RerunCondition<I> where I: Interner { }#[derive_where(Copy, Clone, Debug, Hash, PartialEq, Eq; I: Interner)]
183#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            RerunCondition<I> where I: Interner,
            SmallCopySet<I::LocalDefId>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    RerunCondition::Never => {}
                    RerunCondition::AnyOpaqueHasInferAsHidden => {}
                    RerunCondition::OpaqueInStorage(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(ref __binding_0)
                        => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    RerunCondition::Always => {}
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            RerunCondition<I> where I: Interner,
            SmallCopySet<I::LocalDefId>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        RerunCondition::Never => { RerunCondition::Never }
                        RerunCondition::AnyOpaqueHasInferAsHidden => {
                            RerunCondition::AnyOpaqueHasInferAsHidden
                        }
                        RerunCondition::OpaqueInStorage(__binding_0) => {
                            RerunCondition::OpaqueInStorage(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                        RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(__binding_0)
                            => {
                            RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                        RerunCondition::Always => { RerunCondition::Always }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    RerunCondition::Never => { RerunCondition::Never }
                    RerunCondition::AnyOpaqueHasInferAsHidden => {
                        RerunCondition::AnyOpaqueHasInferAsHidden
                    }
                    RerunCondition::OpaqueInStorage(__binding_0) => {
                        RerunCondition::OpaqueInStorage(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                    RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(__binding_0)
                        => {
                        RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                    RerunCondition::Always => { RerunCondition::Always }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for RerunCondition<I>
            where
            SmallCopySet<I::LocalDefId>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            SmallCopySet<I::LocalDefId>: ::rustc_type_ir::GenericTypeVisitable<__V>
            {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    RerunCondition::Never => {}
                    RerunCondition::AnyOpaqueHasInferAsHidden => {}
                    RerunCondition::OpaqueInStorage(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(ref __binding_0)
                        => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    RerunCondition::Always => {}
                }
            }
        }
    };GenericTypeVisitable)]
184#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            RerunCondition<I> where
            SmallCopySet<I::LocalDefId>: ::rustc_data_structures::stable_hash::StableHash
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    RerunCondition::Never => {}
                    RerunCondition::AnyOpaqueHasInferAsHidden => {}
                    RerunCondition::OpaqueInStorage(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(ref __binding_0)
                        => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    RerunCondition::Always => {}
                }
            }
        }
    };StableHash_NoContext))]
185pub enum RerunCondition<I: Interner> {
186    Never,
187
188    /// Note that this only reruns according to the condition *if* we are in [`TypingMode::Typeck`].
189    AnyOpaqueHasInferAsHidden,
190    /// Note: unconditionally reruns in postanalysis
191    OpaqueInStorage(SmallCopySet<I::LocalDefId>),
192
193    /// Merges [`Self::AnyOpaqueHasInferAsHidden`] and [`Self::OpaqueInStorage`].
194    /// Note that just like the unmerged [`Self::OpaqueInStorage`], that part of the
195    /// condition only matters in [`TypingMode::Typeck`]
196    OpaqueInStorageOrAnyOpaqueHasInferAsHidden(SmallCopySet<I::LocalDefId>),
197
198    Always,
199}
200
201impl<I: Interner> RerunCondition<I> {
202    /// Merge two rerun states according to the following transition diagram
203    /// (some cells are empty because the table is symmetric, i.e. `a.merge(b)` == `b.merge(a)`).
204    ///
205    /// - "self" here means the current state, i.e. the state of the current column
206    /// - square brackets represents that this is a list of things. Even if the state doesn't
207    /// change, we might grow the list to effectively end up in a different state anyway
208    /// - `[o. in s.]` abbreviates "opaque in storage"
209    ///
210    ///
211    /// |                                 | never  | always | [opaque in storage] | opaque has infer as hidden | [o. in s.] or i. as hidden |
212    /// | ------------------------------- | ------ | ------ | ------------------- | -------------------------- | -------------------------- |
213    /// | never                           | self   | self   | self                | self                       | self                       |
214    /// | always                          |        | always | always              | always                     | always                     |
215    /// | [opaque in storage]             |        |        | concat self         | [o. in s.] or i. as hidden | concat to self             |
216    /// | opaque has infer as hidden type |        |        |                     | self                       | to self                    |
217    ///
218    fn merge(self, other: Self) -> Self {
219        let merged = match (self, other) {
220            (Self::Never, other) | (other, Self::Never) => other,
221            (Self::Always, _) | (_, Self::Always) => Self::Always,
222
223            (Self::OpaqueInStorage(a), Self::OpaqueInStorage(b)) => {
224                a.union(b).map(Self::OpaqueInStorage).unwrap_or(Self::Always)
225            }
226            (Self::AnyOpaqueHasInferAsHidden, Self::AnyOpaqueHasInferAsHidden) => {
227                Self::AnyOpaqueHasInferAsHidden
228            }
229            (
230                Self::AnyOpaqueHasInferAsHidden,
231                Self::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(a),
232            )
233            | (
234                Self::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(a),
235                Self::AnyOpaqueHasInferAsHidden,
236            ) => Self::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(a),
237
238            (
239                Self::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(a),
240                Self::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(b),
241            ) => a
242                .union(b)
243                .map(Self::OpaqueInStorageOrAnyOpaqueHasInferAsHidden)
244                .unwrap_or(Self::Always),
245
246            (Self::OpaqueInStorage(a), Self::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(b))
247            | (Self::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(b), Self::OpaqueInStorage(a)) => a
248                .union(b)
249                .map(Self::OpaqueInStorageOrAnyOpaqueHasInferAsHidden)
250                .unwrap_or(Self::Always),
251
252            (Self::OpaqueInStorage(a), Self::AnyOpaqueHasInferAsHidden)
253            | (Self::AnyOpaqueHasInferAsHidden, Self::OpaqueInStorage(a)) => {
254                Self::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(a)
255            }
256        };
257        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5d8fec0669a64607db9ccbf663e7c23125bf4748/compiler/rustc_type_ir/src/solve/mod.rs:257",
                        "rustc_type_ir::solve", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5d8fec0669a64607db9ccbf663e7c23125bf4748/compiler/rustc_type_ir/src/solve/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(257u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::solve"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("merging rerun state {0:?} + {1:?} => {2:?}",
                                                    self, other, merged) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("merging rerun state {self:?} + {other:?} => {merged:?}");
258        merged
259    }
260
261    #[must_use]
262    fn should_bail(&self) -> Result<(), RerunNonErased> {
263        match self {
264            Self::Always => Err(RerunNonErased(())),
265            Self::Never
266            | Self::OpaqueInStorage(_)
267            | Self::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(_)
268            | Self::AnyOpaqueHasInferAsHidden => Ok(()),
269        }
270    }
271
272    /// Returns true when any access of opaques was attempted.
273    /// i.e. when `self != Self::Never`
274    #[must_use]
275    fn might_rerun(&self) -> bool {
276        match self {
277            Self::Never => false,
278            Self::Always
279            | Self::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(_)
280            | Self::OpaqueInStorage(_)
281            | Self::AnyOpaqueHasInferAsHidden => true,
282        }
283    }
284}
285
286/// Mainly for debugging, to keep track of the source of the rerunning
287/// in [`TypingMode::ErasedNotCoherence`].
288#[derive(#[automatically_derived]
impl ::core::marker::Copy for RerunReason { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for RerunReason { }
#[automatically_derived]
impl ::core::clone::Clone for RerunReason {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for RerunReason {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                RerunReason::NormalizeOpaqueTypeRemoteCrate =>
                    "NormalizeOpaqueTypeRemoteCrate",
                RerunReason::NormalizeOpaqueType => "NormalizeOpaqueType",
                RerunReason::MayUseUnstableFeature => "MayUseUnstableFeature",
                RerunReason::EvaluateConst => "EvaluateConst",
                RerunReason::SkipErasedAttempt => "SkipErasedAttempt",
                RerunReason::SelfTyInfer => "SelfTyInfer",
                RerunReason::FetchEligibleAssocItem =>
                    "FetchEligibleAssocItem",
                RerunReason::AutoTraitLeakage => "AutoTraitLeakage",
                RerunReason::TryStallCoroutine => "TryStallCoroutine",
            })
    }
}Debug, #[automatically_derived]
impl ::core::hash::Hash for RerunReason {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for RerunReason { }
#[automatically_derived]
impl ::core::cmp::PartialEq for RerunReason {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for RerunReason { }Eq)]
289#[derive(const _: () =
    {
        impl<I> ::rustc_type_ir::TypeVisitable<I> for RerunReason where
            I: Interner {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    RerunReason::NormalizeOpaqueTypeRemoteCrate => {}
                    RerunReason::NormalizeOpaqueType => {}
                    RerunReason::MayUseUnstableFeature => {}
                    RerunReason::EvaluateConst => {}
                    RerunReason::SkipErasedAttempt => {}
                    RerunReason::SelfTyInfer => {}
                    RerunReason::FetchEligibleAssocItem => {}
                    RerunReason::AutoTraitLeakage => {}
                    RerunReason::TryStallCoroutine => {}
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<__V> ::rustc_type_ir::GenericTypeVisitable<__V> for
            RerunReason {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    RerunReason::NormalizeOpaqueTypeRemoteCrate => {}
                    RerunReason::NormalizeOpaqueType => {}
                    RerunReason::MayUseUnstableFeature => {}
                    RerunReason::EvaluateConst => {}
                    RerunReason::SkipErasedAttempt => {}
                    RerunReason::SelfTyInfer => {}
                    RerunReason::FetchEligibleAssocItem => {}
                    RerunReason::AutoTraitLeakage => {}
                    RerunReason::TryStallCoroutine => {}
                }
            }
        }
    };GenericTypeVisitable)]
290#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for RerunReason
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    RerunReason::NormalizeOpaqueTypeRemoteCrate => {}
                    RerunReason::NormalizeOpaqueType => {}
                    RerunReason::MayUseUnstableFeature => {}
                    RerunReason::EvaluateConst => {}
                    RerunReason::SkipErasedAttempt => {}
                    RerunReason::SelfTyInfer => {}
                    RerunReason::FetchEligibleAssocItem => {}
                    RerunReason::AutoTraitLeakage => {}
                    RerunReason::TryStallCoroutine => {}
                }
            }
        }
    };StableHash_NoContext))]
291pub enum RerunReason {
292    NormalizeOpaqueTypeRemoteCrate,
293    NormalizeOpaqueType,
294    MayUseUnstableFeature,
295    EvaluateConst,
296    SkipErasedAttempt,
297    SelfTyInfer,
298    FetchEligibleAssocItem,
299    AutoTraitLeakage,
300    TryStallCoroutine,
301}
302
303#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for AccessedOpaques<I> where
    I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for AccessedOpaques<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for AccessedOpaques<I> where I: Interner
    {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            AccessedOpaques {
                reason: ref __field_reason, rerun: ref __field_rerun } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f,
                        "AccessedOpaques");
                ::core::fmt::DebugStruct::field(&mut __builder, "reason",
                    __field_reason);
                ::core::fmt::DebugStruct::field(&mut __builder, "rerun",
                    __field_rerun);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for AccessedOpaques<I> where I: Interner
    {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            AccessedOpaques {
                reason: ref __field_reason, rerun: ref __field_rerun } => {
                ::core::hash::Hash::hash(__field_reason, __state);
                ::core::hash::Hash::hash(__field_rerun, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for AccessedOpaques<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (AccessedOpaques {
                reason: ref __field_reason, rerun: ref __field_rerun },
                AccessedOpaques {
                reason: ref __other_field_reason,
                rerun: ref __other_field_rerun }) =>
                true &&
                        ::core::cmp::PartialEq::eq(__field_reason,
                            __other_field_reason) &&
                    ::core::cmp::PartialEq::eq(__field_rerun,
                        __other_field_rerun),
        }
    }
}
const _: () =
    {
        trait DeriveWhereAssertEq {
            fn assert(&self);
        }
        impl<I: Interner> DeriveWhereAssertEq for AccessedOpaques<I> where
            I: Interner {
            fn assert(&self) {
                struct __AssertEq<__T: ::core::cmp::Eq +
                    ?::core::marker::Sized>(::core::marker::PhantomData<__T>);
                let _: __AssertEq<Option<RerunReason>>;
                let _: __AssertEq<RerunCondition<I>>;
            }
        }
    };
#[automatically_derived]
impl<I: Interner> ::core::cmp::Eq for AccessedOpaques<I> where I: Interner { }#[derive_where(Copy, Clone, Debug, Hash, PartialEq, Eq; I: Interner)]
304#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            AccessedOpaques<I> where I: Interner,
            RerunCondition<I>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    AccessedOpaques { rerun: ref __binding_1, .. } => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            AccessedOpaques<I> where I: Interner,
            RerunCondition<I>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        AccessedOpaques { reason: __binding_0, rerun: __binding_1 }
                            => {
                            AccessedOpaques {
                                reason: __binding_0,
                                rerun: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    AccessedOpaques { reason: __binding_0, rerun: __binding_1 }
                        => {
                        AccessedOpaques {
                            reason: __binding_0,
                            rerun: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for AccessedOpaques<I>
            where
            Option<RerunReason>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            RerunCondition<I>: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    AccessedOpaques {
                        reason: ref __binding_0, rerun: ref __binding_1 } => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable)]
305#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            AccessedOpaques<I> where
            RerunCondition<I>: ::rustc_data_structures::stable_hash::StableHash
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    AccessedOpaques {
                        reason: ref __binding_0, rerun: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
306pub struct AccessedOpaques<I: Interner> {
307    #[cfg_attr(feature = "nightly", type_visitable(ignore))]
308    #[type_foldable(identity)]
309    pub reason: Option<RerunReason>,
310    pub rerun: RerunCondition<I>,
311}
312
313impl<I: Interner> Default for AccessedOpaques<I> {
314    fn default() -> Self {
315        Self { reason: None, rerun: RerunCondition::Never }
316    }
317}
318
319impl<I: Interner> AccessedOpaques<I> {
320    pub fn update(&mut self, other: Self) -> Result<(), RerunNonErased> {
321        *self = Self {
322            // prefer the newest reason
323            reason: other.reason.or(self.reason),
324            // merging accessed states can only result in MultipleOrUnknown
325            rerun: self.rerun.merge(other.rerun),
326        };
327
328        self.should_bail()
329    }
330
331    #[must_use]
332    pub fn might_rerun(&self) -> bool {
333        self.rerun.might_rerun()
334    }
335
336    #[must_use]
337    pub fn should_bail(&self) -> Result<(), RerunNonErased> {
338        self.rerun.should_bail()
339    }
340
341    pub fn rerun_always(&mut self, reason: RerunReason) -> Result<Infallible, RerunNonErased> {
342        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5d8fec0669a64607db9ccbf663e7c23125bf4748/compiler/rustc_type_ir/src/solve/mod.rs:342",
                        "rustc_type_ir::solve", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5d8fec0669a64607db9ccbf663e7c23125bf4748/compiler/rustc_type_ir/src/solve/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(342u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::solve"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("set rerun always")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("set rerun always");
343        match self.update(AccessedOpaques { reason: Some(reason), rerun: RerunCondition::Always }) {
344            Ok(_) => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
345            Err(e) => Err(e),
346        }
347    }
348
349    pub fn rerun_if_in_post_analysis(&mut self, reason: RerunReason) -> Result<(), RerunNonErased> {
350        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5d8fec0669a64607db9ccbf663e7c23125bf4748/compiler/rustc_type_ir/src/solve/mod.rs:350",
                        "rustc_type_ir::solve", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5d8fec0669a64607db9ccbf663e7c23125bf4748/compiler/rustc_type_ir/src/solve/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(350u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::solve"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("set rerun if post analysis")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("set rerun if post analysis");
351        self.update(AccessedOpaques {
352            reason: Some(reason),
353            rerun: RerunCondition::OpaqueInStorage(SmallCopySet::empty()),
354        })
355    }
356
357    pub fn rerun_if_opaque_in_opaque_type_storage(
358        &mut self,
359        reason: RerunReason,
360        defid: I::LocalOpaqueTyId,
361    ) -> Result<(), RerunNonErased> {
362        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5d8fec0669a64607db9ccbf663e7c23125bf4748/compiler/rustc_type_ir/src/solve/mod.rs:362",
                        "rustc_type_ir::solve", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5d8fec0669a64607db9ccbf663e7c23125bf4748/compiler/rustc_type_ir/src/solve/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(362u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::solve"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("set rerun if opaque type {0:?} in storage",
                                                    defid) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("set rerun if opaque type {defid:?} in storage");
363        self.update(AccessedOpaques {
364            reason: Some(reason),
365            rerun: RerunCondition::OpaqueInStorage(SmallCopySet::new(defid.into())),
366        })
367    }
368
369    pub fn rerun_if_any_opaque_has_infer_as_hidden_type(
370        &mut self,
371        reason: RerunReason,
372    ) -> Result<(), RerunNonErased> {
373        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5d8fec0669a64607db9ccbf663e7c23125bf4748/compiler/rustc_type_ir/src/solve/mod.rs:373",
                        "rustc_type_ir::solve", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5d8fec0669a64607db9ccbf663e7c23125bf4748/compiler/rustc_type_ir/src/solve/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(373u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::solve"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("set rerun if any opaque in the storage has a hidden type that is an infer var")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("set rerun if any opaque in the storage has a hidden type that is an infer var");
374        self.update(AccessedOpaques {
375            reason: Some(reason),
376            rerun: RerunCondition::AnyOpaqueHasInferAsHidden,
377        })
378    }
379}
380
381/// A goal is a statement, i.e. `predicate`, we want to prove
382/// given some assumptions, i.e. `param_env`.
383///
384/// Most of the time the `param_env` contains the `where`-bounds of the function
385/// we're currently typechecking while the `predicate` is some trait bound.
386#[automatically_derived]
impl<I: Interner, P> ::core::clone::Clone for Goal<I, P> where I: Interner,
    P: ::core::clone::Clone {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            Goal {
                param_env: ref __field_param_env,
                predicate: ref __field_predicate } =>
                Goal {
                    param_env: ::core::clone::Clone::clone(__field_param_env),
                    predicate: ::core::clone::Clone::clone(__field_predicate),
                },
        }
    }
}
#[automatically_derived]
impl<I: Interner, P> ::core::hash::Hash for Goal<I, P> where I: Interner,
    P: ::core::hash::Hash {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            Goal {
                param_env: ref __field_param_env,
                predicate: ref __field_predicate } => {
                ::core::hash::Hash::hash(__field_param_env, __state);
                ::core::hash::Hash::hash(__field_predicate, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner, P> ::core::cmp::PartialEq for Goal<I, P> where I: Interner,
    P: ::core::cmp::PartialEq {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (Goal {
                param_env: ref __field_param_env,
                predicate: ref __field_predicate }, Goal {
                param_env: ref __other_field_param_env,
                predicate: ref __other_field_predicate }) =>
                true &&
                        ::core::cmp::PartialEq::eq(__field_param_env,
                            __other_field_param_env) &&
                    ::core::cmp::PartialEq::eq(__field_predicate,
                        __other_field_predicate),
        }
    }
}
#[automatically_derived]
impl<I: Interner, P> ::core::fmt::Debug for Goal<I, P> where I: Interner,
    P: ::core::fmt::Debug {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            Goal {
                param_env: ref __field_param_env,
                predicate: ref __field_predicate } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "Goal");
                ::core::fmt::DebugStruct::field(&mut __builder, "param_env",
                    __field_param_env);
                ::core::fmt::DebugStruct::field(&mut __builder, "predicate",
                    __field_predicate);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner, P> ::core::marker::Copy for Goal<I, P> where I: Interner,
    P: Copy {
}#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner, P)]
387#[derive_where(Copy; I: Interner, P: Copy)]
388#[derive(const _: () =
    {
        impl<I: Interner, P> ::rustc_type_ir::TypeVisitable<I> for Goal<I, P>
            where I: Interner, I::ParamEnv: ::rustc_type_ir::TypeVisitable<I>,
            P: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    Goal {
                        param_env: ref __binding_0, predicate: ref __binding_1 } =>
                        {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        impl<I: Interner, P> ::rustc_type_ir::TypeFoldable<I> for Goal<I, P>
            where I: Interner, P: ::rustc_type_ir::TypeFoldable<I>,
            I::ParamEnv: ::rustc_type_ir::TypeFoldable<I>,
            P: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        Goal { param_env: __binding_0, predicate: __binding_1 } => {
                            Goal {
                                param_env: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                predicate: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    Goal { param_env: __binding_0, predicate: __binding_1 } => {
                        Goal {
                            param_env: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            predicate: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, P, J> ::rustc_type_ir::lift::Lift<J> for Goal<I, P>
            where J: Interner, I: ::rustc_type_ir::LiftInto<J>,
            P: ::rustc_type_ir::lift::Lift<J> {
            type Lifted =
                Goal<J, <P as ::rustc_type_ir::lift::Lift<J>>::Lifted>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    Goal { param_env: __binding_0, predicate: __binding_1 } => {
                        Goal {
                            param_env: __binding_0.lift_to_interner(interner),
                            predicate: __binding_1.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic, const _: () =
    {
        unsafe impl<I: Interner, P, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for Goal<I, P> where
            I::ParamEnv: ::rustc_type_ir::GenericTypeVisitable<__V>,
            P: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    Goal {
                        param_env: ref __binding_0, predicate: ref __binding_1 } =>
                        {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable)]
389#[cfg_attr(
390    feature = "nightly",
391    derive(const _: () =
    {
        impl<I: Interner, P, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for Goal<I, P> where
            I::ParamEnv: ::rustc_serialize::Decodable<__D>,
            P: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                Goal {
                    param_env: ::rustc_serialize::Decodable::decode(__decoder),
                    predicate: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, P, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for Goal<I, P> where
            I::ParamEnv: ::rustc_serialize::Encodable<__E>,
            P: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let Goal {
                        param_env: ref __binding_0, predicate: ref __binding_1 } =
                    *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner, P> ::rustc_data_structures::stable_hash::StableHash
            for Goal<I, P> where
            I::ParamEnv: ::rustc_data_structures::stable_hash::StableHash,
            P: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    Goal {
                        param_env: ref __binding_0, predicate: ref __binding_1 } =>
                        {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
392)]
393pub struct Goal<I: Interner, P> {
394    pub param_env: I::ParamEnv,
395    pub predicate: P,
396}
397
398impl<I: Interner, P: Eq> Eq for Goal<I, P> {}
399
400impl<I: Interner, P> Goal<I, P> {
401    pub fn new(cx: I, param_env: I::ParamEnv, predicate: impl Upcast<I, P>) -> Goal<I, P> {
402        Goal { param_env, predicate: predicate.upcast(cx) }
403    }
404
405    /// Updates the goal to one with a different `predicate` but the same `param_env`.
406    pub fn with<Q>(self, cx: I, predicate: impl Upcast<I, Q>) -> Goal<I, Q> {
407        Goal { param_env: self.param_env, predicate: predicate.upcast(cx) }
408    }
409}
410
411/// Why a specific goal has to be proven.
412///
413/// This is used by proof tree visitors, especially for diagnostics purposes.
414///
415/// FIXME(-Znext-solver=coinductive): This will also matter in the future when
416/// deciding whether a step in a cycle is coinductive. We're currently still
417/// matching the old solver behavior here for now, so the `GoalSource` is ignored.
418#[derive(#[automatically_derived]
impl ::core::marker::Copy for GoalSource { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for GoalSource { }
#[automatically_derived]
impl ::core::clone::Clone for GoalSource {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for GoalSource {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                GoalSource::Misc => "Misc",
                GoalSource::ImplWhereBound => "ImplWhereBound",
                GoalSource::AliasBoundConstCondition =>
                    "AliasBoundConstCondition",
                GoalSource::AliasWellFormed => "AliasWellFormed",
                GoalSource::Normalization => "Normalization",
            })
    }
}Debug, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for GoalSource { }
#[automatically_derived]
impl ::core::cmp::PartialEq for GoalSource {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for GoalSource { }Eq, #[automatically_derived]
impl ::core::hash::Hash for GoalSource {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash)]
419#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for GoalSource {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    GoalSource::Misc => {}
                    GoalSource::ImplWhereBound => {}
                    GoalSource::AliasBoundConstCondition => {}
                    GoalSource::AliasWellFormed => {}
                    GoalSource::Normalization => {}
                }
            }
        }
    };StableHash))]
420pub enum GoalSource {
421    Misc,
422    /// We're proving a where-bound of an impl.
423    ImplWhereBound,
424    /// Const conditions that need to hold for `[const]` alias bounds to hold.
425    AliasBoundConstCondition,
426    /// Predicate required for an alias projection to be well-formed.
427    /// This is used in three places:
428    /// 1. projecting to an opaque whose hidden type is already registered in
429    ///    the opaque type storage,
430    /// 2. for rigid projections's trait goal,
431    /// 3. for GAT where clauses.
432    AliasWellFormed,
433    /// Normalizing happens in the current context and is unproductive by itself.
434    Normalization,
435}
436
437#[automatically_derived]
impl<I: Interner, P> ::core::clone::Clone for QueryInput<I, P> where
    I: Interner, Goal<I, P>: ::core::clone::Clone {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            QueryInput {
                goal: ref __field_goal,
                predefined_opaques_in_body: ref __field_predefined_opaques_in_body
                } =>
                QueryInput {
                    goal: ::core::clone::Clone::clone(__field_goal),
                    predefined_opaques_in_body: ::core::clone::Clone::clone(__field_predefined_opaques_in_body),
                },
        }
    }
}
#[automatically_derived]
impl<I: Interner, P> ::core::hash::Hash for QueryInput<I, P> where
    I: Interner, Goal<I, P>: ::core::hash::Hash {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            QueryInput {
                goal: ref __field_goal,
                predefined_opaques_in_body: ref __field_predefined_opaques_in_body
                } => {
                ::core::hash::Hash::hash(__field_goal, __state);
                ::core::hash::Hash::hash(__field_predefined_opaques_in_body,
                    __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner, P> ::core::cmp::PartialEq for QueryInput<I, P> where
    I: Interner, Goal<I, P>: ::core::cmp::PartialEq {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (QueryInput {
                goal: ref __field_goal,
                predefined_opaques_in_body: ref __field_predefined_opaques_in_body
                }, QueryInput {
                goal: ref __other_field_goal,
                predefined_opaques_in_body: ref __other_field_predefined_opaques_in_body
                }) =>
                true &&
                        ::core::cmp::PartialEq::eq(__field_goal, __other_field_goal)
                    &&
                    ::core::cmp::PartialEq::eq(__field_predefined_opaques_in_body,
                        __other_field_predefined_opaques_in_body),
        }
    }
}
#[automatically_derived]
impl<I: Interner, P> ::core::fmt::Debug for QueryInput<I, P> where
    I: Interner, Goal<I, P>: ::core::fmt::Debug {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            QueryInput {
                goal: ref __field_goal,
                predefined_opaques_in_body: ref __field_predefined_opaques_in_body
                } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "QueryInput");
                ::core::fmt::DebugStruct::field(&mut __builder, "goal",
                    __field_goal);
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "predefined_opaques_in_body",
                    __field_predefined_opaques_in_body);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner, P> ::core::marker::Copy for QueryInput<I, P> where
    I: Interner, Goal<I, P>: Copy {
}#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner, Goal<I, P>)]
438#[derive_where(Copy; I: Interner, Goal<I, P>: Copy)]
439#[derive(const _: () =
    {
        impl<I: Interner, P> ::rustc_type_ir::TypeVisitable<I> for
            QueryInput<I, P> where I: Interner,
            Goal<I, P>: ::rustc_type_ir::TypeVisitable<I>,
            I::PredefinedOpaques: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    QueryInput {
                        goal: ref __binding_0,
                        predefined_opaques_in_body: ref __binding_1 } => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        impl<I: Interner, P> ::rustc_type_ir::TypeFoldable<I> for
            QueryInput<I, P> where I: Interner,
            P: ::rustc_type_ir::TypeFoldable<I>,
            Goal<I, P>: ::rustc_type_ir::TypeFoldable<I>,
            I::PredefinedOpaques: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        QueryInput {
                            goal: __binding_0, predefined_opaques_in_body: __binding_1 }
                            => {
                            QueryInput {
                                goal: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                predefined_opaques_in_body: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    QueryInput {
                        goal: __binding_0, predefined_opaques_in_body: __binding_1 }
                        => {
                        QueryInput {
                            goal: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            predefined_opaques_in_body: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        unsafe impl<I: Interner, P, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for QueryInput<I, P>
            where Goal<I, P>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::PredefinedOpaques: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    QueryInput {
                        goal: ref __binding_0,
                        predefined_opaques_in_body: ref __binding_1 } => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable)]
440#[cfg_attr(
441    feature = "nightly",
442    derive(const _: () =
    {
        impl<I: Interner, P, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for QueryInput<I, P> where
            Goal<I, P>: ::rustc_serialize::Decodable<__D>,
            I::PredefinedOpaques: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                QueryInput {
                    goal: ::rustc_serialize::Decodable::decode(__decoder),
                    predefined_opaques_in_body: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, P, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for QueryInput<I, P> where
            Goal<I, P>: ::rustc_serialize::Encodable<__E>,
            I::PredefinedOpaques: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let QueryInput {
                        goal: ref __binding_0,
                        predefined_opaques_in_body: ref __binding_1 } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner, P> ::rustc_data_structures::stable_hash::StableHash
            for QueryInput<I, P> where
            Goal<I, P>: ::rustc_data_structures::stable_hash::StableHash,
            I::PredefinedOpaques: ::rustc_data_structures::stable_hash::StableHash
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    QueryInput {
                        goal: ref __binding_0,
                        predefined_opaques_in_body: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
443)]
444pub struct QueryInput<I: Interner, P> {
445    pub goal: Goal<I, P>,
446    pub predefined_opaques_in_body: I::PredefinedOpaques,
447}
448
449impl<I: Interner, P: Eq> Eq for QueryInput<I, P> {}
450
451/// Which trait candidates should be preferred over other candidates? By default, prefer where
452/// bounds over alias bounds. For marker traits, prefer alias bounds over where bounds.
453#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for CandidatePreferenceMode { }
#[automatically_derived]
impl ::core::clone::Clone for CandidatePreferenceMode {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for CandidatePreferenceMode { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for CandidatePreferenceMode {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                CandidatePreferenceMode::Default => "Default",
                CandidatePreferenceMode::Marker => "Marker",
            })
    }
}Debug)]
454pub enum CandidatePreferenceMode {
455    /// Prefers where bounds over alias bounds
456    Default,
457    /// Prefers alias bounds over where bounds
458    Marker,
459}
460
461impl CandidatePreferenceMode {
462    /// Given `trait_def_id`, which candidate preference mode should be used?
463    pub fn compute<I: Interner>(cx: I, trait_id: I::TraitId) -> CandidatePreferenceMode {
464        let is_sizedness_or_auto_or_default_goal = cx.is_sizedness_trait(trait_id)
465            || cx.trait_is_auto(trait_id)
466            || cx.is_default_trait(trait_id);
467        if is_sizedness_or_auto_or_default_goal {
468            CandidatePreferenceMode::Marker
469        } else {
470            CandidatePreferenceMode::Default
471        }
472    }
473}
474
475/// Possible ways the given goal can be proven.
476#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for CandidateSource<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for CandidateSource<I> where
    I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for CandidateSource<I> where I: Interner
    {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            CandidateSource::Impl(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            CandidateSource::BuiltinImpl(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            CandidateSource::ParamEnv(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            CandidateSource::AliasBound(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            CandidateSource::CoherenceUnknowable => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for CandidateSource<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        if ::core::mem::discriminant(self) ==
                ::core::mem::discriminant(__other) {
            match (self, __other) {
                (CandidateSource::Impl(ref __field_0),
                    CandidateSource::Impl(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (CandidateSource::BuiltinImpl(ref __field_0),
                    CandidateSource::BuiltinImpl(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (CandidateSource::ParamEnv(ref __field_0),
                    CandidateSource::ParamEnv(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (CandidateSource::AliasBound(ref __field_0),
                    CandidateSource::AliasBound(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                _ => true,
            }
        } else { false }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for CandidateSource<I> where I: Interner
    {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            CandidateSource::Impl(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "Impl");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            CandidateSource::BuiltinImpl(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "BuiltinImpl");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            CandidateSource::ParamEnv(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "ParamEnv");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            CandidateSource::AliasBound(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "AliasBound");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            CandidateSource::CoherenceUnknowable =>
                ::core::fmt::Formatter::write_str(__f, "CoherenceUnknowable"),
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
477pub enum CandidateSource<I: Interner> {
478    /// A user written impl.
479    ///
480    /// ## Examples
481    ///
482    /// ```rust
483    /// fn main() {
484    ///     let x: Vec<u32> = Vec::new();
485    ///     // This uses the impl from the standard library to prove `Vec<T>: Clone`.
486    ///     let y = x.clone();
487    /// }
488    /// ```
489    Impl(I::ImplId),
490    /// A builtin impl generated by the compiler. When adding a new special
491    /// trait, try to use actual impls whenever possible. Builtin impls should
492    /// only be used in cases where the impl cannot be manually be written.
493    ///
494    /// Notable examples are auto traits, `Sized`, and `DiscriminantKind`.
495    /// For a list of all traits with builtin impls, check out the
496    /// `EvalCtxt::assemble_builtin_impl_candidates` method.
497    BuiltinImpl(BuiltinImplSource),
498    /// An assumption from the environment. Stores a [`ParamEnvSource`], since we
499    /// prefer non-global param-env candidates in candidate assembly.
500    ///
501    /// ## Examples
502    ///
503    /// ```rust
504    /// fn is_clone<T: Clone>(x: T) -> (T, T) {
505    ///     // This uses the assumption `T: Clone` from the `where`-bounds
506    ///     // to prove `T: Clone`.
507    ///     (x.clone(), x)
508    /// }
509    /// ```
510    ParamEnv(ParamEnvSource),
511    /// If the self type is an alias type, e.g. an opaque type or a projection,
512    /// we know the bounds on that alias to hold even without knowing its concrete
513    /// underlying type.
514    ///
515    /// More precisely this candidate is using the `n-th` bound in the `item_bounds` of
516    /// the self type.
517    ///
518    /// ## Examples
519    ///
520    /// ```rust
521    /// trait Trait {
522    ///     type Assoc: Clone;
523    /// }
524    ///
525    /// fn foo<T: Trait>(x: <T as Trait>::Assoc) {
526    ///     // We prove `<T as Trait>::Assoc` by looking at the bounds on `Assoc` in
527    ///     // in the trait definition.
528    ///     let _y = x.clone();
529    /// }
530    /// ```
531    AliasBound(AliasBoundKind),
532    /// A candidate that is registered only during coherence to represent some
533    /// yet-unknown impl that could be produced downstream without violating orphan
534    /// rules.
535    // FIXME: Merge this with the forced ambiguity candidates, so those don't use `Misc`.
536    CoherenceUnknowable,
537}
538
539impl<I: Interner> Eq for CandidateSource<I> {}
540
541#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ParamEnvSource { }
#[automatically_derived]
impl ::core::clone::Clone for ParamEnvSource {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ParamEnvSource { }Copy, #[automatically_derived]
impl ::core::hash::Hash for ParamEnvSource {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for ParamEnvSource { }
#[automatically_derived]
impl ::core::cmp::PartialEq for ParamEnvSource {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ParamEnvSource { }Eq, #[automatically_derived]
impl ::core::fmt::Debug for ParamEnvSource {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                ParamEnvSource::NonGlobal => "NonGlobal",
                ParamEnvSource::Global => "Global",
            })
    }
}Debug)]
542pub enum ParamEnvSource {
543    /// Preferred eagerly.
544    NonGlobal,
545    // Not considered unless there are non-global param-env candidates too.
546    Global,
547}
548
549#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for AliasBoundKind { }
#[automatically_derived]
impl ::core::clone::Clone for AliasBoundKind {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for AliasBoundKind { }Copy, #[automatically_derived]
impl ::core::hash::Hash for AliasBoundKind {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for AliasBoundKind { }
#[automatically_derived]
impl ::core::cmp::PartialEq for AliasBoundKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for AliasBoundKind { }Eq, #[automatically_derived]
impl ::core::fmt::Debug for AliasBoundKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                AliasBoundKind::SelfBounds => "SelfBounds",
                AliasBoundKind::NonSelfBounds => "NonSelfBounds",
            })
    }
}Debug)]
550#[derive(const _: () =
    {
        impl<I> ::rustc_type_ir::TypeVisitable<I> for AliasBoundKind where
            I: Interner {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    AliasBoundKind::SelfBounds => {}
                    AliasBoundKind::NonSelfBounds => {}
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<__V> ::rustc_type_ir::GenericTypeVisitable<__V> for
            AliasBoundKind {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    AliasBoundKind::SelfBounds => {}
                    AliasBoundKind::NonSelfBounds => {}
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I> ::rustc_type_ir::TypeFoldable<I> for AliasBoundKind where
            I: Interner {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        AliasBoundKind::SelfBounds => { AliasBoundKind::SelfBounds }
                        AliasBoundKind::NonSelfBounds => {
                            AliasBoundKind::NonSelfBounds
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    AliasBoundKind::SelfBounds => { AliasBoundKind::SelfBounds }
                    AliasBoundKind::NonSelfBounds => {
                        AliasBoundKind::NonSelfBounds
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
551pub enum AliasBoundKind {
552    /// Alias bound from the self type of a projection
553    SelfBounds,
554    // Alias bound having recursed on the self type of a projection
555    NonSelfBounds,
556}
557
558#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for BuiltinImplSource { }
#[automatically_derived]
impl ::core::clone::Clone for BuiltinImplSource {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<usize>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for BuiltinImplSource { }Copy, #[automatically_derived]
impl ::core::hash::Hash for BuiltinImplSource {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::Object(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            Self::TraitUpcasting(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for BuiltinImplSource { }
#[automatically_derived]
impl ::core::cmp::PartialEq for BuiltinImplSource {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Object(__self_0), Self::Object(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::TraitUpcasting(__self_0),
                    Self::TraitUpcasting(__arg1_0)) => __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for BuiltinImplSource {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<usize>;
    }
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for BuiltinImplSource {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Trivial => ::core::fmt::Formatter::write_str(f, "Trivial"),
            Self::Misc => ::core::fmt::Formatter::write_str(f, "Misc"),
            Self::Object(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Object",
                    &__self_0),
            Self::TraitUpcasting(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "TraitUpcasting", &__self_0),
        }
    }
}Debug)]
559#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            BuiltinImplSource {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    BuiltinImplSource::Trivial => {}
                    BuiltinImplSource::Misc => {}
                    BuiltinImplSource::Object(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    BuiltinImplSource::TraitUpcasting(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, const _: () =
    {
        impl<__E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for BuiltinImplSource {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        BuiltinImplSource::Trivial => { 0usize }
                        BuiltinImplSource::Misc => { 1usize }
                        BuiltinImplSource::Object(ref __binding_0) => { 2usize }
                        BuiltinImplSource::TraitUpcasting(ref __binding_0) => {
                            3usize
                        }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    BuiltinImplSource::Trivial => {}
                    BuiltinImplSource::Misc => {}
                    BuiltinImplSource::Object(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    BuiltinImplSource::TraitUpcasting(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<__D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for BuiltinImplSource {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { BuiltinImplSource::Trivial }
                    1usize => { BuiltinImplSource::Misc }
                    2usize => {
                        BuiltinImplSource::Object(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    3usize => {
                        BuiltinImplSource::TraitUpcasting(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `BuiltinImplSource`, expected 0..4, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext))]
560pub enum BuiltinImplSource {
561    /// A built-in impl that is considered trivial, without any nested requirements. They
562    /// are preferred over where-clauses, and we want to track them explicitly.
563    Trivial,
564    /// Some built-in impl we don't need to differentiate. This should be used
565    /// unless more specific information is necessary.
566    Misc,
567    /// A built-in impl for trait objects. The index is only used in winnowing.
568    // FIXME(-Znext-solver=no): The new solver does not need this index, remove!
569    Object(usize),
570    /// A built-in implementation of `Upcast` for trait objects to other trait objects.
571    ///
572    /// The index is only used for winnowing.
573    // FIXME(-Znext-solver=no): The new solver does not need this index, remove!
574    TraitUpcasting(usize),
575}
576
577#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for FetchEligibleAssocItemResponse<I>
    where I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for FetchEligibleAssocItemResponse<I>
    where I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for FetchEligibleAssocItemResponse<I>
    where I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            FetchEligibleAssocItemResponse::Err(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "Err");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            FetchEligibleAssocItemResponse::Found(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "Found");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            FetchEligibleAssocItemResponse::NotFound(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "NotFound");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            FetchEligibleAssocItemResponse::NotFoundBecauseErased =>
                ::core::fmt::Formatter::write_str(__f,
                    "NotFoundBecauseErased"),
        }
    }
}#[derive_where(Copy, Clone, Debug; I: Interner)]
578pub enum FetchEligibleAssocItemResponse<I: Interner> {
579    Err(I::ErrorGuaranteed),
580    Found(I::ImplOrTraitAssocTermId),
581    NotFound(TypingMode<I, CantBeErased>),
582    NotFoundBecauseErased,
583}
584
585#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for Response<I> where I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for Response<I> where I: Interner { }
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for Response<I> where I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            Response {
                certainty: ref __field_certainty,
                var_values: ref __field_var_values,
                external_constraints: ref __field_external_constraints } => {
                ::core::hash::Hash::hash(__field_certainty, __state);
                ::core::hash::Hash::hash(__field_var_values, __state);
                ::core::hash::Hash::hash(__field_external_constraints,
                    __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for Response<I> where I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (Response {
                certainty: ref __field_certainty,
                var_values: ref __field_var_values,
                external_constraints: ref __field_external_constraints },
                Response {
                certainty: ref __other_field_certainty,
                var_values: ref __other_field_var_values,
                external_constraints: ref __other_field_external_constraints
                }) =>
                true &&
                            ::core::cmp::PartialEq::eq(__field_certainty,
                                __other_field_certainty) &&
                        ::core::cmp::PartialEq::eq(__field_var_values,
                            __other_field_var_values) &&
                    ::core::cmp::PartialEq::eq(__field_external_constraints,
                        __other_field_external_constraints),
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for Response<I> where I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            Response {
                certainty: ref __field_certainty,
                var_values: ref __field_var_values,
                external_constraints: ref __field_external_constraints } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "Response");
                ::core::fmt::DebugStruct::field(&mut __builder, "certainty",
                    __field_certainty);
                ::core::fmt::DebugStruct::field(&mut __builder, "var_values",
                    __field_var_values);
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "external_constraints", __field_external_constraints);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
586#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for Response<I>
            where I: Interner,
            I::GenericArgs: ::rustc_type_ir::TypeVisitable<I>,
            I::ExternalConstraints: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    Response {
                        certainty: ref __binding_0,
                        var_values: ref __binding_1,
                        external_constraints: ref __binding_2 } => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_2,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for Response<I> where
            Certainty: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::GenericArgs: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::ExternalConstraints: ::rustc_type_ir::GenericTypeVisitable<__V>
            {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    Response {
                        certainty: ref __binding_0,
                        var_values: ref __binding_1,
                        external_constraints: ref __binding_2 } => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for Response<I>
            where I: Interner,
            I::GenericArgs: ::rustc_type_ir::TypeFoldable<I>,
            I::ExternalConstraints: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        Response {
                            certainty: __binding_0,
                            var_values: __binding_1,
                            external_constraints: __binding_2 } => {
                            Response {
                                certainty: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                var_values: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                                external_constraints: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_2,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    Response {
                        certainty: __binding_0,
                        var_values: __binding_1,
                        external_constraints: __binding_2 } => {
                        Response {
                            certainty: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            var_values: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                            external_constraints: ::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
587#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            Response<I> where
            I::GenericArgs: ::rustc_data_structures::stable_hash::StableHash,
            I::ExternalConstraints: ::rustc_data_structures::stable_hash::StableHash
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    Response {
                        certainty: ref __binding_0,
                        var_values: ref __binding_1,
                        external_constraints: ref __binding_2 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
588pub struct Response<I: Interner> {
589    pub certainty: Certainty,
590    pub var_values: I::GenericArgs,
591    /// Additional constraints returned by this query.
592    pub external_constraints: I::ExternalConstraints,
593}
594
595impl<I: Interner> Response<I> {
596    pub fn is_identity(&self) -> bool {
597        self.var_values.iter().enumerate().all(|(bv, arg)| match arg.kind() {
598            ty::GenericArgKind::Lifetime(r) => {
599                #[allow(non_exhaustive_omitted_patterns)] match r.kind() {
    ty::ReBound(ty::BoundVarIndexKind::Canonical, br) if
        br.var().as_usize() == bv => true,
    _ => false,
}matches!(r.kind(), ty::ReBound(ty::BoundVarIndexKind::Canonical, br) if br.var().as_usize() == bv)
600            }
601            ty::GenericArgKind::Type(ty) => {
602                #[allow(non_exhaustive_omitted_patterns)] match ty.kind() {
    ty::Bound(ty::BoundVarIndexKind::Canonical, bt) if
        bt.var().as_usize() == bv => true,
    _ => false,
}matches!(ty.kind(), ty::Bound(ty::BoundVarIndexKind::Canonical, bt) if bt.var().as_usize() == bv)
603            }
604            ty::GenericArgKind::Const(ct) => {
605                #[allow(non_exhaustive_omitted_patterns)] match ct.kind() {
    ty::ConstKind::Bound(ty::BoundVarIndexKind::Canonical, bc) if
        bc.var().as_usize() == bv => true,
    _ => false,
}matches!(ct.kind(), ty::ConstKind::Bound(ty::BoundVarIndexKind::Canonical, bc) if bc.var().as_usize() == bv)
606            }
607        })
608    }
609
610    pub fn is_identity_modulo_regions(&self) -> bool {
611        let mut var = ty::BoundVar::ZERO;
612        for arg in self.var_values.iter() {
613            match arg.kind() {
614                ty::GenericArgKind::Lifetime(r) => {
615                    if #[allow(non_exhaustive_omitted_patterns)] match r.kind() {
    ty::ReBound(ty::BoundVarIndexKind::Canonical, br) if var == br.var() =>
        true,
    _ => false,
}matches!(r.kind(), ty::ReBound(ty::BoundVarIndexKind::Canonical, br) if var == br.var())
616                    {
617                        var = var + 1;
618                    } else {
619                        // It's ok if this region var isn't an identity variable
620                    }
621                }
622                ty::GenericArgKind::Type(ty) => {
623                    if #[allow(non_exhaustive_omitted_patterns)] match ty.kind() {
    ty::Bound(ty::BoundVarIndexKind::Canonical, bt) if var == bt.var() =>
        true,
    _ => false,
}matches!(ty.kind(), ty::Bound(ty::BoundVarIndexKind::Canonical, bt) if var == bt.var())
624                    {
625                        var = var + 1;
626                    } else {
627                        return false;
628                    }
629                }
630                ty::GenericArgKind::Const(ct) => {
631                    if #[allow(non_exhaustive_omitted_patterns)] match ct.kind() {
    ty::ConstKind::Bound(ty::BoundVarIndexKind::Canonical, bc) if
        var == bc.var() => true,
    _ => false,
}matches!(ct.kind(), ty::ConstKind::Bound(ty::BoundVarIndexKind::Canonical, bc) if var == bc.var())
632                    {
633                        var = var + 1;
634                    } else {
635                        return false;
636                    }
637                }
638            }
639        }
640
641        true
642    }
643}
644
645impl<I: Interner> Eq for Response<I> {}
646
647#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for ExternalRegionConstraints<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            ExternalRegionConstraints::Old(ref __field_0) =>
                ExternalRegionConstraints::Old {
                    0: ::core::clone::Clone::clone(__field_0),
                },
            ExternalRegionConstraints::NextGen(ref __field_0) =>
                ExternalRegionConstraints::NextGen {
                    0: ::core::clone::Clone::clone(__field_0),
                },
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for ExternalRegionConstraints<I> where
    I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            ExternalRegionConstraints::Old(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            ExternalRegionConstraints::NextGen(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for ExternalRegionConstraints<I>
    where I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        if ::core::mem::discriminant(self) ==
                ::core::mem::discriminant(__other) {
            match (self, __other) {
                (ExternalRegionConstraints::Old(ref __field_0),
                    ExternalRegionConstraints::Old(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (ExternalRegionConstraints::NextGen(ref __field_0),
                    ExternalRegionConstraints::NextGen(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                _ => unsafe { ::core::hint::unreachable_unchecked() },
            }
        } else { false }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for ExternalRegionConstraints<I> where
    I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            ExternalRegionConstraints::Old(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "Old");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            ExternalRegionConstraints::NextGen(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "NextGen");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner)]
648#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            ExternalRegionConstraints<I> where I: Interner,
            Vec<(ty::RegionConstraint<I>,
            VisibleForLeakCheck)>: ::rustc_type_ir::TypeVisitable<I>,
            RegionConstraint<I>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    ExternalRegionConstraints::Old(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    ExternalRegionConstraints::NextGen(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for
            ExternalRegionConstraints<I> where
            Vec<(ty::RegionConstraint<I>,
            VisibleForLeakCheck)>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            RegionConstraint<I>: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    ExternalRegionConstraints::Old(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    ExternalRegionConstraints::NextGen(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            ExternalRegionConstraints<I> where I: Interner,
            Vec<(ty::RegionConstraint<I>,
            VisibleForLeakCheck)>: ::rustc_type_ir::TypeFoldable<I>,
            RegionConstraint<I>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        ExternalRegionConstraints::Old(__binding_0) => {
                            ExternalRegionConstraints::Old(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                        ExternalRegionConstraints::NextGen(__binding_0) => {
                            ExternalRegionConstraints::NextGen(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    ExternalRegionConstraints::Old(__binding_0) => {
                        ExternalRegionConstraints::Old(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                    ExternalRegionConstraints::NextGen(__binding_0) => {
                        ExternalRegionConstraints::NextGen(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
649#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            ExternalRegionConstraints<I> where
            Vec<(ty::RegionConstraint<I>,
            VisibleForLeakCheck)>: ::rustc_data_structures::stable_hash::StableHash,
            RegionConstraint<I>: ::rustc_data_structures::stable_hash::StableHash
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    ExternalRegionConstraints::Old(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    ExternalRegionConstraints::NextGen(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
650pub enum ExternalRegionConstraints<I: Interner> {
651    /// normal region constraints used on stable/when -Znext-solver is used by itself
652    Old(Vec<(ty::RegionConstraint<I>, VisibleForLeakCheck)>),
653    /// new form of region constraints used when `-Zassumptions-on-binders` is enabled.
654    /// supports ORs.
655    NextGen(RegionConstraint<I>),
656}
657
658impl<I: Interner> ExternalRegionConstraints<I> {
659    pub fn is_empty(&self) -> bool {
660        match self {
661            Self::Old(r) => r.is_empty(),
662            Self::NextGen(r) => r.is_true(),
663        }
664    }
665}
666
667/// Additional constraints returned on success.
668#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for ExternalConstraintsData<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            ExternalConstraintsData {
                region_constraints: ref __field_region_constraints,
                opaque_types: ref __field_opaque_types,
                normalization_nested_goals: ref __field_normalization_nested_goals
                } =>
                ExternalConstraintsData {
                    region_constraints: ::core::clone::Clone::clone(__field_region_constraints),
                    opaque_types: ::core::clone::Clone::clone(__field_opaque_types),
                    normalization_nested_goals: ::core::clone::Clone::clone(__field_normalization_nested_goals),
                },
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for ExternalConstraintsData<I> where
    I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            ExternalConstraintsData {
                region_constraints: ref __field_region_constraints,
                opaque_types: ref __field_opaque_types,
                normalization_nested_goals: ref __field_normalization_nested_goals
                } => {
                ::core::hash::Hash::hash(__field_region_constraints, __state);
                ::core::hash::Hash::hash(__field_opaque_types, __state);
                ::core::hash::Hash::hash(__field_normalization_nested_goals,
                    __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for ExternalConstraintsData<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (ExternalConstraintsData {
                region_constraints: ref __field_region_constraints,
                opaque_types: ref __field_opaque_types,
                normalization_nested_goals: ref __field_normalization_nested_goals
                }, ExternalConstraintsData {
                region_constraints: ref __other_field_region_constraints,
                opaque_types: ref __other_field_opaque_types,
                normalization_nested_goals: ref __other_field_normalization_nested_goals
                }) =>
                true &&
                            ::core::cmp::PartialEq::eq(__field_region_constraints,
                                __other_field_region_constraints) &&
                        ::core::cmp::PartialEq::eq(__field_opaque_types,
                            __other_field_opaque_types) &&
                    ::core::cmp::PartialEq::eq(__field_normalization_nested_goals,
                        __other_field_normalization_nested_goals),
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for ExternalConstraintsData<I> where
    I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            ExternalConstraintsData {
                region_constraints: ref __field_region_constraints,
                opaque_types: ref __field_opaque_types,
                normalization_nested_goals: ref __field_normalization_nested_goals
                } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f,
                        "ExternalConstraintsData");
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "region_constraints", __field_region_constraints);
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "opaque_types", __field_opaque_types);
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "normalization_nested_goals",
                    __field_normalization_nested_goals);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner)]
669#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            ExternalConstraintsData<I> where I: Interner,
            ExternalRegionConstraints<I>: ::rustc_type_ir::TypeVisitable<I>,
            Vec<(ty::OpaqueTypeKey<I>,
            I::Ty)>: ::rustc_type_ir::TypeVisitable<I>,
            NestedNormalizationGoals<I>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    ExternalConstraintsData {
                        region_constraints: ref __binding_0,
                        opaque_types: ref __binding_1,
                        normalization_nested_goals: ref __binding_2 } => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_2,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for
            ExternalConstraintsData<I> where
            ExternalRegionConstraints<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            Vec<(ty::OpaqueTypeKey<I>,
            I::Ty)>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            NestedNormalizationGoals<I>: ::rustc_type_ir::GenericTypeVisitable<__V>
            {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    ExternalConstraintsData {
                        region_constraints: ref __binding_0,
                        opaque_types: ref __binding_1,
                        normalization_nested_goals: ref __binding_2 } => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            ExternalConstraintsData<I> where I: Interner,
            ExternalRegionConstraints<I>: ::rustc_type_ir::TypeFoldable<I>,
            Vec<(ty::OpaqueTypeKey<I>,
            I::Ty)>: ::rustc_type_ir::TypeFoldable<I>,
            NestedNormalizationGoals<I>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        ExternalConstraintsData {
                            region_constraints: __binding_0,
                            opaque_types: __binding_1,
                            normalization_nested_goals: __binding_2 } => {
                            ExternalConstraintsData {
                                region_constraints: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                opaque_types: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                                normalization_nested_goals: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_2,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    ExternalConstraintsData {
                        region_constraints: __binding_0,
                        opaque_types: __binding_1,
                        normalization_nested_goals: __binding_2 } => {
                        ExternalConstraintsData {
                            region_constraints: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            opaque_types: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                            normalization_nested_goals: ::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
670#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            ExternalConstraintsData<I> where
            ExternalRegionConstraints<I>: ::rustc_data_structures::stable_hash::StableHash,
            Vec<(ty::OpaqueTypeKey<I>,
            I::Ty)>: ::rustc_data_structures::stable_hash::StableHash,
            NestedNormalizationGoals<I>: ::rustc_data_structures::stable_hash::StableHash
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ExternalConstraintsData {
                        region_constraints: ref __binding_0,
                        opaque_types: ref __binding_1,
                        normalization_nested_goals: ref __binding_2 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
671pub struct ExternalConstraintsData<I: Interner> {
672    pub region_constraints: ExternalRegionConstraints<I>,
673    pub opaque_types: Vec<(ty::OpaqueTypeKey<I>, I::Ty)>,
674    pub normalization_nested_goals: NestedNormalizationGoals<I>,
675}
676
677impl<I: Interner> Eq for ExternalConstraintsData<I> {}
678
679impl<I: Interner> ExternalConstraintsData<I> {
680    pub fn new(cx: I) -> Self {
681        let region_constraints = match cx.assumptions_on_binders() {
682            true => ExternalRegionConstraints::NextGen(RegionConstraint::new_true()),
683            false => ExternalRegionConstraints::Old(::alloc::vec::Vec::new()vec![]),
684        };
685
686        Self {
687            region_constraints,
688            opaque_types: ::alloc::vec::Vec::new()vec![],
689            normalization_nested_goals: NestedNormalizationGoals::default(),
690        }
691    }
692
693    pub fn is_empty(&self) -> bool {
694        let ExternalConstraintsData {
695            region_constraints,
696            opaque_types,
697            normalization_nested_goals,
698        } = self;
699        region_constraints.is_empty()
700            && opaque_types.is_empty()
701            && normalization_nested_goals.is_empty()
702    }
703}
704
705/// Whether the given region constraint should be considered/ignored for
706/// leak check. In most part of the compiler, this should be `Yes`, except
707/// for applying constraints from the nested goals in next-solver.
708/// `Unreachable` is used in places in which leak check isn't done, e.g.
709/// borrowck.
710#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for VisibleForLeakCheck { }
#[automatically_derived]
impl ::core::clone::Clone for VisibleForLeakCheck {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for VisibleForLeakCheck { }Copy, #[automatically_derived]
impl ::core::hash::Hash for VisibleForLeakCheck {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for VisibleForLeakCheck { }
#[automatically_derived]
impl ::core::cmp::PartialEq for VisibleForLeakCheck {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for VisibleForLeakCheck { }Eq, #[automatically_derived]
impl ::core::fmt::Debug for VisibleForLeakCheck {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                VisibleForLeakCheck::Yes => "Yes",
                VisibleForLeakCheck::No => "No",
                VisibleForLeakCheck::Unreachable => "Unreachable",
            })
    }
}Debug)]
711#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            VisibleForLeakCheck {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    VisibleForLeakCheck::Yes => {}
                    VisibleForLeakCheck::No => {}
                    VisibleForLeakCheck::Unreachable => {}
                }
            }
        }
    };StableHash_NoContext))]
712pub enum VisibleForLeakCheck {
713    Yes,
714    No,
715    Unreachable,
716}
717
718impl VisibleForLeakCheck {
719    pub fn and(self, other: VisibleForLeakCheck) -> VisibleForLeakCheck {
720        match (self, other) {
721            // Make sure that we never overwrite that constraints shouldn't
722            // be encountered by the leak checked
723            (VisibleForLeakCheck::Unreachable, _) | (_, VisibleForLeakCheck::Unreachable) => {
724                VisibleForLeakCheck::Unreachable
725            }
726            (VisibleForLeakCheck::No, _) | (_, VisibleForLeakCheck::No) => VisibleForLeakCheck::No,
727            (VisibleForLeakCheck::Yes, VisibleForLeakCheck::Yes) => VisibleForLeakCheck::Yes,
728        }
729    }
730
731    pub fn or(self, other: VisibleForLeakCheck) -> VisibleForLeakCheck {
732        match (self, other) {
733            // Make sure that we never overwrite that constraints shouldn't
734            // be encountered by the leak checked
735            (VisibleForLeakCheck::Unreachable, _) | (_, VisibleForLeakCheck::Unreachable) => {
736                VisibleForLeakCheck::Unreachable
737            }
738            (VisibleForLeakCheck::Yes, _) | (_, VisibleForLeakCheck::Yes) => {
739                VisibleForLeakCheck::Yes
740            }
741            (VisibleForLeakCheck::No, VisibleForLeakCheck::No) => VisibleForLeakCheck::No,
742        }
743    }
744}
745
746#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for NestedNormalizationGoals<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            NestedNormalizationGoals(ref __field_0) =>
                NestedNormalizationGoals {
                    0: ::core::clone::Clone::clone(__field_0),
                },
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for NestedNormalizationGoals<I> where
    I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            NestedNormalizationGoals(ref __field_0) => {
                ::core::hash::Hash::hash(__field_0, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for NestedNormalizationGoals<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (NestedNormalizationGoals(ref __field_0),
                NestedNormalizationGoals(ref __other_field_0)) =>
                true &&
                    ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for NestedNormalizationGoals<I> where
    I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            NestedNormalizationGoals(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f,
                        "NestedNormalizationGoals");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::default::Default for NestedNormalizationGoals<I>
    where I: Interner {
    fn default() -> Self {
        NestedNormalizationGoals(::core::default::Default::default())
    }
}#[derive_where(Clone, Hash, PartialEq, Debug, Default; I: Interner)]
747#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            NestedNormalizationGoals<I> where I: Interner,
            Vec<(GoalSource,
            Goal<I, I::Predicate>)>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    NestedNormalizationGoals(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for
            NestedNormalizationGoals<I> where
            Vec<(GoalSource,
            Goal<I,
            I::Predicate>)>: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    NestedNormalizationGoals(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            NestedNormalizationGoals<I> where I: Interner,
            Vec<(GoalSource,
            Goal<I, I::Predicate>)>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        NestedNormalizationGoals(__binding_0) => {
                            NestedNormalizationGoals(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    NestedNormalizationGoals(__binding_0) => {
                        NestedNormalizationGoals(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
748#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            NestedNormalizationGoals<I> where
            Vec<(GoalSource,
            Goal<I,
            I::Predicate>)>: ::rustc_data_structures::stable_hash::StableHash
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    NestedNormalizationGoals(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
749pub struct NestedNormalizationGoals<I: Interner>(pub Vec<(GoalSource, Goal<I, I::Predicate>)>);
750
751impl<I: Interner> Eq for NestedNormalizationGoals<I> {}
752
753impl<I: Interner> NestedNormalizationGoals<I> {
754    pub fn empty() -> Self {
755        NestedNormalizationGoals(::alloc::vec::Vec::new()vec![])
756    }
757
758    pub fn is_empty(&self) -> bool {
759        self.0.is_empty()
760    }
761}
762
763#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Certainty { }
#[automatically_derived]
impl ::core::clone::Clone for Certainty {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<MaybeInfo>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Certainty { }Copy, #[automatically_derived]
impl ::core::hash::Hash for Certainty {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::Maybe(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for Certainty { }
#[automatically_derived]
impl ::core::cmp::PartialEq for Certainty {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Maybe(__self_0), Self::Maybe(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Certainty {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<MaybeInfo>;
    }
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for Certainty {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Yes => ::core::fmt::Formatter::write_str(f, "Yes"),
            Self::Maybe(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Maybe",
                    &__self_0),
        }
    }
}Debug)]
764#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for Certainty {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    Certainty::Yes => {}
                    Certainty::Maybe(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash))]
765pub enum Certainty {
766    Yes,
767    Maybe(MaybeInfo),
768}
769
770#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for MaybeInfo { }
#[automatically_derived]
impl ::core::clone::Clone for MaybeInfo {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<MaybeCause>;
        let _: ::core::clone::AssertParamIsClone<OpaqueTypesJank>;
        let _: ::core::clone::AssertParamIsClone<StalledOnCoroutines>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for MaybeInfo { }Copy, #[automatically_derived]
impl ::core::hash::Hash for MaybeInfo {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.cause, state);
        ::core::hash::Hash::hash(&self.opaque_types_jank, state);
        ::core::hash::Hash::hash(&self.stalled_on_coroutines, state)
    }
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for MaybeInfo { }
#[automatically_derived]
impl ::core::cmp::PartialEq for MaybeInfo {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.cause == other.cause &&
                self.opaque_types_jank == other.opaque_types_jank &&
            self.stalled_on_coroutines == other.stalled_on_coroutines
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for MaybeInfo {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<MaybeCause>;
        let _: ::core::cmp::AssertParamIsEq<OpaqueTypesJank>;
        let _: ::core::cmp::AssertParamIsEq<StalledOnCoroutines>;
    }
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for MaybeInfo {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "MaybeInfo",
            "cause", &self.cause, "opaque_types_jank",
            &self.opaque_types_jank, "stalled_on_coroutines",
            &&self.stalled_on_coroutines)
    }
}Debug)]
771#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for MaybeInfo {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    MaybeInfo {
                        cause: ref __binding_0,
                        opaque_types_jank: ref __binding_1,
                        stalled_on_coroutines: ref __binding_2 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
772pub struct MaybeInfo {
773    pub cause: MaybeCause,
774    pub opaque_types_jank: OpaqueTypesJank,
775    pub stalled_on_coroutines: StalledOnCoroutines,
776}
777
778impl MaybeInfo {
779    pub const AMBIGUOUS: MaybeInfo = MaybeInfo {
780        cause: MaybeCause::Ambiguity,
781        opaque_types_jank: OpaqueTypesJank::AllGood,
782        stalled_on_coroutines: StalledOnCoroutines::No,
783    };
784
785    fn and(self, other: MaybeInfo) -> MaybeInfo {
786        MaybeInfo {
787            cause: self.cause.and(other.cause),
788            opaque_types_jank: self.opaque_types_jank.and(other.opaque_types_jank),
789            stalled_on_coroutines: self.stalled_on_coroutines.and(other.stalled_on_coroutines),
790        }
791    }
792
793    pub fn or(self, other: MaybeInfo) -> MaybeInfo {
794        MaybeInfo {
795            cause: self.cause.or(other.cause),
796            opaque_types_jank: self.opaque_types_jank.or(other.opaque_types_jank),
797            stalled_on_coroutines: self.stalled_on_coroutines.or(other.stalled_on_coroutines),
798        }
799    }
800}
801
802/// Supporting not-yet-defined opaque types in HIR typeck is somewhat
803/// challenging. Ideally we'd normalize them to a new inference variable
804/// and just defer type inference which relies on the opaque until we've
805/// constrained the hidden type.
806///
807/// This doesn't work for method and function calls as we need to guide type
808/// inference for the function arguments. We treat not-yet-defined opaque types
809/// as if they were rigid instead in these places.
810///
811/// When we encounter a `?hidden_type_of_opaque: Trait<?var>` goal, we use the
812/// item bounds and blanket impls to guide inference by constraining other type
813/// variables, see `EvalCtxt::try_assemble_bounds_via_registered_opaques`. We
814/// always keep the certainty as `Maybe` so that we properly prove these goals
815/// once the hidden type has been constrained.
816///
817/// If we fail to prove the trait goal via item bounds or blanket impls, the
818/// goal would have errored if the opaque type were rigid. In this case, we
819/// set `OpaqueTypesJank::ErrorIfRigidSelfTy` in the [Certainty].
820///
821/// Places in HIR typeck where we want to treat not-yet-defined opaque types as if
822/// they were kind of rigid then use `fn root_goal_may_hold_opaque_types_jank` which
823/// returns `false` if the goal doesn't hold or if `OpaqueTypesJank::ErrorIfRigidSelfTy`
824/// is set (i.e. proving it required relies on some `?hidden_ty: NotInItemBounds` goal).
825///
826/// This is subtly different from actually treating not-yet-defined opaque types as
827/// rigid, e.g. it allows constraining opaque types if they are not the self-type of
828/// a goal. It is good enough for now and only matters for very rare type inference
829/// edge cases. We can improve this later on if necessary.
830#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for OpaqueTypesJank { }
#[automatically_derived]
impl ::core::clone::Clone for OpaqueTypesJank {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for OpaqueTypesJank { }Copy, #[automatically_derived]
impl ::core::hash::Hash for OpaqueTypesJank {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for OpaqueTypesJank { }
#[automatically_derived]
impl ::core::cmp::PartialEq for OpaqueTypesJank {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for OpaqueTypesJank { }Eq, #[automatically_derived]
impl ::core::fmt::Debug for OpaqueTypesJank {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                OpaqueTypesJank::AllGood => "AllGood",
                OpaqueTypesJank::ErrorIfRigidSelfTy => "ErrorIfRigidSelfTy",
            })
    }
}Debug)]
831#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            OpaqueTypesJank {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    OpaqueTypesJank::AllGood => {}
                    OpaqueTypesJank::ErrorIfRigidSelfTy => {}
                }
            }
        }
    };StableHash))]
832pub enum OpaqueTypesJank {
833    AllGood,
834    ErrorIfRigidSelfTy,
835}
836impl OpaqueTypesJank {
837    fn and(self, other: OpaqueTypesJank) -> OpaqueTypesJank {
838        match (self, other) {
839            (OpaqueTypesJank::AllGood, OpaqueTypesJank::AllGood) => OpaqueTypesJank::AllGood,
840            (OpaqueTypesJank::ErrorIfRigidSelfTy, _) | (_, OpaqueTypesJank::ErrorIfRigidSelfTy) => {
841                OpaqueTypesJank::ErrorIfRigidSelfTy
842            }
843        }
844    }
845
846    pub fn or(self, other: OpaqueTypesJank) -> OpaqueTypesJank {
847        match (self, other) {
848            (OpaqueTypesJank::ErrorIfRigidSelfTy, OpaqueTypesJank::ErrorIfRigidSelfTy) => {
849                OpaqueTypesJank::ErrorIfRigidSelfTy
850            }
851            (OpaqueTypesJank::AllGood, _) | (_, OpaqueTypesJank::AllGood) => {
852                OpaqueTypesJank::AllGood
853            }
854        }
855    }
856}
857
858#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for StalledOnCoroutines { }
#[automatically_derived]
impl ::core::clone::Clone for StalledOnCoroutines {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for StalledOnCoroutines { }Copy, #[automatically_derived]
impl ::core::hash::Hash for StalledOnCoroutines {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for StalledOnCoroutines { }
#[automatically_derived]
impl ::core::cmp::PartialEq for StalledOnCoroutines {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for StalledOnCoroutines { }Eq, #[automatically_derived]
impl ::core::fmt::Debug for StalledOnCoroutines {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                StalledOnCoroutines::Yes => "Yes",
                StalledOnCoroutines::No => "No",
            })
    }
}Debug)]
859#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            StalledOnCoroutines {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    StalledOnCoroutines::Yes => {}
                    StalledOnCoroutines::No => {}
                }
            }
        }
    };StableHash_NoContext))]
860pub enum StalledOnCoroutines {
861    Yes,
862    No,
863}
864
865impl StalledOnCoroutines {
866    fn and(self, other: StalledOnCoroutines) -> StalledOnCoroutines {
867        match (self, other) {
868            (StalledOnCoroutines::No, StalledOnCoroutines::No) => StalledOnCoroutines::No,
869            (StalledOnCoroutines::Yes, _) | (_, StalledOnCoroutines::Yes) => {
870                StalledOnCoroutines::Yes
871            }
872        }
873    }
874
875    pub fn or(self, other: StalledOnCoroutines) -> StalledOnCoroutines {
876        // `StalledOnCoroutines::Yes` is contagious: obtaining `Certainty::Maybe`
877        // while a candidate is stalled on a coroutine might have been
878        // `Certainty::Yes` or `NoSolution` if it were not stalled.
879        StalledOnCoroutines::and(self, other)
880    }
881}
882
883impl Certainty {
884    pub const AMBIGUOUS: Certainty = Certainty::Maybe(MaybeInfo::AMBIGUOUS);
885
886    /// Use this function to merge the certainty of multiple nested subgoals.
887    ///
888    /// Given an impl like `impl<T: Foo + Bar> Baz for T {}`, we have 2 nested
889    /// subgoals whenever we use the impl as a candidate: `T: Foo` and `T: Bar`.
890    /// If evaluating `T: Foo` results in ambiguity and `T: Bar` results in
891    /// success, we merge these two responses. This results in ambiguity.
892    ///
893    /// If we unify ambiguity with overflow, we return overflow. This doesn't matter
894    /// inside of the solver as we do not distinguish ambiguity from overflow. It does
895    /// however matter for diagnostics. If `T: Foo` resulted in overflow and `T: Bar`
896    /// in ambiguity without changing the inference state, we still want to tell the
897    /// user that `T: Baz` results in overflow.
898    pub fn and(self, other: Certainty) -> Certainty {
899        match (self, other) {
900            (Certainty::Yes, Certainty::Yes) => Certainty::Yes,
901            (Certainty::Yes, Certainty::Maybe { .. }) => other,
902            (Certainty::Maybe { .. }, Certainty::Yes) => self,
903            (Certainty::Maybe(a_maybe), Certainty::Maybe(b_maybe)) => {
904                Certainty::Maybe(a_maybe.and(b_maybe))
905            }
906        }
907    }
908
909    pub const fn overflow(suggest_increasing_limit: bool) -> Certainty {
910        Certainty::Maybe(MaybeInfo {
911            cause: MaybeCause::Overflow { suggest_increasing_limit, keep_constraints: false },
912            opaque_types_jank: OpaqueTypesJank::AllGood,
913            stalled_on_coroutines: StalledOnCoroutines::No,
914        })
915    }
916
917    pub fn is_yes(&self) -> bool {
918        match self {
919            Certainty::Yes => true,
920            Certainty::Maybe(_) => false,
921        }
922    }
923
924    pub fn is_overflow(&self) -> bool {
925        match self {
926            Certainty::Maybe(MaybeInfo { cause: MaybeCause::Overflow { .. }, .. }) => true,
927            _ => false,
928        }
929    }
930}
931
932/// Why we failed to evaluate a goal.
933#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for MaybeCause { }
#[automatically_derived]
impl ::core::clone::Clone for MaybeCause {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for MaybeCause { }Copy, #[automatically_derived]
impl ::core::hash::Hash for MaybeCause {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::Overflow {
                suggest_increasing_limit: __self_0, keep_constraints: __self_1
                } => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state)
            }
            _ => {}
        }
    }
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for MaybeCause { }
#[automatically_derived]
impl ::core::cmp::PartialEq for MaybeCause {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Overflow {
                    suggest_increasing_limit: __self_0,
                    keep_constraints: __self_1 }, Self::Overflow {
                    suggest_increasing_limit: __arg1_0,
                    keep_constraints: __arg1_1 }) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for MaybeCause {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for MaybeCause {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Ambiguity =>
                ::core::fmt::Formatter::write_str(f, "Ambiguity"),
            Self::Overflow {
                suggest_increasing_limit: __self_0, keep_constraints: __self_1
                } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "Overflow", "suggest_increasing_limit", __self_0,
                    "keep_constraints", &__self_1),
        }
    }
}Debug)]
934#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for MaybeCause {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    MaybeCause::Ambiguity => {}
                    MaybeCause::Overflow {
                        suggest_increasing_limit: ref __binding_0,
                        keep_constraints: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash))]
935pub enum MaybeCause {
936    /// We failed due to ambiguity. This ambiguity can either
937    /// be a true ambiguity, i.e. there are multiple different answers,
938    /// or we hit a case where we just don't bother, e.g. `?x: Trait` goals.
939    Ambiguity,
940    /// We gave up due to an overflow, most often by hitting the recursion limit.
941    Overflow { suggest_increasing_limit: bool, keep_constraints: bool },
942}
943
944impl MaybeCause {
945    fn and(self, other: MaybeCause) -> MaybeCause {
946        match (self, other) {
947            (MaybeCause::Ambiguity, MaybeCause::Ambiguity) => MaybeCause::Ambiguity,
948            (MaybeCause::Ambiguity, MaybeCause::Overflow { .. }) => other,
949            (MaybeCause::Overflow { .. }, MaybeCause::Ambiguity) => self,
950            (
951                MaybeCause::Overflow {
952                    suggest_increasing_limit: limit_a,
953                    keep_constraints: keep_a,
954                },
955                MaybeCause::Overflow {
956                    suggest_increasing_limit: limit_b,
957                    keep_constraints: keep_b,
958                },
959            ) => MaybeCause::Overflow {
960                suggest_increasing_limit: limit_a && limit_b,
961                keep_constraints: keep_a && keep_b,
962            },
963        }
964    }
965
966    pub fn or(self, other: MaybeCause) -> MaybeCause {
967        match (self, other) {
968            (MaybeCause::Ambiguity, MaybeCause::Ambiguity) => MaybeCause::Ambiguity,
969
970            // When combining ambiguity + overflow, we can keep constraints.
971            (
972                MaybeCause::Ambiguity,
973                MaybeCause::Overflow { suggest_increasing_limit, keep_constraints: _ },
974            ) => MaybeCause::Overflow { suggest_increasing_limit, keep_constraints: true },
975            (
976                MaybeCause::Overflow { suggest_increasing_limit, keep_constraints: _ },
977                MaybeCause::Ambiguity,
978            ) => MaybeCause::Overflow { suggest_increasing_limit, keep_constraints: true },
979
980            (
981                MaybeCause::Overflow {
982                    suggest_increasing_limit: limit_a,
983                    keep_constraints: keep_a,
984                },
985                MaybeCause::Overflow {
986                    suggest_increasing_limit: limit_b,
987                    keep_constraints: keep_b,
988                },
989            ) => MaybeCause::Overflow {
990                suggest_increasing_limit: limit_a || limit_b,
991                keep_constraints: keep_a || keep_b,
992            },
993        }
994    }
995}
996
997/// Indicates that a `impl Drop for Adt` is `const` or not.
998#[derive(#[automatically_derived]
impl ::core::fmt::Debug for AdtDestructorKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                AdtDestructorKind::NotConst => "NotConst",
                AdtDestructorKind::Const => "Const",
            })
    }
}Debug)]
999pub enum AdtDestructorKind {
1000    NotConst,
1001    Const,
1002}
1003
1004/// Which sizedness trait - `Sized`, `MetaSized`? `PointeeSized` is omitted as it is removed during
1005/// lowering.
1006#[derive(#[automatically_derived]
impl ::core::marker::Copy for SizedTraitKind { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for SizedTraitKind { }
#[automatically_derived]
impl ::core::clone::Clone for SizedTraitKind {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for SizedTraitKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                SizedTraitKind::Sized => "Sized",
                SizedTraitKind::MetaSized => "MetaSized",
            })
    }
}Debug, #[automatically_derived]
impl ::core::cmp::Eq for SizedTraitKind { }Eq, #[automatically_derived]
impl ::core::hash::Hash for SizedTraitKind {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for SizedTraitKind { }
#[automatically_derived]
impl ::core::cmp::PartialEq for SizedTraitKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq)]
1007#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            SizedTraitKind {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    SizedTraitKind::Sized => {}
                    SizedTraitKind::MetaSized => {}
                }
            }
        }
    };StableHash))]
1008pub enum SizedTraitKind {
1009    /// `Sized` trait
1010    Sized,
1011    /// `MetaSized` trait
1012    MetaSized,
1013}
1014
1015impl SizedTraitKind {
1016    /// Returns `DefId` of corresponding language item.
1017    pub fn require_lang_item<I: Interner>(self, cx: I) -> I::TraitId {
1018        cx.require_trait_lang_item(match self {
1019            SizedTraitKind::Sized => SolverTraitLangItem::Sized,
1020            SizedTraitKind::MetaSized => SolverTraitLangItem::MetaSized,
1021        })
1022    }
1023}
1024
1025#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for SucceededInErased<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            SucceededInErased::Yes {
                accessed_opaques: ref __field_accessed_opaques } =>
                SucceededInErased::Yes {
                    accessed_opaques: ::core::clone::Clone::clone(__field_accessed_opaques),
                },
            SucceededInErased::No => SucceededInErased::No,
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for SucceededInErased<I> where
    I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            SucceededInErased::Yes {
                accessed_opaques: ref __field_accessed_opaques } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "Yes");
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "accessed_opaques", __field_accessed_opaques);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
            SucceededInErased::No =>
                ::core::fmt::Formatter::write_str(__f, "No"),
        }
    }
}#[derive_where(Clone, Debug; I: Interner)]
1026pub enum SucceededInErased<I: Interner> {
1027    /// This goal previously succeeded in erased mode, which based on `accessed_opaques`
1028    /// might make us take a fast path slightly more often.
1029    Yes {
1030        accessed_opaques: AccessedOpaques<I>,
1031    },
1032    No,
1033}
1034
1035#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for GoalStalledOnOpaques<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            GoalStalledOnOpaques::No => GoalStalledOnOpaques::No,
            GoalStalledOnOpaques::Yes {
                num_opaques_in_storage: ref __field_num_opaques_in_storage,
                previously_succeeded_in_erased: ref __field_previously_succeeded_in_erased
                } =>
                GoalStalledOnOpaques::Yes {
                    num_opaques_in_storage: ::core::clone::Clone::clone(__field_num_opaques_in_storage),
                    previously_succeeded_in_erased: ::core::clone::Clone::clone(__field_previously_succeeded_in_erased),
                },
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for GoalStalledOnOpaques<I> where
    I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            GoalStalledOnOpaques::No =>
                ::core::fmt::Formatter::write_str(__f, "No"),
            GoalStalledOnOpaques::Yes {
                num_opaques_in_storage: ref __field_num_opaques_in_storage,
                previously_succeeded_in_erased: ref __field_previously_succeeded_in_erased
                } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "Yes");
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "num_opaques_in_storage", __field_num_opaques_in_storage);
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "previously_succeeded_in_erased",
                    __field_previously_succeeded_in_erased);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Debug; I: Interner)]
1036pub enum GoalStalledOnOpaques<I: Interner> {
1037    /// This goal got stalled in `compute_goal_fast_path`. Usually this means
1038    /// the goal is stalled on not that much, only one or two variables, and
1039    /// definitely nothing to do with opaque types. So we don't store that information.
1040    No,
1041    Yes {
1042        num_opaques_in_storage: usize,
1043        previously_succeeded_in_erased: SucceededInErased<I>,
1044    },
1045}
1046
1047/// The conditions that must change for a goal to warrant
1048#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for GoalStalledOn<I> where I: Interner
    {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            GoalStalledOn {
                stalled_vars: ref __field_stalled_vars,
                sub_roots: ref __field_sub_roots,
                stalled_maybe_info: ref __field_stalled_maybe_info,
                opaques: ref __field_opaques } =>
                GoalStalledOn {
                    stalled_vars: ::core::clone::Clone::clone(__field_stalled_vars),
                    sub_roots: ::core::clone::Clone::clone(__field_sub_roots),
                    stalled_maybe_info: ::core::clone::Clone::clone(__field_stalled_maybe_info),
                    opaques: ::core::clone::Clone::clone(__field_opaques),
                },
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for GoalStalledOn<I> where I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            GoalStalledOn {
                stalled_vars: ref __field_stalled_vars,
                sub_roots: ref __field_sub_roots,
                stalled_maybe_info: ref __field_stalled_maybe_info,
                opaques: ref __field_opaques } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "GoalStalledOn");
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "stalled_vars", __field_stalled_vars);
                ::core::fmt::DebugStruct::field(&mut __builder, "sub_roots",
                    __field_sub_roots);
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "stalled_maybe_info", __field_stalled_maybe_info);
                ::core::fmt::DebugStruct::field(&mut __builder, "opaques",
                    __field_opaques);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Debug; I: Interner)]
1049pub struct GoalStalledOn<I: Interner> {
1050    // `ThinVec` is important for performance. See #160005.
1051    pub stalled_vars: ThinVec<TyOrConstInferVar>,
1052    // `ThinVec` is important for performance. See #160005.
1053    pub sub_roots: ThinVec<TyVid>,
1054    /// The `MaybeInfo` that will be returned on subsequent evaluations if this
1055    /// goal remains stalled.
1056    pub stalled_maybe_info: MaybeInfo,
1057    pub opaques: GoalStalledOnOpaques<I>,
1058}
1059
1060/// For some goals we can trivially answer some questions without going through
1061/// canonicalization. There are three options:
1062#[derive(#[automatically_derived]
impl<I: ::core::clone::Clone + Interner> ::core::clone::Clone for
    ComputeGoalFastPathOutcome<I> {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            Self::NoFastPath => ComputeGoalFastPathOutcome::NoFastPath,
            Self::TriviallyHolds =>
                ComputeGoalFastPathOutcome::TriviallyHolds,
            Self::TriviallyStalled { stalled_on: __self_0 } =>
                ComputeGoalFastPathOutcome::TriviallyStalled {
                    stalled_on: ::core::clone::Clone::clone(__self_0),
                },
        }
    }
}Clone, #[automatically_derived]
impl<I: ::core::fmt::Debug + Interner> ::core::fmt::Debug for
    ComputeGoalFastPathOutcome<I> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::NoFastPath =>
                ::core::fmt::Formatter::write_str(f, "NoFastPath"),
            Self::TriviallyHolds =>
                ::core::fmt::Formatter::write_str(f, "TriviallyHolds"),
            Self::TriviallyStalled { stalled_on: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "TriviallyStalled", "stalled_on", &__self_0),
        }
    }
}Debug)]
1063pub enum ComputeGoalFastPathOutcome<I: Interner> {
1064    /// Do not attempt the fast path. Compute as normal.
1065    NoFastPath,
1066    /// The goal trivially holds, immediately produce a result with [`Certainty::Yes`]
1067    TriviallyHolds,
1068    /// The goal is trivially stalled: we know for sure that it makes no sense to compute it right
1069    /// now, but can return information about what its stalled on and when it can be computed for real.
1070    TriviallyStalled { stalled_on: GoalStalledOn<I> },
1071}
1072
1073/// Helper for `InferCtxt::ty_or_const_infer_var_changed` (see comment on that), used
1074/// for `traits::fulfill`'s list of `stalled_on` inference variables and for merging
1075/// ambiguity errors caused by the same inference variable during error reporting.
1076#[derive(#[automatically_derived]
impl ::core::marker::Copy for TyOrConstInferVar { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for TyOrConstInferVar { }
#[automatically_derived]
impl ::core::clone::Clone for TyOrConstInferVar {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<TyVid>;
        let _: ::core::clone::AssertParamIsClone<IntVid>;
        let _: ::core::clone::AssertParamIsClone<FloatVid>;
        let _: ::core::clone::AssertParamIsClone<ConstVid>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for TyOrConstInferVar {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Ty(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ty",
                    &__self_0),
            Self::TyInt(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "TyInt",
                    &__self_0),
            Self::TyFloat(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "TyFloat", &__self_0),
            Self::Const(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Const",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for TyOrConstInferVar { }
#[automatically_derived]
impl ::core::cmp::PartialEq for TyOrConstInferVar {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Ty(__self_0), Self::Ty(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::TyInt(__self_0), Self::TyInt(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::TyFloat(__self_0), Self::TyFloat(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::Const(__self_0), Self::Const(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for TyOrConstInferVar {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<TyVid>;
        let _: ::core::cmp::AssertParamIsEq<IntVid>;
        let _: ::core::cmp::AssertParamIsEq<FloatVid>;
        let _: ::core::cmp::AssertParamIsEq<ConstVid>;
    }
}Eq)]
1077pub enum TyOrConstInferVar {
1078    /// Equivalent to `ty::Infer(ty::TyVar(_))`.
1079    Ty(TyVid),
1080    /// Equivalent to `ty::Infer(ty::IntVar(_))`.
1081    TyInt(IntVid),
1082    /// Equivalent to `ty::Infer(ty::FloatVar(_))`.
1083    TyFloat(FloatVid),
1084
1085    /// Equivalent to `ty::ConstKind::Infer(ty::InferConst::Var(_))`.
1086    Const(ConstVid),
1087}
1088
1089impl TyOrConstInferVar {
1090    pub fn as_type<I: Interner>(&self, interner: I) -> Option<I::Ty> {
1091        match self {
1092            Self::Ty(vid) => Some(I::Ty::new_var(interner, *vid)),
1093            Self::TyInt(_) | Self::TyFloat(_) | Self::Const(_) => None,
1094        }
1095    }
1096
1097    /// Tries to extract an inference variable from a type or a constant, returns `None`
1098    /// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`) and
1099    /// for constants other than `ty::ConstKind::Infer(_)` (or `InferConst::Fresh`).
1100    pub fn maybe_from_generic_arg<I: Interner>(arg: I::GenericArg) -> Option<Self> {
1101        match arg.kind() {
1102            GenericArgKind::Type(ty) => Self::maybe_from_ty::<I>(ty),
1103            GenericArgKind::Const(ct) => Self::maybe_from_const::<I>(ct),
1104            GenericArgKind::Lifetime(_) => None,
1105        }
1106    }
1107
1108    /// Tries to extract an inference variable from a type or a constant, returns `None`
1109    /// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`) and
1110    /// for constants other than `ty::ConstKind::Infer(_)` (or `InferConst::Fresh`).
1111    pub fn maybe_from_term<I: Interner>(term: I::Term) -> Option<Self> {
1112        match term.kind() {
1113            TermKind::Ty(ty) => Self::maybe_from_ty::<I>(ty),
1114            TermKind::Const(ct) => Self::maybe_from_const::<I>(ct),
1115        }
1116    }
1117
1118    /// Tries to extract an inference variable from a type, returns `None`
1119    /// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`).
1120    fn maybe_from_ty<I: Interner>(ty: I::Ty) -> Option<Self> {
1121        match ty.kind() {
1122            ty::Infer(ty::TyVar(v)) => Some(TyOrConstInferVar::Ty(v)),
1123            ty::Infer(ty::IntVar(v)) => Some(TyOrConstInferVar::TyInt(v)),
1124            ty::Infer(ty::FloatVar(v)) => Some(TyOrConstInferVar::TyFloat(v)),
1125            _ => None,
1126        }
1127    }
1128
1129    /// Tries to extract an inference variable from a constant, returns `None`
1130    /// for constants other than `ty::ConstKind::Infer(_)` (or `InferConst::Fresh`).
1131    fn maybe_from_const<I: Interner>(ct: Const<I>) -> Option<Self> {
1132        match ct.kind() {
1133            ty::ConstKind::Infer(InferConst::Var(v)) => Some(TyOrConstInferVar::Const(v)),
1134            _ => None,
1135        }
1136    }
1137}