diff options
| author | P1start <rewi-github@whanau.org> | 2014-07-19 00:45:17 +1200 |
|---|---|---|
| committer | P1start <rewi-github@whanau.org> | 2014-08-30 09:10:05 +1200 |
| commit | de7abd88244a9fe7033cb71e22af0601d1b811b9 (patch) | |
| tree | 0f57eaeba2ecc2d72a618872a7e06885d5e611db /src/libcore | |
| parent | bd159d3867473ee43959706519066531d76af7ba (diff) | |
Unify non-snake-case lints and non-uppercase statics lints
This unifies the `non_snake_case_functions` and `uppercase_variables` lints into one lint, `non_snake_case`. It also now checks for non-snake-case modules. This also extends the non-camel-case types lint to check type parameters, and merges the `non_uppercase_pattern_statics` lint into the `non_uppercase_statics` lint. Because the `uppercase_variables` lint is now part of the `non_snake_case` lint, all non-snake-case variables that start with lowercase characters (such as `fooBar`) will now trigger the `non_snake_case` lint. New code should be updated to use the new `non_snake_case` lint instead of the previous `non_snake_case_functions` and `uppercase_variables` lints. All use of the `non_uppercase_pattern_statics` should be replaced with the `non_uppercase_statics` lint. Any code that previously contained non-snake-case module or variable names should be updated to use snake case names or disable the `non_snake_case` lint. Any code with non-camel-case type parameters should be changed to use camel case or disable the `non_camel_case_types` lint. [breaking-change]
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/char.rs | 2 | ||||
| -rw-r--r-- | src/libcore/fmt/mod.rs | 2 | ||||
| -rw-r--r-- | src/libcore/str.rs | 54 |
3 files changed, 29 insertions, 29 deletions
diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 4e9a72c6af5..95267a8f9e5 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -12,7 +12,7 @@ //! //! For more details, see ::unicode::char (a.k.a. std::char) -#![allow(non_snake_case_functions)] +#![allow(non_snake_case)] #![doc(primitive = "char")] use mem::transmute; diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index f7ff92f5ce3..32663e5eb0f 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -668,7 +668,7 @@ macro_rules! tuple ( () => (); ( $($name:ident,)+ ) => ( impl<$($name:Show),*> Show for ($($name,)*) { - #[allow(uppercase_variables, dead_assignment)] + #[allow(non_snake_case, dead_assignment)] fn fmt(&self, f: &mut Formatter) -> Result { try!(write!(f, "(")); let ($(ref $name,)*) = *self; diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 5cbeda94d0f..b067e6299ee 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -394,9 +394,9 @@ impl NaiveSearcher { fn next(&mut self, haystack: &[u8], needle: &[u8]) -> Option<(uint, uint)> { while self.position + needle.len() <= haystack.len() { if haystack.slice(self.position, self.position + needle.len()) == needle { - let matchPos = self.position; + let match_pos = self.position; self.position += needle.len(); // add 1 for all matches - return Some((matchPos, matchPos + needle.len())); + return Some((match_pos, match_pos + needle.len())); } else { self.position += 1; } @@ -410,7 +410,7 @@ impl NaiveSearcher { #[deriving(Clone)] struct TwoWaySearcher { // constants - critPos: uint, + crit_pos: uint, period: uint, byteset: u64, @@ -423,32 +423,31 @@ struct TwoWaySearcher { // Crochemore, M., Perrin, D., 1991, Two-way string-matching, Journal of the ACM 38(3):651-675. impl TwoWaySearcher { fn new(needle: &[u8]) -> TwoWaySearcher { - let (critPos1, period1) = TwoWaySearcher::maximal_suffix(needle, false); - let (critPos2, period2) = TwoWaySearcher::maximal_suffix(needle, true); + let (crit_pos1, period1) = TwoWaySearcher::maximal_suffix(needle, false); + let (crit_pos2, period2) = TwoWaySearcher::maximal_suffix(needle, true); - let critPos; + let crit_pos; let period; - if critPos1 > critPos2 { - critPos = critPos1; + if crit_pos1 > crit_pos2 { + crit_pos = crit_pos1; period = period1; } else { - critPos = critPos2; + crit_pos = crit_pos2; period = period2; } let byteset = needle.iter() .fold(0, |a, &b| (1 << ((b & 0x3f) as uint)) | a); - - // The logic here (calculating critPos and period, the final if statement to see which + // The logic here (calculating crit_pos and period, the final if statement to see which // period to use for the TwoWaySearcher) is essentially an implementation of the // "small-period" function from the paper (p. 670) // - // In the paper they check whether `needle.slice_to(critPos)` is a suffix of - // `needle.slice(critPos, critPos + period)`, which is precisely what this does - if needle.slice_to(critPos) == needle.slice(period, period + critPos) { + // In the paper they check whether `needle.slice_to(crit_pos)` is a suffix of + // `needle.slice(crit_pos, crit_pos + period)`, which is precisely what this does + if needle.slice_to(crit_pos) == needle.slice(period, period + crit_pos) { TwoWaySearcher { - critPos: critPos, + crit_pos: crit_pos, period: period, byteset: byteset, @@ -457,8 +456,8 @@ impl TwoWaySearcher { } } else { TwoWaySearcher { - critPos: critPos, - period: cmp::max(critPos, needle.len() - critPos) + 1, + crit_pos: crit_pos, + period: cmp::max(crit_pos, needle.len() - crit_pos) + 1, byteset: byteset, position: 0, @@ -468,7 +467,7 @@ impl TwoWaySearcher { } #[inline] - fn next(&mut self, haystack: &[u8], needle: &[u8], longPeriod: bool) -> Option<(uint, uint)> { + fn next(&mut self, haystack: &[u8], needle: &[u8], long_period: bool) -> Option<(uint, uint)> { 'search: loop { // Check that we have room to search in if self.position + needle.len() > haystack.len() { @@ -484,11 +483,12 @@ impl TwoWaySearcher { } // See if the right part of the needle matches - let start = if longPeriod { self.critPos } else { cmp::max(self.critPos, self.memory) }; + let start = if long_period { self.crit_pos } + else { cmp::max(self.crit_pos, self.memory) }; for i in range(start, needle.len()) { if needle[i] != haystack[self.position + i] { - self.position += i - self.critPos + 1; - if !longPeriod { + self.position += i - self.crit_pos + 1; + if !long_period { self.memory = 0; } continue 'search; @@ -496,11 +496,11 @@ impl TwoWaySearcher { } // See if the left part of the needle matches - let start = if longPeriod { 0 } else { self.memory }; - for i in range(start, self.critPos).rev() { + let start = if long_period { 0 } else { self.memory }; + for i in range(start, self.crit_pos).rev() { if needle[i] != haystack[self.position + i] { self.position += self.period; - if !longPeriod { + if !long_period { self.memory = needle.len() - self.period; } continue 'search; @@ -508,12 +508,12 @@ impl TwoWaySearcher { } // We have found a match! - let matchPos = self.position; + let match_pos = self.position; self.position += needle.len(); // add self.period for all matches - if !longPeriod { + if !long_period { self.memory = 0; // set to needle.len() - self.period for all matches } - return Some((matchPos, matchPos + needle.len())); + return Some((match_pos, match_pos + needle.len())); } } |
