Skip to main content

rustc_trait_selection/traits/
fulfill.rs

1use std::marker::PhantomData;
2use std::ops::ControlFlow;
3
4use rustc_data_structures::obligation_forest::{
5    Error, ForestObligation, ObligationForest, ObligationProcessor, Outcome, ProcessResult,
6};
7use rustc_hir::def_id::LocalDefId;
8use rustc_infer::infer::DefineOpaqueTypes;
9use rustc_infer::traits::{
10    FromSolverError, PolyTraitObligation, PredicateObligations, ProjectionCacheKey, SelectionError,
11    TraitEngine, TraitErrors,
12};
13use rustc_middle::ty::abstract_const::NotConstEvaluatable;
14use rustc_middle::ty::error::{ExpectedFound, TypeError};
15use rustc_middle::ty::{
16    self, Binder, Const, DelayedSet, GenericArgs, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable,
17    TypeVisitableExt, TypeVisitor, TypingMode, may_use_unstable_feature,
18};
19use rustc_next_trait_solver::solve::TyOrConstInferVar;
20use rustc_span::bug;
21use thin_vec::{ThinVec, thin_vec};
22use tracing::{debug, debug_span, instrument};
23
24use super::effects::{self, HostEffectObligation};
25use super::project::{self, ProjectAndUnifyResult};
26use super::select::SelectionContext;
27use super::{
28    EvaluationResult, FulfillmentError, FulfillmentErrorCode, PredicateObligation,
29    ScrubbedTraitError, const_evaluatable, wf,
30};
31use crate::error_reporting::InferCtxtErrorExt;
32use crate::infer::InferCtxt;
33use crate::traits::normalize::normalize_with_depth_to;
34use crate::traits::project::{PolyProjectionObligation, ProjectionCacheKeyExt as _};
35use crate::traits::query::evaluate_obligation::InferCtxtExt;
36use crate::traits::{EvaluateConstErr, implicit_fast_path};
37
38pub(crate) type PendingPredicateObligations<'tcx> = ThinVec<PendingPredicateObligation<'tcx>>;
39
40impl<'tcx> ForestObligation for PendingPredicateObligation<'tcx> {
41    /// Note that we include both the `ParamEnv` and the `Predicate`,
42    /// as the `ParamEnv` can influence whether fulfillment succeeds
43    /// or fails.
44    type CacheKey = ty::ParamEnvAnd<'tcx, ty::Predicate<'tcx>>;
45
46    fn as_cache_key(&self) -> Self::CacheKey {
47        self.obligation.param_env.and(self.obligation.predicate)
48    }
49}
50
51/// The fulfillment context is used to drive trait resolution. It
52/// consists of a list of obligations that must be (eventually)
53/// satisfied. The job is to track which are satisfied, which yielded
54/// errors, and which are still pending. At any point, users can call
55/// `try_evaluate_obligations`, and the fulfillment context will try to do
56/// selection, retaining only those obligations that remain
57/// ambiguous. This may be helpful in pushing type inference
58/// along. Once all type inference constraints have been generated, the
59/// method `evaluate_obligations_error_on_ambiguity` can be used to report any remaining
60/// ambiguous cases as errors.
61pub struct FulfillmentContext<'tcx, E: 'tcx> {
62    /// A list of all obligations that have been registered with this
63    /// fulfillment context.
64    predicates: ObligationForest<PendingPredicateObligation<'tcx>>,
65
66    /// The snapshot in which this context was created. Using the context
67    /// outside of this snapshot leads to subtle bugs if the snapshot
68    /// gets rolled back. Because of this we explicitly check that we only
69    /// use the context in exactly this snapshot.
70    usable_in_snapshot: usize,
71
72    _errors: PhantomData<E>,
73}
74
75#[derive(#[automatically_derived]impl<'tcx> ::core::clone::Clone for
    PendingPredicateObligation<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        PendingPredicateObligation {
            obligation: ::core::clone::Clone::clone(&self.obligation),
            stalled_on: ::core::clone::Clone::clone(&self.stalled_on),
        }
    }
}Clone, #[automatically_derived]impl<'tcx> ::core::fmt::Debug for
    PendingPredicateObligation<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "PendingPredicateObligation obligation stalled_on",
            &self.obligation, &&self.stalled_on)
    }
}Debug)]
76pub struct PendingPredicateObligation<'tcx> {
77    pub obligation: PredicateObligation<'tcx>,
78    // This is far more often read than modified, meaning that we
79    // should mostly optimize for reading speed, while modifying is not as relevant.
80    //
81    // For whatever reason using a boxed slice is slower than using a `Vec` here.
82    pub stalled_on: Vec<TyOrConstInferVar>,
83}
84
85// `PendingPredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
86#[cfg(target_pointer_width = "64")]
87const _: [(); 72] =
    [(); ::std::mem::size_of::<PendingPredicateObligation<'_>>()];rustc_data_structures::static_assert_size!(PendingPredicateObligation<'_>, 72);
88
89impl<'tcx, E> FulfillmentContext<'tcx, E>
90where
91    E: FromSolverError<'tcx, OldSolverError<'tcx>>,
92{
93    /// Creates a new fulfillment context.
94    pub(super) fn new(infcx: &InferCtxt<'tcx>) -> FulfillmentContext<'tcx, E> {
95        if !!infcx.next_trait_solver() {
    {
        ::core::panicking::panic_fmt(format_args!("old trait solver fulfillment context created when infcx is set up for new trait solver"));
    }
};assert!(
96            !infcx.next_trait_solver(),
97            "old trait solver fulfillment context created when \
98            infcx is set up for new trait solver"
99        );
100        FulfillmentContext {
101            predicates: ObligationForest::new(),
102            usable_in_snapshot: infcx.num_open_snapshots(),
103            _errors: PhantomData,
104        }
105    }
106
107    /// Attempts to select obligations using `selcx`.
108    fn select(&mut self, selcx: SelectionContext<'_, 'tcx>) -> TraitErrors<E> {
109        let span = {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("select",
                        "rustc_trait_selection::traits::fulfill",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs"),
                        ::tracing_core::__macro_support::Option::Some(109u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::fulfill"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("obligation_forest_size")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("obligation_forest_size");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::SPAN)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let mut interest = ::tracing::subscriber::Interest::never();
    if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                    &&
                    ::tracing::Level::DEBUG <=
                        ::tracing::level_filters::LevelFilter::current() &&
                { interest = __CALLSITE.interest(); !interest.is_never() } &&
            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                interest) {
        let meta = __CALLSITE.metadata();
        ::tracing::Span::new(meta,
            &{
                    #[allow(unused_imports)]
                    use ::tracing::field::{debug, display, Value};
                    meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self.predicates.len())
                                                as &dyn ::tracing::field::Value))])
                })
    } else {
        let span =
            ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
        {};
        span
    }
}debug_span!("select", obligation_forest_size = ?self.predicates.len());
110        let _enter = span.enter();
111        let infcx = selcx.infcx;
112
113        // Process pending obligations.
114        let outcome: Outcome<_, _> =
115            self.predicates.process_obligations(&mut FulfillProcessor { selcx });
116
117        // FIXME: if we kept the original cache key, we could mark projection
118        // obligations as complete for the projection cache here.
119
120        let errors = TraitErrors::from_iter(
121            outcome.errors.into_iter().map(|err| E::from_solver_error(infcx, OldSolverError(err))),
122        );
123
124        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs:124",
                        "rustc_trait_selection::traits::fulfill",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs"),
                        ::tracing_core::__macro_support::Option::Some(124u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::fulfill"),
                        ::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!("select({0} predicates remaining, {1} errors) done",
                                                    self.predicates.len(), errors.len()) as
                                            &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(
125            "select({} predicates remaining, {} errors) done",
126            self.predicates.len(),
127            errors.len()
128        );
129
130        errors
131    }
132}
133
134impl<'tcx, E> TraitEngine<'tcx, E> for FulfillmentContext<'tcx, E>
135where
136    E: FromSolverError<'tcx, OldSolverError<'tcx>>,
137{
138    #[inline]
139    fn register_predicate_obligation(
140        &mut self,
141        infcx: &InferCtxt<'tcx>,
142        mut obligation: PredicateObligation<'tcx>,
143    ) {
144        {
    match (&self.usable_in_snapshot, &infcx.num_open_snapshots()) {
        (left_val, right_val) => {
            if !(*left_val == *right_val) {
                let kind = ::core::panicking::AssertKind::Eq;
                ::core::panicking::assert_failed(kind, &*left_val,
                    &*right_val, ::core::option::Option::None);
            }
        }
    }
};assert_eq!(self.usable_in_snapshot, infcx.num_open_snapshots());
145        // this helps to reduce duplicate errors, as well as making
146        // debug output much nicer to read and so on.
147        if true {
    if !!obligation.param_env.has_non_region_infer() {
        ::core::panicking::panic("assertion failed: !obligation.param_env.has_non_region_infer()")
    };
};debug_assert!(!obligation.param_env.has_non_region_infer());
148        obligation.predicate = infcx.deeply_resolve_ignoring_regions(obligation.predicate);
149
150        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs:150",
                        "rustc_trait_selection::traits::fulfill",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs"),
                        ::tracing_core::__macro_support::Option::Some(150u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::fulfill"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("obligation")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("obligation");
                                            NAME.as_str()
                                        }], ::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!("register_predicate_obligation")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?obligation, "register_predicate_obligation");
151
152        self.predicates
153            .register_obligation(PendingPredicateObligation { obligation, stalled_on: ::alloc::vec::Vec::new()vec![] });
154    }
155
156    fn collect_remaining_errors(&mut self, infcx: &InferCtxt<'tcx>) -> TraitErrors<E> {
157        TraitErrors::from_iter(
158            self.predicates
159                .to_errors(FulfillmentErrorCode::Ambiguity { overflow: None })
160                .into_iter()
161                .map(|err| E::from_solver_error(infcx, OldSolverError(err))),
162        )
163    }
164
165    fn try_evaluate_obligations(&mut self, infcx: &InferCtxt<'tcx>) -> TraitErrors<E> {
166        let selcx = SelectionContext::new(infcx);
167        self.select(selcx)
168    }
169
170    fn drain_stalled_obligations_for_coroutines(
171        &mut self,
172        infcx: &InferCtxt<'tcx>,
173    ) -> PredicateObligations<'tcx> {
174        let stalled_coroutines = match infcx.typing_mode_raw().assert_not_erased() {
175            TypingMode::Typeck { defining_opaque_types_and_generators } => {
176                defining_opaque_types_and_generators
177            }
178            TypingMode::PostTypeckThroughBorrowck { defining_opaque_types: _ }
179            | TypingMode::PostBorrowck { defined_opaque_types: _ }
180            | TypingMode::Reflection
181            | TypingMode::PostAnalysis
182            | TypingMode::Codegen => return Default::default(),
183            TypingMode::Coherence => {
184                {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("old solver coherence")));
}unreachable!("old solver coherence")
185            }
186        };
187
188        if stalled_coroutines.is_empty() {
189            return Default::default();
190        }
191
192        let mut processor = DrainProcessor {
193            infcx,
194            removed_predicates: PredicateObligations::new(),
195            stalled_coroutines,
196        };
197        let outcome: Outcome<_, _> = self.predicates.process_obligations(&mut processor);
198        if !outcome.errors.is_empty() {
    ::core::panicking::panic("assertion failed: outcome.errors.is_empty()")
};assert!(outcome.errors.is_empty());
199        return processor.removed_predicates;
200
201        struct DrainProcessor<'a, 'tcx> {
202            infcx: &'a InferCtxt<'tcx>,
203            removed_predicates: PredicateObligations<'tcx>,
204            stalled_coroutines: &'tcx ty::List<LocalDefId>,
205        }
206
207        impl<'tcx> ObligationProcessor for DrainProcessor<'_, 'tcx> {
208            type Obligation = PendingPredicateObligation<'tcx>;
209            type Error = !;
210            type OUT = Outcome<Self::Obligation, Self::Error>;
211
212            fn needs_process_obligation(&self, pending_obligation: &Self::Obligation) -> bool {
213                struct StalledOnCoroutines<'tcx> {
214                    pub stalled_coroutines: &'tcx ty::List<LocalDefId>,
215                    pub cache: DelayedSet<Ty<'tcx>>,
216                }
217
218                impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for StalledOnCoroutines<'tcx> {
219                    type Result = ControlFlow<()>;
220
221                    fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result {
222                        if !self.cache.insert(ty) {
223                            return ControlFlow::Continue(());
224                        }
225
226                        if let ty::Coroutine(def_id, _) = ty.kind()
227                            && def_id
228                                .as_local()
229                                .is_some_and(|def_id| self.stalled_coroutines.contains(&def_id))
230                        {
231                            ControlFlow::Break(())
232                        } else if ty.has_coroutines() {
233                            ty.super_visit_with(self)
234                        } else {
235                            ControlFlow::Continue(())
236                        }
237                    }
238                }
239
240                self.infcx
241                    .deeply_resolve_ignoring_regions(pending_obligation.obligation.predicate)
242                    .visit_with(&mut StalledOnCoroutines {
243                        stalled_coroutines: self.stalled_coroutines,
244                        cache: Default::default(),
245                    })
246                    .is_break()
247            }
248
249            fn process_obligation(
250                &mut self,
251                pending_obligation: &mut PendingPredicateObligation<'tcx>,
252            ) -> ProcessResult<PendingPredicateObligation<'tcx>, !> {
253                if !self.needs_process_obligation(pending_obligation) {
    ::core::panicking::panic("assertion failed: self.needs_process_obligation(pending_obligation)")
};assert!(self.needs_process_obligation(pending_obligation));
254                self.removed_predicates.push(pending_obligation.obligation.clone());
255                ProcessResult::Changed(Default::default())
256            }
257
258            fn process_backedge<'c, I>(
259                &mut self,
260                cycle: I,
261                _marker: PhantomData<&'c PendingPredicateObligation<'tcx>>,
262            ) -> Result<(), !>
263            where
264                I: Clone + Iterator<Item = &'c PendingPredicateObligation<'tcx>>,
265            {
266                self.removed_predicates.extend(cycle.map(|c| c.obligation.clone()));
267                Ok(())
268            }
269        }
270    }
271
272    fn has_pending_obligations(&self) -> bool {
273        self.predicates.has_pending_obligations()
274    }
275
276    fn pending_obligations(&self) -> PredicateObligations<'tcx> {
277        self.predicates.map_pending_obligations(|o| o.obligation.clone())
278    }
279}
280
281struct FulfillProcessor<'a, 'tcx> {
282    selcx: SelectionContext<'a, 'tcx>,
283}
284
285fn mk_pending<'tcx>(
286    parent: &PredicateObligation<'tcx>,
287    os: PredicateObligations<'tcx>,
288) -> PendingPredicateObligations<'tcx> {
289    os.into_iter()
290        .map(|mut o| {
291            o.set_depth_from_parent(parent.recursion_depth);
292            PendingPredicateObligation { obligation: o, stalled_on: ::alloc::vec::Vec::new()vec![] }
293        })
294        .collect()
295}
296
297impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
298    type Obligation = PendingPredicateObligation<'tcx>;
299    type Error = FulfillmentErrorCode<'tcx>;
300    type OUT = Outcome<Self::Obligation, Self::Error>;
301
302    /// Compared to `needs_process_obligation` this and its callees
303    /// contain some optimizations that come at the price of false negatives.
304    ///
305    /// They
306    /// - reduce branching by covering only the most common case
307    /// - take a read-only view of the unification tables which allows skipping undo_log
308    ///   construction.
309    /// - bail out on value-cache misses in ena to avoid pointer chasing
310    /// - hoist RefCell locking out of the loop
311    #[inline]
312    fn skippable_obligations<'b>(
313        &'b self,
314        it: impl Iterator<Item = &'b Self::Obligation>,
315    ) -> usize {
316        let is_unchanged = self.selcx.infcx.is_ty_infer_var_definitely_unchanged();
317
318        it.take_while(|o| match o.stalled_on.as_slice() {
319            [o] => is_unchanged(*o),
320            _ => false,
321        })
322        .count()
323    }
324
325    /// Identifies whether a predicate obligation needs processing.
326    ///
327    /// This is always inlined because it has a single callsite and it is
328    /// called *very* frequently. Be careful modifying this code! Several
329    /// compile-time benchmarks are very sensitive to even small changes.
330    #[inline(always)]
331    fn needs_process_obligation(&self, pending_obligation: &Self::Obligation) -> bool {
332        if self.selcx.infcx.disable_trait_solver_fast_paths() {
333            return true;
334        }
335
336        // If we were stalled on some unresolved variables, first check whether
337        // any of them have been resolved; if not, don't bother doing more work
338        // yet.
339        let stalled_on = &pending_obligation.stalled_on;
340        match stalled_on.len() {
341            // This case is the hottest most of the time, being hit up to 99%
342            // of the time. `keccak` and `cranelift-codegen-0.82.1` are
343            // benchmarks that particularly stress this path.
344            1 => self.selcx.infcx.ty_or_const_infer_var_changed(stalled_on[0]),
345
346            // In this case we haven't changed, but wish to make a change. Note
347            // that this is a special case, and is not equivalent to the `_`
348            // case below, which would return `false` for an empty `stalled_on`
349            // vector.
350            //
351            // This case is usually hit only 1% of the time or less, though it
352            // reaches 20% in `wasmparser-0.101.0`.
353            0 => true,
354
355            // This case is usually hit only 1% of the time or less, though it
356            // reaches 95% in `mime-0.3.16`, 64% in `wast-54.0.0`, and 12% in
357            // `inflate-0.4.5`.
358            //
359            // The obvious way of writing this, with a call to `any()` and no
360            // closure, is currently slower than this version.
361            _ => (|| {
362                for &infer_var in stalled_on {
363                    if self.selcx.infcx.ty_or_const_infer_var_changed(infer_var) {
364                        return true;
365                    }
366                }
367                false
368            })(),
369        }
370    }
371
372    /// Processes a predicate obligation and returns either:
373    /// - `Changed(v)` if the predicate is true, presuming that `v` are also true
374    /// - `Unchanged` if we don't have enough info to be sure
375    /// - `Error(e)` if the predicate does not hold
376    ///
377    /// This is called much less often than `needs_process_obligation`, so we
378    /// never inline it.
379    #[inline(never)]
380    {}
#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() ||
            { false } {
        __tracing_attr_span =
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("process_obligation",
                                    "rustc_trait_selection::traits::fulfill",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs"),
                                    ::tracing_core::__macro_support::Option::Some(380u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::fulfill"),
                                    ::tracing_core::field::FieldSet::new(&[],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{ meta.fields().value_set_all(&[]) })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return:
                    ProcessResult<PendingPredicateObligation<'tcx>,
                    FulfillmentErrorCode<'tcx>> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            pending_obligation.stalled_on.clear();
            let obligation = &mut pending_obligation.obligation;
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs:389",
                                    "rustc_trait_selection::traits::fulfill",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs"),
                                    ::tracing_core::__macro_support::Option::Some(389u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::fulfill"),
                                    ::tracing_core::field::FieldSet::new(&["message",
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("obligation")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("obligation");
                                                        NAME.as_str()
                                                    }], ::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!("pre-resolve")
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            if obligation.predicate.has_non_region_infer() {
                obligation.predicate =
                    self.selcx.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
            }
            let obligation = &pending_obligation.obligation;
            let infcx = self.selcx.infcx;
            if !infcx.disable_trait_solver_fast_paths() &&
                    implicit_fast_path(infcx.tcx, obligation.predicate,
                        obligation.param_env) {
                return ProcessResult::Changed(::thin_vec::ThinVec::new());
            }
            if obligation.predicate.has_aliases() {
                let mut obligations = PredicateObligations::new();
                let predicate =
                    normalize_with_depth_to(&mut self.selcx,
                        obligation.param_env, obligation.cause.clone(),
                        obligation.recursion_depth + 1,
                        ty::Unnormalized::new_wip(obligation.predicate),
                        &mut obligations);
                if predicate != obligation.predicate {
                    obligations.push(obligation.with(infcx.tcx, predicate));
                    return ProcessResult::Changed(mk_pending(obligation,
                                obligations));
                }
            }
            let binder = obligation.predicate.kind();
            match binder.no_bound_vars() {
                None =>
                    match binder.skip_binder() {
                        ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_ref))
                            => {
                            let trait_obligation =
                                obligation.with(infcx.tcx, binder.rebind(trait_ref));
                            self.process_trait_obligation(obligation, trait_obligation,
                                &mut pending_obligation.stalled_on)
                        }
                        ty::PredicateKind::Clause(ty::ClauseKind::Projection(data))
                            => {
                            let project_obligation =
                                obligation.with(infcx.tcx, binder.rebind(data));
                            self.process_projection_obligation(obligation,
                                project_obligation, &mut pending_obligation.stalled_on)
                        }
                        ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(_))
                            | ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(_))
                            |
                            ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(..))
                            | ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) |
                            ty::PredicateKind::DynCompatible(_) |
                            ty::PredicateKind::Subtype(_) | ty::PredicateKind::Coerce(_)
                            |
                            ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
                            | ty::PredicateKind::ConstEquate(..) |
                            ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(..)) =>
                            {
                            let pred =
                                ty::Binder::dummy(infcx.enter_forall_and_leak_universe(binder));
                            let mut obligations =
                                PredicateObligations::with_capacity(1);
                            obligations.push(obligation.with(infcx.tcx, pred));
                            ProcessResult::Changed(mk_pending(obligation, obligations))
                        }
                        ty::PredicateKind::Ambiguous => ProcessResult::Unchanged,
                        ty::PredicateKind::NormalizesTo(..) => {
                            ::rustc_span::macros::bug_impl(None,
                                format_args!("NormalizesTo is only used by the new solver"),
                                Location::caller())
                        }
                        ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(_))
                            => {
                            {
                                ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
                                        format_args!("unexpected higher ranked `UnstableFeature` goal")));
                            }
                        }
                        ty::PredicateKind::Clause(ty::ClauseKind::CompressedTrait(_))
                            => ::core::panicking::unreachable_default_msg(),
                    },
                Some(pred) =>
                    match pred {
                        ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) => {
                            let trait_obligation =
                                obligation.with(infcx.tcx, Binder::dummy(data));
                            self.process_trait_obligation(obligation, trait_obligation,
                                &mut pending_obligation.stalled_on)
                        }
                        ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(data))
                            => {
                            let host_obligation = obligation.with(infcx.tcx, data);
                            self.process_host_obligation(obligation, host_obligation,
                                &mut pending_obligation.stalled_on)
                        }
                        ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(data))
                            => {
                            if infcx.considering_regions {
                                infcx.register_region_outlives_constraint(data,
                                    ty::VisibleForLeakCheck::Yes, &obligation.cause);
                            }
                            ProcessResult::Changed(Default::default())
                        }
                        ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(ty::OutlivesClause(t_a,
                            r_b))) => {
                            if infcx.considering_regions {
                                infcx.register_type_outlives_constraint(t_a, r_b,
                                    &obligation.cause);
                            }
                            ProcessResult::Changed(Default::default())
                        }
                        ty::PredicateKind::Clause(ty::ClauseKind::Projection(ref data))
                            => {
                            let project_obligation =
                                obligation.with(infcx.tcx, Binder::dummy(*data));
                            self.process_projection_obligation(obligation,
                                project_obligation, &mut pending_obligation.stalled_on)
                        }
                        ty::PredicateKind::DynCompatible(trait_def_id) => {
                            if !self.selcx.tcx().is_dyn_compatible(trait_def_id) {
                                ProcessResult::Error(FulfillmentErrorCode::Select(SelectionError::Unimplemented))
                            } else { ProcessResult::Changed(Default::default()) }
                        }
                        ty::PredicateKind::Ambiguous => ProcessResult::Unchanged,
                        ty::PredicateKind::NormalizesTo(..) => {
                            ::rustc_span::macros::bug_impl(None,
                                format_args!("NormalizesTo is only used by the new solver"),
                                Location::caller())
                        }
                        ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct,
                            ty)) => {
                            let ct = infcx.shallow_resolve_const(ct);
                            let ct_ty =
                                match ct.kind() {
                                    ty::ConstKind::Infer(var) => {
                                        let var =
                                            match var {
                                                ty::InferConst::Var(vid) => TyOrConstInferVar::Const(vid),
                                                ty::InferConst::Fresh(_) => {
                                                    ::rustc_span::macros::bug_impl(None,
                                                        format_args!("encountered fresh const in fulfill"),
                                                        Location::caller())
                                                }
                                            };
                                        pending_obligation.stalled_on.clear();
                                        pending_obligation.stalled_on.extend([var]);
                                        return ProcessResult::Unchanged;
                                    }
                                    ty::ConstKind::Error(_) => {
                                        return ProcessResult::Changed(PendingPredicateObligations::new());
                                    }
                                    ty::ConstKind::Value(cv) => cv.ty,
                                    ty::ConstKind::Alias(_, alias_const) => {
                                        alias_const.type_of(infcx.tcx).skip_norm_wip()
                                    }
                                    ty::ConstKind::Expr(_) => {
                                        return ProcessResult::Changed(mk_pending(obligation,
                                                    PredicateObligations::new()));
                                    }
                                    ty::ConstKind::Placeholder(_) => {
                                        ::rustc_span::macros::bug_impl(None,
                                            format_args!("placeholder const {0:?} in old solver", ct),
                                            Location::caller())
                                    }
                                    ty::ConstKind::Bound(_, _) =>
                                        ::rustc_span::macros::bug_impl(None,
                                            format_args!("escaping bound vars in {0:?}", ct),
                                            Location::caller()),
                                    ty::ConstKind::Param(param_ct) => {
                                        param_ct.find_const_ty_from_env(obligation.param_env)
                                    }
                                };
                            match infcx.eq_raw(&obligation.cause, obligation.param_env,
                                    DefineOpaqueTypes::Yes, ct_ty, ty) {
                                Ok(inf_ok) =>
                                    ProcessResult::Changed(mk_pending(obligation,
                                            inf_ok.into_obligations())),
                                Err(_) =>
                                    ProcessResult::Error(FulfillmentErrorCode::Select(SelectionError::ConstArgHasWrongType {
                                                ct,
                                                ct_ty,
                                                expected_ty: ty,
                                            })),
                            }
                        }
                        _ if
                            !self.selcx.tcx().recursion_limit().value_within_limit(obligation.recursion_depth)
                            => {
                            self.selcx.infcx.err_ctxt().report_overflow_obligation(&obligation,
                                false);
                        }
                        ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term))
                            => {
                            if term.is_trivially_wf(self.selcx.tcx()) {
                                return ProcessResult::Changed(::thin_vec::ThinVec::new());
                            }
                            match wf::obligations(self.selcx.infcx,
                                    obligation.param_env, obligation.cause.body_def_id,
                                    obligation.recursion_depth + 1, term, obligation.cause.span)
                                {
                                None => {
                                    pending_obligation.stalled_on =
                                        ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                [TyOrConstInferVar::maybe_from_term::<TyCtxt<'tcx>>(term).unwrap()]));
                                    ProcessResult::Unchanged
                                }
                                Some(os) =>
                                    ProcessResult::Changed(mk_pending(obligation, os)),
                            }
                        }
                        ty::PredicateKind::Subtype(subtype) => {
                            match self.selcx.infcx.subtype_predicate(&obligation.cause,
                                    obligation.param_env, Binder::dummy(subtype)) {
                                Err((a, b)) => {
                                    pending_obligation.stalled_on =
                                        ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                [TyOrConstInferVar::Ty(a), TyOrConstInferVar::Ty(b)]));
                                    ProcessResult::Unchanged
                                }
                                Ok(Ok(ok)) => {
                                    ProcessResult::Changed(mk_pending(obligation,
                                            ok.obligations))
                                }
                                Ok(Err(err)) => {
                                    let expected_found =
                                        if subtype.a_is_expected {
                                            ExpectedFound::new(subtype.a, subtype.b)
                                        } else { ExpectedFound::new(subtype.b, subtype.a) };
                                    ProcessResult::Error(FulfillmentErrorCode::Subtype(expected_found,
                                            err))
                                }
                            }
                        }
                        ty::PredicateKind::Coerce(coerce) => {
                            match self.selcx.infcx.coerce_predicate(&obligation.cause,
                                    obligation.param_env, Binder::dummy(coerce)) {
                                Err((a, b)) => {
                                    pending_obligation.stalled_on =
                                        ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                [TyOrConstInferVar::Ty(a), TyOrConstInferVar::Ty(b)]));
                                    ProcessResult::Unchanged
                                }
                                Ok(Ok(ok)) => {
                                    ProcessResult::Changed(mk_pending(obligation,
                                            ok.obligations))
                                }
                                Ok(Err(err)) => {
                                    let expected_found = ExpectedFound::new(coerce.b, coerce.a);
                                    ProcessResult::Error(FulfillmentErrorCode::Subtype(expected_found,
                                            err))
                                }
                            }
                        }
                        ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(alias_const))
                            => {
                            match const_evaluatable::is_const_evaluatable(self.selcx.infcx,
                                    alias_const, obligation.param_env, obligation.cause.span) {
                                Ok(()) => ProcessResult::Changed(Default::default()),
                                Err(NotConstEvaluatable::MentionsInfer) => {
                                    pending_obligation.stalled_on.clear();
                                    pending_obligation.stalled_on.extend(alias_const.walk().filter_map(TyOrConstInferVar::maybe_from_generic_arg::<TyCtxt<'tcx>>));
                                    ProcessResult::Unchanged
                                }
                                Err(e @ NotConstEvaluatable::MentionsParam | e @
                                    NotConstEvaluatable::Error(_)) =>
                                    ProcessResult::Error(FulfillmentErrorCode::Select(SelectionError::NotConstEvaluatable(e))),
                            }
                        }
                        ty::PredicateKind::ConstEquate(c1, c2) => {
                            let tcx = self.selcx.tcx();
                            if !tcx.features().generic_const_exprs() {
                                {
                                    ::core::panicking::panic_fmt(format_args!("`ConstEquate` without a feature gate: {0:?} {1:?}",
                                            c1, c2));
                                }
                            };
                            {
                                let c1 = tcx.expand_abstract_consts(c1);
                                let c2 = tcx.expand_abstract_consts(c2);
                                {
                                    use ::tracing::__macro_support::Callsite as _;
                                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                        {
                                            static META: ::tracing::Metadata<'static> =
                                                {
                                                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs:721",
                                                        "rustc_trait_selection::traits::fulfill",
                                                        ::tracing::Level::DEBUG,
                                                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs"),
                                                        ::tracing_core::__macro_support::Option::Some(721u32),
                                                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::fulfill"),
                                                        ::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!("equating consts:\nc1= {0:?}\nc2= {1:?}",
                                                                                    c1, c2) as &dyn ::tracing::field::Value))])
                                            });
                                    } else { ; }
                                };
                                match (c1.kind(), c2.kind()) {
                                    (ty::ConstKind::Alias(_, a), ty::ConstKind::Alias(_, b)) if
                                        a.kind == b.kind &&
                                            #[allow(non_exhaustive_omitted_patterns)] match a.kind {
                                                ty::AliasConstKind::Projection { .. } |
                                                    ty::AliasConstKind::InherentSelf { .. } |
                                                    ty::AliasConstKind::InherentImpl { .. } => true,
                                                _ => false,
                                            } => {
                                        if let Ok(new_obligations) =
                                                infcx.eq_raw(&obligation.cause, obligation.param_env,
                                                    DefineOpaqueTypes::Yes, ty::AliasTerm::from(a),
                                                    ty::AliasTerm::from(b)) {
                                            return ProcessResult::Changed(mk_pending(obligation,
                                                        new_obligations.into_obligations()));
                                        }
                                    }
                                    (_, ty::ConstKind::Alias(_, _)) |
                                        (ty::ConstKind::Alias(_, _), _) => (),
                                    (_, _) => {
                                        if let Ok(new_obligations) =
                                                infcx.eq_raw(&obligation.cause, obligation.param_env,
                                                    DefineOpaqueTypes::Yes, c1, c2) {
                                            return ProcessResult::Changed(mk_pending(obligation,
                                                        new_obligations.into_obligations()));
                                        }
                                    }
                                }
                            }
                            let stalled_on = &mut pending_obligation.stalled_on;
                            let mut evaluate =
                                |c: Const<'tcx>|
                                    {
                                        if let ty::ConstKind::Alias(_, alias_const) = c.kind() {
                                            match super::try_evaluate_const(self.selcx.infcx, c,
                                                    obligation.param_env, |ty| Ok::<_, !>(ty.skip_norm_wip())) {
                                                Ok(val) => Ok(val),
                                                e @ Err(EvaluateConstErr::HasGenericsOrInfers) => {
                                                    stalled_on.extend(alias_const.args.iter().filter_map(TyOrConstInferVar::maybe_from_generic_arg::<TyCtxt<'tcx>>));
                                                    e
                                                }
                                                e @
                                                    Err(EvaluateConstErr::EvaluationFailure(_) |
                                                    EvaluateConstErr::InvalidConstParamTy(_)) => e,
                                            }
                                        } else { Ok(c) }
                                    };
                            match (evaluate(c1), evaluate(c2)) {
                                (Ok(c1), Ok(c2)) => {
                                    match self.selcx.infcx.eq_raw(&obligation.cause,
                                            obligation.param_env, DefineOpaqueTypes::Yes, c1, c2) {
                                        Ok(inf_ok) =>
                                            ProcessResult::Changed(mk_pending(obligation,
                                                    inf_ok.into_obligations())),
                                        Err(err) => {
                                            ProcessResult::Error(FulfillmentErrorCode::ConstEquate(ExpectedFound::new(c1,
                                                        c2), err))
                                        }
                                    }
                                }
                                (Err(EvaluateConstErr::InvalidConstParamTy(e)), _) |
                                    (_, Err(EvaluateConstErr::InvalidConstParamTy(e))) => {
                                    ProcessResult::Error(FulfillmentErrorCode::Select(SelectionError::NotConstEvaluatable(NotConstEvaluatable::Error(e))))
                                }
                                (Err(EvaluateConstErr::EvaluationFailure(e)), _) |
                                    (_, Err(EvaluateConstErr::EvaluationFailure(e))) => {
                                    ProcessResult::Error(FulfillmentErrorCode::Select(SelectionError::NotConstEvaluatable(NotConstEvaluatable::Error(e))))
                                }
                                (Err(EvaluateConstErr::HasGenericsOrInfers), _) |
                                    (_, Err(EvaluateConstErr::HasGenericsOrInfers)) => {
                                    if c1.has_non_region_infer() || c2.has_non_region_infer() {
                                        ProcessResult::Unchanged
                                    } else {
                                        let expected_found = ExpectedFound::new(c1, c2);
                                        ProcessResult::Error(FulfillmentErrorCode::ConstEquate(expected_found,
                                                TypeError::ConstMismatch(expected_found)))
                                    }
                                }
                            }
                        }
                        ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol))
                            => {
                            if may_use_unstable_feature(self.selcx.infcx,
                                    obligation.param_env, symbol) {
                                ProcessResult::Changed(Default::default())
                            } else { ProcessResult::Unchanged }
                        }
                        ty::PredicateKind::Clause(ty::ClauseKind::CompressedTrait(_))
                            => ::core::panicking::unreachable_default_msg(),
                    },
            }
        }
    }
}#[instrument(level = "debug", skip(self, pending_obligation))]
381    fn process_obligation(
382        &mut self,
383        pending_obligation: &mut PendingPredicateObligation<'tcx>,
384    ) -> ProcessResult<PendingPredicateObligation<'tcx>, FulfillmentErrorCode<'tcx>> {
385        pending_obligation.stalled_on.clear();
386
387        let obligation = &mut pending_obligation.obligation;
388
389        debug!(?obligation, "pre-resolve");
390
391        if obligation.predicate.has_non_region_infer() {
392            obligation.predicate =
393                self.selcx.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
394        }
395
396        let obligation = &pending_obligation.obligation;
397
398        let infcx = self.selcx.infcx;
399
400        if !infcx.disable_trait_solver_fast_paths()
401            && implicit_fast_path(infcx.tcx, obligation.predicate, obligation.param_env)
402        {
403            return ProcessResult::Changed(thin_vec![]);
404        }
405
406        if obligation.predicate.has_aliases() {
407            let mut obligations = PredicateObligations::new();
408            let predicate = normalize_with_depth_to(
409                &mut self.selcx,
410                obligation.param_env,
411                obligation.cause.clone(),
412                obligation.recursion_depth + 1,
413                ty::Unnormalized::new_wip(obligation.predicate),
414                &mut obligations,
415            );
416            if predicate != obligation.predicate {
417                obligations.push(obligation.with(infcx.tcx, predicate));
418                return ProcessResult::Changed(mk_pending(obligation, obligations));
419            }
420        }
421        let binder = obligation.predicate.kind();
422        match binder.no_bound_vars() {
423            None => match binder.skip_binder() {
424                // Evaluation will discard candidates using the leak check.
425                // This means we need to pass it the bound version of our
426                // predicate.
427                ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_ref)) => {
428                    let trait_obligation = obligation.with(infcx.tcx, binder.rebind(trait_ref));
429
430                    self.process_trait_obligation(
431                        obligation,
432                        trait_obligation,
433                        &mut pending_obligation.stalled_on,
434                    )
435                }
436                ty::PredicateKind::Clause(ty::ClauseKind::Projection(data)) => {
437                    let project_obligation = obligation.with(infcx.tcx, binder.rebind(data));
438
439                    self.process_projection_obligation(
440                        obligation,
441                        project_obligation,
442                        &mut pending_obligation.stalled_on,
443                    )
444                }
445                ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(_))
446                | ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(_))
447                | ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(..))
448                | ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_))
449                | ty::PredicateKind::DynCompatible(_)
450                | ty::PredicateKind::Subtype(_)
451                | ty::PredicateKind::Coerce(_)
452                | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
453                | ty::PredicateKind::ConstEquate(..)
454                // FIXME(const_trait_impl): We may need to do this using the higher-ranked
455                // pred instead of just instantiating it with placeholders b/c of
456                // higher-ranked implied bound issues in the old solver.
457                | ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(..)) => {
458                    let pred = ty::Binder::dummy(infcx.enter_forall_and_leak_universe(binder));
459                    let mut obligations = PredicateObligations::with_capacity(1);
460                    obligations.push(obligation.with(infcx.tcx, pred));
461
462                    ProcessResult::Changed(mk_pending(obligation, obligations))
463                }
464                ty::PredicateKind::Ambiguous => ProcessResult::Unchanged,
465                ty::PredicateKind::NormalizesTo(..) => {
466                    bug!("NormalizesTo is only used by the new solver")
467                }
468                ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(_)) => {
469                    unreachable!("unexpected higher ranked `UnstableFeature` goal")
470                }
471                ty::PredicateKind::Clause(ty::ClauseKind::CompressedTrait(_)) => unreachable!(),
472            },
473            Some(pred) => match pred {
474                ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) => {
475                    let trait_obligation = obligation.with(infcx.tcx, Binder::dummy(data));
476
477                    self.process_trait_obligation(
478                        obligation,
479                        trait_obligation,
480                        &mut pending_obligation.stalled_on,
481                    )
482                }
483
484                ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(data)) => {
485                    let host_obligation = obligation.with(infcx.tcx, data);
486
487                    self.process_host_obligation(
488                        obligation,
489                        host_obligation,
490                        &mut pending_obligation.stalled_on,
491                    )
492                }
493
494                ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(data)) => {
495                    if infcx.considering_regions {
496                        infcx.register_region_outlives_constraint(
497                            data,
498                            ty::VisibleForLeakCheck::Yes,
499                            &obligation.cause,
500                        );
501                    }
502
503                    ProcessResult::Changed(Default::default())
504                }
505
506                ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(ty::OutlivesClause(
507                    t_a,
508                    r_b,
509                ))) => {
510                    if infcx.considering_regions {
511                        infcx.register_type_outlives_constraint(t_a, r_b, &obligation.cause);
512                    }
513                    ProcessResult::Changed(Default::default())
514                }
515
516                ty::PredicateKind::Clause(ty::ClauseKind::Projection(ref data)) => {
517                    let project_obligation = obligation.with(infcx.tcx, Binder::dummy(*data));
518
519                    self.process_projection_obligation(
520                        obligation,
521                        project_obligation,
522                        &mut pending_obligation.stalled_on,
523                    )
524                }
525
526                ty::PredicateKind::DynCompatible(trait_def_id) => {
527                    if !self.selcx.tcx().is_dyn_compatible(trait_def_id) {
528                        ProcessResult::Error(FulfillmentErrorCode::Select(
529                            SelectionError::Unimplemented,
530                        ))
531                    } else {
532                        ProcessResult::Changed(Default::default())
533                    }
534                }
535
536                ty::PredicateKind::Ambiguous => ProcessResult::Unchanged,
537                ty::PredicateKind::NormalizesTo(..) => {
538                    bug!("NormalizesTo is only used by the new solver")
539                }
540                // Compute `ConstArgHasType` above the overflow check below.
541                // This is because this is not ever a useful obligation to report
542                // as the cause of an overflow.
543                ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
544                    let ct = infcx.shallow_resolve_const(ct);
545                    let ct_ty = match ct.kind() {
546                        ty::ConstKind::Infer(var) => {
547                            let var = match var {
548                                ty::InferConst::Var(vid) => TyOrConstInferVar::Const(vid),
549                                ty::InferConst::Fresh(_) => {
550                                    bug!("encountered fresh const in fulfill")
551                                }
552                            };
553                            pending_obligation.stalled_on.clear();
554                            pending_obligation.stalled_on.extend([var]);
555                            return ProcessResult::Unchanged;
556                        }
557                        ty::ConstKind::Error(_) => {
558                            return ProcessResult::Changed(PendingPredicateObligations::new());
559                        }
560                        ty::ConstKind::Value(cv) => cv.ty,
561                        ty::ConstKind::Alias(_, alias_const) => {
562                            alias_const.type_of(infcx.tcx).skip_norm_wip()
563                        }
564                        // FIXME(generic_const_exprs): we should construct an alias like
565                        // `<lhs_ty as Add<rhs_ty>>::Output` when this is an `Expr` representing
566                        // `lhs + rhs`.
567                        ty::ConstKind::Expr(_) => {
568                            return ProcessResult::Changed(mk_pending(
569                                obligation,
570                                PredicateObligations::new(),
571                            ));
572                        }
573                        ty::ConstKind::Placeholder(_) => {
574                            bug!("placeholder const {:?} in old solver", ct)
575                        }
576                        ty::ConstKind::Bound(_, _) => bug!("escaping bound vars in {:?}", ct),
577                        ty::ConstKind::Param(param_ct) => {
578                            param_ct.find_const_ty_from_env(obligation.param_env)
579                        }
580                    };
581
582                    match infcx.eq_raw(
583                        &obligation.cause,
584                        obligation.param_env,
585                        // Only really exercised by generic_const_exprs
586                        DefineOpaqueTypes::Yes,
587                        ct_ty,
588                        ty,
589                    ) {
590                        Ok(inf_ok) => ProcessResult::Changed(mk_pending(
591                            obligation,
592                            inf_ok.into_obligations(),
593                        )),
594                        Err(_) => ProcessResult::Error(FulfillmentErrorCode::Select(
595                            SelectionError::ConstArgHasWrongType { ct, ct_ty, expected_ty: ty },
596                        )),
597                    }
598                }
599
600                // General case overflow check. Allow `process_trait_obligation`
601                // and `process_projection_obligation` to handle checking for
602                // the recursion limit themselves. Also don't check some
603                // predicate kinds that don't give further obligations.
604                _ if !self
605                    .selcx
606                    .tcx()
607                    .recursion_limit()
608                    .value_within_limit(obligation.recursion_depth) =>
609                {
610                    self.selcx.infcx.err_ctxt().report_overflow_obligation(&obligation, false);
611                }
612
613                ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
614                    if term.is_trivially_wf(self.selcx.tcx()) {
615                        return ProcessResult::Changed(thin_vec![]);
616                    }
617
618                    match wf::obligations(
619                        self.selcx.infcx,
620                        obligation.param_env,
621                        obligation.cause.body_def_id,
622                        obligation.recursion_depth + 1,
623                        term,
624                        obligation.cause.span,
625                    ) {
626                        None => {
627                            pending_obligation.stalled_on = vec![
628                                TyOrConstInferVar::maybe_from_term::<TyCtxt<'tcx>>(term).unwrap(),
629                            ];
630                            ProcessResult::Unchanged
631                        }
632                        Some(os) => ProcessResult::Changed(mk_pending(obligation, os)),
633                    }
634                }
635
636                ty::PredicateKind::Subtype(subtype) => {
637                    match self.selcx.infcx.subtype_predicate(
638                        &obligation.cause,
639                        obligation.param_env,
640                        Binder::dummy(subtype),
641                    ) {
642                        Err((a, b)) => {
643                            // None means that both are unresolved.
644                            pending_obligation.stalled_on =
645                                vec![TyOrConstInferVar::Ty(a), TyOrConstInferVar::Ty(b)];
646                            ProcessResult::Unchanged
647                        }
648                        Ok(Ok(ok)) => {
649                            ProcessResult::Changed(mk_pending(obligation, ok.obligations))
650                        }
651                        Ok(Err(err)) => {
652                            let expected_found = if subtype.a_is_expected {
653                                ExpectedFound::new(subtype.a, subtype.b)
654                            } else {
655                                ExpectedFound::new(subtype.b, subtype.a)
656                            };
657                            ProcessResult::Error(FulfillmentErrorCode::Subtype(expected_found, err))
658                        }
659                    }
660                }
661
662                ty::PredicateKind::Coerce(coerce) => {
663                    match self.selcx.infcx.coerce_predicate(
664                        &obligation.cause,
665                        obligation.param_env,
666                        Binder::dummy(coerce),
667                    ) {
668                        Err((a, b)) => {
669                            // None means that both are unresolved.
670                            pending_obligation.stalled_on =
671                                vec![TyOrConstInferVar::Ty(a), TyOrConstInferVar::Ty(b)];
672                            ProcessResult::Unchanged
673                        }
674                        Ok(Ok(ok)) => {
675                            ProcessResult::Changed(mk_pending(obligation, ok.obligations))
676                        }
677                        Ok(Err(err)) => {
678                            let expected_found = ExpectedFound::new(coerce.b, coerce.a);
679                            ProcessResult::Error(FulfillmentErrorCode::Subtype(expected_found, err))
680                        }
681                    }
682                }
683
684                ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(alias_const)) => {
685                    match const_evaluatable::is_const_evaluatable(
686                        self.selcx.infcx,
687                        alias_const,
688                        obligation.param_env,
689                        obligation.cause.span,
690                    ) {
691                        Ok(()) => ProcessResult::Changed(Default::default()),
692                        Err(NotConstEvaluatable::MentionsInfer) => {
693                            pending_obligation.stalled_on.clear();
694                            pending_obligation.stalled_on.extend(alias_const.walk().filter_map(
695                                TyOrConstInferVar::maybe_from_generic_arg::<TyCtxt<'tcx>>,
696                            ));
697                            ProcessResult::Unchanged
698                        }
699                        Err(
700                            e @ NotConstEvaluatable::MentionsParam
701                            | e @ NotConstEvaluatable::Error(_),
702                        ) => ProcessResult::Error(FulfillmentErrorCode::Select(
703                            SelectionError::NotConstEvaluatable(e),
704                        )),
705                    }
706                }
707
708                ty::PredicateKind::ConstEquate(c1, c2) => {
709                    let tcx = self.selcx.tcx();
710                    assert!(
711                        tcx.features().generic_const_exprs(),
712                        "`ConstEquate` without a feature gate: {c1:?} {c2:?}",
713                    );
714                    // FIXME: we probably should only try to unify abstract constants
715                    // if the constants depend on generic parameters.
716                    //
717                    // Let's just see where this breaks :shrug:
718                    {
719                        let c1 = tcx.expand_abstract_consts(c1);
720                        let c2 = tcx.expand_abstract_consts(c2);
721                        debug!("equating consts:\nc1= {:?}\nc2= {:?}", c1, c2);
722
723                        match (c1.kind(), c2.kind()) {
724                            (ty::ConstKind::Alias(_, a), ty::ConstKind::Alias(_, b))
725                                if a.kind == b.kind
726                                    && matches!(
727                                        a.kind,
728                                        ty::AliasConstKind::Projection { .. }
729                                            | ty::AliasConstKind::InherentSelf { .. }
730                                            | ty::AliasConstKind::InherentImpl { .. }
731                                    ) =>
732                            {
733                                if let Ok(new_obligations) = infcx
734                                    // Can define opaque types as this is only reachable with
735                                    // `generic_const_exprs`
736                                    .eq_raw(
737                                        &obligation.cause,
738                                        obligation.param_env,
739                                        DefineOpaqueTypes::Yes,
740                                        ty::AliasTerm::from(a),
741                                        ty::AliasTerm::from(b),
742                                    )
743                                {
744                                    return ProcessResult::Changed(mk_pending(
745                                        obligation,
746                                        new_obligations.into_obligations(),
747                                    ));
748                                }
749                            }
750                            (_, ty::ConstKind::Alias(_, _)) | (ty::ConstKind::Alias(_, _), _) => (),
751                            (_, _) => {
752                                if let Ok(new_obligations) = infcx
753                                    // Can define opaque types as this is only reachable with
754                                    // `generic_const_exprs`
755                                    .eq_raw(
756                                        &obligation.cause,
757                                        obligation.param_env,
758                                        DefineOpaqueTypes::Yes,
759                                        c1,
760                                        c2,
761                                    )
762                                {
763                                    return ProcessResult::Changed(mk_pending(
764                                        obligation,
765                                        new_obligations.into_obligations(),
766                                    ));
767                                }
768                            }
769                        }
770                    }
771
772                    let stalled_on = &mut pending_obligation.stalled_on;
773
774                    let mut evaluate = |c: Const<'tcx>| {
775                        if let ty::ConstKind::Alias(_, alias_const) = c.kind() {
776                            match super::try_evaluate_const(
777                                self.selcx.infcx,
778                                c,
779                                obligation.param_env,
780                                |ty| Ok::<_, !>(ty.skip_norm_wip()),
781                            ) {
782                                Ok(val) => Ok(val),
783                                e @ Err(EvaluateConstErr::HasGenericsOrInfers) => {
784                                    stalled_on.extend(alias_const.args.iter().filter_map(
785                                        TyOrConstInferVar::maybe_from_generic_arg::<TyCtxt<'tcx>>,
786                                    ));
787                                    e
788                                }
789                                e @ Err(
790                                    EvaluateConstErr::EvaluationFailure(_)
791                                    | EvaluateConstErr::InvalidConstParamTy(_),
792                                ) => e,
793                            }
794                        } else {
795                            Ok(c)
796                        }
797                    };
798
799                    match (evaluate(c1), evaluate(c2)) {
800                        (Ok(c1), Ok(c2)) => {
801                            match self.selcx.infcx.eq_raw(
802                                &obligation.cause,
803                                obligation.param_env,
804                                // Can define opaque types as this is only reachable with
805                                // `generic_const_exprs`
806                                DefineOpaqueTypes::Yes,
807                                c1,
808                                c2,
809                            ) {
810                                Ok(inf_ok) => ProcessResult::Changed(mk_pending(
811                                    obligation,
812                                    inf_ok.into_obligations(),
813                                )),
814                                Err(err) => {
815                                    ProcessResult::Error(FulfillmentErrorCode::ConstEquate(
816                                        ExpectedFound::new(c1, c2),
817                                        err,
818                                    ))
819                                }
820                            }
821                        }
822                        (Err(EvaluateConstErr::InvalidConstParamTy(e)), _)
823                        | (_, Err(EvaluateConstErr::InvalidConstParamTy(e))) => {
824                            ProcessResult::Error(FulfillmentErrorCode::Select(
825                                SelectionError::NotConstEvaluatable(NotConstEvaluatable::Error(e)),
826                            ))
827                        }
828                        (Err(EvaluateConstErr::EvaluationFailure(e)), _)
829                        | (_, Err(EvaluateConstErr::EvaluationFailure(e))) => {
830                            ProcessResult::Error(FulfillmentErrorCode::Select(
831                                SelectionError::NotConstEvaluatable(NotConstEvaluatable::Error(e)),
832                            ))
833                        }
834                        (Err(EvaluateConstErr::HasGenericsOrInfers), _)
835                        | (_, Err(EvaluateConstErr::HasGenericsOrInfers)) => {
836                            if c1.has_non_region_infer() || c2.has_non_region_infer() {
837                                ProcessResult::Unchanged
838                            } else {
839                                // Two different constants using generic parameters ~> error.
840                                let expected_found = ExpectedFound::new(c1, c2);
841                                ProcessResult::Error(FulfillmentErrorCode::ConstEquate(
842                                    expected_found,
843                                    TypeError::ConstMismatch(expected_found),
844                                ))
845                            }
846                        }
847                    }
848                }
849                ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
850                    if may_use_unstable_feature(self.selcx.infcx, obligation.param_env, symbol) {
851                        ProcessResult::Changed(Default::default())
852                    } else {
853                        ProcessResult::Unchanged
854                    }
855                }
856                ty::PredicateKind::Clause(ty::ClauseKind::CompressedTrait(_)) => unreachable!(),
857            },
858        }
859    }
860
861    #[inline(never)]
862    fn process_backedge<'c, I>(
863        &mut self,
864        cycle: I,
865        _marker: PhantomData<&'c PendingPredicateObligation<'tcx>>,
866    ) -> Result<(), FulfillmentErrorCode<'tcx>>
867    where
868        I: Clone + Iterator<Item = &'c PendingPredicateObligation<'tcx>>,
869    {
870        if self.selcx.coinductive_match(cycle.clone().map(|s| s.obligation.predicate)) {
871            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs:871",
                        "rustc_trait_selection::traits::fulfill",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs"),
                        ::tracing_core::__macro_support::Option::Some(871u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::fulfill"),
                        ::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!("process_child_obligations: coinductive match")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("process_child_obligations: coinductive match");
872            Ok(())
873        } else {
874            let cycle = cycle.map(|c| c.obligation.clone()).collect();
875            Err(FulfillmentErrorCode::Cycle(cycle))
876        }
877    }
878}
879
880impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
881    {}
#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() ||
            { false } {
        __tracing_attr_span =
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("process_trait_obligation",
                                    "rustc_trait_selection::traits::fulfill",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs"),
                                    ::tracing_core::__macro_support::Option::Some(881u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::fulfill"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("trait_obligation")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("trait_obligation");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_obligation)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return:
                    ProcessResult<PendingPredicateObligation<'tcx>,
                    FulfillmentErrorCode<'tcx>> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            if true {
                if !!self.selcx.typing_mode().is_coherence() {
                    {
                        ::core::panicking::panic_fmt(format_args!("old solver coherence"));
                    }
                };
            };
            let infcx = self.selcx.infcx;
            if obligation.predicate.is_global() {
                if infcx.predicate_must_hold_considering_regions(obligation) {
                    {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs:894",
                                            "rustc_trait_selection::traits::fulfill",
                                            ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs"),
                                            ::tracing_core::__macro_support::Option::Some(894u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::fulfill"),
                                            ::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!("selecting trait at depth {0} evaluated to holds",
                                                                        obligation.recursion_depth) as
                                                                &dyn ::tracing::field::Value))])
                                });
                        } else { ; }
                    };
                    return ProcessResult::Changed(Default::default());
                }
            }
            match self.selcx.poly_select(&trait_obligation) {
                Ok(Some(impl_source)) => {
                    {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs:904",
                                            "rustc_trait_selection::traits::fulfill",
                                            ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs"),
                                            ::tracing_core::__macro_support::Option::Some(904u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::fulfill"),
                                            ::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!("selecting trait at depth {0} yielded Ok(Some)",
                                                                        obligation.recursion_depth) as
                                                                &dyn ::tracing::field::Value))])
                                });
                        } else { ; }
                    };
                    ProcessResult::Changed(mk_pending(obligation,
                            impl_source.nested_obligations()))
                }
                Ok(None) => {
                    {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs:908",
                                            "rustc_trait_selection::traits::fulfill",
                                            ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs"),
                                            ::tracing_core::__macro_support::Option::Some(908u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::fulfill"),
                                            ::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!("selecting trait at depth {0} yielded Ok(None)",
                                                                        obligation.recursion_depth) as
                                                                &dyn ::tracing::field::Value))])
                                });
                        } else { ; }
                    };
                    stalled_on.clear();
                    stalled_on.extend(args_infer_vars(&self.selcx,
                            trait_obligation.predicate.map_bound(|pred|
                                    pred.trait_ref.args)));
                    {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs:920",
                                            "rustc_trait_selection::traits::fulfill",
                                            ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs"),
                                            ::tracing_core::__macro_support::Option::Some(920u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::fulfill"),
                                            ::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!("process_predicate: pending obligation {0:?} now stalled on {1:?}",
                                                                        infcx.deeply_resolve_ignoring_regions(obligation.clone()),
                                                                        stalled_on) as &dyn ::tracing::field::Value))])
                                });
                        } else { ; }
                    };
                    ProcessResult::Unchanged
                }
                Err(selection_err) => {
                    {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs:929",
                                            "rustc_trait_selection::traits::fulfill",
                                            ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs"),
                                            ::tracing_core::__macro_support::Option::Some(929u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::fulfill"),
                                            ::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!("selecting trait at depth {0} yielded Err",
                                                                        obligation.recursion_depth) as
                                                                &dyn ::tracing::field::Value))])
                                });
                        } else { ; }
                    };
                    ProcessResult::Error(FulfillmentErrorCode::Select(selection_err))
                }
            }
        }
    }
}#[instrument(level = "debug", skip(self, obligation, stalled_on))]
882    fn process_trait_obligation(
883        &mut self,
884        obligation: &PredicateObligation<'tcx>,
885        trait_obligation: PolyTraitObligation<'tcx>,
886        stalled_on: &mut Vec<TyOrConstInferVar>,
887    ) -> ProcessResult<PendingPredicateObligation<'tcx>, FulfillmentErrorCode<'tcx>> {
888        debug_assert!(!self.selcx.typing_mode().is_coherence(), "old solver coherence");
889        let infcx = self.selcx.infcx;
890        if obligation.predicate.is_global() {
891            // no type variables present, can use evaluation for better caching.
892            // FIXME: consider caching errors too.
893            if infcx.predicate_must_hold_considering_regions(obligation) {
894                debug!(
895                    "selecting trait at depth {} evaluated to holds",
896                    obligation.recursion_depth
897                );
898                return ProcessResult::Changed(Default::default());
899            }
900        }
901
902        match self.selcx.poly_select(&trait_obligation) {
903            Ok(Some(impl_source)) => {
904                debug!("selecting trait at depth {} yielded Ok(Some)", obligation.recursion_depth);
905                ProcessResult::Changed(mk_pending(obligation, impl_source.nested_obligations()))
906            }
907            Ok(None) => {
908                debug!("selecting trait at depth {} yielded Ok(None)", obligation.recursion_depth);
909
910                // This is a bit subtle: for the most part, the
911                // only reason we can fail to make progress on
912                // trait selection is because we don't have enough
913                // information about the types in the trait.
914                stalled_on.clear();
915                stalled_on.extend(args_infer_vars(
916                    &self.selcx,
917                    trait_obligation.predicate.map_bound(|pred| pred.trait_ref.args),
918                ));
919
920                debug!(
921                    "process_predicate: pending obligation {:?} now stalled on {:?}",
922                    infcx.deeply_resolve_ignoring_regions(obligation.clone()),
923                    stalled_on
924                );
925
926                ProcessResult::Unchanged
927            }
928            Err(selection_err) => {
929                debug!("selecting trait at depth {} yielded Err", obligation.recursion_depth);
930
931                ProcessResult::Error(FulfillmentErrorCode::Select(selection_err))
932            }
933        }
934    }
935
936    fn process_projection_obligation(
937        &mut self,
938        obligation: &PredicateObligation<'tcx>,
939        project_obligation: PolyProjectionObligation<'tcx>,
940        stalled_on: &mut Vec<TyOrConstInferVar>,
941    ) -> ProcessResult<PendingPredicateObligation<'tcx>, FulfillmentErrorCode<'tcx>> {
942        if true {
    if !!self.selcx.typing_mode().is_coherence() {
        {
            ::core::panicking::panic_fmt(format_args!("old solver coherence"));
        }
    };
};debug_assert!(!self.selcx.typing_mode().is_coherence(), "old solver coherence");
943
944        let tcx = self.selcx.tcx();
945        let infcx = self.selcx.infcx;
946        if obligation.predicate.is_global() {
947            // no type variables present, can use evaluation for better caching.
948            // FIXME: consider caching errors too.
949            if infcx.predicate_must_hold_considering_regions(obligation) {
950                if let Some(key) = ProjectionCacheKey::from_poly_projection_obligation(
951                    &mut self.selcx,
952                    &project_obligation,
953                ) {
954                    // If `predicate_must_hold_considering_regions` succeeds, then we've
955                    // evaluated all sub-obligations. We can therefore mark the 'root'
956                    // obligation as complete, and skip evaluating sub-obligations.
957                    infcx
958                        .inner
959                        .borrow_mut()
960                        .projection_cache()
961                        .complete(key, EvaluationResult::EvaluatedToOk);
962                }
963                return ProcessResult::Changed(Default::default());
964            } else {
965                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs:965",
                        "rustc_trait_selection::traits::fulfill",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_trait_selection/src/traits/fulfill.rs"),
                        ::tracing_core::__macro_support::Option::Some(965u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::fulfill"),
                        ::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!("Does NOT hold: {0:?}",
                                                    obligation) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("Does NOT hold: {:?}", obligation);
966            }
967        }
968
969        match project::poly_project_and_unify_term(&mut self.selcx, &project_obligation) {
970            ProjectAndUnifyResult::Holds(os) if os.is_empty() => {
971                ProcessResult::Changed(mk_pending(obligation, os))
972            }
973            ProjectAndUnifyResult::Holds(os) => {
974                let input_projection_term = infcx
975                    .deeply_resolve_ignoring_regions(project_obligation.predicate)
976                    .map_bound(|p| p.projection_term);
977                let all_same_projection_term = os.iter().all(|o| {
978                    let Some(proj_clause) = o.predicate.as_projection_clause() else {
979                        return false;
980                    };
981                    infcx
982                        .deeply_resolve_ignoring_regions(proj_clause)
983                        .map_bound(|p| p.projection_term)
984                        == input_projection_term
985                });
986                if all_same_projection_term {
987                    // Every nested obligation has the same projection term as the obligation
988                    // we are processing, so registering would make fulfillment process the same
989                    // obligation forever. This happens when unifying the projection with the
990                    // predicate's term spawns a delayed copy of the predicate itself, see
991                    // `InferCtxt::instantiate_var`. E.g. in Issue #159750, processing
992                    // `<_ as Queryable>::Output == ?0` returns `Holds` with the single nested
993                    // obligation `<_ as Queryable>::Output == ?1` where `?1` is merely unioned
994                    // with `?0`.
995                    // Since at this point the code will not compile, error immediately.
996                    ProcessResult::Error(FulfillmentErrorCode::Ambiguity { overflow: None })
997                } else {
998                    ProcessResult::Changed(mk_pending(obligation, os))
999                }
1000            }
1001            ProjectAndUnifyResult::FailedNormalization => {
1002                stalled_on.clear();
1003                stalled_on.extend(args_infer_vars(
1004                    &self.selcx,
1005                    project_obligation.predicate.map_bound(|pred| pred.projection_term.args),
1006                ));
1007                ProcessResult::Unchanged
1008            }
1009            // Let the caller handle the recursion
1010            ProjectAndUnifyResult::Recursive => {
1011                let mut obligations = PredicateObligations::with_capacity(1);
1012                obligations.push(project_obligation.with(tcx, project_obligation.predicate));
1013
1014                ProcessResult::Changed(mk_pending(obligation, obligations))
1015            }
1016            ProjectAndUnifyResult::MismatchedProjectionTypes(e) => {
1017                ProcessResult::Error(FulfillmentErrorCode::Project(e))
1018            }
1019        }
1020    }
1021
1022    fn process_host_obligation(
1023        &mut self,
1024        obligation: &PredicateObligation<'tcx>,
1025        host_obligation: HostEffectObligation<'tcx>,
1026        stalled_on: &mut Vec<TyOrConstInferVar>,
1027    ) -> ProcessResult<PendingPredicateObligation<'tcx>, FulfillmentErrorCode<'tcx>> {
1028        match effects::evaluate_host_effect_obligation(&mut self.selcx, &host_obligation) {
1029            Ok(nested) => ProcessResult::Changed(mk_pending(obligation, nested)),
1030            Err(effects::EvaluationFailure::Ambiguous) => {
1031                stalled_on.clear();
1032                stalled_on.extend(args_infer_vars(
1033                    &self.selcx,
1034                    ty::Binder::dummy(host_obligation.predicate.trait_ref.args),
1035                ));
1036                ProcessResult::Unchanged
1037            }
1038            Err(effects::EvaluationFailure::NoSolution) => {
1039                ProcessResult::Error(FulfillmentErrorCode::Select(SelectionError::Unimplemented))
1040            }
1041        }
1042    }
1043}
1044
1045/// Returns the set of inference variables contained in `args`.
1046fn args_infer_vars<'tcx>(
1047    selcx: &SelectionContext<'_, 'tcx>,
1048    args: ty::Binder<'tcx, GenericArgs<'tcx>>,
1049) -> impl Iterator<Item = TyOrConstInferVar> {
1050    selcx
1051        .infcx
1052        .deeply_resolve_ignoring_regions(args)
1053        .skip_binder() // ok because this check doesn't care about regions
1054        .iter()
1055        .filter(|arg| arg.has_non_region_infer())
1056        .flat_map(|arg| {
1057            let mut walker = arg.walk();
1058            while let Some(c) = walker.next() {
1059                if !c.has_non_region_infer() {
1060                    walker.visited.remove(&c);
1061                    walker.skip_current_subtree();
1062                }
1063            }
1064            walker.visited.into_iter()
1065        })
1066        .filter_map(TyOrConstInferVar::maybe_from_generic_arg::<TyCtxt<'tcx>>)
1067}
1068
1069#[derive(#[automatically_derived]impl<'tcx> ::core::fmt::Debug for OldSolverError<'tcx>
    {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "OldSolverError", &&self.0)
    }
}Debug)]
1070pub struct OldSolverError<'tcx>(
1071    Error<PendingPredicateObligation<'tcx>, FulfillmentErrorCode<'tcx>>,
1072);
1073
1074impl<'tcx> FromSolverError<'tcx, OldSolverError<'tcx>> for FulfillmentError<'tcx> {
1075    fn from_solver_error(_infcx: &InferCtxt<'tcx>, error: OldSolverError<'tcx>) -> Self {
1076        let mut iter = error.0.backtrace.into_iter();
1077        let obligation = iter.next().unwrap().obligation;
1078        // The root obligation is the last item in the backtrace - if there's only
1079        // one item, then it's the same as the main obligation
1080        let root_obligation = iter.next_back().map_or_else(|| obligation.clone(), |e| e.obligation);
1081        FulfillmentError::new(obligation, error.0.error, root_obligation)
1082    }
1083}
1084
1085impl<'tcx> FromSolverError<'tcx, OldSolverError<'tcx>> for ScrubbedTraitError<'tcx> {
1086    fn from_solver_error(_infcx: &InferCtxt<'tcx>, error: OldSolverError<'tcx>) -> Self {
1087        match error.0.error {
1088            FulfillmentErrorCode::Select(_)
1089            | FulfillmentErrorCode::Project(_)
1090            | FulfillmentErrorCode::Outlives
1091            | FulfillmentErrorCode::Subtype(_, _)
1092            | FulfillmentErrorCode::ConstEquate(_, _) => ScrubbedTraitError::TrueError,
1093            FulfillmentErrorCode::Ambiguity { overflow: _ } => ScrubbedTraitError::Ambiguity,
1094            FulfillmentErrorCode::Cycle(cycle) => ScrubbedTraitError::Cycle(cycle),
1095        }
1096    }
1097}