@@ -413,17 +413,33 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
413
413
}
414
414
415
415
ty:: Predicate :: TypeOutlives ( ref binder) => {
416
- // For now, we just check that there are no higher-ranked
417
- // regions. If there are, we will call this obligation an
418
- // error. Eventually we should be able to support some
419
- // cases here, I imagine (e.g., `for<'a> int : 'a`).
416
+ // Check if there are higher-ranked regions.
420
417
match selcx. tcx ( ) . no_late_bound_regions ( binder) {
418
+ // If there are, inspect the underlying type further.
421
419
None => {
422
- errors. push (
423
- FulfillmentError :: new (
424
- obligation. clone ( ) ,
425
- CodeSelectionError ( Unimplemented ) ) )
420
+ // Convert from `Binder<OutlivesPredicate<Ty, Region>>` to `Binder<Ty>`.
421
+ let binder = binder. map_bound_ref ( |pred| pred. 0 ) ;
422
+
423
+ // Check if the type has any bound regions.
424
+ match selcx. tcx ( ) . no_late_bound_regions ( & binder) {
425
+ // If so, this obligation is an error (for now). Eventually we should be
426
+ // able to support additional cases here, like `for<'a> &'a str: 'a`.
427
+ None => {
428
+ errors. push (
429
+ FulfillmentError :: new (
430
+ obligation. clone ( ) ,
431
+ CodeSelectionError ( Unimplemented ) ) )
432
+ }
433
+ // Otherwise, we have something of the form
434
+ // `for<'a> T: 'a where 'a not in T`, which we can treat as `T: 'static`.
435
+ Some ( t_a) => {
436
+ register_region_obligation ( t_a, ty:: ReStatic ,
437
+ obligation. cause . clone ( ) ,
438
+ region_obligations) ;
439
+ }
440
+ }
426
441
}
442
+ // If there aren't, register the obligation.
427
443
Some ( ty:: OutlivesPredicate ( t_a, r_b) ) => {
428
444
register_region_obligation ( t_a, r_b,
429
445
obligation. cause . clone ( ) ,
0 commit comments