Skip to content

Unconditionnal recursion not reported when using derive macros #142360

Open
@bleycommits

Description

@bleycommits

Code

#[derive(Default)]
struct Thing(Box<Thing>);

Thing::default() // unconditional recursion leading to a stack overflow

Current output

N/A

Desired output

Rustc should print the unconditional recursion lint and maybe recommend a rewrite in some way?

Rationale and extra context

In this case I meant to write Option<Box<...>>

Other cases

Rust Version

rustc 1.89.0-nightly (1677d46cb 2025-06-10)
binary: rustc
commit-hash: 1677d46cb128cc8f285dbd32b0dc4d7a46437050
commit-date: 2025-06-10
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5

Anything else?

playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions