Skip to main content

rustc_borrowck/type_check/
canonical.rs

1use std::fmt;
2
3use rustc_errors::ErrorGuaranteed;
4use rustc_infer::infer::canonical::Canonical;
5use rustc_infer::infer::outlives::env::RegionBoundPairs;
6use rustc_middle::bug;
7use rustc_middle::mir::{Body, ConstraintCategory};
8use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, Unnormalized, Upcast};
9use rustc_span::Span;
10use rustc_span::def_id::DefId;
11use rustc_trait_selection::traits::ObligationCause;
12use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput};
13use tracing::{debug, instrument};
14
15use super::{Locations, NormalizeLocation, TypeChecker};
16use crate::BorrowckInferCtxt;
17use crate::diagnostics::ToUniverseInfo;
18use crate::type_check::{MirTypeckRegionConstraints, constraint_conversion};
19use crate::universal_regions::UniversalRegions;
20
21#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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("fully_perform_op_raw",
                                    "rustc_borrowck::type_check::canonical",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/canonical.rs"),
                                    ::tracing_core::__macro_support::Option::Some(21u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("body")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("body");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("universal_regions")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("universal_regions");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("region_bound_pairs")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("region_bound_pairs");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("known_type_outlives_obligations")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("known_type_outlives_obligations");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("locations")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("locations");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("category")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("category");
                                                        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::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::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(&body)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&universal_regions)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region_bound_pairs)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&known_type_outlives_obligations)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&locations)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&category)
                                                            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: Result<R, ErrorGuaranteed> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            let old_universe = infcx.universe();
            let TypeOpOutput {
                    output, constraints: query_constraints, error_info } =
                op.fully_perform(infcx, infcx.root_def_id,
                        locations.span(body))?;
            if true {
                let data = infcx.take_and_reset_region_constraints();
                if !data.is_empty() {
                    {
                        ::core::panicking::panic_fmt(format_args!("leftover region constraints: {0:#?}",
                                data));
                    };
                }
            }
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/type_check/canonical.rs:48",
                                    "rustc_borrowck::type_check::canonical",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/canonical.rs"),
                                    ::tracing_core::__macro_support::Option::Some(48u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("output")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("output");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("query_constraints")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("query_constraints");
                                                        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(&::tracing::field::debug(&output)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&query_constraints)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            if let Some(data) = query_constraints {
                constraint_conversion::ConstraintConversion::new(infcx,
                        universal_regions, region_bound_pairs,
                        known_type_outlives_obligations, locations,
                        locations.span(body), category,
                        constraints).convert_all(data);
            }
            let universe = infcx.universe();
            if old_universe != universe && let Some(error_info) = error_info {
                let universe_info = error_info.to_universe_info(old_universe);
                for u in (old_universe + 1)..=universe {
                    constraints.universe_causes.insert(u,
                        universe_info.clone());
                }
            }
            Ok(output)
        }
    }
}#[instrument(skip(infcx, constraints, op), level = "trace")]
22pub(crate) fn fully_perform_op_raw<'tcx, R: fmt::Debug, Op>(
23    infcx: &BorrowckInferCtxt<'tcx>,
24    body: &Body<'tcx>,
25    universal_regions: &UniversalRegions<'tcx>,
26    region_bound_pairs: &RegionBoundPairs<'tcx>,
27    known_type_outlives_obligations: &[ty::PolyTypeOutlivesPredicate<'tcx>],
28    constraints: &mut MirTypeckRegionConstraints<'tcx>,
29    locations: Locations,
30    category: ConstraintCategory<'tcx>,
31    op: Op,
32) -> Result<R, ErrorGuaranteed>
33where
34    Op: type_op::TypeOp<'tcx, Output = R>,
35    Op::ErrorInfo: ToUniverseInfo<'tcx>,
36{
37    let old_universe = infcx.universe();
38
39    let TypeOpOutput { output, constraints: query_constraints, error_info } =
40        op.fully_perform(infcx, infcx.root_def_id, locations.span(body))?;
41    if cfg!(debug_assertions) {
42        let data = infcx.take_and_reset_region_constraints();
43        if !data.is_empty() {
44            panic!("leftover region constraints: {data:#?}");
45        }
46    }
47
48    debug!(?output, ?query_constraints);
49
50    if let Some(data) = query_constraints {
51        constraint_conversion::ConstraintConversion::new(
52            infcx,
53            universal_regions,
54            region_bound_pairs,
55            known_type_outlives_obligations,
56            locations,
57            locations.span(body),
58            category,
59            constraints,
60        )
61        .convert_all(data);
62    }
63
64    // If the query has created new universes and errors are going to be emitted, register the
65    // cause of these new universes for improved diagnostics.
66    let universe = infcx.universe();
67    if old_universe != universe
68        && let Some(error_info) = error_info
69    {
70        let universe_info = error_info.to_universe_info(old_universe);
71        for u in (old_universe + 1)..=universe {
72            constraints.universe_causes.insert(u, universe_info.clone());
73        }
74    }
75
76    Ok(output)
77}
78
79impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
80    /// Given some operation `op` that manipulates types, proves
81    /// predicates, or otherwise uses the inference context, executes
82    /// `op` and then executes all the further obligations that `op`
83    /// returns. This will yield a set of outlives constraints amongst
84    /// regions which are extracted and stored as having occurred at
85    /// `locations`.
86    ///
87    /// **Any `rustc_infer::infer` operations that might generate region
88    /// constraints should occur within this method so that those
89    /// constraints can be properly localized!**
90    #[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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("fully_perform_op",
                                    "rustc_borrowck::type_check::canonical",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/canonical.rs"),
                                    ::tracing_core::__macro_support::Option::Some(90u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("locations")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("locations");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("category")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("category");
                                                        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::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::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(&locations)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&category)
                                                            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: Result<R, ErrorGuaranteed> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            fully_perform_op_raw(self.infcx, self.body,
                self.universal_regions, self.region_bound_pairs,
                self.known_type_outlives_obligations, self.constraints,
                locations, category, op)
        }
    }
}#[instrument(skip(self, op), level = "trace")]
91    pub(super) fn fully_perform_op<R: fmt::Debug, Op>(
92        &mut self,
93        locations: Locations,
94        category: ConstraintCategory<'tcx>,
95        op: Op,
96    ) -> Result<R, ErrorGuaranteed>
97    where
98        Op: type_op::TypeOp<'tcx, Output = R>,
99        Op::ErrorInfo: ToUniverseInfo<'tcx>,
100    {
101        fully_perform_op_raw(
102            self.infcx,
103            self.body,
104            self.universal_regions,
105            self.region_bound_pairs,
106            self.known_type_outlives_obligations,
107            self.constraints,
108            locations,
109            category,
110            op,
111        )
112    }
113
114    pub(super) fn instantiate_canonical<T>(
115        &mut self,
116        span: Span,
117        canonical: &Canonical<'tcx, T>,
118    ) -> T
119    where
120        T: TypeFoldable<TyCtxt<'tcx>>,
121    {
122        let (instantiated, _) = self.infcx.instantiate_canonical(span, canonical);
123        instantiated
124    }
125
126    #[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("prove_trait_ref",
                                    "rustc_borrowck::type_check::canonical",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/canonical.rs"),
                                    ::tracing_core::__macro_support::Option::Some(126u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("trait_ref")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("trait_ref");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("locations")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("locations");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("category")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("category");
                                                        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_ref)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&locations)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&category)
                                                            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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            self.prove_clause(ty::ClauseKind::Trait(ty::TraitPredicate {
                        trait_ref,
                        polarity: ty::PredicatePolarity::Positive,
                    }), locations, category);
        }
    }
}#[instrument(skip(self), level = "debug")]
127    pub(super) fn prove_trait_ref(
128        &mut self,
129        trait_ref: ty::TraitRef<'tcx>,
130        locations: Locations,
131        category: ConstraintCategory<'tcx>,
132    ) {
133        self.prove_clause(
134            ty::ClauseKind::Trait(ty::TraitPredicate {
135                trait_ref,
136                polarity: ty::PredicatePolarity::Positive,
137            }),
138            locations,
139            category,
140        );
141    }
142
143    #[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("normalize_and_prove_instantiated_predicates",
                                    "rustc_borrowck::type_check::canonical",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/canonical.rs"),
                                    ::tracing_core::__macro_support::Option::Some(143u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("_def_id")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("_def_id");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("instantiated_predicates")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("instantiated_predicates");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("locations")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("locations");
                                                        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(&_def_id)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&instantiated_predicates)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&locations)
                                                            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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            for (predicate, span) in instantiated_predicates {
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/type_check/canonical.rs:153",
                                        "rustc_borrowck::type_check::canonical",
                                        ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/canonical.rs"),
                                        ::tracing_core::__macro_support::Option::Some(153u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
                                        ::tracing_core::field::FieldSet::new(&[{
                                                            const NAME:
                                                                ::tracing::__macro_support::FieldName<{
                                                                    ::tracing::__macro_support::FieldName::len("span")
                                                                }> =
                                                                ::tracing::__macro_support::FieldName::new("span");
                                                            NAME.as_str()
                                                        },
                                                        {
                                                            const NAME:
                                                                ::tracing::__macro_support::FieldName<{
                                                                    ::tracing::__macro_support::FieldName::len("predicate")
                                                                }> =
                                                                ::tracing::__macro_support::FieldName::new("predicate");
                                                            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(&::tracing::field::debug(&span)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&predicate)
                                                            as &dyn ::tracing::field::Value))])
                            });
                    } else { ; }
                };
                let category = ConstraintCategory::Predicate(span);
                let clause =
                    self.normalize_with_category(predicate, locations,
                        category);
                self.prove_clause(clause, locations, category);
            }
        }
    }
}#[instrument(level = "debug", skip(self))]
144    pub(super) fn normalize_and_prove_instantiated_predicates(
145        &mut self,
146        // Keep this parameter for now, in case we start using
147        // it in `ConstraintCategory` at some point.
148        _def_id: DefId,
149        instantiated_predicates: ty::InstantiatedPredicates<'tcx>,
150        locations: Locations,
151    ) {
152        for (predicate, span) in instantiated_predicates {
153            debug!(?span, ?predicate);
154            let category = ConstraintCategory::Predicate(span);
155            let clause = self.normalize_with_category(predicate, locations, category);
156            self.prove_clause(clause, locations, category);
157        }
158    }
159
160    pub(super) fn prove_clauses(
161        &mut self,
162        clauses: impl IntoIterator<Item: Upcast<TyCtxt<'tcx>, ty::Clause<'tcx>> + std::fmt::Debug>,
163        locations: Locations,
164        category: ConstraintCategory<'tcx>,
165    ) {
166        for clause in clauses {
167            self.prove_clause(clause, locations, category);
168        }
169    }
170
171    #[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("prove_clause",
                                    "rustc_borrowck::type_check::canonical",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/canonical.rs"),
                                    ::tracing_core::__macro_support::Option::Some(171u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("clause")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("clause");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("locations")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("locations");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("category")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("category");
                                                        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(&clause)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&locations)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&category)
                                                            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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let param_env = self.infcx.param_env;
            let predicate = clause.upcast(self.tcx()).upcast(self.tcx());
            let _: Result<_, ErrorGuaranteed> =
                self.fully_perform_op(locations, category,
                    param_env.and(type_op::prove_predicate::ProvePredicate {
                            predicate,
                        }));
        }
    }
}#[instrument(skip(self), level = "debug")]
172    pub(super) fn prove_clause(
173        &mut self,
174        clause: impl Upcast<TyCtxt<'tcx>, ty::Clause<'tcx>> + std::fmt::Debug,
175        locations: Locations,
176        category: ConstraintCategory<'tcx>,
177    ) {
178        let param_env = self.infcx.param_env;
179        // Upcast to a `Clause`, then to a `Predicate`.
180        let predicate = clause.upcast(self.tcx()).upcast(self.tcx());
181        let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(
182            locations,
183            category,
184            param_env.and(type_op::prove_predicate::ProvePredicate { predicate }),
185        );
186    }
187
188    pub(super) fn normalize<T>(
189        &mut self,
190        value: Unnormalized<'tcx, T>,
191        location: impl NormalizeLocation,
192    ) -> T
193    where
194        T: type_op::normalize::Normalizable<'tcx> + fmt::Display + Copy + 'tcx,
195    {
196        self.normalize_with_category(value, location, ConstraintCategory::Boring)
197    }
198
199    pub(super) fn deeply_normalize<T>(
200        &mut self,
201        value: Unnormalized<'tcx, T>,
202        location: impl NormalizeLocation,
203    ) -> Result<T, ErrorGuaranteed>
204    where
205        T: type_op::normalize::Normalizable<'tcx> + fmt::Display + Copy + 'tcx,
206    {
207        self.fully_perform_op(
208            location.to_locations(),
209            ConstraintCategory::Boring,
210            self.infcx.param_env.and(type_op::normalize::Normalize { value }),
211        )
212    }
213
214    #[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("normalize_with_category",
                                    "rustc_borrowck::type_check::canonical",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/canonical.rs"),
                                    ::tracing_core::__macro_support::Option::Some(214u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("value")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("value");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("location")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("location");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("category")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("category");
                                                        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(&value)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&location)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&category)
                                                            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: T = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let param_env = self.infcx.param_env;
            let result: Result<_, ErrorGuaranteed> =
                self.fully_perform_op(location.to_locations(), category,
                    param_env.and(type_op::normalize::Normalize { value }));
            result.unwrap_or(value.skip_norm_wip())
        }
    }
}#[instrument(skip(self), level = "debug")]
215    pub(super) fn normalize_with_category<T>(
216        &mut self,
217        value: Unnormalized<'tcx, T>,
218        location: impl NormalizeLocation,
219        category: ConstraintCategory<'tcx>,
220    ) -> T
221    where
222        T: type_op::normalize::Normalizable<'tcx> + fmt::Display + Copy + 'tcx,
223    {
224        let param_env = self.infcx.param_env;
225        let result: Result<_, ErrorGuaranteed> = self.fully_perform_op(
226            location.to_locations(),
227            category,
228            param_env.and(type_op::normalize::Normalize { value }),
229        );
230        result.unwrap_or(value.skip_norm_wip())
231    }
232
233    #[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("struct_tail",
                                    "rustc_borrowck::type_check::canonical",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/canonical.rs"),
                                    ::tracing_core::__macro_support::Option::Some(233u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("ty");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("location")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("location");
                                                        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(&ty)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&location)
                                                            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: Ty<'tcx> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let tcx = self.tcx();
            let body = self.body;
            let cause =
                ObligationCause::misc(location.to_locations().span(body),
                    body.source.def_id().expect_local());
            let mut normalize = |ty| self.normalize(ty, location);
            tcx.struct_tail_raw(ty, &cause, &mut normalize, || {})
        }
    }
}#[instrument(skip(self), level = "debug")]
234    pub(super) fn struct_tail(
235        &mut self,
236        ty: Ty<'tcx>,
237        location: impl NormalizeLocation,
238    ) -> Ty<'tcx> {
239        let tcx = self.tcx();
240        let body = self.body;
241
242        let cause = ObligationCause::misc(
243            location.to_locations().span(body),
244            body.source.def_id().expect_local(),
245        );
246
247        let mut normalize = |ty| self.normalize(ty, location);
248        tcx.struct_tail_raw(ty, &cause, &mut normalize, || {})
249    }
250
251    #[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("ascribe_user_type",
                                    "rustc_borrowck::type_check::canonical",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/canonical.rs"),
                                    ::tracing_core::__macro_support::Option::Some(251u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("mir_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("mir_ty");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("user_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("user_ty");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("span")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("span");
                                                        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(&mir_ty)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&user_ty)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let _: Result<_, ErrorGuaranteed> =
                self.fully_perform_op(Locations::All(span),
                    ConstraintCategory::Boring,
                    self.infcx.param_env.and(type_op::ascribe_user_type::AscribeUserType {
                            mir_ty,
                            user_ty,
                        }));
        }
    }
}#[instrument(skip(self), level = "debug")]
252    pub(super) fn ascribe_user_type(
253        &mut self,
254        mir_ty: Ty<'tcx>,
255        user_ty: ty::UserType<'tcx>,
256        span: Span,
257    ) {
258        let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(
259            Locations::All(span),
260            ConstraintCategory::Boring,
261            self.infcx
262                .param_env
263                .and(type_op::ascribe_user_type::AscribeUserType { mir_ty, user_ty }),
264        );
265    }
266
267    /// *Incorrectly* skips the WF checks we normally do in `ascribe_user_type`.
268    ///
269    /// FIXME(#104478, #104477): This is a hack for backward-compatibility.
270    #[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("ascribe_user_type_skip_wf",
                                    "rustc_borrowck::type_check::canonical",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/canonical.rs"),
                                    ::tracing_core::__macro_support::Option::Some(270u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("mir_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("mir_ty");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("user_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("user_ty");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("span")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("span");
                                                        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(&mir_ty)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&user_ty)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let ty::UserTypeKind::Ty(user_ty) =
                user_ty.kind else {
                    ::rustc_middle::util::bug::bug_fmt(format_args!("impossible case reached"))
                };
            if let ty::Infer(_) = user_ty.kind() {
                self.eq_types(user_ty, mir_ty, Locations::All(span),
                        ConstraintCategory::Boring).unwrap();
                return;
            }
            let mir_ty =
                match self.infcx.next_trait_solver() {
                    true => mir_ty,
                    false =>
                        self.normalize(Unnormalized::new_wip(mir_ty),
                            Locations::All(span)),
                };
            let cause = ObligationCause::dummy_with_span(span);
            let param_env = self.infcx.param_env;
            let _: Result<_, ErrorGuaranteed> =
                self.fully_perform_op(Locations::All(span),
                    ConstraintCategory::Boring,
                    type_op::custom::CustomTypeOp::new(|ocx|
                            {
                                let user_ty =
                                    ocx.normalize(&cause, param_env,
                                        Unnormalized::new_wip(user_ty));
                                ocx.eq(&cause, param_env, user_ty, mir_ty)?;
                                Ok(())
                            }, "ascribe_user_type_skip_wf"));
        }
    }
}#[instrument(skip(self), level = "debug")]
271    pub(super) fn ascribe_user_type_skip_wf(
272        &mut self,
273        mir_ty: Ty<'tcx>,
274        user_ty: ty::UserType<'tcx>,
275        span: Span,
276    ) {
277        let ty::UserTypeKind::Ty(user_ty) = user_ty.kind else { bug!() };
278
279        // A fast path for a common case with closure input/output types.
280        if let ty::Infer(_) = user_ty.kind() {
281            self.eq_types(user_ty, mir_ty, Locations::All(span), ConstraintCategory::Boring)
282                .unwrap();
283            return;
284        }
285
286        // This is a hack. `body.local_decls` are not necessarily normalized in the old
287        // solver due to not deeply normalizing in writeback. So we must re-normalize here.
288        //
289        // I am not sure of a test case where this actually matters. There is a similar
290        // hack in `equate_inputs_and_outputs` which does have associated test cases.
291        let mir_ty = match self.infcx.next_trait_solver() {
292            true => mir_ty,
293            false => self.normalize(Unnormalized::new_wip(mir_ty), Locations::All(span)),
294        };
295
296        let cause = ObligationCause::dummy_with_span(span);
297        let param_env = self.infcx.param_env;
298        let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(
299            Locations::All(span),
300            ConstraintCategory::Boring,
301            type_op::custom::CustomTypeOp::new(
302                |ocx| {
303                    // The `AscribeUserType` query would normally emit a wf
304                    // obligation for the unnormalized user_ty here. This is
305                    // where the "incorrectly skips the WF checks we normally do"
306                    // happens
307                    let user_ty = ocx.normalize(&cause, param_env, Unnormalized::new_wip(user_ty));
308                    ocx.eq(&cause, param_env, user_ty, mir_ty)?;
309                    Ok(())
310                },
311                "ascribe_user_type_skip_wf",
312            ),
313        );
314    }
315}