File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 74c69e1053188d92b86bc8b28cbf1af87d31ea2d
2
+ refs/heads/master: a83414b6e8879b2485374469f7f5fe60f22ae936
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
5
5
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
Original file line number Diff line number Diff line change @@ -452,17 +452,28 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) {
452
452
fn check_item_non_camel_case_types( cx: ty:: ctxt, it: @ast:: item) {
453
453
fn is_camel_case( ident: ast:: ident) -> bool {
454
454
assert ident. is_not_empty( ) ;
455
- let ident = ident_without_trailing_underscores( ident) ;
455
+ let ident = ident_without_trailing_underscores( * ident) ;
456
+ let ident = ident_without_leading_underscores( ident) ;
456
457
char :: is_uppercase( str :: char_at( ident, 0 ) ) &&
457
458
!ident. contains_char( '_' )
458
459
}
459
460
460
- fn ident_without_trailing_underscores( ident: ast :: ident ) -> ~str {
461
- match str :: rfind( * ident, |c| c != '_' ) {
462
- some( idx) => ( * ident) . slice( 0 , idx + 1 ) ,
461
+ fn ident_without_trailing_underscores( ident: ~ str ) -> ~str {
462
+ match str :: rfind( ident, |c| c != '_' ) {
463
+ some( idx) => ident. slice( 0 , idx + 1 ) ,
463
464
none => {
464
465
// all underscores
465
- * ident
466
+ ident
467
+ }
468
+ }
469
+ }
470
+
471
+ fn ident_without_leading_underscores( ident: ~str ) -> ~str {
472
+ match str :: find( ident, |c| c != '_' ) {
473
+ some( idx) => ident. slice( idx, ident. len( ) ) ,
474
+ none => {
475
+ // all underscores
476
+ ident
466
477
}
467
478
}
468
479
}
You can’t perform that action at this time.
0 commit comments