@@ -24,8 +24,8 @@ pub(super) fn infer_predicates(
24
24
25
25
// If new predicates were added then we need to re-calculate
26
26
// 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 ! [ ] ;
29
29
30
30
// Visit all the crates and infer predicates
31
31
for id in tcx. hir_free_items ( ) {
@@ -83,14 +83,27 @@ pub(super) fn infer_predicates(
83
83
. get ( & item_did. to_def_id ( ) )
84
84
. map_or ( 0 , |p| p. as_ref ( ) . skip_binder ( ) . len ( ) ) ;
85
85
if item_required_predicates. len ( ) > item_predicates_len {
86
- predicates_added = true ;
86
+ predicates_added. push ( item_did ) ;
87
87
global_inferred_outlives
88
88
. insert ( item_did. to_def_id ( ) , ty:: EarlyBinder :: bind ( item_required_predicates) ) ;
89
89
}
90
90
}
91
91
92
- if !predicates_added {
92
+ if predicates_added. is_empty ( ) {
93
+ // We've reached a fixed point.
93
94
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 ( ) ;
94
107
}
95
108
}
96
109
0 commit comments