File tree Expand file tree Collapse file tree 2 files changed +49
-2
lines changed Expand file tree Collapse file tree 2 files changed +49
-2
lines changed Original file line number Diff line number Diff line change 11//@no-rustfix
22
33#![ warn( clippy:: unconditional_recursion) ]
4- #![ allow( clippy:: partialeq_ne_impl) ]
4+ #![ allow( clippy:: partialeq_ne_impl, clippy :: default_constructed_unit_structs ) ]
55
66enum Foo {
77 A ,
@@ -232,6 +232,38 @@ impl std::string::ToString for S11 {
232232 }
233233}
234234
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+
235267fn main ( ) {
236268 // test code goes here
237269}
Original file line number Diff line number Diff line change @@ -325,5 +325,20 @@ note: recursive call site
325325LL | mine == theirs
326326 | ^^^^^^^^^^^^^^
327327
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
329344
You can’t perform that action at this time.
0 commit comments