Skip to content

Commit 0235971

Browse files
committed
Change camel case warning to upper camel case
Rust structs should be named in upper camel case aka PascalCase. "Upper camel case" was decided upon as the preferred phrase over PascalCase per: rust-lang/rfcs#2389
1 parent 99a5c59 commit 0235971

File tree

5 files changed

+39
-37
lines changed

5 files changed

+39
-37
lines changed

src/doc/rustc/src/lints/listing/warn-by-default.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ struct s;
163163
This will produce:
164164

165165
```text
166-
warning: type `s` should have a camel case name such as `S`
166+
warning: type `s` should have an upper camel case name such as `S`
167167
--> src/main.rs:1:1
168168
|
169169
1 | struct s;

src/librustc_lint/nonstandard_style.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ impl NonCamelCaseTypes {
8989
if !is_camel_case(name) {
9090
let c = to_camel_case(&name.as_str());
9191
let m = if c.is_empty() {
92-
format!("{} `{}` should have a camel case name such as `CamelCase`", sort, name)
92+
format!("{} `{}` should have an upper camel case name such as
93+
`CamelCase`", sort, name)
9394
} else {
94-
format!("{} `{}` should have a camel case name such as `{}`", sort, name, c)
95+
format!("{} `{}` should have an upper camel case name such as
96+
`{}`", sort, name, c)
9597
};
9698
cx.span_lint(NON_CAMEL_CASE_TYPES, span, &m);
9799
}

src/test/ui/lint/lint-group-nonstandard-style.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
warning: type `snake_case` should have a camel case name such as `SnakeCase`
1+
warning: type `snake_case` should have an upper camel case name such as `SnakeCase`
22
--> $DIR/lint-group-nonstandard-style.rs:22:9
33
|
4-
LL | struct snake_case; //~ WARN should have a camel
4+
LL | struct snake_case; //~ WARN should have an upper camel
55
| ^^^^^^^^^^^^^^^^^^
66
|
77
note: lint level defined here

src/test/ui/lint/lint-non-camel-case-types.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22
#![allow(dead_code)]
33

44
struct ONE_TWO_THREE;
5-
//~^ ERROR type `ONE_TWO_THREE` should have a camel case name such as `OneTwoThree`
5+
//~^ ERROR type `ONE_TWO_THREE` should have an upper camel case name such as `OneTwoThree`
66

7-
struct foo { //~ ERROR type `foo` should have a camel case name such as `Foo`
7+
struct foo { //~ ERROR type `foo` should have an upper camel case name such as `Foo`
88
bar: isize,
99
}
1010

11-
enum foo2 { //~ ERROR type `foo2` should have a camel case name such as `Foo2`
11+
enum foo2 { //~ ERROR type `foo2` should have an upper camel case name such as `Foo2`
1212
Bar
1313
}
1414

15-
struct foo3 { //~ ERROR type `foo3` should have a camel case name such as `Foo3`
15+
struct foo3 { //~ ERROR type `foo3` should have an upper camel case name such as `Foo3`
1616
bar: isize
1717
}
1818

19-
type foo4 = isize; //~ ERROR type `foo4` should have a camel case name such as `Foo4`
19+
type foo4 = isize; //~ ERROR type `foo4` should have an upper camel case name such as `Foo4`
2020

2121
enum Foo5 {
22-
bar //~ ERROR variant `bar` should have a camel case name such as `Bar`
22+
bar //~ ERROR variant `bar` should have an upper camel case name such as `Bar`
2323
}
2424

25-
trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6`
25+
trait foo6 { //~ ERROR trait `foo6` should have an upper camel case name such as `Foo6`
2626
fn dummy(&self) { }
2727
}
2828

29-
fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty`
29+
fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have an upper camel case name such as `Ty`
3030

3131
#[repr(C)]
3232
struct foo7 {
@@ -35,10 +35,10 @@ struct foo7 {
3535

3636
struct X86_64;
3737

38-
struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64`
38+
struct X86__64; //~ ERROR type `X86__64` should have an upper camel case name such as `X86_64`
3939

40-
struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123`
40+
struct Abc_123; //~ ERROR type `Abc_123` should have an upper camel case name such as `Abc123`
4141

42-
struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3`
42+
struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have an upper camel case name such as `A1B2C3`
4343

4444
fn main() { }

src/test/ui/lint/lint-non-camel-case-types.stderr

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: type `ONE_TWO_THREE` should have a camel case name such as `OneTwoThree`
1+
error: type `ONE_TWO_THREE` should have an upper camel case name such as `OneTwoThree`
22
--> $DIR/lint-non-camel-case-types.rs:4:1
33
|
44
LL | struct ONE_TWO_THREE;
@@ -10,72 +10,72 @@ note: lint level defined here
1010
LL | #![forbid(non_camel_case_types)]
1111
| ^^^^^^^^^^^^^^^^^^^^
1212

13-
error: type `foo` should have a camel case name such as `Foo`
13+
error: type `foo` should have an upper camel case name such as `Foo`
1414
--> $DIR/lint-non-camel-case-types.rs:7:1
1515
|
16-
LL | / struct foo { //~ ERROR type `foo` should have a camel case name such as `Foo`
16+
LL | / struct foo { //~ ERROR type `foo` should have an upper camel case name such as `Foo`
1717
LL | | bar: isize,
1818
LL | | }
1919
| |_^
2020

21-
error: type `foo2` should have a camel case name such as `Foo2`
21+
error: type `foo2` should have an upper camel case name such as `Foo2`
2222
--> $DIR/lint-non-camel-case-types.rs:11:1
2323
|
24-
LL | / enum foo2 { //~ ERROR type `foo2` should have a camel case name such as `Foo2`
24+
LL | / enum foo2 { //~ ERROR type `foo2` should have an upper camel case name such as `Foo2`
2525
LL | | Bar
2626
LL | | }
2727
| |_^
2828

29-
error: type `foo3` should have a camel case name such as `Foo3`
29+
error: type `foo3` should have an upper camel case name such as `Foo3`
3030
--> $DIR/lint-non-camel-case-types.rs:15:1
3131
|
32-
LL | / struct foo3 { //~ ERROR type `foo3` should have a camel case name such as `Foo3`
32+
LL | / struct foo3 { //~ ERROR type `foo3` should have an upper camel case name such as `Foo3`
3333
LL | | bar: isize
3434
LL | | }
3535
| |_^
3636

37-
error: type `foo4` should have a camel case name such as `Foo4`
37+
error: type `foo4` should have an upper camel case name such as `Foo4`
3838
--> $DIR/lint-non-camel-case-types.rs:19:1
3939
|
40-
LL | type foo4 = isize; //~ ERROR type `foo4` should have a camel case name such as `Foo4`
40+
LL | type foo4 = isize; //~ ERROR type `foo4` should have an upper camel case name such as `Foo4`
4141
| ^^^^^^^^^^^^^^^^^^
4242

43-
error: variant `bar` should have a camel case name such as `Bar`
43+
error: variant `bar` should have an upper camel case name such as `Bar`
4444
--> $DIR/lint-non-camel-case-types.rs:22:5
4545
|
46-
LL | bar //~ ERROR variant `bar` should have a camel case name such as `Bar`
46+
LL | bar //~ ERROR variant `bar` should have an upper camel case name such as `Bar`
4747
| ^^^
4848

49-
error: trait `foo6` should have a camel case name such as `Foo6`
49+
error: trait `foo6` should have an upper camel case name such as `Foo6`
5050
--> $DIR/lint-non-camel-case-types.rs:25:1
5151
|
52-
LL | / trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6`
52+
LL | / trait foo6 { //~ ERROR trait `foo6` should have an upper camel case name such as `Foo6`
5353
LL | | fn dummy(&self) { }
5454
LL | | }
5555
| |_^
5656

57-
error: type parameter `ty` should have a camel case name such as `Ty`
57+
error: type parameter `ty` should have an upper camel case name such as `Ty`
5858
--> $DIR/lint-non-camel-case-types.rs:29:6
5959
|
60-
LL | fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty`
60+
LL | fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have an upper camel case name such as `Ty`
6161
| ^^
6262

63-
error: type `X86__64` should have a camel case name such as `X86_64`
63+
error: type `X86__64` should have an upper camel case name such as `X86_64`
6464
--> $DIR/lint-non-camel-case-types.rs:38:1
6565
|
66-
LL | struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64`
66+
LL | struct X86__64; //~ ERROR type `X86__64` should have an upper camel case name such as `X86_64`
6767
| ^^^^^^^^^^^^^^^
6868

69-
error: type `Abc_123` should have a camel case name such as `Abc123`
69+
error: type `Abc_123` should have an upper camel case name such as `Abc123`
7070
--> $DIR/lint-non-camel-case-types.rs:40:1
7171
|
72-
LL | struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123`
72+
LL | struct Abc_123; //~ ERROR type `Abc_123` should have an upper camel case name such as `Abc123`
7373
| ^^^^^^^^^^^^^^^
7474

75-
error: type `A1_b2_c3` should have a camel case name such as `A1B2C3`
75+
error: type `A1_b2_c3` should have an upper camel case name such as `A1B2C3`
7676
--> $DIR/lint-non-camel-case-types.rs:42:1
7777
|
78-
LL | struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3`
78+
LL | struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have an upper camel case name such as `A1B2C3`
7979
| ^^^^^^^^^^^^^^^^
8080

8181
error: aborting due to 11 previous errors

0 commit comments

Comments
 (0)