File tree 4 files changed +19
-13
lines changed
4 files changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -59,10 +59,10 @@ impl NonCamelCaseTypes {
59
59
60
60
fn is_camel_case ( name : ast:: Name ) -> bool {
61
61
let name = name. as_str ( ) ;
62
+ let name = name. trim_matches ( '_' ) ;
62
63
if name. is_empty ( ) {
63
64
return true ;
64
65
}
65
- let name = name. trim_matches ( '_' ) ;
66
66
67
67
// start with a non-lowercase letter rather than non-uppercase
68
68
// 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 {
43
43
bar : isize ,
44
44
}
45
45
46
- type __ = isize ; //~ ERROR type `__` should have a camel case name such as `CamelCase`
47
-
48
46
struct X86_64 ;
49
47
50
48
struct 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`
60
60
LL | fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty`
61
61
| ^^
62
62
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
-
69
63
error: 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
71
65
|
72
66
LL | struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64`
73
67
| ^^^^^^^^^^^^^^^
74
68
75
69
error: 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
77
71
|
78
72
LL | struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123`
79
73
| ^^^^^^^^^^^^^^^
80
74
81
75
error: 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
83
77
|
84
78
LL | struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3`
85
79
| ^^^^^^^^^^^^^^^^
86
80
87
- error: aborting due to 12 previous errors
81
+ error: aborting due to 11 previous errors
88
82
You can’t perform that action at this time.
0 commit comments