You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Router::<_>::new and <Router<_> as Default>::default are mutually recursive. #57965 tracks detecting unconditional recursion across function calls, which would at least emit a compiler warning in this case.
Thanks for the report! Since this appears not to actually be a problem with rustc, and there's already an issue tracking the diagnostic, I'm going to close this issue. Anyone should feel free to reopen if there's something I'm missing.
This problem happens when using Struct update syntax with Default implementation (https://doc.rust-lang.org/book/ch05-01-defining-structs.html#creating-instances-from-other-instances-with-struct-update-syntax).
I have found this bug in a more complicated piece of code, but I was able to create a simpler reproduction.
I expected this to just print "Hello, world!", but instead it panics with a stack overflow:
Changing the Struct update syntax to explicit parameters resolves the issue:
Meta
The issue is reproducible with both stable and nightly compilers and adding RUST_BACKTRACE=1 or RUST_BACKTRACE=full does not produce a stack trace.
The reproduction runs also on playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e5dd848f3af5f5f2b1f13c1d70163f5b
The text was updated successfully, but these errors were encountered: