Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Let statement with wildcard lead to warnings for unused variables #57

Closed
rust-lang/rust
#88271
@roxelo

Description

@roxelo

There seem to be inconsistencies with lint warnings when using let statement with wildcards inside closures.

struct Props {
    field_1: u32, //~ WARNING: field is never read: `field_1`
    field_2: u32, //~ WARNING: field is never read: `field_2`
}

fn inside_closures() {
    let props_2 = Props { //~ WARNING: unused variable: `props_2`
        field_1: 1,
        field_2: 1,
    };

    let _ = || {
        let _: Props = props_2; // Warning lint does not consider `props_2` as being used here.
    };
}

fn ourside_closures() {
    let props_2 = Props {
        field_1: 1,
        field_2: 1,
    };

    let _: Props = props_2; // Warning lint does not consider `props_2` as being used here.
}

Note this same inconsistency takes place without type anotation.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions