@@ -69,6 +69,7 @@ use crate::infer::{
69
69
use crate::traits::{ObligationCause, ObligationCauseCode};
70
70
use rustc_data_structures::undo_log::UndoLogs;
71
71
use rustc_hir::def_id::LocalDefId;
72
+ use rustc_middle::mir::ConstraintCategory;
72
73
use rustc_middle::ty::subst::GenericArgKind;
73
74
use rustc_middle::ty::{self, Region, Ty, TyCtxt, TypeVisitable};
74
75
use smallvec::smallvec;
@@ -163,7 +164,8 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
163
164
164
165
let outlives =
165
166
&mut TypeOutlives::new(self, self.tcx, ®ion_bound_pairs, None, param_env);
166
- outlives.type_must_outlive(origin, sup_type, sub_region);
167
+ let category = ConstraintCategory::BoringNoLocation;
168
+ outlives.type_must_outlive(origin, sup_type, sub_region, category);
167
169
}
168
170
}
169
171
@@ -207,6 +209,7 @@ pub trait TypeOutlivesDelegate<'tcx> {
207
209
origin: SubregionOrigin<'tcx>,
208
210
a: ty::Region<'tcx>,
209
211
b: ty::Region<'tcx>,
212
+ constraint_category: ConstraintCategory<'tcx>,
210
213
);
211
214
212
215
fn push_verify(
@@ -255,25 +258,27 @@ where
255
258
origin: infer::SubregionOrigin<'tcx>,
256
259
ty: Ty<'tcx>,
257
260
region: ty::Region<'tcx>,
261
+ category: ConstraintCategory<'tcx>,
258
262
) {
259
263
assert!(!ty.has_escaping_bound_vars());
260
264
261
265
let mut components = smallvec![];
262
266
push_outlives_components(self.tcx, ty, &mut components);
263
- self.components_must_outlive(origin, &components, region);
267
+ self.components_must_outlive(origin, &components, region, category );
264
268
}
265
269
266
270
fn components_must_outlive(
267
271
&mut self,
268
272
origin: infer::SubregionOrigin<'tcx>,
269
273
components: &[Component<'tcx>],
270
274
region: ty::Region<'tcx>,
275
+ category: ConstraintCategory<'tcx>,
271
276
) {
272
277
for component in components.iter() {
273
278
let origin = origin.clone();
274
279
match component {
275
280
Component::Region(region1) => {
276
- self.delegate.push_sub_region_constraint(origin, region, *region1);
281
+ self.delegate.push_sub_region_constraint(origin, region, *region1, category );
277
282
}
278
283
Component::Param(param_ty) => {
279
284
self.param_ty_must_outlive(origin, region, *param_ty);
@@ -282,7 +287,7 @@ where
282
287
self.projection_must_outlive(origin, region, *projection_ty);
283
288
}
284
289
Component::EscapingProjection(subcomponents) => {
285
- self.components_must_outlive(origin, &subcomponents, region);
290
+ self.components_must_outlive(origin, &subcomponents, region, category );
286
291
}
287
292
Component::UnresolvedInferenceVariable(v) => {
288
293
// ignore this, we presume it will yield an error
@@ -389,13 +394,19 @@ where
389
394
if approx_env_bounds.is_empty() && trait_bounds.is_empty() && needs_infer {
390
395
debug!("projection_must_outlive: no declared bounds");
391
396
397
+ let constraint = ConstraintCategory::BoringNoLocation;
392
398
for k in projection_ty.substs {
393
399
match k.unpack() {
394
400
GenericArgKind::Lifetime(lt) => {
395
- self.delegate.push_sub_region_constraint(origin.clone(), region, lt);
401
+ self.delegate.push_sub_region_constraint(
402
+ origin.clone(),
403
+ region,
404
+ lt,
405
+ constraint,
406
+ );
396
407
}
397
408
GenericArgKind::Type(ty) => {
398
- self.type_must_outlive(origin.clone(), ty, region);
409
+ self.type_must_outlive(origin.clone(), ty, region, constraint );
399
410
}
400
411
GenericArgKind::Const(_) => {
401
412
// Const parameters don't impose constraints.
@@ -433,7 +444,8 @@ where
433
444
let unique_bound = trait_bounds[0];
434
445
debug!("projection_must_outlive: unique trait bound = {:?}", unique_bound);
435
446
debug!("projection_must_outlive: unique declared bound appears in trait ref");
436
- self.delegate.push_sub_region_constraint(origin, region, unique_bound);
447
+ let category = ConstraintCategory::BoringNoLocation;
448
+ self.delegate.push_sub_region_constraint(origin, region, unique_bound, category);
437
449
return;
438
450
}
439
451
@@ -455,6 +467,7 @@ impl<'cx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'cx, 'tcx> {
455
467
origin: SubregionOrigin<'tcx>,
456
468
a: ty::Region<'tcx>,
457
469
b: ty::Region<'tcx>,
470
+ _constraint_category: ConstraintCategory<'tcx>,
458
471
) {
459
472
self.sub_regions(origin, a, b)
460
473
}
0 commit comments