Skip to content

Extra non_snake_case warning when punning field name in pattern #89469

Closed
@cole-miller

Description

@cole-miller

Here's a minimized version of the code I'm working with:

#[derive(Clone, Copy)]
#[allow(non_snake_case)]
struct Entry {
    Δ: u16,
    : u16,
    : u8,
}

static TABLE: [Entry; 1] = [Entry { Δ: 0, : 0, : 0 }];

pub mod inner {
    pub fn f(k: usize) -> u16 {
        let super::Entry { Δ,,} = super::TABLE[k]; /* here */
        Δ
    }
}

Compiling this on stable or nightly gives a non_snake_case warning on the indicated line, despite the allow(non_snake_case) attribute on struct Entry. A similar issue was reported before in #66362, and addressed in a follow-up PR #66660, but it seems to be cropping up again here, maybe because a non-ASCII field name is involved. It was agreed in #66362 that punning of non-snake-case fields in patterns should not produce an additional warning, so I think this is a bona fide bug. (Incidentally, on stable the same warning appears twice in the compiler output, but this duplication seems to be fixed on nightly.)

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-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