rust-lang / rust-lang/rust

`todo!()` in function arguments causes the function call to be linted

Open
#150,472 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lints C-enhancement L-unreachable_code T-compiler
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.