@@ -69,6 +69,7 @@ use crate::infer::{
6969use crate :: traits:: { ObligationCause , ObligationCauseCode } ;
7070use rustc_data_structures:: undo_log:: UndoLogs ;
7171use rustc_hir:: def_id:: LocalDefId ;
72+ use rustc_middle:: mir:: ConstraintCategory ;
7273use rustc_middle:: ty:: subst:: GenericArgKind ;
7374use rustc_middle:: ty:: { self , Region , Ty , TyCtxt , TypeVisitable } ;
7475use smallvec:: smallvec;
@@ -163,7 +164,8 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
163164
164165 let outlives =
165166 & mut TypeOutlives :: new ( self , self . tcx , & region_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) ;
167169 }
168170 }
169171
@@ -207,6 +209,7 @@ pub trait TypeOutlivesDelegate<'tcx> {
207209 origin : SubregionOrigin < ' tcx > ,
208210 a : ty:: Region < ' tcx > ,
209211 b : ty:: Region < ' tcx > ,
212+ constraint_category : ConstraintCategory < ' tcx > ,
210213 ) ;
211214
212215 fn push_verify (
@@ -255,25 +258,27 @@ where
255258 origin : infer:: SubregionOrigin < ' tcx > ,
256259 ty : Ty < ' tcx > ,
257260 region : ty:: Region < ' tcx > ,
261+ category : ConstraintCategory < ' tcx > ,
258262 ) {
259263 assert ! ( !ty. has_escaping_bound_vars( ) ) ;
260264
261265 let mut components = smallvec ! [ ] ;
262266 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 ) ;
264268 }
265269
266270 fn components_must_outlive (
267271 & mut self ,
268272 origin : infer:: SubregionOrigin < ' tcx > ,
269273 components : & [ Component < ' tcx > ] ,
270274 region : ty:: Region < ' tcx > ,
275+ category : ConstraintCategory < ' tcx > ,
271276 ) {
272277 for component in components. iter ( ) {
273278 let origin = origin. clone ( ) ;
274279 match component {
275280 Component :: Region ( region1) => {
276- self . delegate . push_sub_region_constraint ( origin, region, * region1) ;
281+ self . delegate . push_sub_region_constraint ( origin, region, * region1, category ) ;
277282 }
278283 Component :: Param ( param_ty) => {
279284 self . param_ty_must_outlive ( origin, region, * param_ty) ;
@@ -282,7 +287,7 @@ where
282287 self . projection_must_outlive ( origin, region, * projection_ty) ;
283288 }
284289 Component :: EscapingProjection ( subcomponents) => {
285- self . components_must_outlive ( origin, & subcomponents, region) ;
290+ self . components_must_outlive ( origin, & subcomponents, region, category ) ;
286291 }
287292 Component :: UnresolvedInferenceVariable ( v) => {
288293 // ignore this, we presume it will yield an error
@@ -389,13 +394,19 @@ where
389394 if approx_env_bounds. is_empty ( ) && trait_bounds. is_empty ( ) && needs_infer {
390395 debug ! ( "projection_must_outlive: no declared bounds" ) ;
391396
397+ let constraint = ConstraintCategory :: BoringNoLocation ;
392398 for k in projection_ty. substs {
393399 match k. unpack ( ) {
394400 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+ ) ;
396407 }
397408 GenericArgKind :: Type ( ty) => {
398- self . type_must_outlive ( origin. clone ( ) , ty, region) ;
409+ self . type_must_outlive ( origin. clone ( ) , ty, region, constraint ) ;
399410 }
400411 GenericArgKind :: Const ( _) => {
401412 // Const parameters don't impose constraints.
@@ -433,7 +444,8 @@ where
433444 let unique_bound = trait_bounds[ 0 ] ;
434445 debug ! ( "projection_must_outlive: unique trait bound = {:?}" , unique_bound) ;
435446 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) ;
437449 return ;
438450 }
439451
@@ -455,6 +467,7 @@ impl<'cx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'cx, 'tcx> {
455467 origin : SubregionOrigin < ' tcx > ,
456468 a : ty:: Region < ' tcx > ,
457469 b : ty:: Region < ' tcx > ,
470+ _constraint_category : ConstraintCategory < ' tcx > ,
458471 ) {
459472 self . sub_regions ( origin, a, b)
460473 }
0 commit comments