File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,31 @@ struct S5;
158158impl_partial_eq ! ( S5 ) ;
159159//~^ ERROR: function cannot return without recursing
160160
161+ struct S6 {
162+ field : String ,
163+ }
164+
165+ impl PartialEq for S6 {
166+ fn eq ( & self , other : & Self ) -> bool {
167+ let mine = & self . field ;
168+ let theirs = & other. field ;
169+ mine == theirs // Should not warn!
170+ }
171+ }
172+
173+ struct S7 < ' a > {
174+ field : & ' a S7 < ' a > ,
175+ }
176+
177+ impl < ' a > PartialEq for S7 < ' a > {
178+ fn eq ( & self , other : & Self ) -> bool {
179+ //~^ ERROR: function cannot return without recursing
180+ let mine = & self . field ;
181+ let theirs = & other. field ;
182+ mine == theirs
183+ }
184+ }
185+
161186fn main ( ) {
162187 // test code goes here
163188}
Original file line number Diff line number Diff line change @@ -247,5 +247,22 @@ LL | impl_partial_eq!(S5);
247247 | -------------------- in this macro invocation
248248 = note: this error originates in the macro `impl_partial_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
249249
250- error: aborting due to 19 previous errors
250+ error: function cannot return without recursing
251+ --> $DIR/unconditional_recursion.rs:178:5
252+ |
253+ LL | / fn eq(&self, other: &Self) -> bool {
254+ LL | |
255+ LL | | let mine = &self.field;
256+ LL | | let theirs = &other.field;
257+ LL | | mine == theirs
258+ LL | | }
259+ | |_____^
260+ |
261+ note: recursive call site
262+ --> $DIR/unconditional_recursion.rs:182:9
263+ |
264+ LL | mine == theirs
265+ | ^^^^^^^^^^^^^^
266+
267+ error: aborting due to 20 previous errors
251268
You can’t perform that action at this time.
0 commit comments