Skip to content

Unused variable warning for default trait methods #92696

Closed as not planned
Closed as not planned
@CryZe

Description

@CryZe

Given the following code: Playground

pub trait AutoSplitter {
    type Data;
    fn update(&mut self) -> Option<Self::Data>;
    fn should_start(data: &Self::Data) -> bool {
        false
    }
}

The current output is:

warning: unused variable: `data`
 --> src/lib.rs:4:21
  |
4 |     fn should_start(data: &Self::Data) -> bool {
  |                     ^^^^ help: if this is intentional, prefix it with an underscore: `_data`
  |
  = note: `#[warn(unused_variables)]` on by default

Ideally the compiler should not emit any warnings as prefixing the parameter with an underscore would negatively affect the documentation and auto generated implementations via an IDE / rust-analyzer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-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