Skip to content

NewLint: unused tuple element #13975

Open
@SpriteOvO

Description

What it does

Detecting if any element in a tuple variable is unused.

Advantage

  • If a new element is added, other places that use this tuple may forget to update the use of new elements.

Drawbacks

  • It can be a little noisy.
  • It cannot be ignored by adding a prefix underscore, but only using #[allow] or #[expect].

Base on that, this lint probably should be in the pedantic category.

Example

fn main() {
    let a = (1, 2);
    println!("{}", a.0);
}

Emit warning

warning: unused tuple element : `a.1`
 --> src/main.rs:2:9
  |
2 |     let a = (1, 2);
  |         ^ 

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions