File tree Expand file tree Collapse file tree 3 files changed +44
-4
lines changed
compiler/rustc_hir_analysis/src/outlives Expand file tree Collapse file tree 3 files changed +44
-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: Option < Vec < _ > > = None ;
2929
3030 // Visit all the crates and infer predicates
3131 for id in tcx. hir_free_items ( ) {
@@ -83,13 +83,34 @@ 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. get_or_insert_default ( ) . 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 let Some ( ids) = predicates_added {
93+ if !tcx. recursion_limit ( ) . value_within_limit ( i) {
94+ let msg = if let & [ id] = & ids[ ..] {
95+ format ! (
96+ "overflow computing implied lifetime bounds for `{}`" ,
97+ tcx. def_path_str( id) ,
98+ )
99+ } else {
100+ "overflow computing implied lifetime bounds" . to_string ( )
101+ } ;
102+ tcx. dcx ( )
103+ . struct_span_err (
104+ ids. iter ( ) . map ( |id| tcx. def_span ( * id) ) . collect :: < Vec < _ > > ( ) ,
105+ msg,
106+ )
107+ . emit ( ) ;
108+ for id in ids {
109+ global_inferred_outlives. shift_remove ( & id. to_def_id ( ) ) ;
110+ }
111+ break ;
112+ }
113+ } else {
93114 break ;
94115 }
95116 }
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