Skip to content

Commit dcef9d0

Browse files
Fix stutter lints
1 parent 9afd8ab commit dcef9d0

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

clippy_lints/src/double_comparison.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ declare_clippy_lint! {
4040
"unnecessary double comparisons that can be simplified"
4141
}
4242

43+
#[allow(clippy::stutter)]
4344
pub struct DoubleComparisonPass;
4445

4546
impl LintPass for DoubleComparisonPass {

clippy_lints/src/enum_variants.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::syntax::ast::*;
1616
use crate::syntax::source_map::Span;
1717
use crate::syntax::symbol::LocalInternedString;
1818
use crate::utils::{span_help_and_lint, span_lint};
19-
use crate::utils::{camel_case_from, camel_case_until, in_macro};
19+
use crate::utils::{camel_case, in_macro};
2020

2121
/// **What it does:** Detects enumeration variants that are prefixed or suffixed
2222
/// by the same characters.
@@ -184,19 +184,19 @@ fn check_variant(
184184
}
185185
}
186186
let first = var2str(&def.variants[0]);
187-
let mut pre = &first[..camel_case_until(&*first)];
188-
let mut post = &first[camel_case_from(&*first)..];
187+
let mut pre = &first[..camel_case::until(&*first)];
188+
let mut post = &first[camel_case::from(&*first)..];
189189
for var in &def.variants {
190190
let name = var2str(var);
191191

192192
let pre_match = partial_match(pre, &name);
193193
pre = &pre[..pre_match];
194-
let pre_camel = camel_case_until(pre);
194+
let pre_camel = camel_case::until(pre);
195195
pre = &pre[..pre_camel];
196196
while let Some((next, last)) = name[pre.len()..].chars().zip(pre.chars().rev()).next() {
197197
if next.is_lowercase() {
198198
let last = pre.len() - last.len_utf8();
199-
let last_camel = camel_case_until(&pre[..last]);
199+
let last_camel = camel_case::until(&pre[..last]);
200200
pre = &pre[..last_camel];
201201
} else {
202202
break;
@@ -206,7 +206,7 @@ fn check_variant(
206206
let post_match = partial_rmatch(post, &name);
207207
let post_end = post.len() - post_match;
208208
post = &post[post_end..];
209-
let post_camel = camel_case_from(post);
209+
let post_camel = camel_case::from(post);
210210
post = &post[post_camel..];
211211
}
212212
let (what, value) = match (pre.is_empty(), post.is_empty()) {

clippy_lints/src/question_mark.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ declare_clippy_lint!{
4444
"checks for expressions that could be replaced by the question mark operator"
4545
}
4646

47+
#[allow(clippy::stutter)]
4748
#[derive(Copy, Clone)]
4849
pub struct QuestionMarkPass;
4950

clippy_lints/src/utils/camel_case.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
/// Return the index of the character after the first camel-case component of
1212
/// `s`.
13-
pub fn camel_case_until(s: &str) -> usize {
13+
pub fn until(s: &str) -> usize {
1414
let mut iter = s.char_indices();
1515
if let Some((_, first)) = iter.next() {
1616
if !first.is_uppercase() {
@@ -43,7 +43,7 @@ pub fn camel_case_until(s: &str) -> usize {
4343
}
4444

4545
/// Return index of the last camel-case component of `s`.
46-
pub fn camel_case_from(s: &str) -> usize {
46+
pub fn from(s: &str) -> usize {
4747
let mut iter = s.char_indices().rev();
4848
if let Some((_, first)) = iter.next() {
4949
if !first.is_lowercase() {
@@ -73,52 +73,52 @@ pub fn camel_case_from(s: &str) -> usize {
7373

7474
#[cfg(test)]
7575
mod test {
76-
use super::{camel_case_from, camel_case_until};
76+
use super::{from, until};
7777

7878
#[test]
7979
fn from_full() {
80-
assert_eq!(camel_case_from("AbcDef"), 0);
81-
assert_eq!(camel_case_from("Abc"), 0);
80+
assert_eq!(from("AbcDef"), 0);
81+
assert_eq!(from("Abc"), 0);
8282
}
8383

8484
#[test]
8585
fn from_partial() {
86-
assert_eq!(camel_case_from("abcDef"), 3);
87-
assert_eq!(camel_case_from("aDbc"), 1);
86+
assert_eq!(from("abcDef"), 3);
87+
assert_eq!(from("aDbc"), 1);
8888
}
8989

9090
#[test]
9191
fn from_not() {
92-
assert_eq!(camel_case_from("AbcDef_"), 7);
93-
assert_eq!(camel_case_from("AbcDD"), 5);
92+
assert_eq!(from("AbcDef_"), 7);
93+
assert_eq!(from("AbcDD"), 5);
9494
}
9595

9696
#[test]
9797
fn from_caps() {
98-
assert_eq!(camel_case_from("ABCD"), 4);
98+
assert_eq!(from("ABCD"), 4);
9999
}
100100

101101
#[test]
102102
fn until_full() {
103-
assert_eq!(camel_case_until("AbcDef"), 6);
104-
assert_eq!(camel_case_until("Abc"), 3);
103+
assert_eq!(until("AbcDef"), 6);
104+
assert_eq!(until("Abc"), 3);
105105
}
106106

107107
#[test]
108108
fn until_not() {
109-
assert_eq!(camel_case_until("abcDef"), 0);
110-
assert_eq!(camel_case_until("aDbc"), 0);
109+
assert_eq!(until("abcDef"), 0);
110+
assert_eq!(until("aDbc"), 0);
111111
}
112112

113113
#[test]
114114
fn until_partial() {
115-
assert_eq!(camel_case_until("AbcDef_"), 6);
116-
assert_eq!(camel_case_until("CallTypeC"), 8);
117-
assert_eq!(camel_case_until("AbcDD"), 3);
115+
assert_eq!(until("AbcDef_"), 6);
116+
assert_eq!(until("CallTypeC"), 8);
117+
assert_eq!(until("AbcDD"), 3);
118118
}
119119

120120
#[test]
121121
fn until_caps() {
122-
assert_eq!(camel_case_until("ABCD"), 0);
122+
assert_eq!(until("ABCD"), 0);
123123
}
124-
}
124+
}

clippy_lints/src/utils/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ use crate::syntax::source_map::{Span, DUMMY_SP};
3333
use crate::syntax::errors::DiagnosticBuilder;
3434
use crate::syntax::symbol::keywords;
3535

36-
mod camel_case;
37-
pub use self::camel_case::{camel_case_from, camel_case_until};
36+
pub mod camel_case;
3837

3938
pub mod comparisons;
4039
pub mod conf;

0 commit comments

Comments
 (0)