Skip to content

unused variable: warn about std::collections that are pushed to but not used afterwards #49151

@matthiaskrgr

Description

@matthiaskrgr
fn main() {
        let mut var: Vec<i64> = Vec::new();
        var.push(1);
}

I would expect a warning here that var is unused.
I get that it is "used" in the sense that we push to it, however the resulting vector is still not done anything with.

Some kind of dead-store warning about the collection being unused/never queried after receiving an item might be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-collectionsArea: `std::collections`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.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions