File tree Expand file tree Collapse file tree 4 files changed +19
-13
lines changed Expand file tree Collapse file tree 4 files changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -59,10 +59,10 @@ impl NonCamelCaseTypes {
5959
6060 fn is_camel_case ( name : ast:: Name ) -> bool {
6161 let name = name. as_str ( ) ;
62+ let name = name. trim_matches ( '_' ) ;
6263 if name. is_empty ( ) {
6364 return true ;
6465 }
65- let name = name. trim_matches ( '_' ) ;
6666
6767 // start with a non-lowercase letter rather than non-uppercase
6868 // ones (some scripts don't have a concept of upper/lowercase)
Original file line number Diff line number Diff line change 1+ // compile-pass
2+
3+ #![ forbid( non_camel_case_types) ]
4+ #![ allow( dead_code) ]
5+
6+ // None of the following types should generate a warning
7+ struct _X { }
8+ struct __X { }
9+ struct __ { }
10+ struct X_ { }
11+ struct X__ { }
12+ struct X___ { }
13+
14+ fn main ( ) { }
Original file line number Diff line number Diff line change @@ -43,8 +43,6 @@ struct foo7 {
4343 bar : isize ,
4444}
4545
46- type __ = isize ; //~ ERROR type `__` should have a camel case name such as `CamelCase`
47-
4846struct X86_64 ;
4947
5048struct X86__64 ; //~ ERROR type `X86__64` should have a camel case name such as `X86_64`
Original file line number Diff line number Diff line change @@ -60,29 +60,23 @@ error: type parameter `ty` should have a camel case name such as `Ty`
6060LL | fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty`
6161 | ^^
6262
63- error: type `__` should have a camel case name such as `CamelCase`
64- --> $DIR/lint-non-camel-case-types.rs:46:1
65- |
66- LL | type __ = isize; //~ ERROR type `__` should have a camel case name such as `CamelCase`
67- | ^^^^^^^^^^^^^^^^
68-
6963error: type `X86__64` should have a camel case name such as `X86_64`
70- --> $DIR/lint-non-camel-case-types.rs:50 :1
64+ --> $DIR/lint-non-camel-case-types.rs:48 :1
7165 |
7266LL | struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64`
7367 | ^^^^^^^^^^^^^^^
7468
7569error: type `Abc_123` should have a camel case name such as `Abc123`
76- --> $DIR/lint-non-camel-case-types.rs:52 :1
70+ --> $DIR/lint-non-camel-case-types.rs:50 :1
7771 |
7872LL | struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123`
7973 | ^^^^^^^^^^^^^^^
8074
8175error: type `A1_b2_c3` should have a camel case name such as `A1B2C3`
82- --> $DIR/lint-non-camel-case-types.rs:54 :1
76+ --> $DIR/lint-non-camel-case-types.rs:52 :1
8377 |
8478LL | struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3`
8579 | ^^^^^^^^^^^^^^^^
8680
87- error: aborting due to 12 previous errors
81+ error: aborting due to 11 previous errors
8882
You can’t perform that action at this time.
0 commit comments