File tree Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -264,6 +264,28 @@ impl S13 {
264264 }
265265}
266266
267- fn main ( ) {
268- // test code goes here
267+ struct S14 {
268+ field : String ,
269+ }
270+
271+ impl PartialEq for S14 {
272+ fn eq ( & self , other : & Self ) -> bool {
273+ // Should not warn!
274+ self . field . eq ( & other. field )
275+ }
276+ }
277+
278+ struct S15 < ' a > {
279+ field : & ' a S15 < ' a > ,
269280}
281+
282+ impl PartialEq for S15 < ' _ > {
283+ fn eq ( & self , other : & Self ) -> bool {
284+ //~^ ERROR: function cannot return without recursing
285+ let mine = & self . field ;
286+ let theirs = & other. field ;
287+ mine. eq ( theirs)
288+ }
289+ }
290+
291+ fn main ( ) { }
Original file line number Diff line number Diff line change @@ -340,5 +340,22 @@ note: recursive call site
340340LL | Self::default()
341341 | ^^^^^^^^^^^^^^^
342342
343- error: aborting due to 26 previous errors
343+ error: function cannot return without recursing
344+ --> $DIR/unconditional_recursion.rs:283:5
345+ |
346+ LL | / fn eq(&self, other: &Self) -> bool {
347+ LL | |
348+ LL | | let mine = &self.field;
349+ LL | | let theirs = &other.field;
350+ LL | | mine.eq(theirs)
351+ LL | | }
352+ | |_____^
353+ |
354+ note: recursive call site
355+ --> $DIR/unconditional_recursion.rs:287:9
356+ |
357+ LL | mine.eq(theirs)
358+ | ^^^^^^^^^^^^^^^
359+
360+ error: aborting due to 27 previous errors
344361
You can’t perform that action at this time.
0 commit comments