Open
Description
Code
#[derive(Default)]
struct VariantA {
pub name: String
}
#[derive(Default)]
struct VariantB {
pub name: String
}
enum DefaultEnum {
A(VariantA),
B(VariantB)
}
impl Default for DefaultEnum {
fn default() -> Self {
Default::default()
}
}
fn main() {
let default_enum: DefaultEnum = Default::default();
}
Current output
Compiling playground v0.0.1 (/playground)
warning: function cannot return without recursing
--> src/main.rs:19:5
|
19 | fn default() -> Self {
| ^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
20 | Default::default()
| ------------------ recursive call site
|
= help: a `loop` may express intention better if this is on purpose
= note: `#[warn(unconditional_recursion)]` on by default
warning: `playground` (bin "playground") generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 0.63s
Running `target/debug/playground`
Desired output
should be an error instead of a warning
Rationale and extra context
This causes a stack overflow and should not compile
Other cases
No response
Anything else?
No response