summaryrefslogtreecommitdiffstats
path: root/tests/ui/lint/issue-66362-no-snake-case-warning-for-field-puns.rs
blob: c2b81959f2cb81297184b217787b056408119655 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#![deny(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

enum Foo {
    Bad {
        lowerCamelCaseName: bool,
        //~^ ERROR structure field `lowerCamelCaseName` should have a snake case name
    },
    Good {
        snake_case_name: bool,
    },
}

fn main() {
    let b = Foo::Bad { lowerCamelCaseName: true };

    match b {
        Foo::Bad { lowerCamelCaseName } => {}
        Foo::Good { snake_case_name: lowerCamelCaseBinding } => { }
        //~^ ERROR variable `lowerCamelCaseBinding` should have a snake case name
    }

    if let Foo::Good { snake_case_name: anotherLowerCamelCaseBinding } = b { }
    //~^ ERROR variable `anotherLowerCamelCaseBinding` should have a snake case name

    if let Foo::Bad { lowerCamelCaseName: yetAnotherLowerCamelCaseBinding } = b { }
    //~^ ERROR variable `yetAnotherLowerCamelCaseBinding` should have a snake case name
}