Skip to content

allow(unused_variables) doesn't work on struct field bindings in patterns #138428

Closed
@camsteffen

Description

@camsteffen

I tried this code:

pub struct Foo {
    bar: u32,
    baz: u32,
}

pub fn test(foo: Foo) {
    let Foo {
        #[allow(unused_variables)]
        bar,
        #[allow(unused_variables)]
        baz,
    } = foo;
}

I expected to see this happen:

no lint

Instead, this happened:

unused_variables lint occurs even though it is allowed

Meta

rustc version 1.85.0

Playground

Metadata

Metadata

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-patternsRelating to patterns and pattern matchingC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions