Skip to content

Commit de7abd8

Browse files
committed
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]
1 parent bd159d3 commit de7abd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+214
-176
lines changed

src/doc/guide-ffi.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ extern crate libc;
477477

478478
#[cfg(target_os = "win32", target_arch = "x86")]
479479
#[link(name = "kernel32")]
480-
#[allow(non_snake_case_functions)]
480+
#[allow(non_snake_case)]
481481
extern "stdcall" {
482482
fn SetEnvironmentVariableA(n: *const u8, v: *const u8) -> libc::c_int;
483483
}

src/etc/unicode.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
3535
// NOTE: The following code was generated by "src/etc/unicode.py", do not edit directly
3636
37-
#![allow(missing_doc, non_uppercase_statics, non_snake_case_functions)]
37+
#![allow(missing_doc, non_uppercase_statics, non_snake_case)]
3838
'''
3939

4040
# Mapping taken from Table 12 from:

src/libcollections/hash/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ macro_rules! impl_hash_tuple(
159159
impl<S: Writer, $($name: Hash<S>),*> Hash<S> for ($($name,)*) {
160160
#[allow(uppercase_variables)]
161161
#[inline]
162+
#[allow(non_snake_case)]
162163
fn hash(&self, state: &mut S) {
163164
match *self {
164165
($(ref $name,)*) => {

src/libcore/char.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//!
1313
//! For more details, see ::unicode::char (a.k.a. std::char)
1414
15-
#![allow(non_snake_case_functions)]
15+
#![allow(non_snake_case)]
1616
#![doc(primitive = "char")]
1717

1818
use mem::transmute;

src/libcore/fmt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ macro_rules! tuple (
668668
() => ();
669669
( $($name:ident,)+ ) => (
670670
impl<$($name:Show),*> Show for ($($name,)*) {
671-
#[allow(uppercase_variables, dead_assignment)]
671+
#[allow(non_snake_case, dead_assignment)]
672672
fn fmt(&self, f: &mut Formatter) -> Result {
673673
try!(write!(f, "("));
674674
let ($(ref $name,)*) = *self;

src/libcore/str.rs

+27-27
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,9 @@ impl NaiveSearcher {
394394
fn next(&mut self, haystack: &[u8], needle: &[u8]) -> Option<(uint, uint)> {
395395
while self.position + needle.len() <= haystack.len() {
396396
if haystack.slice(self.position, self.position + needle.len()) == needle {
397-
let matchPos = self.position;
397+
let match_pos = self.position;
398398
self.position += needle.len(); // add 1 for all matches
399-
return Some((matchPos, matchPos + needle.len()));
399+
return Some((match_pos, match_pos + needle.len()));
400400
} else {
401401
self.position += 1;
402402
}
@@ -410,7 +410,7 @@ impl NaiveSearcher {
410410
#[deriving(Clone)]
411411
struct TwoWaySearcher {
412412
// constants
413-
critPos: uint,
413+
crit_pos: uint,
414414
period: uint,
415415
byteset: u64,
416416

@@ -423,32 +423,31 @@ struct TwoWaySearcher {
423423
// Crochemore, M., Perrin, D., 1991, Two-way string-matching, Journal of the ACM 38(3):651-675.
424424
impl TwoWaySearcher {
425425
fn new(needle: &[u8]) -> TwoWaySearcher {
426-
let (critPos1, period1) = TwoWaySearcher::maximal_suffix(needle, false);
427-
let (critPos2, period2) = TwoWaySearcher::maximal_suffix(needle, true);
426+
let (crit_pos1, period1) = TwoWaySearcher::maximal_suffix(needle, false);
427+
let (crit_pos2, period2) = TwoWaySearcher::maximal_suffix(needle, true);
428428

429-
let critPos;
429+
let crit_pos;
430430
let period;
431-
if critPos1 > critPos2 {
432-
critPos = critPos1;
431+
if crit_pos1 > crit_pos2 {
432+
crit_pos = crit_pos1;
433433
period = period1;
434434
} else {
435-
critPos = critPos2;
435+
crit_pos = crit_pos2;
436436
period = period2;
437437
}
438438

439439
let byteset = needle.iter()
440440
.fold(0, |a, &b| (1 << ((b & 0x3f) as uint)) | a);
441441

442-
443-
// The logic here (calculating critPos and period, the final if statement to see which
442+
// The logic here (calculating crit_pos and period, the final if statement to see which
444443
// period to use for the TwoWaySearcher) is essentially an implementation of the
445444
// "small-period" function from the paper (p. 670)
446445
//
447-
// In the paper they check whether `needle.slice_to(critPos)` is a suffix of
448-
// `needle.slice(critPos, critPos + period)`, which is precisely what this does
449-
if needle.slice_to(critPos) == needle.slice(period, period + critPos) {
446+
// In the paper they check whether `needle.slice_to(crit_pos)` is a suffix of
447+
// `needle.slice(crit_pos, crit_pos + period)`, which is precisely what this does
448+
if needle.slice_to(crit_pos) == needle.slice(period, period + crit_pos) {
450449
TwoWaySearcher {
451-
critPos: critPos,
450+
crit_pos: crit_pos,
452451
period: period,
453452
byteset: byteset,
454453

@@ -457,8 +456,8 @@ impl TwoWaySearcher {
457456
}
458457
} else {
459458
TwoWaySearcher {
460-
critPos: critPos,
461-
period: cmp::max(critPos, needle.len() - critPos) + 1,
459+
crit_pos: crit_pos,
460+
period: cmp::max(crit_pos, needle.len() - crit_pos) + 1,
462461
byteset: byteset,
463462

464463
position: 0,
@@ -468,7 +467,7 @@ impl TwoWaySearcher {
468467
}
469468

470469
#[inline]
471-
fn next(&mut self, haystack: &[u8], needle: &[u8], longPeriod: bool) -> Option<(uint, uint)> {
470+
fn next(&mut self, haystack: &[u8], needle: &[u8], long_period: bool) -> Option<(uint, uint)> {
472471
'search: loop {
473472
// Check that we have room to search in
474473
if self.position + needle.len() > haystack.len() {
@@ -484,36 +483,37 @@ impl TwoWaySearcher {
484483
}
485484

486485
// See if the right part of the needle matches
487-
let start = if longPeriod { self.critPos } else { cmp::max(self.critPos, self.memory) };
486+
let start = if long_period { self.crit_pos }
487+
else { cmp::max(self.crit_pos, self.memory) };
488488
for i in range(start, needle.len()) {
489489
if needle[i] != haystack[self.position + i] {
490-
self.position += i - self.critPos + 1;
491-
if !longPeriod {
490+
self.position += i - self.crit_pos + 1;
491+
if !long_period {
492492
self.memory = 0;
493493
}
494494
continue 'search;
495495
}
496496
}
497497

498498
// See if the left part of the needle matches
499-
let start = if longPeriod { 0 } else { self.memory };
500-
for i in range(start, self.critPos).rev() {
499+
let start = if long_period { 0 } else { self.memory };
500+
for i in range(start, self.crit_pos).rev() {
501501
if needle[i] != haystack[self.position + i] {
502502
self.position += self.period;
503-
if !longPeriod {
503+
if !long_period {
504504
self.memory = needle.len() - self.period;
505505
}
506506
continue 'search;
507507
}
508508
}
509509

510510
// We have found a match!
511-
let matchPos = self.position;
511+
let match_pos = self.position;
512512
self.position += needle.len(); // add self.period for all matches
513-
if !longPeriod {
513+
if !long_period {
514514
self.memory = 0; // set to needle.len() - self.period for all matches
515515
}
516-
return Some((matchPos, matchPos + needle.len()));
516+
return Some((match_pos, match_pos + needle.len()));
517517
}
518518
}
519519

src/liblibc/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@
7474
*/
7575

7676
#![allow(non_camel_case_types)]
77-
#![allow(non_snake_case_functions)]
77+
#![allow(non_snake_case)]
7878
#![allow(non_uppercase_statics)]
7979
#![allow(missing_doc)]
80-
#![allow(uppercase_variables)]
80+
#![allow(non_snake_case)]
8181

8282
#[cfg(test)] extern crate std;
8383
#[cfg(test)] extern crate test;

src/libnative/io/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
//! play. The only dependencies of these modules are the normal system libraries
2222
//! that you would find on the respective platform.
2323
24-
#![allow(non_snake_case_functions)]
24+
#![allow(non_snake_case)]
2525

2626
use libc::c_int;
2727
use libc;

src/libnative/io/process.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ fn free_handle(_handle: *mut ()) {
838838

839839
#[cfg(unix)]
840840
fn translate_status(status: c_int) -> rtio::ProcessExit {
841-
#![allow(non_snake_case_functions)]
841+
#![allow(non_snake_case)]
842842
#[cfg(target_os = "linux")]
843843
#[cfg(target_os = "android")]
844844
mod imp {

src/libnum/bigint.rs

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ pub type DoubleBigDigit = u64;
7878
pub static ZERO_BIG_DIGIT: BigDigit = 0;
7979
static ZERO_VEC: [BigDigit, ..1] = [ZERO_BIG_DIGIT];
8080

81+
#[allow(non_snake_case)]
8182
pub mod BigDigit {
8283
use super::BigDigit;
8384
use super::DoubleBigDigit;

src/librbml/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ mod tests {
11321132

11331133
#[cfg(test)]
11341134
mod bench {
1135-
#![allow(non_snake_case_functions)]
1135+
#![allow(non_snake_case)]
11361136
use test::Bencher;
11371137
use super::reader;
11381138

src/libregex/test/bench.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
#![allow(non_snake_case_functions)]
10+
#![allow(non_snake_case)]
1111

1212
use std::rand::{Rng, task_rng};
1313
use stdtest::Bencher;

src/librustc/diagnostics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![allow(non_snake_case)]
12+
1113
register_diagnostic!(E0001, r##"
1214
This error suggests that the expression arm corresponding to the noted pattern
1315
will never be reached as for all possible values of the expression being matched,

0 commit comments

Comments
 (0)