Skip to content

Unused warnings should trigger for swaps #2911

Closed
@catamorphism

Description

@catamorphism

From @jruderman 's comment on #1832:

IMO, the "unused" warning should be per-assignment, not per-variable.

fn main() {
   let mut x = 10;
   x = 20;
   log(error, x);
}

should warn because the first assignment to x is unused.

fn main() {
   let mut x = 10;
   log(error, x);
   x = 20;
}

should warn because the second assignment to x is unused. Finally, the original example,

fn main() {
   let mut x = 10, y = 20;
   x <-> y;
   log(error, y);
}

should warn because the second assignment to x is unused.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-type-systemArea: Type systemC-cleanupCategory: PRs that clean code up or issues documenting cleanup.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions