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::solve::NoSolution;
12use rustc_trait_selection::traits::ObligationCause;
13use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
14use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput};
15use tracing::{debug, instrument};
16
17use super::{Locations, NormalizeLocation, TypeChecker};
18use crate::BorrowckInferCtxt;
19use crate::diagnostics::ToUniverseInfo;
20use crate::type_check::{MirTypeckRegionConstraints, constraint_conversion};
21use crate::universal_regions::UniversalRegions;
22
23#[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(23u32),
::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
::tracing_core::field::FieldSet::new(&["body",
"universal_regions", "region_bound_pairs",
"known_type_outlives_obligations", "locations", "category"],
::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};
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(&body)
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(&universal_regions)
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(®ion_bound_pairs)
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(&known_type_outlives_obligations)
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(&locations)
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(&category)
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: 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:50",
"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(50u32),
::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
::tracing_core::field::FieldSet::new(&["output",
"query_constraints"],
::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(&output) as
&dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&query_constraints)
as &dyn 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")]
24pub(crate) fn fully_perform_op_raw<'tcx, R: fmt::Debug, Op>(
25 infcx: &BorrowckInferCtxt<'tcx>,
26 body: &Body<'tcx>,
27 universal_regions: &UniversalRegions<'tcx>,
28 region_bound_pairs: &RegionBoundPairs<'tcx>,
29 known_type_outlives_obligations: &[ty::PolyTypeOutlivesPredicate<'tcx>],
30 constraints: &mut MirTypeckRegionConstraints<'tcx>,
31 locations: Locations,
32 category: ConstraintCategory<'tcx>,
33 op: Op,
34) -> Result<R, ErrorGuaranteed>
35where
36 Op: type_op::TypeOp<'tcx, Output = R>,
37 Op::ErrorInfo: ToUniverseInfo<'tcx>,
38{
39 let old_universe = infcx.universe();
40
41 let TypeOpOutput { output, constraints: query_constraints, error_info } =
42 op.fully_perform(infcx, infcx.root_def_id, locations.span(body))?;
43 if cfg!(debug_assertions) {
44 let data = infcx.take_and_reset_region_constraints();
45 if !data.is_empty() {
46 panic!("leftover region constraints: {data:#?}");
47 }
48 }
49
50 debug!(?output, ?query_constraints);
51
52 if let Some(data) = query_constraints {
53 constraint_conversion::ConstraintConversion::new(
54 infcx,
55 universal_regions,
56 region_bound_pairs,
57 known_type_outlives_obligations,
58 locations,
59 locations.span(body),
60 category,
61 constraints,
62 )
63 .convert_all(data);
64 }
65
66 let universe = infcx.universe();
69 if old_universe != universe
70 && let Some(error_info) = error_info
71 {
72 let universe_info = error_info.to_universe_info(old_universe);
73 for u in (old_universe + 1)..=universe {
74 constraints.universe_causes.insert(u, universe_info.clone());
75 }
76 }
77
78 Ok(output)
79}
80
81impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
82 #[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(92u32),
::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
::tracing_core::field::FieldSet::new(&["locations",
"category"],
::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};
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(&locations)
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(&category)
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: 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")]
93 pub(super) fn fully_perform_op<R: fmt::Debug, Op>(
94 &mut self,
95 locations: Locations,
96 category: ConstraintCategory<'tcx>,
97 op: Op,
98 ) -> Result<R, ErrorGuaranteed>
99 where
100 Op: type_op::TypeOp<'tcx, Output = R>,
101 Op::ErrorInfo: ToUniverseInfo<'tcx>,
102 {
103 fully_perform_op_raw(
104 self.infcx,
105 self.body,
106 self.universal_regions,
107 self.region_bound_pairs,
108 self.known_type_outlives_obligations,
109 self.constraints,
110 locations,
111 category,
112 op,
113 )
114 }
115
116 pub(super) fn instantiate_canonical<T>(
117 &mut self,
118 span: Span,
119 canonical: &Canonical<'tcx, T>,
120 ) -> T
121 where
122 T: TypeFoldable<TyCtxt<'tcx>>,
123 {
124 let (instantiated, _) = self.infcx.instantiate_canonical(span, canonical);
125 instantiated
126 }
127
128 #[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(128u32),
::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
::tracing_core::field::FieldSet::new(&["trait_ref",
"locations", "category"],
::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(&trait_ref)
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(&locations)
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(&category)
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;
}
{
self.prove_predicate(ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitPredicate {
trait_ref,
polarity: ty::PredicatePolarity::Positive,
}))), locations, category);
}
}
}#[instrument(skip(self), level = "debug")]
129 pub(super) fn prove_trait_ref(
130 &mut self,
131 trait_ref: ty::TraitRef<'tcx>,
132 locations: Locations,
133 category: ConstraintCategory<'tcx>,
134 ) {
135 self.prove_predicate(
136 ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::Trait(
137 ty::TraitPredicate { trait_ref, polarity: ty::PredicatePolarity::Positive },
138 ))),
139 locations,
140 category,
141 );
142 }
143
144 #[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(144u32),
::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
::tracing_core::field::FieldSet::new(&["_def_id",
"instantiated_predicates", "locations"],
::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(&_def_id)
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(&instantiated_predicates)
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(&locations)
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;
}
{
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:154",
"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(154u32),
::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
::tracing_core::field::FieldSet::new(&["span", "predicate"],
::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(&span) as
&dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&predicate)
as &dyn Value))])
});
} else { ; }
};
let category = ConstraintCategory::Predicate(span);
let predicate =
self.normalize_with_category(predicate, locations,
category);
self.prove_predicate(predicate, locations, category);
}
}
}
}#[instrument(level = "debug", skip(self))]
145 pub(super) fn normalize_and_prove_instantiated_predicates(
146 &mut self,
147 _def_id: DefId,
150 instantiated_predicates: ty::InstantiatedPredicates<'tcx>,
151 locations: Locations,
152 ) {
153 for (predicate, span) in instantiated_predicates {
154 debug!(?span, ?predicate);
155 let category = ConstraintCategory::Predicate(span);
156 let predicate = self.normalize_with_category(predicate, locations, category);
157 self.prove_predicate(predicate, locations, category);
158 }
159 }
160
161 pub(super) fn prove_predicates(
162 &mut self,
163 predicates: impl IntoIterator<Item: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>> + std::fmt::Debug>,
164 locations: Locations,
165 category: ConstraintCategory<'tcx>,
166 ) {
167 for predicate in predicates {
168 self.prove_predicate(predicate, locations, category);
169 }
170 }
171
172 #[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_predicate",
"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(172u32),
::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
::tracing_core::field::FieldSet::new(&["predicate",
"locations", "category"],
::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(&predicate)
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(&locations)
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(&category)
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 param_env = self.infcx.param_env;
let predicate = predicate.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")]
173 pub(super) fn prove_predicate(
174 &mut self,
175 predicate: impl Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>> + std::fmt::Debug,
176 locations: Locations,
177 category: ConstraintCategory<'tcx>,
178 ) {
179 let param_env = self.infcx.param_env;
180 let predicate = predicate.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>(&mut self, value: T, location: impl NormalizeLocation) -> T
189 where
190 T: type_op::normalize::Normalizable<'tcx> + fmt::Display + Copy + 'tcx,
191 {
192 self.normalize_with_category(
193 Unnormalized::new_wip(value),
194 location,
195 ConstraintCategory::Boring,
196 )
197 }
198
199 pub(super) fn deeply_normalize<T>(&mut self, value: T, location: impl NormalizeLocation) -> T
200 where
201 T: type_op::normalize::Normalizable<'tcx> + fmt::Display + Copy + 'tcx,
202 {
203 let result: Result<_, ErrorGuaranteed> = self.fully_perform_op(
204 location.to_locations(),
205 ConstraintCategory::Boring,
206 self.infcx.param_env.and(type_op::normalize::DeeplyNormalize { value }),
207 );
208 result.unwrap_or(value)
209 }
210
211 #[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(211u32),
::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
::tracing_core::field::FieldSet::new(&["value", "location",
"category"],
::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(&value)
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(&location)
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(&category)
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: T = loop {};
return __tracing_attr_fake_return;
}
{
let value = value.skip_normalization();
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)
}
}
}#[instrument(skip(self), level = "debug")]
212 pub(super) fn normalize_with_category<T>(
213 &mut self,
214 value: Unnormalized<'tcx, T>,
215 location: impl NormalizeLocation,
216 category: ConstraintCategory<'tcx>,
217 ) -> T
218 where
219 T: type_op::normalize::Normalizable<'tcx> + fmt::Display + Copy + 'tcx,
220 {
221 let value = value.skip_normalization();
222 let param_env = self.infcx.param_env;
223 let result: Result<_, ErrorGuaranteed> = self.fully_perform_op(
224 location.to_locations(),
225 category,
226 param_env.and(type_op::normalize::Normalize { value }),
227 );
228 result.unwrap_or(value)
229 }
230
231 #[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(231u32),
::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
::tracing_core::field::FieldSet::new(&["ty", "location"],
::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(&ty)
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(&location)
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: 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());
if self.infcx.next_trait_solver() {
let param_env = self.infcx.param_env;
self.fully_perform_op(location.to_locations(),
ConstraintCategory::Boring,
CustomTypeOp::new(|ocx|
{
let structurally_normalize =
|ty|
{
ocx.structurally_normalize_ty(&cause, param_env,
Unnormalized::new_wip(ty)).unwrap_or_else(|_|
::rustc_middle::util::bug::bug_fmt(format_args!("struct tail should have been computable, since we computed it in HIR")))
};
let tail =
tcx.struct_tail_raw(ty, &cause, structurally_normalize,
|| {});
Ok(tail)
},
"normalizing struct tail")).unwrap_or_else(|guar|
Ty::new_error(tcx, guar))
} else {
let mut normalize = |ty| self.normalize(ty, location);
let tail =
tcx.struct_tail_raw(ty, &cause, &mut normalize, || {});
normalize(tail)
}
}
}
}#[instrument(skip(self), level = "debug")]
232 pub(super) fn struct_tail(
233 &mut self,
234 ty: Ty<'tcx>,
235 location: impl NormalizeLocation,
236 ) -> Ty<'tcx> {
237 let tcx = self.tcx();
238 let body = self.body;
239
240 let cause = ObligationCause::misc(
241 location.to_locations().span(body),
242 body.source.def_id().expect_local(),
243 );
244
245 if self.infcx.next_trait_solver() {
246 let param_env = self.infcx.param_env;
247 self.fully_perform_op(
249 location.to_locations(),
250 ConstraintCategory::Boring,
251 CustomTypeOp::new(
252 |ocx| {
253 let structurally_normalize = |ty| {
254 ocx.structurally_normalize_ty(&cause, param_env, Unnormalized::new_wip(ty))
255 .unwrap_or_else(|_| bug!("struct tail should have been computable, since we computed it in HIR"))
256 };
257
258 let tail = tcx.struct_tail_raw(
259 ty,
260 &cause,
261 structurally_normalize,
262 || {},
263 );
264
265 Ok(tail)
266 },
267 "normalizing struct tail",
268 ),
269 )
270 .unwrap_or_else(|guar| Ty::new_error(tcx, guar))
271 } else {
272 let mut normalize = |ty| self.normalize(ty, location);
273 let tail = tcx.struct_tail_raw(ty, &cause, &mut normalize, || {});
274 normalize(tail)
275 }
276 }
277
278 #[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("structurally_resolve",
"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(278u32),
::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
::tracing_core::field::FieldSet::new(&["ty", "location"],
::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(&ty)
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(&location)
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: Ty<'tcx> = loop {};
return __tracing_attr_fake_return;
}
{
if self.infcx.next_trait_solver() {
let body = self.body;
let param_env = self.infcx.param_env;
self.fully_perform_op(location.to_locations(),
ConstraintCategory::Boring,
CustomTypeOp::new(|ocx|
{
ocx.structurally_normalize_ty(&ObligationCause::misc(location.to_locations().span(body),
body.source.def_id().expect_local()), param_env,
Unnormalized::new_wip(ty)).map_err(|_| NoSolution)
},
"normalizing struct tail")).unwrap_or_else(|guar|
Ty::new_error(self.tcx(), guar))
} else { self.normalize(ty, location) }
}
}
}#[instrument(skip(self), level = "debug")]
279 pub(super) fn structurally_resolve(
280 &mut self,
281 ty: Ty<'tcx>,
282 location: impl NormalizeLocation,
283 ) -> Ty<'tcx> {
284 if self.infcx.next_trait_solver() {
285 let body = self.body;
286 let param_env = self.infcx.param_env;
287 self.fully_perform_op(
289 location.to_locations(),
290 ConstraintCategory::Boring,
291 CustomTypeOp::new(
292 |ocx| {
293 ocx.structurally_normalize_ty(
294 &ObligationCause::misc(
295 location.to_locations().span(body),
296 body.source.def_id().expect_local(),
297 ),
298 param_env,
299 Unnormalized::new_wip(ty),
300 )
301 .map_err(|_| NoSolution)
302 },
303 "normalizing struct tail",
304 ),
305 )
306 .unwrap_or_else(|guar| Ty::new_error(self.tcx(), guar))
307 } else {
308 self.normalize(ty, location)
309 }
310 }
311
312 #[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(312u32),
::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
::tracing_core::field::FieldSet::new(&["mir_ty", "user_ty",
"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(&mir_ty)
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(&user_ty)
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;
}
{
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")]
313 pub(super) fn ascribe_user_type(
314 &mut self,
315 mir_ty: Ty<'tcx>,
316 user_ty: ty::UserType<'tcx>,
317 span: Span,
318 ) {
319 let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(
320 Locations::All(span),
321 ConstraintCategory::Boring,
322 self.infcx
323 .param_env
324 .and(type_op::ascribe_user_type::AscribeUserType { mir_ty, user_ty }),
325 );
326 }
327
328 #[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(331u32),
::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::canonical"),
::tracing_core::field::FieldSet::new(&["mir_ty", "user_ty",
"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(&mir_ty)
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(&user_ty)
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;
}
{
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(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")]
332 pub(super) fn ascribe_user_type_skip_wf(
333 &mut self,
334 mir_ty: Ty<'tcx>,
335 user_ty: ty::UserType<'tcx>,
336 span: Span,
337 ) {
338 let ty::UserTypeKind::Ty(user_ty) = user_ty.kind else { bug!() };
339
340 if let ty::Infer(_) = user_ty.kind() {
342 self.eq_types(user_ty, mir_ty, Locations::All(span), ConstraintCategory::Boring)
343 .unwrap();
344 return;
345 }
346
347 let mir_ty = match self.infcx.next_trait_solver() {
353 true => mir_ty,
354 false => self.normalize(mir_ty, Locations::All(span)),
355 };
356
357 let cause = ObligationCause::dummy_with_span(span);
358 let param_env = self.infcx.param_env;
359 let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(
360 Locations::All(span),
361 ConstraintCategory::Boring,
362 type_op::custom::CustomTypeOp::new(
363 |ocx| {
364 let user_ty = ocx.normalize(&cause, param_env, Unnormalized::new_wip(user_ty));
369 ocx.eq(&cause, param_env, user_ty, mir_ty)?;
370 Ok(())
371 },
372 "ascribe_user_type_skip_wf",
373 ),
374 );
375 }
376}