about summary refs log tree commit diff
path: root/src/librustc
diff options
context:
space:
mode:
authorP1start <rewi-github@whanau.org>2014-09-13 13:59:15 +1200
committerP1start <rewi-github@whanau.org>2014-10-03 20:39:56 +1300
commit45044124e46bbfd1ab9869ffce71259ae93866ff (patch)
tree61c40510ab81a455ad14742397b4a605444d072a /src/librustc
parent333592edde810324c9730a89372fa5164d10871d (diff)
downloadrust-45044124e46bbfd1ab9869ffce71259ae93866ff.tar.gz
rust-45044124e46bbfd1ab9869ffce71259ae93866ff.zip
Improve the `non_snake_case` lint to give better suggestions
Diffstat (limited to 'src/librustc')
-rw-r--r--src/librustc/lint/builtin.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs
index 8ffda8bd827..ea647fda848 100644
--- a/src/librustc/lint/builtin.rs
+++ b/src/librustc/lint/builtin.rs
@@ -871,13 +871,17 @@ impl NonSnakeCase {
         fn to_snake_case(str: &str) -> String {
             let mut words = vec![];
             for s in str.split('_') {
+                let mut last_upper = false;
                 let mut buf = String::new();
                 if s.is_empty() { continue; }
                 for ch in s.chars() {
-                    if !buf.is_empty() && buf.as_slice() != "'" && ch.is_uppercase() {
+                    if !buf.is_empty() && buf.as_slice() != "'"
+                                       && ch.is_uppercase()
+                                       && !last_upper {
                         words.push(buf);
                         buf = String::new();
                     }
+                    last_upper = ch.is_uppercase();
                     buf.push_char(ch.to_lowercase());
                 }
                 words.push(buf);