Skip to main content

rustc_borrowck/type_check/
input_output.rs

1//! This module contains code to equate the input/output types appearing
2//! in the MIR with the expected input/output types from the function
3//! signature. This requires a bit of processing, as the expected types
4//! are supplied to us before normalization and may contain opaque
5//! `impl Trait` instances. In contrast, the input/output types found in
6//! the MIR (specifically, in the special local variables for the
7//! `RETURN_PLACE` the MIR arguments) are always fully normalized (and
8//! contain revealed `impl Trait` values).
9
10use std::assert_matches;
11
12use itertools::Itertools;
13use rustc_hir as hir;
14use rustc_infer::infer::{BoundRegionConversionTime, RegionVariableOrigin};
15use rustc_middle::mir::*;
16use rustc_middle::ty::{self, Ty};
17use rustc_span::Span;
18use tracing::{debug, instrument};
19
20use super::{Locations, TypeChecker};
21use crate::renumber::RegionCtxt;
22use crate::universal_regions::DefiningTy;
23
24impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25    /// Check explicit closure signature annotation,
26    /// e.g., `|x: FxIndexMap<_, &'static u32>| ...`.
27    #[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("check_signature_annotation",
                                    "rustc_borrowck::type_check::input_output",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/input_output.rs"),
                                    ::tracing_core::__macro_support::Option::Some(27u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::input_output"),
                                    ::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(&[]) })
                } 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 mir_def_id = self.body.source.def_id().expect_local();
            if !self.tcx().is_closure_like(mir_def_id.to_def_id()) { return; }
            let user_provided_poly_sig =
                self.tcx().closure_user_provided_sig(mir_def_id);
            let user_provided_sig =
                self.instantiate_canonical(self.body.span,
                    &user_provided_poly_sig);
            let mut user_provided_sig =
                self.infcx.instantiate_binder_with_fresh_vars(self.body.span,
                    BoundRegionConversionTime::FnCall, user_provided_sig);
            if let DefiningTy::CoroutineClosure(_, args) =
                    self.universal_regions.defining_ty {
                match self.tcx().coroutine_kind(self.tcx().coroutine_for_closure(mir_def_id))
                    {
                    Some(hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Async
                        | hir::CoroutineDesugaring::Gen,
                        hir::CoroutineSource::Closure)) => {}
                    ref left_val => {
                        ::core::panicking::assert_matches_failed(left_val,
                            "Some(hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Async |\nhir::CoroutineDesugaring::Gen, hir::CoroutineSource::Closure))",
                            ::core::option::Option::Some(format_args!("this needs to be modified if we\'re lowering non-async closures")));
                    }
                };
                let args = args.as_coroutine_closure();
                let tupled_upvars_ty =
                    ty::CoroutineClosureSignature::tupled_upvars_by_closure_kind(self.tcx(),
                        args.kind(),
                        Ty::new_tup(self.tcx(), user_provided_sig.inputs()),
                        args.tupled_upvars_ty(),
                        args.coroutine_captures_by_ref_ty(),
                        self.infcx.next_region_var(RegionVariableOrigin::Misc(self.body.span),
                            || { RegionCtxt::Unknown }));
                let next_ty_var = || self.infcx.next_ty_var(self.body.span);
                let output_ty =
                    Ty::new_coroutine(self.tcx(),
                        self.tcx().coroutine_for_closure(mir_def_id),
                        ty::CoroutineArgs::new(self.tcx(),
                                ty::CoroutineArgsParts {
                                    parent_args: args.parent_args(),
                                    kind_ty: Ty::from_coroutine_closure_kind(self.tcx(),
                                        args.kind()),
                                    return_ty: user_provided_sig.output(),
                                    tupled_upvars_ty,
                                    resume_ty: next_ty_var(),
                                    yield_ty: next_ty_var(),
                                }).args);
                user_provided_sig =
                    self.tcx().mk_fn_sig(user_provided_sig.inputs().iter().copied(),
                        output_ty, user_provided_sig.c_variadic,
                        user_provided_sig.safety, user_provided_sig.abi);
            }
            let is_coroutine_with_implicit_resume_ty =
                self.tcx().is_coroutine(mir_def_id.to_def_id()) &&
                    user_provided_sig.inputs().is_empty();
            for (&user_ty, arg_decl) in
                user_provided_sig.inputs().iter().zip_eq(self.body.args_iter().skip(1
                                +
                                if is_coroutine_with_implicit_resume_ty {
                                    1
                                } else { 0 }).map(|local| &self.body.local_decls[local])) {
                self.ascribe_user_type_skip_wf(arg_decl.ty,
                    ty::UserType::new(ty::UserTypeKind::Ty(user_ty)),
                    arg_decl.source_info.span);
            }
            let output_decl = &self.body.local_decls[RETURN_PLACE];
            self.ascribe_user_type_skip_wf(output_decl.ty,
                ty::UserType::new(ty::UserTypeKind::Ty(user_provided_sig.output())),
                output_decl.source_info.span);
        }
    }
}#[instrument(skip(self), level = "debug")]
28    pub(super) fn check_signature_annotation(&mut self) {
29        let mir_def_id = self.body.source.def_id().expect_local();
30
31        if !self.tcx().is_closure_like(mir_def_id.to_def_id()) {
32            return;
33        }
34
35        let user_provided_poly_sig = self.tcx().closure_user_provided_sig(mir_def_id);
36
37        // Instantiate the canonicalized variables from user-provided signature
38        // (e.g., the `_` in the code above) with fresh variables.
39        // Then replace the bound items in the fn sig with fresh variables,
40        // so that they represent the view from "inside" the closure.
41        let user_provided_sig = self.instantiate_canonical(self.body.span, &user_provided_poly_sig);
42        let mut user_provided_sig = self.infcx.instantiate_binder_with_fresh_vars(
43            self.body.span,
44            BoundRegionConversionTime::FnCall,
45            user_provided_sig,
46        );
47
48        // FIXME(async_closures): It's kind of wacky that we must apply this
49        // transformation here, since we do the same thing in HIR typeck.
50        // Maybe we could just fix up the canonicalized signature during HIR typeck?
51        if let DefiningTy::CoroutineClosure(_, args) = self.universal_regions.defining_ty {
52            assert_matches!(
53                self.tcx().coroutine_kind(self.tcx().coroutine_for_closure(mir_def_id)),
54                Some(hir::CoroutineKind::Desugared(
55                    hir::CoroutineDesugaring::Async | hir::CoroutineDesugaring::Gen,
56                    hir::CoroutineSource::Closure
57                )),
58                "this needs to be modified if we're lowering non-async closures"
59            );
60            // Make sure to use the args from `DefiningTy` so the right NLL region vids are
61            // prepopulated into the type.
62            let args = args.as_coroutine_closure();
63            let tupled_upvars_ty = ty::CoroutineClosureSignature::tupled_upvars_by_closure_kind(
64                self.tcx(),
65                args.kind(),
66                Ty::new_tup(self.tcx(), user_provided_sig.inputs()),
67                args.tupled_upvars_ty(),
68                args.coroutine_captures_by_ref_ty(),
69                self.infcx.next_region_var(RegionVariableOrigin::Misc(self.body.span), || {
70                    RegionCtxt::Unknown
71                }),
72            );
73
74            let next_ty_var = || self.infcx.next_ty_var(self.body.span);
75            let output_ty = Ty::new_coroutine(
76                self.tcx(),
77                self.tcx().coroutine_for_closure(mir_def_id),
78                ty::CoroutineArgs::new(
79                    self.tcx(),
80                    ty::CoroutineArgsParts {
81                        parent_args: args.parent_args(),
82                        kind_ty: Ty::from_coroutine_closure_kind(self.tcx(), args.kind()),
83                        return_ty: user_provided_sig.output(),
84                        tupled_upvars_ty,
85                        // For async closures, none of these can be annotated, so just fill
86                        // them with fresh ty vars.
87                        resume_ty: next_ty_var(),
88                        yield_ty: next_ty_var(),
89                    },
90                )
91                .args,
92            );
93
94            user_provided_sig = self.tcx().mk_fn_sig(
95                user_provided_sig.inputs().iter().copied(),
96                output_ty,
97                user_provided_sig.c_variadic,
98                user_provided_sig.safety,
99                user_provided_sig.abi,
100            );
101        }
102
103        let is_coroutine_with_implicit_resume_ty = self.tcx().is_coroutine(mir_def_id.to_def_id())
104            && user_provided_sig.inputs().is_empty();
105
106        for (&user_ty, arg_decl) in user_provided_sig.inputs().iter().zip_eq(
107            // In MIR, closure args begin with an implicit `self`.
108            // Also, coroutines have a resume type which may be implicitly `()`.
109            self.body
110                .args_iter()
111                .skip(1 + if is_coroutine_with_implicit_resume_ty { 1 } else { 0 })
112                .map(|local| &self.body.local_decls[local]),
113        ) {
114            self.ascribe_user_type_skip_wf(
115                arg_decl.ty,
116                ty::UserType::new(ty::UserTypeKind::Ty(user_ty)),
117                arg_decl.source_info.span,
118            );
119        }
120
121        // If the user explicitly annotated the output type, enforce it.
122        let output_decl = &self.body.local_decls[RETURN_PLACE];
123        self.ascribe_user_type_skip_wf(
124            output_decl.ty,
125            ty::UserType::new(ty::UserTypeKind::Ty(user_provided_sig.output())),
126            output_decl.source_info.span,
127        );
128    }
129
130    //  FIXME(BoxyUwU): This should probably be part of a larger borrowck dev-guide chapter
131    //
132    /// Enforce that the types of the locals corresponding to the inputs and output of
133    /// the body are equal to those of the (normalized) signature.
134    ///
135    /// This is necessary for two reasons:
136    /// - Locals in the MIR all start out with `'erased` regions and then are replaced
137    ///    with unconstrained nll vars. If we have a function returning `&'a u32` then
138    ///    the local `_0: &'?10 u32` needs to have its region var equated with the nll
139    ///    var representing `'a`. i.e. borrow check must uphold that `'?10 = 'a`.
140    /// - When computing the normalized signature we may introduce new unconstrained nll
141    ///    vars due to higher ranked where clauses ([#136547]). We then wind up with implied
142    ///    bounds involving these vars.
143    ///
144    ///    For this reason it is important that we equate with the *normalized* signature
145    ///    which was produced when computing implied bounds. If we do not do so then we will
146    ///    wind up with implied bounds on nll vars which cannot actually be used as the nll
147    ///    var never gets related to anything.
148    ///
149    /// For 'closure-like' bodies this function effectively relates the *inferred* signature
150    /// of the closure against the locals corresponding to the closure's inputs/output. It *does
151    /// not* relate the user provided types for the signature to the locals, this is handled
152    /// separately by: [`TypeChecker::check_signature_annotation`].
153    ///
154    /// [#136547]: <https://www.github.com/rust-lang/rust/issues/136547>
155    #[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("equate_inputs_and_outputs",
                                    "rustc_borrowck::type_check::input_output",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/input_output.rs"),
                                    ::tracing_core::__macro_support::Option::Some(155u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::input_output"),
                                    ::tracing_core::field::FieldSet::new(&["normalized_inputs_and_output"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&normalized_inputs_and_output)
                                                            as &dyn 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 (&normalized_output_ty, normalized_input_tys) =
                normalized_inputs_and_output.split_last().unwrap();
            {
                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/input_output.rs:160",
                                    "rustc_borrowck::type_check::input_output",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/input_output.rs"),
                                    ::tracing_core::__macro_support::Option::Some(160u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::input_output"),
                                    ::tracing_core::field::FieldSet::new(&["normalized_output_ty"],
                                        ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&normalized_output_ty)
                                                        as &dyn Value))])
                        });
                } else { ; }
            };
            {
                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/input_output.rs:161",
                                    "rustc_borrowck::type_check::input_output",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/input_output.rs"),
                                    ::tracing_core::__macro_support::Option::Some(161u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::input_output"),
                                    ::tracing_core::field::FieldSet::new(&["normalized_input_tys"],
                                        ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&normalized_input_tys)
                                                        as &dyn Value))])
                        });
                } else { ; }
            };
            for (argument_index, &normalized_input_ty) in
                normalized_input_tys.iter().enumerate() {
                if argument_index + 1 >= self.body.local_decls.len() {
                    self.tcx().dcx().span_bug(self.body.span,
                        "found more normalized_input_ty than local_decls");
                }
                let local = Local::from_usize(argument_index + 1);
                let mir_input_ty = self.body.local_decls[local].ty;
                let mir_input_span =
                    self.body.local_decls[local].source_info.span;
                self.equate_normalized_input_or_output(normalized_input_ty,
                    mir_input_ty, mir_input_span);
            }
            if let Some(mir_yield_ty) = self.body.yield_ty() {
                let yield_span =
                    self.body.local_decls[RETURN_PLACE].source_info.span;
                self.equate_normalized_input_or_output(self.universal_regions.yield_ty.unwrap(),
                    mir_yield_ty, yield_span);
            }
            if let Some(mir_resume_ty) = self.body.resume_ty() {
                let yield_span =
                    self.body.local_decls[RETURN_PLACE].source_info.span;
                self.equate_normalized_input_or_output(self.universal_regions.resume_ty.unwrap(),
                    mir_resume_ty, yield_span);
            }
            let mir_output_ty = self.body.return_ty();
            let output_span =
                self.body.local_decls[RETURN_PLACE].source_info.span;
            self.equate_normalized_input_or_output(normalized_output_ty,
                mir_output_ty, output_span);
        }
    }
}#[instrument(skip(self), level = "debug")]
156    pub(super) fn equate_inputs_and_outputs(&mut self, normalized_inputs_and_output: &[Ty<'tcx>]) {
157        let (&normalized_output_ty, normalized_input_tys) =
158            normalized_inputs_and_output.split_last().unwrap();
159
160        debug!(?normalized_output_ty);
161        debug!(?normalized_input_tys);
162
163        // Equate expected input tys with those in the MIR.
164        for (argument_index, &normalized_input_ty) in normalized_input_tys.iter().enumerate() {
165            if argument_index + 1 >= self.body.local_decls.len() {
166                self.tcx()
167                    .dcx()
168                    .span_bug(self.body.span, "found more normalized_input_ty than local_decls");
169            }
170
171            // In MIR, argument N is stored in local N+1.
172            let local = Local::from_usize(argument_index + 1);
173
174            let mir_input_ty = self.body.local_decls[local].ty;
175
176            let mir_input_span = self.body.local_decls[local].source_info.span;
177            self.equate_normalized_input_or_output(
178                normalized_input_ty,
179                mir_input_ty,
180                mir_input_span,
181            );
182        }
183
184        if let Some(mir_yield_ty) = self.body.yield_ty() {
185            let yield_span = self.body.local_decls[RETURN_PLACE].source_info.span;
186            self.equate_normalized_input_or_output(
187                self.universal_regions.yield_ty.unwrap(),
188                mir_yield_ty,
189                yield_span,
190            );
191        }
192
193        if let Some(mir_resume_ty) = self.body.resume_ty() {
194            let yield_span = self.body.local_decls[RETURN_PLACE].source_info.span;
195            self.equate_normalized_input_or_output(
196                self.universal_regions.resume_ty.unwrap(),
197                mir_resume_ty,
198                yield_span,
199            );
200        }
201
202        // Equate expected output ty with the type of the RETURN_PLACE in MIR
203        let mir_output_ty = self.body.return_ty();
204        let output_span = self.body.local_decls[RETURN_PLACE].source_info.span;
205        self.equate_normalized_input_or_output(normalized_output_ty, mir_output_ty, output_span);
206    }
207
208    #[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("equate_normalized_input_or_output",
                                    "rustc_borrowck::type_check::input_output",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/input_output.rs"),
                                    ::tracing_core::__macro_support::Option::Some(208u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::input_output"),
                                    ::tracing_core::field::FieldSet::new(&["a", "b", "span"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&a)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&b)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            as &dyn 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;
        }
        {
            if self.infcx.next_trait_solver() {
                return self.eq_types(a, b, Locations::All(span),
                            ConstraintCategory::BoringNoLocation).unwrap_or_else(|terr|
                            {
                                {
                                    crate::type_check::mirbug(self.tcx(), self.last_span,
                                        ::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("broken MIR in {0:?} ({1:?}): {2}",
                                                        self.body().source.def_id(), Location::START,
                                                        format_args!("equate_normalized_input_or_output: `{0:?}=={1:?}` failed with `{2:?}`",
                                                            a, b, terr)))
                                            }))
                                };
                            });
            }
            if let Err(_) =
                    self.eq_types(a, b, Locations::All(span),
                        ConstraintCategory::BoringNoLocation) {
                let b = self.normalize(b, Locations::All(span));
                self.eq_types(a, b, Locations::All(span),
                        ConstraintCategory::BoringNoLocation).unwrap_or_else(|terr|
                        {
                            {
                                crate::type_check::mirbug(self.tcx(), self.last_span,
                                    ::alloc::__export::must_use({
                                            ::alloc::fmt::format(format_args!("broken MIR in {0:?} ({1:?}): {2}",
                                                    self.body().source.def_id(), Location::START,
                                                    format_args!("equate_normalized_input_or_output: `{0:?}=={1:?}` failed with `{2:?}`",
                                                        a, b, terr)))
                                        }))
                            };
                        });
            };
        }
    }
}#[instrument(skip(self), level = "debug")]
209    fn equate_normalized_input_or_output(&mut self, a: Ty<'tcx>, b: Ty<'tcx>, span: Span) {
210        if self.infcx.next_trait_solver() {
211            return self
212                .eq_types(a, b, Locations::All(span), ConstraintCategory::BoringNoLocation)
213                .unwrap_or_else(|terr| {
214                    span_mirbug!(
215                        self,
216                        Location::START,
217                        "equate_normalized_input_or_output: `{a:?}=={b:?}` failed with `{terr:?}`",
218                    );
219                });
220        }
221
222        // This is a hack. `body.local_decls` are not necessarily normalized in the old
223        // solver due to not deeply normalizing in writeback. So we must re-normalize here.
224        //
225        // However, in most cases normalizing is unnecessary so we only do so if it may be
226        // necessary for type equality to hold. This leads to some (very minor) performance
227        // wins.
228        if let Err(_) =
229            self.eq_types(a, b, Locations::All(span), ConstraintCategory::BoringNoLocation)
230        {
231            let b = self.normalize(b, Locations::All(span));
232            self.eq_types(a, b, Locations::All(span), ConstraintCategory::BoringNoLocation)
233                .unwrap_or_else(|terr| {
234                    span_mirbug!(
235                        self,
236                        Location::START,
237                        "equate_normalized_input_or_output: `{a:?}=={b:?}` failed with `{terr:?}`",
238                    );
239                });
240        };
241    }
242}