1use rustc_data_structures::transitive_relation::{TransitiveRelation, TransitiveRelationBuilder};
63use rustc_data_structures::undo_log::UndoLogs;
64use rustc_middle::bug;
65use rustc_middle::mir::ConstraintCategory;
66use rustc_middle::ty::outlives::{Component, push_outlives_components};
67use rustc_middle::ty::{
68 self, GenericArgKind, GenericArgsRef, PolyTypeOutlivesClause, Region, RegionVid, Ty, TyCtxt,
69 TypeVisitableExt, Upcast,
70};
71use rustc_type_ir::region_constraint::{self, LeafRegionConstraint};
72use smallvec::smallvec;
73use tracing::{debug, instrument};
74
75use super::env::OutlivesEnvironment;
76use crate::infer::outlives::env::RegionBoundPairs;
77use crate::infer::outlives::verify::VerifyBoundCx;
78use crate::infer::snapshot::undo_log::UndoLog;
79use crate::infer::{
80 self, GenericKind, InferCtxt, SolverRegionConstraint, SubregionOrigin, TypeOutlivesConstraint,
81 VerifyBound,
82};
83use crate::traits::{ObligationCause, ObligationCauseCode};
84
85impl<'tcx> InferCtxt<'tcx> {
86 pub fn register_outlives_constraint(
87 &self,
88 ty::OutlivesClause(arg, r2): ty::ArgOutlivesClause<'tcx>,
89 vis: ty::VisibleForLeakCheck,
90 cause: &ObligationCause<'tcx>,
91 ) {
92 match arg.kind() {
93 ty::GenericArgKind::Lifetime(r1) => {
94 self.register_region_outlives_constraint(ty::OutlivesClause(r1, r2), vis, cause);
95 }
96 ty::GenericArgKind::Type(ty1) => {
97 self.register_type_outlives_constraint(ty1, r2, cause);
98 }
99 ty::GenericArgKind::Const(_) => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
100 }
101 }
102
103 pub fn register_region_eq_constraint(
104 &self,
105 ty::RegionEqPredicate(r_a, r_b): ty::RegionEqPredicate<'tcx>,
106 vis: ty::VisibleForLeakCheck,
107 cause: &ObligationCause<'tcx>,
108 ) {
109 let origin = SubregionOrigin::from_obligation_cause(cause, || {
110 SubregionOrigin::RelateRegionParamBound(cause.span, None)
111 });
112 self.equate_regions(origin, r_a, r_b, vis);
113 }
114
115 pub fn register_region_outlives_constraint(
116 &self,
117 ty::OutlivesClause(r_a, r_b): ty::RegionOutlivesClause<'tcx>,
118 vis: ty::VisibleForLeakCheck,
119 cause: &ObligationCause<'tcx>,
120 ) {
121 let origin = SubregionOrigin::from_obligation_cause(cause, || {
122 SubregionOrigin::RelateRegionParamBound(cause.span, None)
123 });
124 self.sub_regions(origin, r_b, r_a, vis);
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("register_type_outlives_constraint_inner",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(133u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
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(&obligation)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: () = loop {};
return __tracing_attr_fake_return;
}
{
let mut inner = self.inner.borrow_mut();
inner.undo_log.push(UndoLog::PushTypeOutlivesConstraint);
inner.region_obligations.push(obligation);
}
}
}#[instrument(level = "debug", skip(self))]
134 pub fn register_type_outlives_constraint_inner(
135 &self,
136 obligation: TypeOutlivesConstraint<'tcx>,
137 ) {
138 let mut inner = self.inner.borrow_mut();
139 inner.undo_log.push(UndoLog::PushTypeOutlivesConstraint);
140 inner.region_obligations.push(obligation);
141 }
142
143 pub fn register_solver_region_constraint(&self, c: SolverRegionConstraint<'tcx>) {
144 let mut inner = self.inner.borrow_mut();
145
146 let old_constraint = inner.solver_region_constraint_storage.get_constraint();
147 let new_constraint = rustc_type_ir::region_constraint::RegionConstraint::build_and(
148 c,
149 old_constraint.clone(),
150 );
151
152 inner.undo_log.push(UndoLog::OverwriteSolverRegionConstraint { old_constraint });
156 inner.solver_region_constraint_storage.overwrite(new_constraint);
157 }
158
159 pub fn register_type_outlives_constraint(
160 &self,
161 sup_type: Ty<'tcx>,
162 sub_region: Region<'tcx>,
163 cause: &ObligationCause<'tcx>,
164 ) {
165 if !!self.tcx.assumptions_on_binders() {
::core::panicking::panic("assertion failed: !self.tcx.assumptions_on_binders()")
};assert!(!self.tcx.assumptions_on_binders());
166
167 if sup_type.is_global() {
172 return;
173 }
174
175 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs:175",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(175u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("sup_type")
}> =
::tracing::__macro_support::FieldName::new("sup_type");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("sub_region")
}> =
::tracing::__macro_support::FieldName::new("sub_region");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("cause")
}> =
::tracing::__macro_support::FieldName::new("cause");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&sup_type)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&sub_region)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&cause)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?sup_type, ?sub_region, ?cause);
176 let origin = SubregionOrigin::from_obligation_cause(cause, || {
177 SubregionOrigin::RelateParamBound(
178 cause.span,
179 sup_type,
180 match cause.code().peel_derives() {
181 ObligationCauseCode::WhereClause(_, span)
182 | ObligationCauseCode::WhereClauseInExpr(_, span, ..)
183 | ObligationCauseCode::OpaqueTypeBound(span, _)
184 if !span.is_dummy() =>
185 {
186 Some(*span)
187 }
188 _ => None,
189 },
190 )
191 });
192
193 self.register_type_outlives_constraint_inner(TypeOutlivesConstraint {
194 sup_type,
195 sub_region,
196 origin,
197 });
198 }
199
200 pub fn take_registered_region_obligations(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
202 if !!self.in_snapshot() {
{
::core::panicking::panic_fmt(format_args!("cannot take registered region obligations in a snapshot"));
}
};assert!(!self.in_snapshot(), "cannot take registered region obligations in a snapshot");
203 std::mem::take(&mut self.inner.borrow_mut().region_obligations)
204 }
205
206 pub fn num_registered_region_obligations(&self) -> usize {
207 self.inner.borrow().region_obligations.len()
208 }
209
210 pub fn registered_region_obligations_since(
211 &self,
212 prev: usize,
213 ) -> Vec<TypeOutlivesConstraint<'tcx>> {
214 self.inner.borrow().region_obligations.iter().skip(prev).cloned().collect()
215 }
216
217 pub fn clone_registered_region_obligations(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
218 self.inner.borrow().region_obligations.clone()
219 }
220
221 pub fn register_region_assumption(&self, assumption: ty::ArgOutlivesClause<'tcx>) {
222 let mut inner = self.inner.borrow_mut();
223 inner.undo_log.push(UndoLog::PushRegionAssumption);
224 inner.region_assumptions.push(assumption);
225 }
226
227 pub fn take_registered_region_assumptions(&self) -> Vec<ty::ArgOutlivesClause<'tcx>> {
228 if !!self.in_snapshot() {
{
::core::panicking::panic_fmt(format_args!("cannot take registered region assumptions in a snapshot"));
}
};assert!(!self.in_snapshot(), "cannot take registered region assumptions in a snapshot");
229 std::mem::take(&mut self.inner.borrow_mut().region_assumptions)
230 }
231
232 pub fn destructure_solver_region_constraints_for_regionck(
233 &self,
234 outlives_env: &OutlivesEnvironment<'tcx>,
235 ) {
236 let mut region_outlives = TransitiveRelationBuilder::default();
240 for (r1, r2) in outlives_env.free_region_map().relation.base_edges() {
241 region_outlives.add(r2, r1);
242 }
243 let assumptions = rustc_type_ir::region_constraint::Assumptions::new(
244 self,
245 assumed_type_outlives(
246 self.tcx,
247 outlives_env.known_type_outlives(),
248 outlives_env.region_bound_pairs(),
249 ),
250 region_outlives.freeze(),
251 ty::UniverseIndex::ROOT,
252 );
253 self.destructure_solver_region_constraints(assumptions, self);
254 }
255
256 pub fn destructure_solver_region_constraints_for_borrowck(
257 &self,
258 conversion: impl TypeOutlivesDelegate<'tcx>,
260 known_type_outlives: &[PolyTypeOutlivesClause<'tcx>],
261 region_bound_pairs: &RegionBoundPairs<'tcx>,
262 region_outlives: TransitiveRelation<RegionVid>,
263 ) {
264 let assumptions = region_constraint::Assumptions::new(
265 self,
266 assumed_type_outlives(self.tcx, known_type_outlives, region_bound_pairs),
267 region_outlives.maybe_map(|r| Some(Region::new_var(self.tcx, r))).unwrap(),
268 ty::UniverseIndex::ROOT,
269 );
270 self.destructure_solver_region_constraints(assumptions, conversion);
271 }
272
273 {}
#[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("destructure_solver_region_constraints",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(273u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("assumptions")
}> =
::tracing::__macro_support::FieldName::new("assumptions");
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(&assumptions)
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;
}
{
if !self.tcx.assumptions_on_binders() {
::core::panicking::panic("assertion failed: self.tcx.assumptions_on_binders()")
};
if !self.next_trait_solver() {
::core::panicking::panic("assertion failed: self.next_trait_solver()")
};
let constraint =
self.inner.borrow().solver_region_constraint_storage.get_constraint();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs:283",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(283u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::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::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let constraint =
region_constraint::destructure_type_outlives_constraints_in_root(self,
constraint, &assumptions);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs:289",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(289u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::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::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let constraint =
region_constraint::propagate_ambiguity(constraint);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs:291",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(291u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::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::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
for c in
constraint.and_constraint.0.into_iter().chain(constraint.or_constraint.0.into_iter().flat_map(|and_constraint|
and_constraint.0.into_iter())) {
use LeafRegionConstraint::*;
match c {
Ambiguity(span) => {
self.dcx().struct_span_err(span,
"unable to satisfy constraints involving placeholders due to unknown implied bounds").emit();
}
RegionOutlives(a, b, span) => {
let origin = SubregionOrigin::SolverRegionConstraint(span);
let category = origin.to_constraint_category();
conversion.push_sub_region_constraint(origin, b, a,
category);
}
AliasTyOutlivesViaEnv(..) | PlaceholderTyOutlives(..) => {
::core::panicking::panic("internal error: entered unreachable code")
}
}
}
}
}
}#[instrument(level = "debug", skip(self, conversion))]
274 pub fn destructure_solver_region_constraints(
275 &self,
276 assumptions: rustc_type_ir::region_constraint::Assumptions<TyCtxt<'tcx>>,
277 mut conversion: impl TypeOutlivesDelegate<'tcx>,
278 ) {
279 assert!(self.tcx.assumptions_on_binders());
280 assert!(self.next_trait_solver());
281
282 let constraint = self.inner.borrow().solver_region_constraint_storage.get_constraint();
283 debug!(?constraint);
284 let constraint = region_constraint::destructure_type_outlives_constraints_in_root(
285 self,
286 constraint,
287 &assumptions,
288 );
289 debug!(?constraint);
290 let constraint = region_constraint::propagate_ambiguity(constraint);
291 debug!(?constraint);
292
293 for c in constraint.and_constraint.0.into_iter().chain(
295 constraint
296 .or_constraint
297 .0
298 .into_iter()
299 .flat_map(|and_constraint| and_constraint.0.into_iter()),
300 ) {
301 use LeafRegionConstraint::*;
302
303 match c {
304 Ambiguity(span) => {
305 self.dcx()
306 .struct_span_err(
307 span,
308 "unable to satisfy constraints involving placeholders due to unknown implied bounds",
309 )
310 .emit();
311 }
312 RegionOutlives(a, b, span) => {
313 let origin = SubregionOrigin::SolverRegionConstraint(span);
314 let category = origin.to_constraint_category();
315 conversion.push_sub_region_constraint(
316 origin, b, a, category,
318 );
319 }
320 AliasTyOutlivesViaEnv(..) | PlaceholderTyOutlives(..) => {
321 unreachable!()
322 }
323 }
324 }
325 }
326
327 {}
#[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("process_registered_region_obligations",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(336u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::tracing_core::field::FieldSet::new(&[],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{ meta.fields().value_set_all(&[]) })
} 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 rustc_type_ir::InferCtxtLike;
if !!self.in_snapshot() {
{
::core::panicking::panic_fmt(format_args!("cannot process registered region obligations in a snapshot"));
}
};
if self.tcx.assumptions_on_binders() {
self.destructure_solver_region_constraints_for_regionck(outlives_env);
}
for iteration in 0.. {
let my_region_obligations =
self.take_registered_region_obligations();
if my_region_obligations.is_empty() { break; }
if !self.tcx.recursion_limit().value_within_limit(iteration) {
::rustc_middle::util::bug::bug_fmt(format_args!("unexpected overflowed when processing region obligations: {0:#?}",
my_region_obligations));
}
for TypeOutlivesConstraint { sup_type, sub_region, origin } in
my_region_obligations {
#[allow(rustc::usage_of_type_ir_traits)]
let (sup_type, sub_region) =
self.deeply_resolve_via_unification_table((sup_type,
sub_region));
if self.tcx.sess.opts.unstable_opts.higher_ranked_assumptions
&&
outlives_env.higher_ranked_assumptions().contains(&ty::OutlivesClause(sup_type.into(),
sub_region)) {
continue;
}
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs:380",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(380u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("sup_type")
}> =
::tracing::__macro_support::FieldName::new("sup_type");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("sub_region")
}> =
::tracing::__macro_support::FieldName::new("sub_region");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("origin")
}> =
::tracing::__macro_support::FieldName::new("origin");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&sup_type)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&sub_region)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let outlives =
&mut TypeOutlives::new(self, self.tcx,
outlives_env.region_bound_pairs(), None,
outlives_env.known_type_outlives());
let category = origin.to_constraint_category();
outlives.type_must_outlive(origin, sup_type, sub_region,
category);
}
}
}
}
}#[instrument(level = "debug", skip(self, outlives_env))]
337 pub fn process_registered_region_obligations(&self, outlives_env: &OutlivesEnvironment<'tcx>) {
338 use rustc_type_ir::InferCtxtLike;
339 assert!(!self.in_snapshot(), "cannot process registered region obligations in a snapshot");
340
341 if self.tcx.assumptions_on_binders() {
342 self.destructure_solver_region_constraints_for_regionck(outlives_env);
343 }
344
345 for iteration in 0.. {
347 let my_region_obligations = self.take_registered_region_obligations();
348 if my_region_obligations.is_empty() {
349 break;
350 }
351
352 if !self.tcx.recursion_limit().value_within_limit(iteration) {
353 bug!(
357 "unexpected overflowed when processing region obligations: {my_region_obligations:#?}"
358 );
359 }
360
361 for TypeOutlivesConstraint { sup_type, sub_region, origin } in my_region_obligations {
362 #[allow(rustc::usage_of_type_ir_traits)]
369 let (sup_type, sub_region) =
370 self.deeply_resolve_via_unification_table((sup_type, sub_region));
371
372 if self.tcx.sess.opts.unstable_opts.higher_ranked_assumptions
373 && outlives_env
374 .higher_ranked_assumptions()
375 .contains(&ty::OutlivesClause(sup_type.into(), sub_region))
376 {
377 continue;
378 }
379
380 debug!(?sup_type, ?sub_region, ?origin);
381
382 let outlives = &mut TypeOutlives::new(
383 self,
384 self.tcx,
385 outlives_env.region_bound_pairs(),
386 None,
387 outlives_env.known_type_outlives(),
388 );
389 let category = origin.to_constraint_category();
390 outlives.type_must_outlive(origin, sup_type, sub_region, category);
391 }
392 }
393 }
394}
395
396fn assumed_type_outlives<'tcx>(
404 tcx: TyCtxt<'tcx>,
405 known_type_outlives: &[PolyTypeOutlivesClause<'tcx>],
406 region_bound_pairs: &RegionBoundPairs<'tcx>,
407) -> Vec<ty::Clause<'tcx>> {
408 known_type_outlives
409 .iter()
410 .copied()
411 .chain(region_bound_pairs.iter().map(|&ty::OutlivesClause(kind, r)| {
412 ty::Binder::dummy(ty::OutlivesClause(kind.to_ty(tcx), r))
413 }))
414 .map(|c| c.map_bound(ty::ClauseKind::TypeOutlives).upcast(tcx))
415 .collect()
416}
417
418pub struct TypeOutlives<'cx, 'tcx, D>
425where
426 D: TypeOutlivesDelegate<'tcx>,
427{
428 delegate: D,
431 tcx: TyCtxt<'tcx>,
432 verify_bound: VerifyBoundCx<'cx, 'tcx>,
433}
434
435pub trait TypeOutlivesDelegate<'tcx> {
436 fn push_sub_region_constraint(
437 &mut self,
438 origin: SubregionOrigin<'tcx>,
439 a: ty::Region<'tcx>,
440 b: ty::Region<'tcx>,
441 constraint_category: ConstraintCategory<'tcx>,
442 );
443
444 fn push_verify(
445 &mut self,
446 origin: SubregionOrigin<'tcx>,
447 kind: GenericKind<'tcx>,
448 a: ty::Region<'tcx>,
449 bound: VerifyBound<'tcx>,
450 );
451}
452
453impl<'cx, 'tcx, D> TypeOutlives<'cx, 'tcx, D>
454where
455 D: TypeOutlivesDelegate<'tcx>,
456{
457 pub fn new(
458 delegate: D,
459 tcx: TyCtxt<'tcx>,
460 region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
461 implicit_region_bound: Option<ty::Region<'tcx>>,
462 caller_bounds: &'cx [ty::PolyTypeOutlivesClause<'tcx>],
463 ) -> Self {
464 Self {
465 delegate,
466 tcx,
467 verify_bound: VerifyBoundCx::new(
468 tcx,
469 region_bound_pairs,
470 implicit_region_bound,
471 caller_bounds,
472 ),
473 }
474 }
475
476 {}
#[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("type_must_outlive",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(484u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("origin")
}> =
::tracing::__macro_support::FieldName::new("origin");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("ty")
}> =
::tracing::__macro_support::FieldName::new("ty");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("region")
}> =
::tracing::__macro_support::FieldName::new("region");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("category")
}> =
::tracing::__macro_support::FieldName::new("category");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ty)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(®ion)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&category)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: () = loop {};
return __tracing_attr_fake_return;
}
{
if !!ty.has_escaping_bound_vars() {
::core::panicking::panic("assertion failed: !ty.has_escaping_bound_vars()")
};
if true {
if !!ty.has_non_region_infer() {
::core::panicking::panic("assertion failed: !ty.has_non_region_infer()")
};
};
if true {
if !(!self.tcx.next_trait_solver_globally() ||
!ty.has_non_rigid_aliases()) {
{
::core::panicking::panic_fmt(format_args!("{0:?} has non-rigid aliases",
ty));
}
};
};
let mut components = ::smallvec::SmallVec::new();
push_outlives_components(self.tcx, ty, &mut components);
self.components_must_outlive(origin, &components, region,
category);
}
}
}#[instrument(level = "debug", skip(self))]
485 pub fn type_must_outlive(
486 &mut self,
487 origin: infer::SubregionOrigin<'tcx>,
488 ty: Ty<'tcx>,
489 region: ty::Region<'tcx>,
490 category: ConstraintCategory<'tcx>,
491 ) {
492 assert!(!ty.has_escaping_bound_vars());
493 debug_assert!(!ty.has_non_region_infer());
494 debug_assert!(
495 !self.tcx.next_trait_solver_globally() || !ty.has_non_rigid_aliases(),
496 "{ty:?} has non-rigid aliases"
497 );
498
499 let mut components = smallvec![];
500 push_outlives_components(self.tcx, ty, &mut components);
501 self.components_must_outlive(origin, &components, region, category);
502 }
503
504 fn components_must_outlive(
505 &mut self,
506 origin: infer::SubregionOrigin<'tcx>,
507 components: &[Component<TyCtxt<'tcx>>],
508 region: ty::Region<'tcx>,
509 category: ConstraintCategory<'tcx>,
510 ) {
511 for component in components.iter() {
512 let origin = origin.clone();
513 match component {
514 Component::Region(region1) => {
515 self.delegate.push_sub_region_constraint(origin, region, *region1, category);
516 }
517 Component::Param(param_ty) => {
518 self.param_ty_must_outlive(origin, region, *param_ty);
519 }
520 Component::Placeholder(placeholder_ty) => {
521 self.placeholder_ty_must_outlive(origin, region, *placeholder_ty);
522 }
523 Component::Alias(is_rigid, alias_ty) => {
524 if true {
{
match (&*is_rigid, &ty::IsRigid::yes_if_next_solver(self.tcx)) {
(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);
}
}
}
};
};debug_assert_eq!(*is_rigid, ty::IsRigid::yes_if_next_solver(self.tcx));
525 self.alias_ty_must_outlive(origin, region, *alias_ty);
526 }
527 Component::EscapingAlias(subcomponents) => {
528 self.components_must_outlive(origin, subcomponents, region, category);
529 }
530 Component::UnresolvedInferenceVariable(v) => {
531 self.tcx.dcx().span_delayed_bug(
535 origin.span(),
536 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unresolved inference variable in outlives: {0:?}",
v))
})format!("unresolved inference variable in outlives: {v:?}"),
537 );
538 }
539 }
540 }
541 }
542
543 {}
#[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("param_ty_must_outlive",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(543u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("origin")
}> =
::tracing::__macro_support::FieldName::new("origin");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("region")
}> =
::tracing::__macro_support::FieldName::new("region");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("param_ty")
}> =
::tracing::__macro_support::FieldName::new("param_ty");
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(&origin)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(®ion)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(¶m_ty)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: () = loop {};
return __tracing_attr_fake_return;
}
{
let verify_bound =
self.verify_bound.param_or_placeholder_bound(param_ty.to_ty(self.tcx));
self.delegate.push_verify(origin, GenericKind::Param(param_ty),
region, verify_bound);
}
}
}#[instrument(level = "debug", skip(self))]
544 fn param_ty_must_outlive(
545 &mut self,
546 origin: infer::SubregionOrigin<'tcx>,
547 region: ty::Region<'tcx>,
548 param_ty: ty::ParamTy,
549 ) {
550 let verify_bound = self.verify_bound.param_or_placeholder_bound(param_ty.to_ty(self.tcx));
551 self.delegate.push_verify(origin, GenericKind::Param(param_ty), region, verify_bound);
552 }
553
554 {}
#[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("placeholder_ty_must_outlive",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(554u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("origin")
}> =
::tracing::__macro_support::FieldName::new("origin");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("region")
}> =
::tracing::__macro_support::FieldName::new("region");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("placeholder_ty")
}> =
::tracing::__macro_support::FieldName::new("placeholder_ty");
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(&origin)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(®ion)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&placeholder_ty)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: () = loop {};
return __tracing_attr_fake_return;
}
{
let verify_bound =
self.verify_bound.param_or_placeholder_bound(Ty::new_placeholder(self.tcx,
placeholder_ty));
self.delegate.push_verify(origin,
GenericKind::Placeholder(placeholder_ty), region,
verify_bound);
}
}
}#[instrument(level = "debug", skip(self))]
555 fn placeholder_ty_must_outlive(
556 &mut self,
557 origin: infer::SubregionOrigin<'tcx>,
558 region: ty::Region<'tcx>,
559 placeholder_ty: ty::PlaceholderType<'tcx>,
560 ) {
561 let verify_bound = self
562 .verify_bound
563 .param_or_placeholder_bound(Ty::new_placeholder(self.tcx, placeholder_ty));
564 self.delegate.push_verify(
565 origin,
566 GenericKind::Placeholder(placeholder_ty),
567 region,
568 verify_bound,
569 );
570 }
571
572 {}
#[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("alias_ty_must_outlive",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(572u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("origin")
}> =
::tracing::__macro_support::FieldName::new("origin");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("region")
}> =
::tracing::__macro_support::FieldName::new("region");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("alias_ty")
}> =
::tracing::__macro_support::FieldName::new("alias_ty");
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(&origin)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(®ion)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&alias_ty)
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;
}
{
if alias_ty.args.is_empty() { return; }
if alias_ty.has_non_region_infer() {
self.tcx.dcx().span_delayed_bug(origin.span(),
"an alias has infers during region solving");
return;
}
let trait_bounds: Vec<_> =
rustc_type_ir::outlives::declared_bounds_from_definition(self.tcx,
alias_ty).collect();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs:611",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(611u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("trait_bounds")
}> =
::tracing::__macro_support::FieldName::new("trait_bounds");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_bounds)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let approx_env_bounds =
self.verify_bound.approx_declared_bounds_from_env(alias_ty);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs:617",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(617u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("approx_env_bounds")
}> =
::tracing::__macro_support::FieldName::new("approx_env_bounds");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&approx_env_bounds)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let kind = alias_ty.kind;
if approx_env_bounds.is_empty() && trait_bounds.is_empty() &&
(alias_ty.has_infer_regions() ||
#[allow(non_exhaustive_omitted_patterns)] match kind {
ty::Opaque { .. } => true,
_ => false,
}) {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs:638",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(638u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::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!("no declared bounds")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let opt_variances = self.tcx.opt_alias_variances(kind);
self.args_must_outlive(alias_ty.args, origin, region,
opt_variances);
return;
}
if !trait_bounds.is_empty() &&
trait_bounds[1..].iter().map(|r|
Some(*r)).chain(approx_env_bounds.iter().map(|b|
b.map_bound(|b|
b.1).no_bound_vars())).all(|b| b == Some(trait_bounds[0])) {
let unique_bound = trait_bounds[0];
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs:669",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(669u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("unique_bound")
}> =
::tracing::__macro_support::FieldName::new("unique_bound");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&unique_bound)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs:670",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(670u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::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!("unique declared bound appears in trait ref")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let category = origin.to_constraint_category();
self.delegate.push_sub_region_constraint(origin, region,
unique_bound, category);
return;
}
let verify_bound = self.verify_bound.alias_bound(alias_ty);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs:682",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(682u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::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!("alias_must_outlive: pushing {0:?}",
verify_bound) as &dyn ::tracing::field::Value))])
});
} else { ; }
};
self.delegate.push_verify(origin, GenericKind::Alias(alias_ty),
region, verify_bound);
}
}
}#[instrument(level = "debug", skip(self))]
573 fn alias_ty_must_outlive(
574 &mut self,
575 origin: infer::SubregionOrigin<'tcx>,
576 region: ty::Region<'tcx>,
577 alias_ty: ty::AliasTy<'tcx>,
578 ) {
579 if alias_ty.args.is_empty() {
581 return;
582 }
583
584 if alias_ty.has_non_region_infer() {
585 self.tcx
586 .dcx()
587 .span_delayed_bug(origin.span(), "an alias has infers during region solving");
588 return;
589 }
590
591 let trait_bounds: Vec<_> =
609 rustc_type_ir::outlives::declared_bounds_from_definition(self.tcx, alias_ty).collect();
610
611 debug!(?trait_bounds);
612
613 let approx_env_bounds = self.verify_bound.approx_declared_bounds_from_env(alias_ty);
617 debug!(?approx_env_bounds);
618
619 let kind = alias_ty.kind;
634 if approx_env_bounds.is_empty()
635 && trait_bounds.is_empty()
636 && (alias_ty.has_infer_regions() || matches!(kind, ty::Opaque { .. }))
637 {
638 debug!("no declared bounds");
639 let opt_variances = self.tcx.opt_alias_variances(kind);
640 self.args_must_outlive(alias_ty.args, origin, region, opt_variances);
641 return;
642 }
643
644 if !trait_bounds.is_empty()
655 && trait_bounds[1..]
656 .iter()
657 .map(|r| Some(*r))
658 .chain(
659 approx_env_bounds.iter().map(|b| b.map_bound(|b| b.1).no_bound_vars()),
665 )
666 .all(|b| b == Some(trait_bounds[0]))
667 {
668 let unique_bound = trait_bounds[0];
669 debug!(?unique_bound);
670 debug!("unique declared bound appears in trait ref");
671 let category = origin.to_constraint_category();
672 self.delegate.push_sub_region_constraint(origin, region, unique_bound, category);
673 return;
674 }
675
676 let verify_bound = self.verify_bound.alias_bound(alias_ty);
682 debug!("alias_must_outlive: pushing {:?}", verify_bound);
683 self.delegate.push_verify(origin, GenericKind::Alias(alias_ty), region, verify_bound);
684 }
685
686 {}
#[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("args_must_outlive",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/215a8af4bb4c106cccf6d6535f84eaae91818265/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(686u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("args")
}> =
::tracing::__macro_support::FieldName::new("args");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("origin")
}> =
::tracing::__macro_support::FieldName::new("origin");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("region")
}> =
::tracing::__macro_support::FieldName::new("region");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("opt_variances")
}> =
::tracing::__macro_support::FieldName::new("opt_variances");
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(&args)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(®ion)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&opt_variances)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: () = loop {};
return __tracing_attr_fake_return;
}
{
let constraint = origin.to_constraint_category();
for (index, arg) in args.iter().enumerate() {
match arg.kind() {
GenericArgKind::Lifetime(lt) => {
let variance =
if let Some(variances) = opt_variances {
variances[index]
} else { ty::Invariant };
if variance == ty::Invariant {
self.delegate.push_sub_region_constraint(origin.clone(),
region, lt, constraint);
}
}
GenericArgKind::Type(ty) => {
self.type_must_outlive(origin.clone(), ty, region,
constraint);
}
GenericArgKind::Const(_) => {}
}
}
}
}
}#[instrument(level = "debug", skip(self))]
687 fn args_must_outlive(
688 &mut self,
689 args: GenericArgsRef<'tcx>,
690 origin: infer::SubregionOrigin<'tcx>,
691 region: ty::Region<'tcx>,
692 opt_variances: Option<&[ty::Variance]>,
693 ) {
694 let constraint = origin.to_constraint_category();
695 for (index, arg) in args.iter().enumerate() {
696 match arg.kind() {
697 GenericArgKind::Lifetime(lt) => {
698 let variance = if let Some(variances) = opt_variances {
699 variances[index]
700 } else {
701 ty::Invariant
702 };
703 if variance == ty::Invariant {
704 self.delegate.push_sub_region_constraint(
705 origin.clone(),
706 region,
707 lt,
708 constraint,
709 );
710 }
711 }
712 GenericArgKind::Type(ty) => {
713 self.type_must_outlive(origin.clone(), ty, region, constraint);
714 }
715 GenericArgKind::Const(_) => {
716 }
718 }
719 }
720 }
721}
722
723impl<'cx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'tcx> {
724 fn push_sub_region_constraint(
725 &mut self,
726 origin: SubregionOrigin<'tcx>,
727 a: ty::Region<'tcx>,
728 b: ty::Region<'tcx>,
729 _constraint_category: ConstraintCategory<'tcx>,
730 ) {
731 self.sub_regions(origin, a, b, ty::VisibleForLeakCheck::Unreachable)
733 }
734
735 fn push_verify(
736 &mut self,
737 origin: SubregionOrigin<'tcx>,
738 kind: GenericKind<'tcx>,
739 a: ty::Region<'tcx>,
740 bound: VerifyBound<'tcx>,
741 ) {
742 self.verify_generic_bound(origin, kind, a, bound)
743 }
744}