-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #66660 - jumbatm:dont_warn_about_snake_case_in_patter…
…ns, r=centril Don't warn about snake case for field puns. Closes #66362.
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/test/ui/lint/issue-66362-no-snake-case-warning-for-field-puns.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
32 changes: 32 additions & 0 deletions
32
src/test/ui/lint/issue-66362-no-snake-case-warning-for-field-puns.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|