Skip to content

Pattern matching for parameters in Impl blocks does not count struct fields as used #20343

Closed
@Dr-Emann

Description

@Dr-Emann

Example Code:

struct A;
struct B{ b: u32 } // warning: struct field is never used: `b`
impl A {
    fn do_stuff(&B{b}: &B) {
        println!("{}", b); // b field is used
    }
}

fn main() {
    let b = B{b:3};
    A::do_stuff(&b);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions