Skip to content

Commit 738144e

Browse files
committed
---
yaml --- r: 20972 b: refs/heads/snap-stage3 c: d99ca69 h: refs/heads/master v: v3
1 parent a6ad82f commit 738144e

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: e430a699f2c60890d9b86069fd0c68a70ece7120
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 8d5a51e9d7f51ba9c80a34121b158c8c2ef9cdd7
4+
refs/heads/snap-stage3: d99ca69cf7207e31d7ddffe849a4235cc63899d7
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/rustc/middle/lint.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,21 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) {
452452
fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) {
453453
fn is_camel_case(ident: ast::ident) -> bool {
454454
assert ident.is_not_empty();
455-
char::is_uppercase(str::char_at(*ident, 0)) &&
455+
let ident = ident_without_trailing_underscores(ident);
456+
char::is_uppercase(str::char_at(ident, 0)) &&
456457
!ident.contains_char('_')
457458
}
458459

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),
463+
none => {
464+
// all underscores
465+
*ident
466+
}
467+
}
468+
}
469+
459470
fn check_case(cx: ty::ctxt, ident: ast::ident,
460471
expr_id: ast::node_id, item_id: ast::node_id,
461472
span: span) {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This is ok because we often use the trailing underscore to mean 'prime'
2+
3+
#[forbid(non_camel_case_types)]
4+
type Foo_ = int;
5+
6+
fn main() { }

0 commit comments

Comments
 (0)