This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +36
-4
lines changed
compiler/rustc_hir_analysis/src/outlives Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ pub(super) fn infer_predicates(
2424
2525 // If new predicates were added then we need to re-calculate
2626 // all crates since there could be new implied predicates.
27- loop {
28- let mut predicates_added = false ;
27+ for i in 0 .. {
28+ let mut predicates_added = vec ! [ ] ;
2929
3030 // Visit all the crates and infer predicates
3131 for id in tcx. hir_free_items ( ) {
@@ -83,14 +83,27 @@ pub(super) fn infer_predicates(
8383 . get ( & item_did. to_def_id ( ) )
8484 . map_or ( 0 , |p| p. as_ref ( ) . skip_binder ( ) . len ( ) ) ;
8585 if item_required_predicates. len ( ) > item_predicates_len {
86- predicates_added = true ;
86+ predicates_added. push ( item_did ) ;
8787 global_inferred_outlives
8888 . insert ( item_did. to_def_id ( ) , ty:: EarlyBinder :: bind ( item_required_predicates) ) ;
8989 }
9090 }
9191
92- if !predicates_added {
92+ if predicates_added. is_empty ( ) {
93+ // We've reached a fixed point.
9394 break ;
95+ } else if !tcx. recursion_limit ( ) . value_within_limit ( i) {
96+ let msg = if let & [ id] = & predicates_added[ ..] {
97+ format ! ( "overflow computing implied lifetime bounds for `{}`" , tcx. def_path_str( id) , )
98+ } else {
99+ "overflow computing implied lifetime bounds" . to_string ( )
100+ } ;
101+ tcx. dcx ( )
102+ . struct_span_fatal (
103+ predicates_added. iter ( ) . map ( |id| tcx. def_span ( * id) ) . collect :: < Vec < _ > > ( ) ,
104+ msg,
105+ )
106+ . emit ( ) ;
94107 }
95108 }
96109
Original file line number Diff line number Diff line change 1+ trait Tailed < ' a > : ' a {
2+ type Tail : Tailed < ' a > ;
3+ }
4+
5+ struct List < ' a , T : Tailed < ' a > > {
6+ //~^ ERROR overflow computing implied lifetime bounds for `List`
7+ next : Box < List < ' a , T :: Tail > > ,
8+ node : & ' a T ,
9+ }
10+
11+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: overflow computing implied lifetime bounds for `List`
2+ --> $DIR/overflow.rs:5:1
3+ |
4+ LL | struct List<'a, T: Tailed<'a>> {
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+ error: aborting due to 1 previous error
8+
You can’t perform that action at this time.
0 commit comments