Unconditionnal recursion not reported when using derive macros
Open
Nobody has claimed this yet.
A-diagnostics
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Thing::default() example with the linked Rust Playground and the reported rustc nightly version. Trace how the Default derive macro-generated implementation is handled by the unconditional-recursion lint; done means the compiler reports the recursion for this case, with any rewrite recommendation matching the issue's agreed scope.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100