diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-02-16 10:35:05 -0800 |
|---|---|---|
| committer | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-02-19 10:02:52 -0800 |
| commit | ae86c03af261fd116d53f98766fb3700435b0bc1 (patch) | |
| tree | f3975f42d0e05be8a9237672450cb07351e9387e | |
| parent | 3c0eca7940f51e267528bba537cdeb8ce9f7e506 (diff) | |
librustc: change check_item_non_camel_case_types to not copy
| -rw-r--r-- | src/librustc/middle/lint.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 191e17ed15a..0bc4ec2569f 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -834,26 +834,23 @@ fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) { fn is_camel_case(cx: ty::ctxt, ident: ast::ident) -> bool { let ident = cx.sess.str_of(ident); assert !ident.is_empty(); - let ident = ident_without_trailing_underscores(ident); + let ident = ident_without_trailing_underscores(*ident); let ident = ident_without_leading_underscores(ident); char::is_uppercase(str::char_at(ident, 0)) && !ident.contains_char('_') } - fn ident_without_trailing_underscores(+ident: ~str) -> ~str { + fn ident_without_trailing_underscores(ident: &r/str) -> &r/str { match str::rfind(ident, |c| c != '_') { - Some(idx) => (ident).slice(0, idx + 1), - None => { ident } // all underscores + Some(idx) => str::view(ident, 0, idx + 1), + None => ident, // all underscores } } - fn ident_without_leading_underscores(+ident: ~str) -> ~str { + fn ident_without_leading_underscores(ident: &r/str) -> &r/str { match str::find(ident, |c| c != '_') { - Some(idx) => ident.slice(idx, ident.len()), - None => { - // all underscores - ident - } + Some(idx) => str::view(ident, idx, ident.len()), + None => ident // all underscores } } |
