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