`todo!()` in function arguments causes the function call to be linted
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
pub fn foo<T>(a: T) -> T {
a
}
pub fn bar<T>() -> T {
foo(todo!())
}
I expected to see this happen: it compile with no lints
Instead, this happened: it told me my foo call was unreachable
warning: unreachable call
--> src/lib.rs:6:5
|
6 | foo(todo!())
| ^^^ ------- any code following this expression is unreachable
| |
| unreachable call
|
= note: `#[warn(unreachable_code)]` (part of `#[warn(unused)]`) on by default
while technically true this is not particularly helpful. It's been todo!()'d because I'm in the process of filling out the function arguments.
Meta
playground version:
Nightly channel
Build using the Nightly version: 1.94.0-nightly
(2025-12-27 7b5cde7370b82fecf700)
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
Reproduce the warning with the Rust snippet in the issue, then trace the compiler's unreachable_code lint handling for calls whose argument is todo!(). The change is done when this pattern no longer reports an unreachable-call warning while ordinary unreachable calls retain their existing diagnostics; add or update a regression test for the behavior.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100