diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2021-01-30 22:06:10 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2021-01-30 22:06:10 -0800 |
| commit | fa9a99fefce9fbfc73f74732a03925106a3b6e0f (patch) | |
| tree | 0e34e58b872f5cad62855337804840b34fd5747c | |
| parent | d10ee0d07e40535e3a167a0a857d9e3a1b1d6a3a (diff) | |
| download | rust-fa9a99fefce9fbfc73f74732a03925106a3b6e0f.tar.gz rust-fa9a99fefce9fbfc73f74732a03925106a3b6e0f.zip | |
review comments
| -rw-r--r-- | compiler/rustc_lint/src/nonstandard_style.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index 94fd0e0f097..121dde325f7 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -56,8 +56,19 @@ declare_lint! { declare_lint_pass!(NonCamelCaseTypes => [NON_CAMEL_CASE_TYPES]); +/// Some unicode characters *have* case, are considered upper case or lower case, but they *can't* +/// be upper cased or lower cased. For the purposes of the lint suggestion, we care about being able +/// to change the char's case. fn char_has_case(c: char) -> bool { - c.to_lowercase().to_string() != c.to_uppercase().to_string() + let mut l = c.to_lowercase(); + let mut u = c.to_uppercase(); + while let Some(l) = l.next() { + match u.next() { + Some(u) if l != u => return true, + _ => {} + } + } + u.next().is_some() } fn is_camel_case(name: &str) -> bool { |
