Skip to content

Don't warn on unused arguments in unimplemented functions #78136

Closed as not planned
@bugaevc

Description

@bugaevc

The following code:

fn foo(arg: i32) {
    todo!()
}

fn main() {
    foo(35);
}

(playground)

Currently emits a warning:

warning: unused variable: `arg`
 --> src/main.rs:1:8
  |
1 | fn foo(arg: i32) {
  |        ^^^ help: if this is intentional, prefix it with an underscore: `_arg`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted

But todo!() clearly indicates that the argument is unused neither because it's intended to be ignored (in which case it'd be appropriate to rename it to _arg), nor because the author forgot to use it — but simply because the relevant code to use it has not been written yet.

Since todo!() itself does not trigger any warnings (meaning, rustc is fine with trying to compile code with parts that are explicitly not implemented yet), it doesn't seem appropriate to warn about unused variables that are "covered" by todo!().

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-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