Skip to content

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

@BoxyUwU

Description

@BoxyUwU

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.L-unreachable_codeLint: unreachable_codeT-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