Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
improve non_camel_case_types diagnostics
Use a structured suggestion and tighten the span to just the identifier.
- Loading branch information
Showing
9 changed files
with
83 additions
and
82 deletions.
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
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
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
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 |
---|---|---|
@@ -1,82 +1,74 @@ | ||
error: type `ONE_TWO_THREE` should have a camel case name such as `OneTwoThree` | ||
--> $DIR/lint-non-camel-case-types.rs:4:1 | ||
error: type `ONE_TWO_THREE` should have a camel case name | ||
--> $DIR/lint-non-camel-case-types.rs:4:8 | ||
| | ||
LL | struct ONE_TWO_THREE; | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^ help: convert the identifier to camel case: `OneTwoThree` | ||
| | ||
note: lint level defined here | ||
--> $DIR/lint-non-camel-case-types.rs:1:11 | ||
| | ||
LL | #![forbid(non_camel_case_types)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: type `foo` should have a camel case name such as `Foo` | ||
--> $DIR/lint-non-camel-case-types.rs:7:1 | ||
error: type `foo` should have a camel case name | ||
--> $DIR/lint-non-camel-case-types.rs:7:8 | ||
| | ||
LL | / struct foo { //~ ERROR type `foo` should have a camel case name such as `Foo` | ||
LL | | bar: isize, | ||
LL | | } | ||
| |_^ | ||
LL | struct foo { //~ ERROR type `foo` should have a camel case name | ||
| ^^^ help: convert the identifier to camel case: `Foo` | ||
|
||
error: type `foo2` should have a camel case name such as `Foo2` | ||
--> $DIR/lint-non-camel-case-types.rs:11:1 | ||
error: type `foo2` should have a camel case name | ||
--> $DIR/lint-non-camel-case-types.rs:11:6 | ||
| | ||
LL | / enum foo2 { //~ ERROR type `foo2` should have a camel case name such as `Foo2` | ||
LL | | Bar | ||
LL | | } | ||
| |_^ | ||
LL | enum foo2 { //~ ERROR type `foo2` should have a camel case name | ||
| ^^^^ help: convert the identifier to camel case: `Foo2` | ||
|
||
error: type `foo3` should have a camel case name such as `Foo3` | ||
--> $DIR/lint-non-camel-case-types.rs:15:1 | ||
error: type `foo3` should have a camel case name | ||
--> $DIR/lint-non-camel-case-types.rs:15:8 | ||
| | ||
LL | / struct foo3 { //~ ERROR type `foo3` should have a camel case name such as `Foo3` | ||
LL | | bar: isize | ||
LL | | } | ||
| |_^ | ||
LL | struct foo3 { //~ ERROR type `foo3` should have a camel case name | ||
| ^^^^ help: convert the identifier to camel case: `Foo3` | ||
|
||
error: type `foo4` should have a camel case name such as `Foo4` | ||
--> $DIR/lint-non-camel-case-types.rs:19:1 | ||
error: type `foo4` should have a camel case name | ||
--> $DIR/lint-non-camel-case-types.rs:19:6 | ||
| | ||
LL | type foo4 = isize; //~ ERROR type `foo4` should have a camel case name such as `Foo4` | ||
| ^^^^^^^^^^^^^^^^^^ | ||
LL | type foo4 = isize; //~ ERROR type `foo4` should have a camel case name | ||
| ^^^^ help: convert the identifier to camel case: `Foo4` | ||
|
||
error: variant `bar` should have a camel case name such as `Bar` | ||
error: variant `bar` should have a camel case name | ||
--> $DIR/lint-non-camel-case-types.rs:22:5 | ||
| | ||
LL | bar //~ ERROR variant `bar` should have a camel case name such as `Bar` | ||
| ^^^ | ||
LL | bar //~ ERROR variant `bar` should have a camel case name | ||
| ^^^ help: convert the identifier to camel case: `Bar` | ||
|
||
error: trait `foo6` should have a camel case name such as `Foo6` | ||
--> $DIR/lint-non-camel-case-types.rs:25:1 | ||
error: trait `foo6` should have a camel case name | ||
--> $DIR/lint-non-camel-case-types.rs:25:7 | ||
| | ||
LL | / trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6` | ||
LL | | fn dummy(&self) { } | ||
LL | | } | ||
| |_^ | ||
LL | trait foo6 { //~ ERROR trait `foo6` should have a camel case name | ||
| ^^^^ help: convert the identifier to camel case: `Foo6` | ||
|
||
error: type parameter `ty` should have a camel case name such as `Ty` | ||
error: type parameter `ty` should have a camel case name | ||
--> $DIR/lint-non-camel-case-types.rs:29:6 | ||
| | ||
LL | fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty` | ||
| ^^ | ||
LL | fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name | ||
| ^^ help: convert the identifier to camel case: `Ty` | ||
|
||
error: type `X86__64` should have a camel case name such as `X86_64` | ||
--> $DIR/lint-non-camel-case-types.rs:38:1 | ||
error: type `X86__64` should have a camel case name | ||
--> $DIR/lint-non-camel-case-types.rs:38:8 | ||
| | ||
LL | struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64` | ||
| ^^^^^^^^^^^^^^^ | ||
LL | struct X86__64; //~ ERROR type `X86__64` should have a camel case name | ||
| ^^^^^^^ help: convert the identifier to camel case: `X86_64` | ||
|
||
error: type `Abc_123` should have a camel case name such as `Abc123` | ||
--> $DIR/lint-non-camel-case-types.rs:40:1 | ||
error: type `Abc_123` should have a camel case name | ||
--> $DIR/lint-non-camel-case-types.rs:40:8 | ||
| | ||
LL | struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123` | ||
| ^^^^^^^^^^^^^^^ | ||
LL | struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name | ||
| ^^^^^^^ help: convert the identifier to camel case: `Abc123` | ||
|
||
error: type `A1_b2_c3` should have a camel case name such as `A1B2C3` | ||
--> $DIR/lint-non-camel-case-types.rs:42:1 | ||
error: type `A1_b2_c3` should have a camel case name | ||
--> $DIR/lint-non-camel-case-types.rs:42:8 | ||
| | ||
LL | struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3` | ||
| ^^^^^^^^^^^^^^^^ | ||
LL | struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name | ||
| ^^^^^^^^ help: convert the identifier to camel case: `A1B2C3` | ||
|
||
error: aborting due to 11 previous errors | ||
|
2 changes: 2 additions & 0 deletions
2
...pass/test-allow-non-camel-case-variant.rs → ...st/ui/lint/lint-non-camel-case-variant.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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// compile-pass | ||
|
||
#![deny(non_camel_case_types)] | ||
|
||
pub enum Foo { | ||
|
2 changes: 2 additions & 0 deletions
2
...n-camel-case-with-trailing-underscores.rs → ...n-camel-case-with-trailing-underscores.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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// compile-pass | ||
|
||
#![allow(dead_code)] | ||
// This is ok because we often use the trailing underscore to mean 'prime' | ||
|
||
|
4 changes: 2 additions & 2 deletions
4
...se-types-non-uppercase-statics-unicode.rs → ...ui/lint/lint-nonstandard-style-unicode.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
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
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