File tree 2 files changed +49
-2
lines changed
2 files changed +49
-2
lines changed Original file line number Diff line number Diff line change 1
1
//@no-rustfix
2
2
3
3
#![ warn( clippy:: unconditional_recursion) ]
4
- #![ allow( clippy:: partialeq_ne_impl) ]
4
+ #![ allow( clippy:: partialeq_ne_impl, clippy :: default_constructed_unit_structs ) ]
5
5
6
6
enum Foo {
7
7
A ,
@@ -232,6 +232,38 @@ impl std::string::ToString for S11 {
232
232
}
233
233
}
234
234
235
+ struct S12 ;
236
+
237
+ impl std:: default:: Default for S12 {
238
+ fn default ( ) -> Self {
239
+ Self :: new ( )
240
+ }
241
+ }
242
+
243
+ impl S12 {
244
+ fn new ( ) -> Self {
245
+ //~^ ERROR: function cannot return without recursing
246
+ Self :: default ( )
247
+ }
248
+
249
+ fn bar ( ) -> Self {
250
+ // Should not warn!
251
+ Self :: default ( )
252
+ }
253
+ }
254
+
255
+ #[ derive( Default ) ]
256
+ struct S13 {
257
+ f : u32 ,
258
+ }
259
+
260
+ impl S13 {
261
+ fn new ( ) -> Self {
262
+ // Shoud not warn!
263
+ Self :: default ( )
264
+ }
265
+ }
266
+
235
267
fn main ( ) {
236
268
// test code goes here
237
269
}
Original file line number Diff line number Diff line change @@ -325,5 +325,20 @@ note: recursive call site
325
325
LL | mine == theirs
326
326
| ^^^^^^^^^^^^^^
327
327
328
- error: aborting due to 25 previous errors
328
+ error: function cannot return without recursing
329
+ --> $DIR/unconditional_recursion.rs:244:5
330
+ |
331
+ LL | / fn new() -> Self {
332
+ LL | |
333
+ LL | | Self::default()
334
+ LL | | }
335
+ | |_____^
336
+ |
337
+ note: recursive call site
338
+ --> $DIR/unconditional_recursion.rs:246:9
339
+ |
340
+ LL | Self::default()
341
+ | ^^^^^^^^^^^^^^^
342
+
343
+ error: aborting due to 26 previous errors
329
344
You can’t perform that action at this time.
0 commit comments