1use rustc_data_structures::transitive_relation::{TransitiveRelation, TransitiveRelationBuilder};
63use rustc_data_structures::undo_log::UndoLogs;
64use rustc_middle::mir::ConstraintCategory;
65use rustc_middle::ty::outlives::{Component, push_outlives_components};
66use rustc_middle::ty::{
67 self, GenericArgKind, GenericArgs, PolyTypeOutlivesClause, Region, RegionVid, Ty, TyCtxt,
68 TypeVisitableExt, Upcast,
69};
70use rustc_span::bug;
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::unreachable_default_msg()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/522d96a5707c154b15960db186c03b84a52b4efb/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.type_outlives_constraints.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.type_outlives_constraints.push(obligation);
141 }
142
143 pub fn register_solver_region_constraint(
144 &self,
145 c: SolverRegionConstraint<'tcx>,
146 vis: ty::VisibleForLeakCheck,
147 ) {
148 self.inner.borrow_mut().unwrap_region_constraints().register_solver_constraint(c, vis);
149 }
150
151 pub fn register_type_outlives_constraint(
152 &self,
153 sup_type: Ty<'tcx>,
154 sub_region: Region<'tcx>,
155 cause: &ObligationCause<'tcx>,
156 ) {
157 if !!self.tcx.assumptions_on_binders() {
::core::panicking::panic("assertion failed: !self.tcx.assumptions_on_binders()")
};assert!(!self.tcx.assumptions_on_binders());
158
159 if sup_type.is_global() {
164 return;
165 }
166
167 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs:167",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(167u32),
::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);
168 let origin = SubregionOrigin::from_obligation_cause(cause, || {
169 SubregionOrigin::RelateParamBound(
170 cause.span,
171 sup_type,
172 match cause.code().peel_derives() {
173 ObligationCauseCode::WhereClause(_, span)
174 | ObligationCauseCode::WhereClauseInExpr(_, span, ..)
175 | ObligationCauseCode::OpaqueTypeBound(span, _)
176 if !span.is_dummy() =>
177 {
178 Some(*span)
179 }
180 _ => None,
181 },
182 )
183 });
184
185 self.register_type_outlives_constraint_inner(TypeOutlivesConstraint {
186 sup_type,
187 sub_region,
188 origin,
189 });
190 }
191
192 pub fn take_registered_type_outlives_constraints(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
194 if !!self.in_snapshot() {
{
::core::panicking::panic_fmt(format_args!("cannot take registered type outlives constraints in a snapshot"));
}
};assert!(
195 !self.in_snapshot(),
196 "cannot take registered type outlives constraints in a snapshot"
197 );
198 std::mem::take(&mut self.inner.borrow_mut().type_outlives_constraints)
199 }
200
201 pub fn num_registered_type_outlives_constraints(&self) -> usize {
202 self.inner.borrow().type_outlives_constraints.len()
203 }
204
205 pub fn registered_type_outlives_constraints_since(
206 &self,
207 prev: usize,
208 ) -> Vec<TypeOutlivesConstraint<'tcx>> {
209 self.inner.borrow().type_outlives_constraints.iter().skip(prev).cloned().collect()
210 }
211
212 pub fn clone_registered_type_outlives_constraints(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
213 self.inner.borrow().type_outlives_constraints.clone()
214 }
215
216 pub fn register_region_assumption(&self, assumption: ty::ArgOutlivesClause<'tcx>) {
217 let mut inner = self.inner.borrow_mut();
218 inner.undo_log.push(UndoLog::PushRegionAssumption);
219 inner.region_assumptions.push(assumption);
220 }
221
222 pub fn take_registered_region_assumptions(&self) -> Vec<ty::ArgOutlivesClause<'tcx>> {
223 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");
224 std::mem::take(&mut self.inner.borrow_mut().region_assumptions)
225 }
226
227 pub fn destructure_solver_region_constraints_for_regionck(
228 &self,
229 outlives_env: &OutlivesEnvironment<'tcx>,
230 ) {
231 let mut region_outlives = TransitiveRelationBuilder::default();
235 for (r1, r2) in outlives_env.free_region_map().relation.base_edges() {
236 region_outlives.add(r2, r1);
237 }
238 let assumptions = rustc_type_ir::region_constraint::Assumptions::new(
239 self,
240 assumed_type_outlives(
241 self.tcx,
242 outlives_env.known_type_outlives(),
243 outlives_env.region_bound_pairs(),
244 ),
245 region_outlives.freeze(),
246 ty::UniverseIndex::ROOT,
247 );
248 self.destructure_solver_region_constraints(assumptions, self);
249 }
250
251 pub fn destructure_solver_region_constraints_for_borrowck(
252 &self,
253 conversion: impl TypeOutlivesDelegate<'tcx>,
255 known_type_outlives: &[PolyTypeOutlivesClause<'tcx>],
256 region_bound_pairs: &RegionBoundPairs<'tcx>,
257 region_outlives: TransitiveRelation<RegionVid>,
258 ) {
259 let assumptions = region_constraint::Assumptions::new(
260 self,
261 assumed_type_outlives(self.tcx, known_type_outlives, region_bound_pairs),
262 region_outlives.maybe_map(|r| Some(Region::new_var(self.tcx, r))).unwrap(),
263 ty::UniverseIndex::ROOT,
264 );
265 self.destructure_solver_region_constraints(assumptions, conversion);
266 }
267
268 {}
#[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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(268u32),
::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()")
};
use LeafRegionConstraint::*;
let solver_constraint = self.get_solver_region_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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs:279",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(279u32),
::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("solver_constraint")
}> =
::tracing::__macro_support::FieldName::new("solver_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(&solver_constraint)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let region_constraint::RootDestructuredConstraints {
constraint, failing_leafs } =
region_constraint::destructure_type_outlives_constraints_in_root(self,
solver_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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs:286",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(286u32),
::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 { ; }
};
if constraint.is_false() {
match failing_leafs.first() {
Some((PlaceholderTyOutlives(_a, _b), span)) => {
self.dcx().struct_span_err(*span,
"unable to satisfy constraints because it cannot be proven").emit();
}
Some((AliasTyOutlivesViaEnv(_), span)) => {
self.dcx().struct_span_err(*span,
"unable to satisfy constraints because it cannot be proven").emit();
}
_ => { ::core::panicking::unreachable_default_msg() }
}
}
for (c, span) in
constraint.and_constraint.into_iter().chain(constraint.or_constraint.into_iter().flatten())
{
match c {
Ambiguity => {
self.dcx().struct_span_err(span,
"unable to satisfy constraints involving placeholders due to unknown implied bounds").emit();
}
RegionOutlives(a, b) => {
let origin = SubregionOrigin::SolverRegionConstraint(span);
let category = origin.to_constraint_category();
conversion.push_sub_region_constraint(origin, b, a,
category);
}
AliasTyOutlivesViaEnv(..) | PlaceholderTyOutlives(..) => {
::core::panicking::unreachable_default_msg()
}
}
}
}
}
}#[instrument(level = "debug", skip(self, conversion))]
269 pub fn destructure_solver_region_constraints(
270 &self,
271 assumptions: rustc_type_ir::region_constraint::Assumptions<TyCtxt<'tcx>>,
272 mut conversion: impl TypeOutlivesDelegate<'tcx>,
273 ) {
274 assert!(self.tcx.assumptions_on_binders());
275 assert!(self.next_trait_solver());
276 use LeafRegionConstraint::*;
277
278 let solver_constraint = self.get_solver_region_constraint();
279 debug!(?solver_constraint);
280 let region_constraint::RootDestructuredConstraints { constraint, failing_leafs } =
281 region_constraint::destructure_type_outlives_constraints_in_root(
282 self,
283 solver_constraint,
284 &assumptions,
285 );
286 debug!(?constraint);
287
288 if constraint.is_false() {
289 match failing_leafs.first() {
290 Some((PlaceholderTyOutlives(_a, _b), span)) => {
291 self.dcx()
292 .struct_span_err(
293 *span,
294 "unable to satisfy constraints because it cannot be proven",
295 )
296 .emit();
297 }
298 Some((AliasTyOutlivesViaEnv(_), span)) => {
299 self.dcx()
300 .struct_span_err(
301 *span,
302 "unable to satisfy constraints because it cannot be proven",
303 )
304 .emit();
305 }
306 _ => {
307 unreachable!()
308 }
309 }
310 }
311
312 for (c, span) in constraint
314 .and_constraint
315 .into_iter()
316 .chain(constraint.or_constraint.into_iter().flatten())
317 {
318 match c {
319 Ambiguity => {
320 self.dcx()
321 .struct_span_err(
322 span,
323 "unable to satisfy constraints involving placeholders due to unknown implied bounds",
324 )
325 .emit();
326 }
327 RegionOutlives(a, b) => {
328 let origin = SubregionOrigin::SolverRegionConstraint(span);
329 let category = origin.to_constraint_category();
330 conversion.push_sub_region_constraint(
331 origin, b, a, category,
333 );
334 }
335 AliasTyOutlivesViaEnv(..) | PlaceholderTyOutlives(..) => {
336 unreachable!()
337 }
338 }
339 }
340 }
341
342 {}
#[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_type_outlives_constraints",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(351u32),
::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;
}
{
if !!self.in_snapshot() {
{
::core::panicking::panic_fmt(format_args!("cannot process registered type outlives constraints in a snapshot"));
}
};
if self.tcx.assumptions_on_binders() {
self.destructure_solver_region_constraints_for_regionck(outlives_env);
}
for iteration in 0.. {
let my_type_outlives_constraints =
self.take_registered_type_outlives_constraints();
if my_type_outlives_constraints.is_empty() { break; }
if !self.tcx.recursion_limit().value_within_limit(iteration) {
::rustc_span::macros::bug_impl(None,
format_args!("unexpected overflowed when processing type outlives constraints: {0:#?}",
my_type_outlives_constraints), Location::caller());
}
for TypeOutlivesConstraint { sup_type, sub_region, origin } in
my_type_outlives_constraints {
#[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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs:402",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(402u32),
::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))]
352 pub fn process_registered_type_outlives_constraints(
353 &self,
354 outlives_env: &OutlivesEnvironment<'tcx>,
355 ) {
356 assert!(
357 !self.in_snapshot(),
358 "cannot process registered type outlives constraints in a snapshot"
359 );
360
361 if self.tcx.assumptions_on_binders() {
362 self.destructure_solver_region_constraints_for_regionck(outlives_env);
363 }
364
365 for iteration in 0.. {
367 let my_type_outlives_constraints = self.take_registered_type_outlives_constraints();
368 if my_type_outlives_constraints.is_empty() {
369 break;
370 }
371
372 if !self.tcx.recursion_limit().value_within_limit(iteration) {
373 bug!(
377 "unexpected overflowed when processing type outlives constraints: {my_type_outlives_constraints:#?}"
378 );
379 }
380
381 for TypeOutlivesConstraint { sup_type, sub_region, origin } in
382 my_type_outlives_constraints
383 {
384 #[allow(rustc::usage_of_type_ir_traits)]
391 let (sup_type, sub_region) =
392 self.deeply_resolve_via_unification_table((sup_type, sub_region));
393
394 if self.tcx.sess.opts.unstable_opts.higher_ranked_assumptions
395 && outlives_env
396 .higher_ranked_assumptions()
397 .contains(&ty::OutlivesClause(sup_type.into(), sub_region))
398 {
399 continue;
400 }
401
402 debug!(?sup_type, ?sub_region, ?origin);
403
404 let outlives = &mut TypeOutlives::new(
405 self,
406 self.tcx,
407 outlives_env.region_bound_pairs(),
408 None,
409 outlives_env.known_type_outlives(),
410 );
411 let category = origin.to_constraint_category();
412 outlives.type_must_outlive(origin, sup_type, sub_region, category);
413 }
414 }
415 }
416}
417
418fn assumed_type_outlives<'tcx>(
426 tcx: TyCtxt<'tcx>,
427 known_type_outlives: &[PolyTypeOutlivesClause<'tcx>],
428 region_bound_pairs: &RegionBoundPairs<'tcx>,
429) -> Vec<ty::Clause<'tcx>> {
430 known_type_outlives
431 .iter()
432 .copied()
433 .chain(region_bound_pairs.iter().map(|&ty::OutlivesClause(kind, r)| {
434 ty::Binder::dummy(ty::OutlivesClause(kind.to_ty(tcx), r))
435 }))
436 .map(|c| c.map_bound(ty::ClauseKind::TypeOutlives).upcast(tcx))
437 .collect()
438}
439
440pub struct TypeOutlives<'cx, 'tcx, D>
447where
448 D: TypeOutlivesDelegate<'tcx>,
449{
450 delegate: D,
453 tcx: TyCtxt<'tcx>,
454 verify_bound: VerifyBoundCx<'cx, 'tcx>,
455}
456
457pub trait TypeOutlivesDelegate<'tcx> {
458 fn push_sub_region_constraint(
459 &mut self,
460 origin: SubregionOrigin<'tcx>,
461 a: ty::Region<'tcx>,
462 b: ty::Region<'tcx>,
463 constraint_category: ConstraintCategory<'tcx>,
464 );
465
466 fn push_verify(
467 &mut self,
468 origin: SubregionOrigin<'tcx>,
469 kind: GenericKind<'tcx>,
470 a: ty::Region<'tcx>,
471 bound: VerifyBound<'tcx>,
472 );
473}
474
475impl<'cx, 'tcx, D> TypeOutlives<'cx, 'tcx, D>
476where
477 D: TypeOutlivesDelegate<'tcx>,
478{
479 pub fn new(
480 delegate: D,
481 tcx: TyCtxt<'tcx>,
482 region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
483 implicit_region_bound: Option<ty::Region<'tcx>>,
484 caller_bounds: &'cx [ty::PolyTypeOutlivesClause<'tcx>],
485 ) -> Self {
486 Self {
487 delegate,
488 tcx,
489 verify_bound: VerifyBoundCx::new(
490 tcx,
491 region_bound_pairs,
492 implicit_region_bound,
493 caller_bounds,
494 ),
495 }
496 }
497
498 {}
#[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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(506u32),
::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))]
507 pub fn type_must_outlive(
508 &mut self,
509 origin: infer::SubregionOrigin<'tcx>,
510 ty: Ty<'tcx>,
511 region: ty::Region<'tcx>,
512 category: ConstraintCategory<'tcx>,
513 ) {
514 assert!(!ty.has_escaping_bound_vars());
515 debug_assert!(!ty.has_non_region_infer());
516 debug_assert!(
517 !self.tcx.next_trait_solver_globally() || !ty.has_non_rigid_aliases(),
518 "{ty:?} has non-rigid aliases"
519 );
520
521 let mut components = smallvec![];
522 push_outlives_components(self.tcx, ty, &mut components);
523 self.components_must_outlive(origin, &components, region, category);
524 }
525
526 fn components_must_outlive(
527 &mut self,
528 origin: infer::SubregionOrigin<'tcx>,
529 components: &[Component<TyCtxt<'tcx>>],
530 region: ty::Region<'tcx>,
531 category: ConstraintCategory<'tcx>,
532 ) {
533 for component in components.iter() {
534 let origin = origin.clone();
535 match component {
536 Component::Region(region1) => {
537 self.delegate.push_sub_region_constraint(origin, region, *region1, category);
538 }
539 Component::Param(param_ty) => {
540 self.param_ty_must_outlive(origin, region, *param_ty);
541 }
542 Component::Placeholder(placeholder_ty) => {
543 self.placeholder_ty_must_outlive(origin, region, *placeholder_ty);
544 }
545 Component::Alias(is_rigid, alias_ty) => {
546 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));
547 self.alias_ty_must_outlive(origin, region, *alias_ty);
548 }
549 Component::EscapingAlias(subcomponents) => {
550 self.components_must_outlive(origin, subcomponents, region, category);
551 }
552 Component::UnresolvedInferenceVariable(v) => {
553 self.tcx.dcx().span_delayed_bug(
557 origin.span(),
558 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unresolved inference variable in outlives: {0:?}",
v))
})format!("unresolved inference variable in outlives: {v:?}"),
559 );
560 }
561 }
562 }
563 }
564
565 {}
#[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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(565u32),
::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))]
566 fn param_ty_must_outlive(
567 &mut self,
568 origin: infer::SubregionOrigin<'tcx>,
569 region: ty::Region<'tcx>,
570 param_ty: ty::ParamTy,
571 ) {
572 let verify_bound = self.verify_bound.param_or_placeholder_bound(param_ty.to_ty(self.tcx));
573 self.delegate.push_verify(origin, GenericKind::Param(param_ty), region, verify_bound);
574 }
575
576 {}
#[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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(576u32),
::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))]
577 fn placeholder_ty_must_outlive(
578 &mut self,
579 origin: infer::SubregionOrigin<'tcx>,
580 region: ty::Region<'tcx>,
581 placeholder_ty: ty::PlaceholderType<'tcx>,
582 ) {
583 let verify_bound = self
584 .verify_bound
585 .param_or_placeholder_bound(Ty::new_placeholder(self.tcx, placeholder_ty));
586 self.delegate.push_verify(
587 origin,
588 GenericKind::Placeholder(placeholder_ty),
589 region,
590 verify_bound,
591 );
592 }
593
594 {}
#[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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(594u32),
::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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs:633",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(633u32),
::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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs:639",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(639u32),
::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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs:660",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(660u32),
::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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs:691",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(691u32),
::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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs:692",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(692u32),
::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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs:704",
"rustc_infer::infer::outlives::obligations",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(704u32),
::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))]
595 fn alias_ty_must_outlive(
596 &mut self,
597 origin: infer::SubregionOrigin<'tcx>,
598 region: ty::Region<'tcx>,
599 alias_ty: ty::AliasTy<'tcx>,
600 ) {
601 if alias_ty.args.is_empty() {
603 return;
604 }
605
606 if alias_ty.has_non_region_infer() {
607 self.tcx
608 .dcx()
609 .span_delayed_bug(origin.span(), "an alias has infers during region solving");
610 return;
611 }
612
613 let trait_bounds: Vec<_> =
631 rustc_type_ir::outlives::declared_bounds_from_definition(self.tcx, alias_ty).collect();
632
633 debug!(?trait_bounds);
634
635 let approx_env_bounds = self.verify_bound.approx_declared_bounds_from_env(alias_ty);
639 debug!(?approx_env_bounds);
640
641 let kind = alias_ty.kind;
656 if approx_env_bounds.is_empty()
657 && trait_bounds.is_empty()
658 && (alias_ty.has_infer_regions() || matches!(kind, ty::Opaque { .. }))
659 {
660 debug!("no declared bounds");
661 let opt_variances = self.tcx.opt_alias_variances(kind);
662 self.args_must_outlive(alias_ty.args, origin, region, opt_variances);
663 return;
664 }
665
666 if !trait_bounds.is_empty()
677 && trait_bounds[1..]
678 .iter()
679 .map(|r| Some(*r))
680 .chain(
681 approx_env_bounds.iter().map(|b| b.map_bound(|b| b.1).no_bound_vars()),
687 )
688 .all(|b| b == Some(trait_bounds[0]))
689 {
690 let unique_bound = trait_bounds[0];
691 debug!(?unique_bound);
692 debug!("unique declared bound appears in trait ref");
693 let category = origin.to_constraint_category();
694 self.delegate.push_sub_region_constraint(origin, region, unique_bound, category);
695 return;
696 }
697
698 let verify_bound = self.verify_bound.alias_bound(alias_ty);
704 debug!("alias_must_outlive: pushing {:?}", verify_bound);
705 self.delegate.push_verify(origin, GenericKind::Alias(alias_ty), region, verify_bound);
706 }
707
708 {}
#[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/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
::tracing_core::__macro_support::Option::Some(708u32),
::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))]
709 fn args_must_outlive(
710 &mut self,
711 args: GenericArgs<'tcx>,
712 origin: infer::SubregionOrigin<'tcx>,
713 region: ty::Region<'tcx>,
714 opt_variances: Option<&[ty::Variance]>,
715 ) {
716 let constraint = origin.to_constraint_category();
717 for (index, arg) in args.iter().enumerate() {
718 match arg.kind() {
719 GenericArgKind::Lifetime(lt) => {
720 let variance = if let Some(variances) = opt_variances {
721 variances[index]
722 } else {
723 ty::Invariant
724 };
725 if variance == ty::Invariant {
726 self.delegate.push_sub_region_constraint(
727 origin.clone(),
728 region,
729 lt,
730 constraint,
731 );
732 }
733 }
734 GenericArgKind::Type(ty) => {
735 self.type_must_outlive(origin.clone(), ty, region, constraint);
736 }
737 GenericArgKind::Const(_) => {
738 }
740 }
741 }
742 }
743}
744
745impl<'cx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'tcx> {
746 fn push_sub_region_constraint(
747 &mut self,
748 origin: SubregionOrigin<'tcx>,
749 a: ty::Region<'tcx>,
750 b: ty::Region<'tcx>,
751 _constraint_category: ConstraintCategory<'tcx>,
752 ) {
753 self.sub_regions(origin, a, b, ty::VisibleForLeakCheck::Unreachable)
755 }
756
757 fn push_verify(
758 &mut self,
759 origin: SubregionOrigin<'tcx>,
760 kind: GenericKind<'tcx>,
761 a: ty::Region<'tcx>,
762 bound: VerifyBound<'tcx>,
763 ) {
764 self.verify_generic_bound(origin, kind, a, bound)
765 }
766}