1use std::ops::Range;
4use std::{cmp, fmt, iter, mem};
5
6use rustc_data_structures::fx::FxHashMap;
7use rustc_data_structures::undo_log::UndoLogs;
8use rustc_data_structures::unify as ut;
9use rustc_index::IndexVec;
10use rustc_macros::{TypeFoldable, TypeVisitable};
11use rustc_middle::ty::{self, ReBound, ReStatic, ReVar, Region, RegionVid, Ty, TyCtxt};
12use rustc_span::{Span, bug, span_bug};
13use rustc_type_ir::TypeVisitableExt;
14use tracing::{debug, instrument};
15
16use self::CombineMapType::*;
17use self::UndoLog::*;
18use super::{RegionVariableOrigin, Rollback, SubregionOrigin};
19use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, Snapshot};
20use crate::infer::unify_key::{RegionVariableValue, RegionVidKey};
21
22mod leak_check;
23
24#[derive(#[automatically_derived]impl<'tcx> ::core::clone::Clone for
RegionConstraintStorage<'tcx> {
#[inline]
fn clone(&self) -> Self {
RegionConstraintStorage {
var_infos: ::core::clone::Clone::clone(&self.var_infos),
legacy_data: ::core::clone::Clone::clone(&self.legacy_data),
solver_data: ::core::clone::Clone::clone(&self.solver_data),
lubs: ::core::clone::Clone::clone(&self.lubs),
glbs: ::core::clone::Clone::clone(&self.glbs),
unification_table: ::core::clone::Clone::clone(&self.unification_table),
any_unifications: ::core::clone::Clone::clone(&self.any_unifications),
}
}
}Clone, #[automatically_derived]impl<'tcx> ::core::default::Default for
RegionConstraintStorage<'tcx> {
#[inline]
fn default() -> Self {
RegionConstraintStorage {
var_infos: ::core::default::Default::default(),
legacy_data: ::core::default::Default::default(),
solver_data: ::core::default::Default::default(),
lubs: ::core::default::Default::default(),
glbs: ::core::default::Default::default(),
unification_table: ::core::default::Default::default(),
any_unifications: ::core::default::Default::default(),
}
}
}Default)]
25pub struct RegionConstraintStorage<'tcx> {
26 pub(super) var_infos: IndexVec<RegionVid, RegionVariableInfo<'tcx>>,
28
29 pub(super) legacy_data: RegionConstraintData<'tcx>,
30 pub(super) solver_data: SolverRegionConstraintData<'tcx>,
34
35 lubs: CombineMap<'tcx>,
39
40 glbs: CombineMap<'tcx>,
44
45 pub(super) unification_table: ut::UnificationTableStorage<RegionVidKey<'tcx>>,
54
55 any_unifications: bool,
58}
59
60pub struct RegionConstraintCollector<'a, 'tcx> {
61 storage: &'a mut RegionConstraintStorage<'tcx>,
62 undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
63}
64
65pub type VarInfos<'tcx> = IndexVec<RegionVid, RegionVariableInfo<'tcx>>;
66
67#[derive(#[automatically_derived]impl<'tcx> ::core::fmt::Debug for
RegionConstraintData<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"RegionConstraintData constraints verifys", &self.constraints,
&&self.verifys)
}
}Debug, #[automatically_derived]impl<'tcx> ::core::default::Default for
RegionConstraintData<'tcx> {
#[inline]
fn default() -> Self {
RegionConstraintData {
constraints: ::core::default::Default::default(),
verifys: ::core::default::Default::default(),
}
}
}Default, #[automatically_derived]impl<'tcx> ::core::clone::Clone for
RegionConstraintData<'tcx> {
#[inline]
fn clone(&self) -> Self {
RegionConstraintData {
constraints: ::core::clone::Clone::clone(&self.constraints),
verifys: ::core::clone::Clone::clone(&self.verifys),
}
}
}Clone)]
72pub struct RegionConstraintData<'tcx> {
73 pub constraints: Vec<(Constraint<'tcx>, SubregionOrigin<'tcx>)>,
76
77 pub verifys: Vec<Verify<'tcx>>,
84}
85
86pub type SolverRegionConstraint<'tcx> =
87 rustc_type_ir::region_constraint::RegionConstraint<TyCtxt<'tcx>, Span>;
88
89#[derive(#[automatically_derived]impl<'tcx> ::core::clone::Clone for
SolverRegionConstraintData<'tcx> {
#[inline]
fn clone(&self) -> Self {
SolverRegionConstraintData(::core::clone::Clone::clone(&self.0))
}
}Clone, #[automatically_derived]impl<'tcx> ::core::fmt::Debug for
SolverRegionConstraintData<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"SolverRegionConstraintData", &&self.0)
}
}Debug)]
90pub struct SolverRegionConstraintData<'tcx>(SolverRegionConstraint<'tcx>);
91
92impl<'tcx> Default for SolverRegionConstraintData<'tcx> {
93 fn default() -> Self {
94 Self::new()
95 }
96}
97
98impl<'tcx> SolverRegionConstraintData<'tcx> {
99 pub(crate) fn new() -> Self {
100 Self(SolverRegionConstraint::new_true())
101 }
102
103 pub(crate) fn get_constraint(&self) -> SolverRegionConstraint<'tcx> {
104 self.0.clone()
105 }
106
107 {}
#[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("overwrite",
"rustc_infer::infer::region_constraints",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs"),
::tracing_core::__macro_support::Option::Some(107u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("constraint")
}> =
::tracing::__macro_support::FieldName::new("constraint");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: () = loop {};
return __tracing_attr_fake_return;
}
{ self.0 = constraint; }
}
}#[instrument(level = "debug", skip(self))]
108 pub(crate) fn overwrite(&mut self, constraint: SolverRegionConstraint<'tcx>) {
109 self.0 = constraint;
110 }
111}
112
113#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for ConstraintKind {
}
#[automatically_derived]impl ::core::clone::Clone for ConstraintKind {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for ConstraintKind { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
ConstraintKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for ConstraintKind {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for ConstraintKind { }Eq, #[automatically_derived]impl ::core::fmt::Debug for ConstraintKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_c_like_enum_write_str(f,
"VarSubVar RegSubVar VarSubReg RegSubReg VarEqVar VarEqReg RegEqReg",
match self {
ConstraintKind::VarSubVar => 0usize,
ConstraintKind::RegSubVar => 10usize,
ConstraintKind::VarSubReg => 20usize,
ConstraintKind::RegSubReg => 30usize,
ConstraintKind::VarEqVar => 40usize,
ConstraintKind::VarEqReg => 49usize,
ConstraintKind::RegEqReg => 58usize,
})
}
}Debug, #[automatically_derived]impl ::core::hash::Hash for ConstraintKind {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash)]
115pub enum ConstraintKind {
116 VarSubVar,
118
119 RegSubVar,
121
122 VarSubReg,
126
127 RegSubReg,
131
132 VarEqVar,
134
135 VarEqReg,
139
140 RegEqReg,
144}
145
146#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
::core::clone::TrivialClone for Constraint<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for Constraint<'tcx> {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<ConstraintKind>;
let _: ::core::clone::AssertParamIsClone<Region<'tcx>>;
let _: ::core::clone::AssertParamIsClone<Region<'tcx>>;
let _: ::core::clone::AssertParamIsClone<ty::VisibleForLeakCheck>;
*self
}
}Clone, #[automatically_derived]impl<'tcx> ::core::marker::Copy for Constraint<'tcx> {
}Copy, #[automatically_derived]impl<'tcx> ::core::marker::StructuralPartialEq for
Constraint<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::cmp::PartialEq for Constraint<'tcx>
{
#[inline]
fn eq(&self, other: &Self) -> bool {
self.kind == other.kind && self.sub == other.sub &&
self.sup == other.sup &&
self.visible_for_leak_check == other.visible_for_leak_check
}
}PartialEq, #[automatically_derived]impl<'tcx> ::core::cmp::Eq for Constraint<'tcx> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<ConstraintKind>;
let _: ::core::cmp::AssertParamIsEq<Region<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<Region<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<ty::VisibleForLeakCheck>;
}
}Eq, #[automatically_derived]impl<'tcx> ::core::fmt::Debug for Constraint<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"Constraint kind sub sup visible_for_leak_check", &self.kind,
&self.sub, &self.sup, &&self.visible_for_leak_check)
}
}Debug, #[automatically_derived]impl<'tcx> ::core::hash::Hash for Constraint<'tcx> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.kind, state);
::core::hash::Hash::hash(&self.sub, state);
::core::hash::Hash::hash(&self.sup, state);
::core::hash::Hash::hash(&self.visible_for_leak_check, state)
}
}Hash)]
148pub struct Constraint<'tcx> {
149 pub kind: ConstraintKind,
150 pub sub: Region<'tcx>,
152 pub sup: Region<'tcx>,
154 pub visible_for_leak_check: ty::VisibleForLeakCheck,
155}
156
157impl Constraint<'_> {
158 pub fn involves_placeholders(&self) -> bool {
159 self.sub.is_placeholder() || self.sup.is_placeholder()
160 }
161
162 pub fn iter_outlives(self) -> impl Iterator<Item = Self> {
163 let Constraint { kind, sub, sup, visible_for_leak_check } = self;
164
165 match kind {
166 ConstraintKind::VarSubVar
167 | ConstraintKind::RegSubVar
168 | ConstraintKind::VarSubReg
169 | ConstraintKind::RegSubReg => iter::once(self).chain(None),
170
171 ConstraintKind::VarEqVar => iter::once(Constraint {
172 kind: ConstraintKind::VarSubVar,
173 sub,
174 sup,
175 visible_for_leak_check,
176 })
177 .chain(Some(Constraint {
178 kind: ConstraintKind::VarSubVar,
179 sub: sup,
180 sup: sub,
181 visible_for_leak_check,
182 })),
183 ConstraintKind::VarEqReg => iter::once(Constraint {
184 kind: ConstraintKind::VarSubReg,
185 sub,
186 sup,
187 visible_for_leak_check,
188 })
189 .chain(Some(Constraint {
190 kind: ConstraintKind::RegSubVar,
191 sub: sup,
192 sup: sub,
193 visible_for_leak_check,
194 })),
195 ConstraintKind::RegEqReg => iter::once(Constraint {
196 kind: ConstraintKind::RegSubReg,
197 sub,
198 sup,
199 visible_for_leak_check,
200 })
201 .chain(Some(Constraint {
202 kind: ConstraintKind::RegSubReg,
203 sub: sup,
204 sup: sub,
205 visible_for_leak_check,
206 })),
207 }
208 }
209}
210
211#[derive(#[automatically_derived]impl<'tcx> ::core::fmt::Debug for Verify<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"Verify kind origin region bound", &self.kind, &self.origin,
&self.region, &&self.bound)
}
}Debug, #[automatically_derived]impl<'tcx> ::core::clone::Clone for Verify<'tcx> {
#[inline]
fn clone(&self) -> Self {
Verify {
kind: ::core::clone::Clone::clone(&self.kind),
origin: ::core::clone::Clone::clone(&self.origin),
region: ::core::clone::Clone::clone(&self.region),
bound: ::core::clone::Clone::clone(&self.bound),
}
}
}Clone)]
212pub struct Verify<'tcx> {
213 pub kind: GenericKind<'tcx>,
214 pub origin: SubregionOrigin<'tcx>,
215 pub region: Region<'tcx>,
216 pub bound: VerifyBound<'tcx>,
217}
218
219#[derive(#[automatically_derived]impl<'tcx> ::core::marker::Copy for GenericKind<'tcx>
{
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
::core::clone::TrivialClone for GenericKind<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for GenericKind<'tcx>
{
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<ty::ParamTy>;
let _: ::core::clone::AssertParamIsClone<ty::PlaceholderType<'tcx>>;
let _: ::core::clone::AssertParamIsClone<ty::AliasTy<'tcx>>;
*self
}
}Clone, #[automatically_derived]impl<'tcx> ::core::marker::StructuralPartialEq for
GenericKind<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::cmp::PartialEq for
GenericKind<'tcx> {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::Param(__self_0), Self::Param(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Placeholder(__self_0), Self::Placeholder(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Alias(__self_0), Self::Alias(__arg1_0)) =>
__self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]impl<'tcx> ::core::cmp::Eq for GenericKind<'tcx> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<ty::ParamTy>;
let _: ::core::cmp::AssertParamIsEq<ty::PlaceholderType<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<ty::AliasTy<'tcx>>;
}
}Eq, #[automatically_derived]impl<'tcx> ::core::hash::Hash for GenericKind<'tcx> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
match self {
Self::Param(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
Self::Placeholder(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
Self::Alias(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
}
}
}Hash, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for GenericKind<'tcx> {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
GenericKind::Param(__binding_0) => {
GenericKind::Param(::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?)
}
GenericKind::Placeholder(__binding_0) => {
GenericKind::Placeholder(::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?)
}
GenericKind::Alias(__binding_0) => {
GenericKind::Alias(::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?)
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
GenericKind::Param(__binding_0) => {
GenericKind::Param(::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder))
}
GenericKind::Placeholder(__binding_0) => {
GenericKind::Placeholder(::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder))
}
GenericKind::Alias(__binding_0) => {
GenericKind::Alias(::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder))
}
}
}
}
};TypeFoldable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for GenericKind<'tcx> {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
GenericKind::Param(ref __binding_0) => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
GenericKind::Placeholder(ref __binding_0) => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
GenericKind::Alias(ref __binding_0) => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable)]
220pub enum GenericKind<'tcx> {
221 Param(ty::ParamTy),
222 Placeholder(ty::PlaceholderType<'tcx>),
223 Alias(ty::AliasTy<'tcx>),
226}
227
228#[derive(#[automatically_derived]impl<'tcx> ::core::fmt::Debug for VerifyBound<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::IfEq(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "IfEq",
&__self_0),
Self::OutlivedBy(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"OutlivedBy", &__self_0),
Self::IsEmpty => ::core::fmt::Formatter::write_str(f, "IsEmpty"),
Self::AnyBound(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"AnyBound", &__self_0),
Self::AllBounds(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"AllBounds", &__self_0),
}
}
}Debug, #[automatically_derived]impl<'tcx> ::core::clone::Clone for VerifyBound<'tcx>
{
#[inline]
fn clone(&self) -> Self {
match self {
Self::IfEq(__self_0) =>
VerifyBound::IfEq(::core::clone::Clone::clone(__self_0)),
Self::OutlivedBy(__self_0) =>
VerifyBound::OutlivedBy(::core::clone::Clone::clone(__self_0)),
Self::IsEmpty => VerifyBound::IsEmpty,
Self::AnyBound(__self_0) =>
VerifyBound::AnyBound(::core::clone::Clone::clone(__self_0)),
Self::AllBounds(__self_0) =>
VerifyBound::AllBounds(::core::clone::Clone::clone(__self_0)),
}
}
}Clone, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for VerifyBound<'tcx> {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
VerifyBound::IfEq(__binding_0) => {
VerifyBound::IfEq(::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?)
}
VerifyBound::OutlivedBy(__binding_0) => {
VerifyBound::OutlivedBy(::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?)
}
VerifyBound::IsEmpty => { VerifyBound::IsEmpty }
VerifyBound::AnyBound(__binding_0) => {
VerifyBound::AnyBound(::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?)
}
VerifyBound::AllBounds(__binding_0) => {
VerifyBound::AllBounds(::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?)
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
VerifyBound::IfEq(__binding_0) => {
VerifyBound::IfEq(::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder))
}
VerifyBound::OutlivedBy(__binding_0) => {
VerifyBound::OutlivedBy(::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder))
}
VerifyBound::IsEmpty => { VerifyBound::IsEmpty }
VerifyBound::AnyBound(__binding_0) => {
VerifyBound::AnyBound(::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder))
}
VerifyBound::AllBounds(__binding_0) => {
VerifyBound::AllBounds(::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder))
}
}
}
}
};TypeFoldable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for VerifyBound<'tcx> {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
VerifyBound::IfEq(ref __binding_0) => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
VerifyBound::OutlivedBy(ref __binding_0) => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
VerifyBound::IsEmpty => {}
VerifyBound::AnyBound(ref __binding_0) => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
VerifyBound::AllBounds(ref __binding_0) => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable)]
246pub enum VerifyBound<'tcx> {
247 IfEq(ty::Binder<'tcx, VerifyIfEq<'tcx>>),
249
250 OutlivedBy(Region<'tcx>),
261
262 IsEmpty,
264
265 AnyBound(Vec<VerifyBound<'tcx>>),
276
277 AllBounds(Vec<VerifyBound<'tcx>>),
289}
290
291#[derive(#[automatically_derived]impl<'tcx> ::core::fmt::Debug for VerifyIfEq<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"VerifyIfEq ty bound", &self.ty, &&self.bound)
}
}Debug, #[automatically_derived]impl<'tcx> ::core::marker::Copy for VerifyIfEq<'tcx> {
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
::core::clone::TrivialClone for VerifyIfEq<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for VerifyIfEq<'tcx> {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
let _: ::core::clone::AssertParamIsClone<Region<'tcx>>;
*self
}
}Clone, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for VerifyIfEq<'tcx> {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
VerifyIfEq { ty: __binding_0, bound: __binding_1 } => {
VerifyIfEq {
ty: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
bound: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
VerifyIfEq { ty: __binding_0, bound: __binding_1 } => {
VerifyIfEq {
ty: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder),
bound: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for VerifyIfEq<'tcx> {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
VerifyIfEq { ty: ref __binding_0, bound: ref __binding_1 }
=> {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable)]
330pub struct VerifyIfEq<'tcx> {
331 pub ty: Ty<'tcx>,
333
334 pub bound: Region<'tcx>,
336}
337
338#[derive(#[automatically_derived]impl<'tcx> ::core::marker::Copy for TwoRegions<'tcx> {
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
::core::clone::TrivialClone for TwoRegions<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for TwoRegions<'tcx> {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<Region<'tcx>>;
let _: ::core::clone::AssertParamIsClone<Region<'tcx>>;
*self
}
}Clone, #[automatically_derived]impl<'tcx> ::core::marker::StructuralPartialEq for
TwoRegions<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::cmp::PartialEq for TwoRegions<'tcx>
{
#[inline]
fn eq(&self, other: &Self) -> bool {
self.a == other.a && self.b == other.b
}
}PartialEq, #[automatically_derived]impl<'tcx> ::core::cmp::Eq for TwoRegions<'tcx> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Region<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<Region<'tcx>>;
}
}Eq, #[automatically_derived]impl<'tcx> ::core::hash::Hash for TwoRegions<'tcx> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.a, state);
::core::hash::Hash::hash(&self.b, state)
}
}Hash)]
339pub(crate) struct TwoRegions<'tcx> {
340 a: Region<'tcx>,
341 b: Region<'tcx>,
342}
343
344#[derive(#[automatically_derived]impl<'tcx> ::core::clone::Clone for UndoLog<'tcx> {
#[inline]
fn clone(&self) -> Self {
match self {
Self::AddVar(__self_0) =>
UndoLog::AddVar(::core::clone::Clone::clone(__self_0)),
Self::AddConstraint(__self_0) =>
UndoLog::AddConstraint(::core::clone::Clone::clone(__self_0)),
Self::AddVerify(__self_0) =>
UndoLog::AddVerify(::core::clone::Clone::clone(__self_0)),
Self::AddCombination(__self_0, __self_1) =>
UndoLog::AddCombination(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
Self::OverwriteSolverRegionConstraint { old_constraint: __self_0 }
=>
UndoLog::OverwriteSolverRegionConstraint {
old_constraint: ::core::clone::Clone::clone(__self_0),
},
}
}
}Clone, #[automatically_derived]impl<'tcx> ::core::marker::StructuralPartialEq for
UndoLog<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::cmp::PartialEq for UndoLog<'tcx> {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::AddVar(__self_0), Self::AddVar(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::AddConstraint(__self_0), Self::AddConstraint(__arg1_0))
=> __self_0 == __arg1_0,
(Self::AddVerify(__self_0), Self::AddVerify(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::AddCombination(__self_0, __self_1),
Self::AddCombination(__arg1_0, __arg1_1)) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
(Self::OverwriteSolverRegionConstraint {
old_constraint: __self_0 },
Self::OverwriteSolverRegionConstraint {
old_constraint: __arg1_0 }) => __self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq)]
345pub(crate) enum UndoLog<'tcx> {
346 AddVar(RegionVid),
348
349 AddConstraint(usize),
351
352 AddVerify(usize),
354
355 AddCombination(CombineMapType, TwoRegions<'tcx>),
357
358 OverwriteSolverRegionConstraint { old_constraint: Box<SolverRegionConstraint<'tcx>> },
360}
361
362#[derive(#[automatically_derived]impl ::core::marker::Copy for CombineMapType { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for CombineMapType {
}
#[automatically_derived]impl ::core::clone::Clone for CombineMapType {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
CombineMapType {
}
#[automatically_derived]impl ::core::cmp::PartialEq for CombineMapType {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq)]
363pub(crate) enum CombineMapType {
364 Lub,
365 Glb,
366}
367
368type CombineMap<'tcx> = FxHashMap<TwoRegions<'tcx>, RegionVid>;
369
370#[derive(#[automatically_derived]impl<'tcx> ::core::fmt::Debug for
RegionVariableInfo<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"RegionVariableInfo origin universe", &self.origin,
&&self.universe)
}
}Debug, #[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
::core::clone::TrivialClone for RegionVariableInfo<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for
RegionVariableInfo<'tcx> {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<RegionVariableOrigin<'tcx>>;
let _: ::core::clone::AssertParamIsClone<ty::UniverseIndex>;
*self
}
}Clone, #[automatically_derived]impl<'tcx> ::core::marker::Copy for
RegionVariableInfo<'tcx> {
}Copy)]
371pub struct RegionVariableInfo<'tcx> {
372 pub origin: RegionVariableOrigin<'tcx>,
373 pub universe: ty::UniverseIndex,
386}
387
388pub(crate) struct RegionSnapshot {
389 any_unifications: bool,
390}
391
392impl<'tcx> RegionConstraintStorage<'tcx> {
393 #[inline]
394 pub(crate) fn with_log<'a>(
395 &'a mut self,
396 undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
397 ) -> RegionConstraintCollector<'a, 'tcx> {
398 RegionConstraintCollector { storage: self, undo_log }
399 }
400}
401
402impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
403 pub fn num_region_vars(&self) -> usize {
404 self.storage.var_infos.len()
405 }
406
407 pub fn take_and_reset_data(&mut self) -> RegionConstraintData<'tcx> {
420 if !!UndoLogs::<UndoLog<'_>>::in_snapshot(&self.undo_log) {
::core::panicking::panic("assertion failed: !UndoLogs::<UndoLog<\'_>>::in_snapshot(&self.undo_log)")
};assert!(!UndoLogs::<UndoLog<'_>>::in_snapshot(&self.undo_log));
421
422 let RegionConstraintStorage {
426 var_infos: _,
427 legacy_data,
428 solver_data: _,
430 lubs,
431 glbs,
432 unification_table: _,
433 any_unifications,
434 } = self.storage;
435
436 lubs.clear();
441 glbs.clear();
442
443 let data = mem::take(legacy_data);
444
445 if *any_unifications {
450 *any_unifications = false;
451 ut::UnificationTable::with_log(&mut self.storage.unification_table, &mut self.undo_log)
453 .reset_unifications(|key| RegionVariableValue::Unknown {
454 universe: self.storage.var_infos[key.vid].universe,
455 });
456 }
457
458 data
459 }
460
461 pub fn legacy_data(&self) -> &RegionConstraintData<'tcx> {
462 &self.storage.legacy_data
463 }
464
465 pub fn solver_data(&self) -> &SolverRegionConstraintData<'tcx> {
466 &self.storage.solver_data
467 }
468
469 pub fn overwrite_solver_constraint(&mut self, constraint: SolverRegionConstraint<'tcx>) {
470 if !!constraint.has_escaping_bound_vars() {
{
::core::panicking::panic_fmt(format_args!("solver region constraint has escaping bound vars, which is indicative of a bug in how constraints are handled: {0:?}",
constraint));
}
};assert!(
471 !constraint.has_escaping_bound_vars(),
472 "solver region constraint has escaping bound vars, which is indicative of a bug in how constraints are handled: {constraint:?}",
473 );
474
475 let old_constraint = self.storage.solver_data.get_constraint();
476 self.storage.solver_data.overwrite(constraint);
477 self.undo_log
478 .push(OverwriteSolverRegionConstraint { old_constraint: Box::new(old_constraint) });
479 }
480
481 pub fn register_solver_constraint(&mut self, constraint: SolverRegionConstraint<'tcx>) {
482 if !!constraint.has_escaping_bound_vars() {
{
::core::panicking::panic_fmt(format_args!("solver region constraint has escaping bound vars, which is indicative of a bug in how constraints are handled: {0:?}",
constraint));
}
};assert!(
483 !constraint.has_escaping_bound_vars(),
484 "solver region constraint has escaping bound vars, which is indicative of a bug in how constraints are handled: {constraint:?}",
485 );
486
487 let old_constraint = self.storage.solver_data.get_constraint();
488 let new_constraint = rustc_type_ir::region_constraint::RegionConstraint::build_and(
489 constraint,
490 old_constraint.clone(),
491 );
492
493 self.undo_log
497 .push(OverwriteSolverRegionConstraint { old_constraint: Box::new(old_constraint) });
498 self.storage.solver_data.overwrite(new_constraint);
499 }
500
501 pub(super) fn start_snapshot(&self) -> RegionSnapshot {
502 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs:502",
"rustc_infer::infer::region_constraints",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs"),
::tracing_core::__macro_support::Option::Some(502u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("RegionConstraintCollector: start_snapshot")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("RegionConstraintCollector: start_snapshot");
503 RegionSnapshot { any_unifications: self.storage.any_unifications }
504 }
505
506 pub(super) fn rollback_to(&mut self, snapshot: RegionSnapshot) {
507 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs:507",
"rustc_infer::infer::region_constraints",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs"),
::tracing_core::__macro_support::Option::Some(507u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("RegionConstraintCollector: rollback_to({0:?})",
snapshot) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("RegionConstraintCollector: rollback_to({:?})", snapshot);
508 self.storage.any_unifications = snapshot.any_unifications;
509 }
510
511 pub(super) fn new_region_var(
512 &mut self,
513 universe: ty::UniverseIndex,
514 origin: RegionVariableOrigin<'tcx>,
515 ) -> RegionVid {
516 let vid = self.storage.var_infos.push(RegionVariableInfo { origin, universe });
517
518 let u_vid = self.unification_table_mut().new_key(RegionVariableValue::Unknown { universe });
519 {
match (&vid, &u_vid.vid) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};assert_eq!(vid, u_vid.vid);
520 self.undo_log.push(AddVar(vid));
521 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs:521",
"rustc_infer::infer::region_constraints",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs"),
::tracing_core::__macro_support::Option::Some(521u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("created new region variable {0:?} in {1:?} with origin {2:?}",
vid, universe, origin) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("created new region variable {:?} in {:?} with origin {:?}", vid, universe, origin);
522 vid
523 }
524
525 pub(super) fn var_origin(&self, vid: RegionVid) -> RegionVariableOrigin<'tcx> {
527 self.storage.var_infos[vid].origin
528 }
529
530 fn add_constraint(&mut self, constraint: Constraint<'tcx>, origin: SubregionOrigin<'tcx>) {
531 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs:532",
"rustc_infer::infer::region_constraints",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs"),
::tracing_core::__macro_support::Option::Some(532u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("RegionConstraintCollector: add_constraint({0:?})",
constraint) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("RegionConstraintCollector: add_constraint({:?})", constraint);
533
534 let index = self.storage.legacy_data.constraints.len();
535 self.storage.legacy_data.constraints.push((constraint, origin));
536 self.undo_log.push(AddConstraint(index));
537 }
538
539 fn add_verify(&mut self, verify: Verify<'tcx>) {
540 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs:541",
"rustc_infer::infer::region_constraints",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs"),
::tracing_core::__macro_support::Option::Some(541u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("RegionConstraintCollector: add_verify({0:?})",
verify) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("RegionConstraintCollector: add_verify({:?})", verify);
542
543 if let VerifyBound::AllBounds(ref bs) = verify.bound
545 && bs.is_empty()
546 {
547 return;
548 }
549
550 let index = self.storage.legacy_data.verifys.len();
551 self.storage.legacy_data.verifys.push(verify);
552 self.undo_log.push(AddVerify(index));
553 }
554
555 pub(super) fn make_eqregion(
556 &mut self,
557 origin: SubregionOrigin<'tcx>,
558 a: Region<'tcx>,
559 b: Region<'tcx>,
560 visible_for_leak_check: ty::VisibleForLeakCheck,
561 ) {
562 if a != b {
563 match (a.kind(), b.kind(), a, b) {
566 (ReBound(..), _, _, _) | (_, ReBound(..), _, _) => {
567 ::rustc_span::macros::bug_impl(Some(origin.span()),
format_args!("cannot relate bound region: {0:?} == {1:?}", a, b),
Location::caller());span_bug!(origin.span(), "cannot relate bound region: {:?} == {:?}", a, b);
568 }
569 (ReVar(a_vid), ReVar(b_vid), _, _) => {
570 self.add_constraint(
571 Constraint {
572 kind: ConstraintKind::VarEqVar,
573 sub: a,
574 sup: b,
575 visible_for_leak_check,
576 },
577 origin,
578 );
579 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs:579",
"rustc_infer::infer::region_constraints",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs"),
::tracing_core::__macro_support::Option::Some(579u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("make_eqregion: unifying {0:?} with {1:?}",
a_vid, b_vid) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("make_eqregion: unifying {:?} with {:?}", a_vid, b_vid);
580 if self.unification_table_mut().unify_var_var(a_vid, b_vid).is_ok() {
581 self.storage.any_unifications = true;
582 }
583 }
584 (ReVar(vid), _, var, reg) | (_, ReVar(vid), reg, var) => {
585 if reg.is_static() {
586 self.add_constraint(
588 Constraint {
589 kind: ConstraintKind::RegSubVar,
590 sub: reg,
591 sup: var,
592 visible_for_leak_check,
593 },
594 origin,
595 );
596 } else {
597 self.add_constraint(
598 Constraint {
599 kind: ConstraintKind::VarEqReg,
600 sub: var,
601 sup: reg,
602 visible_for_leak_check,
603 },
604 origin,
605 );
606 }
607 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs:607",
"rustc_infer::infer::region_constraints",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs"),
::tracing_core::__macro_support::Option::Some(607u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("make_eqregion: unifying {0:?} with {1:?}",
vid, reg) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("make_eqregion: unifying {:?} with {:?}", vid, reg);
608 if self
609 .unification_table_mut()
610 .unify_var_value(vid, RegionVariableValue::Known { value: reg })
611 .is_ok()
612 {
613 self.storage.any_unifications = true;
614 };
615 }
616 (ReStatic, _, st, reg) | (_, ReStatic, reg, st) => {
617 self.add_constraint(
619 Constraint {
620 kind: ConstraintKind::RegSubReg,
621 sub: st,
622 sup: reg,
623 visible_for_leak_check,
624 },
625 origin,
626 );
627 }
628 _ => {
629 self.add_constraint(
630 Constraint {
631 kind: ConstraintKind::RegEqReg,
632 sub: a,
633 sup: b,
634 visible_for_leak_check,
635 },
636 origin,
637 );
638 }
639 }
640 }
641 }
642
643 {}
#[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("make_subregion",
"rustc_infer::infer::region_constraints",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs"),
::tracing_core::__macro_support::Option::Some(643u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("sub")
}> =
::tracing::__macro_support::FieldName::new("sub");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("sup")
}> =
::tracing::__macro_support::FieldName::new("sup");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("visible_for_leak_check")
}> =
::tracing::__macro_support::FieldName::new("visible_for_leak_check");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&sub)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&sup)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&visible_for_leak_check)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: () = loop {};
return __tracing_attr_fake_return;
}
{
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs:652",
"rustc_infer::infer::region_constraints",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs"),
::tracing_core::__macro_support::Option::Some(652u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("origin = {0:#?}",
origin) as &dyn ::tracing::field::Value))])
});
} else { ; }
};
match (sub.kind(), sup.kind()) {
(ReBound(..), _) | (_, ReBound(..)) => {
::rustc_span::macros::bug_impl(Some(origin.span()),
format_args!("cannot relate bound region: {0:?} <= {1:?}",
sub, sup), Location::caller());
}
(_, ReStatic) => {}
(ReVar(sub_id), ReVar(sup_id)) => {
if sub_id != sup_id {
self.add_constraint(Constraint {
kind: ConstraintKind::VarSubVar,
sub,
sup,
visible_for_leak_check,
}, origin);
}
}
(_, ReVar(_)) =>
self.add_constraint(Constraint {
kind: ConstraintKind::RegSubVar,
sub,
sup,
visible_for_leak_check,
}, origin),
(ReVar(_), _) =>
self.add_constraint(Constraint {
kind: ConstraintKind::VarSubReg,
sub,
sup,
visible_for_leak_check,
}, origin),
_ => {
if sub != sup {
self.add_constraint(Constraint {
kind: ConstraintKind::RegSubReg,
sub,
sup,
visible_for_leak_check,
}, origin)
}
}
}
}
}
}#[instrument(skip(self, origin), level = "debug")]
644 pub(super) fn make_subregion(
645 &mut self,
646 origin: SubregionOrigin<'tcx>,
647 sub: Region<'tcx>,
648 sup: Region<'tcx>,
649 visible_for_leak_check: ty::VisibleForLeakCheck,
650 ) {
651 debug!("origin = {:#?}", origin);
653
654 match (sub.kind(), sup.kind()) {
655 (ReBound(..), _) | (_, ReBound(..)) => {
656 span_bug!(origin.span(), "cannot relate bound region: {:?} <= {:?}", sub, sup);
657 }
658 (_, ReStatic) => {
659 }
661 (ReVar(sub_id), ReVar(sup_id)) => {
662 if sub_id != sup_id {
663 self.add_constraint(
664 Constraint {
665 kind: ConstraintKind::VarSubVar,
666 sub,
667 sup,
668 visible_for_leak_check,
669 },
670 origin,
671 );
672 }
673 }
674 (_, ReVar(_)) => self.add_constraint(
675 Constraint { kind: ConstraintKind::RegSubVar, sub, sup, visible_for_leak_check },
676 origin,
677 ),
678 (ReVar(_), _) => self.add_constraint(
679 Constraint { kind: ConstraintKind::VarSubReg, sub, sup, visible_for_leak_check },
680 origin,
681 ),
682 _ => {
683 if sub != sup {
684 self.add_constraint(
685 Constraint {
686 kind: ConstraintKind::RegSubReg,
687 sub,
688 sup,
689 visible_for_leak_check,
690 },
691 origin,
692 )
693 }
694 }
695 }
696 }
697
698 pub(super) fn verify_generic_bound(
699 &mut self,
700 origin: SubregionOrigin<'tcx>,
701 kind: GenericKind<'tcx>,
702 sub: Region<'tcx>,
703 bound: VerifyBound<'tcx>,
704 ) {
705 self.add_verify(Verify { kind, origin, region: sub, bound });
706 }
707
708 pub(super) fn lub_regions(
709 &mut self,
710 tcx: TyCtxt<'tcx>,
711 origin: SubregionOrigin<'tcx>,
712 a: Region<'tcx>,
713 b: Region<'tcx>,
714 ) -> Region<'tcx> {
715 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs:716",
"rustc_infer::infer::region_constraints",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs"),
::tracing_core::__macro_support::Option::Some(716u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("RegionConstraintCollector: lub_regions({0:?}, {1:?})",
a, b) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("RegionConstraintCollector: lub_regions({:?}, {:?})", a, b);
717 if a.is_static() || b.is_static() {
718 a } else if a == b {
720 a } else {
722 self.combine_vars(tcx, Lub, a, b, origin)
723 }
724 }
725
726 pub(super) fn glb_regions(
727 &mut self,
728 tcx: TyCtxt<'tcx>,
729 origin: SubregionOrigin<'tcx>,
730 a: Region<'tcx>,
731 b: Region<'tcx>,
732 ) -> Region<'tcx> {
733 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs:734",
"rustc_infer::infer::region_constraints",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs"),
::tracing_core::__macro_support::Option::Some(734u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("RegionConstraintCollector: glb_regions({0:?}, {1:?})",
a, b) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("RegionConstraintCollector: glb_regions({:?}, {:?})", a, b);
735 if a.is_static() {
736 b } else if b.is_static() {
738 a } else if a == b {
740 a } else {
742 self.combine_vars(tcx, Glb, a, b, origin)
743 }
744 }
745
746 pub fn shallow_resolve_region_var(
749 &mut self,
750 tcx: TyCtxt<'tcx>,
751 vid: ty::RegionVid,
752 ) -> ty::Region<'tcx> {
753 let mut ut = self.unification_table_mut();
754 let root_vid = ut.find(vid).vid;
755 match ut.probe_value(root_vid) {
756 RegionVariableValue::Known { value } => value,
757 RegionVariableValue::Unknown { .. } => ty::Region::new_var(tcx, root_vid),
758 }
759 }
760
761 pub fn try_resolve_region_var(
762 &mut self,
763 vid: ty::RegionVid,
764 ) -> Result<ty::Region<'tcx>, ty::UniverseIndex> {
765 match self.unification_table_mut().probe_value(vid) {
766 RegionVariableValue::Known { value } => Ok(value),
767 RegionVariableValue::Unknown { universe } => Err(universe),
768 }
769 }
770
771 fn combine_map(&mut self, t: CombineMapType) -> &mut CombineMap<'tcx> {
772 match t {
773 Glb => &mut self.storage.glbs,
774 Lub => &mut self.storage.lubs,
775 }
776 }
777
778 fn combine_vars(
779 &mut self,
780 tcx: TyCtxt<'tcx>,
781 t: CombineMapType,
782 a: Region<'tcx>,
783 b: Region<'tcx>,
784 origin: SubregionOrigin<'tcx>,
785 ) -> Region<'tcx> {
786 let vars = TwoRegions { a, b };
787 if let Some(&c) = self.combine_map(t).get(&vars) {
788 return ty::Region::new_var(tcx, c);
789 }
790 let a_universe = self.universe(a);
791 let b_universe = self.universe(b);
792 let c_universe = cmp::max(a_universe, b_universe);
793 let c = self.new_region_var(c_universe, RegionVariableOrigin::Misc(origin.span()));
794 self.combine_map(t).insert(vars, c);
795 self.undo_log.push(AddCombination(t, vars));
796 let new_r = ty::Region::new_var(tcx, c);
797 for old_r in [a, b] {
798 match t {
799 Glb => {
800 self.make_subregion(origin.clone(), new_r, old_r, ty::VisibleForLeakCheck::Yes)
801 }
802 Lub => {
803 self.make_subregion(origin.clone(), old_r, new_r, ty::VisibleForLeakCheck::Yes)
804 }
805 }
806 }
807 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs:807",
"rustc_infer::infer::region_constraints",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f9ceb4a4d45a471eed7bd8c40dddb7c38e749e21/compiler/rustc_infer/src/infer/region_constraints/mod.rs"),
::tracing_core::__macro_support::Option::Some(807u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("combine_vars() c={0:?}",
c) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("combine_vars() c={:?}", c);
808 new_r
809 }
810
811 pub fn universe(&mut self, region: Region<'tcx>) -> ty::UniverseIndex {
812 match region.kind() {
813 ty::ReStatic
814 | ty::ReErased
815 | ty::ReLateParam(..)
816 | ty::ReEarlyParam(..)
817 | ty::ReError(_) => ty::UniverseIndex::ROOT,
818 ty::RePlaceholder(placeholder) => placeholder.universe,
819 ty::ReVar(vid) => match self.try_resolve_region_var(vid) {
820 Ok(value) => self.universe(value),
821 Err(universe) => universe,
822 },
823 ty::ReBound(..) => ::rustc_span::macros::bug_impl(None,
format_args!("universe(): encountered bound region {0:?}", region),
Location::caller())bug!("universe(): encountered bound region {:?}", region),
824 }
825 }
826
827 pub fn vars_since_snapshot<'a>(
828 &'a self,
829 value_count: usize,
830 ) -> (Range<RegionVid>, Vec<RegionVariableOrigin<'tcx>>) {
831 let range =
832 RegionVid::from(value_count)..RegionVid::from(self.storage.unification_table.len());
833 (
834 range.clone(),
835 (range.start..range.end).map(|index| self.storage.var_infos[index].origin).collect(),
836 )
837 }
838
839 pub fn region_constraints_added_in_snapshot(&self, mark: &Snapshot<'tcx>) -> bool {
841 self.undo_log
842 .region_constraints_in_snapshot(mark)
843 .any(|elt| #[allow(non_exhaustive_omitted_patterns)] match elt {
&AddConstraint(_) => true,
_ => false,
}matches!(elt, &AddConstraint(_)))
844 }
845
846 #[inline]
847 fn unification_table_mut(&mut self) -> super::UnificationTable<'_, 'tcx, RegionVidKey<'tcx>> {
848 ut::UnificationTable::with_log(&mut self.storage.unification_table, self.undo_log)
849 }
850}
851
852impl fmt::Debug for RegionSnapshot {
853 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
854 f.write_fmt(format_args!("RegionSnapshot"))write!(f, "RegionSnapshot")
855 }
856}
857
858impl<'tcx> fmt::Debug for GenericKind<'tcx> {
859 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
860 match *self {
861 GenericKind::Param(ref p) => f.write_fmt(format_args!("{0:?}", p))write!(f, "{p:?}"),
862 GenericKind::Placeholder(ref p) => f.write_fmt(format_args!("{0:?}", p))write!(f, "{p:?}"),
863 GenericKind::Alias(ref p) => f.write_fmt(format_args!("{0:?}", p))write!(f, "{p:?}"),
864 }
865 }
866}
867
868impl<'tcx> fmt::Display for GenericKind<'tcx> {
869 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
870 match *self {
871 GenericKind::Param(ref p) => f.write_fmt(format_args!("{0}", p))write!(f, "{p}"),
872 GenericKind::Placeholder(ref p) => f.write_fmt(format_args!("{0}", p))write!(f, "{p}"),
873 GenericKind::Alias(ref p) => f.write_fmt(format_args!("{0}", p))write!(f, "{p}"),
874 }
875 }
876}
877
878impl<'tcx> GenericKind<'tcx> {
879 pub fn to_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
880 match *self {
881 GenericKind::Param(ref p) => p.to_ty(tcx),
882 GenericKind::Placeholder(ref p) => Ty::new_placeholder(tcx, *p),
883 GenericKind::Alias(ref p) => p.to_ty(tcx, ty::IsRigid::yes_if_next_solver(tcx)),
884 }
885 }
886}
887
888impl<'tcx> VerifyBound<'tcx> {
889 pub fn must_hold(&self) -> bool {
890 match self {
891 VerifyBound::IfEq(..) => false,
892 VerifyBound::OutlivedBy(re) => re.is_static(),
893 VerifyBound::IsEmpty => false,
894 VerifyBound::AnyBound(bs) => bs.iter().any(|b| b.must_hold()),
895 VerifyBound::AllBounds(bs) => bs.iter().all(|b| b.must_hold()),
896 }
897 }
898
899 pub fn cannot_hold(&self) -> bool {
900 match self {
901 VerifyBound::IfEq(..) => false,
902 VerifyBound::IsEmpty => false,
903 VerifyBound::OutlivedBy(_) => false,
904 VerifyBound::AnyBound(bs) => bs.iter().all(|b| b.cannot_hold()),
905 VerifyBound::AllBounds(bs) => bs.iter().any(|b| b.cannot_hold()),
906 }
907 }
908
909 pub fn or(self, vb: VerifyBound<'tcx>) -> VerifyBound<'tcx> {
910 if self.must_hold() || vb.cannot_hold() {
911 self
912 } else if self.cannot_hold() || vb.must_hold() {
913 vb
914 } else {
915 VerifyBound::AnyBound(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self, vb]))vec![self, vb])
916 }
917 }
918}
919
920impl<'tcx> RegionConstraintData<'tcx> {
921 pub fn is_empty(&self) -> bool {
924 let RegionConstraintData { constraints, verifys } = self;
925 constraints.is_empty() && verifys.is_empty()
926 }
927}
928
929impl<'tcx> Rollback<UndoLog<'tcx>> for RegionConstraintStorage<'tcx> {
930 fn reverse(&mut self, undo: UndoLog<'tcx>) {
931 match undo {
932 AddVar(vid) => {
933 self.var_infos.pop().unwrap();
934 {
match (&self.var_infos.len(), &vid.index()) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};assert_eq!(self.var_infos.len(), vid.index());
935 }
936 AddConstraint(index) => {
937 self.legacy_data.constraints.pop().unwrap();
938 {
match (&self.legacy_data.constraints.len(), &index) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};assert_eq!(self.legacy_data.constraints.len(), index);
939 }
940 AddVerify(index) => {
941 self.legacy_data.verifys.pop();
942 {
match (&self.legacy_data.verifys.len(), &index) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};assert_eq!(self.legacy_data.verifys.len(), index);
943 }
944 AddCombination(Glb, ref regions) => {
945 self.glbs.remove(regions);
946 }
947 AddCombination(Lub, ref regions) => {
948 self.lubs.remove(regions);
949 }
950 OverwriteSolverRegionConstraint { old_constraint } => {
951 self.solver_data.overwrite(*old_constraint);
952 }
953 }
954 }
955}