Rollup merge of #66660 - jumbatm:dont_warn_about_snake_case_in_patterns, r=centril
Don't warn about snake case for field puns. Closes #66362.
This commit is contained in:
commit
c854aecd62
3 changed files with 75 additions and 1 deletions
|
|
@ -0,0 +1,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
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
error: structure field `lowerCamelCaseName` should have a snake case name
|
||||
--> $DIR/issue-66362-no-snake-case-warning-for-field-puns.rs:7:9
|
||||
|
|
||||
LL | lowerCamelCaseName: bool,
|
||||
| ^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `lower_camel_case_name`
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/issue-66362-no-snake-case-warning-for-field-puns.rs:1:9
|
||||
|
|
||||
LL | #![deny(non_snake_case)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: variable `lowerCamelCaseBinding` should have a snake case name
|
||||
--> $DIR/issue-66362-no-snake-case-warning-for-field-puns.rs:20:38
|
||||
|
|
||||
LL | Foo::Good { snake_case_name: lowerCamelCaseBinding } => { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `lower_camel_case_binding`
|
||||
|
||||
error: variable `anotherLowerCamelCaseBinding` should have a snake case name
|
||||
--> $DIR/issue-66362-no-snake-case-warning-for-field-puns.rs:24:41
|
||||
|
|
||||
LL | if let Foo::Good { snake_case_name: anotherLowerCamelCaseBinding } = b { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `another_lower_camel_case_binding`
|
||||
|
||||
error: variable `yetAnotherLowerCamelCaseBinding` should have a snake case name
|
||||
--> $DIR/issue-66362-no-snake-case-warning-for-field-puns.rs:27:43
|
||||
|
|
||||
LL | if let Foo::Bad { lowerCamelCaseName: yetAnotherLowerCamelCaseBinding } = b { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `yet_another_lower_camel_case_binding`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue