about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2018-08-31 20:57:46 -0700
committerJosh Triplett <josh@joshtriplett.org>2018-09-01 12:19:04 -0700
commitcd51523715a77a30660dfb46898eb407937ec9d7 (patch)
treee8bb667026ca83d8a5efcd96fce320bd65592a15
parent571a624aa92a0f1f1a0276d42262a6d2ad89ba7b (diff)
downloadrust-cd51523715a77a30660dfb46898eb407937ec9d7.tar.gz
rust-cd51523715a77a30660dfb46898eb407937ec9d7.zip
tidy: Use chars for single-character patterns
Fixes the clippy "single_char_pattern" lint, and (marginally) improves
performance.
-rw-r--r--src/tools/tidy/src/cargo.rs2
-rw-r--r--src/tools/tidy/src/errors.rs2
-rw-r--r--src/tools/tidy/src/extdeps.rs2
-rw-r--r--src/tools/tidy/src/features.rs10
-rw-r--r--src/tools/tidy/src/style.rs8
5 files changed, 12 insertions, 12 deletions
diff --git a/src/tools/tidy/src/cargo.rs b/src/tools/tidy/src/cargo.rs
index f40fea60f40..1f0379f1ea8 100644
--- a/src/tools/tidy/src/cargo.rs
+++ b/src/tools/tidy/src/cargo.rs
@@ -67,7 +67,7 @@ fn verify(tomlfile: &Path, libfile: &Path, bad: &mut bool) {
     };
     let mut lines = deps.lines().peekable();
     while let Some(line) = lines.next() {
-        if line.starts_with("[") {
+        if line.starts_with('[') {
             break
         }
 
diff --git a/src/tools/tidy/src/errors.rs b/src/tools/tidy/src/errors.rs
index 3dccffddf93..9f55d6f9ad6 100644
--- a/src/tools/tidy/src/errors.rs
+++ b/src/tools/tidy/src/errors.rs
@@ -50,7 +50,7 @@ pub fn check(path: &Path, bad: &mut bool) {
             }
 
             let mut search = line;
-            while let Some(i) = search.find("E") {
+            while let Some(i) = search.find('E') {
                 search = &search[i + 1..];
                 let code = if search.len() > 4 {
                     search[..4].parse::<u32>()
diff --git a/src/tools/tidy/src/extdeps.rs b/src/tools/tidy/src/extdeps.rs
index 761803a45b8..74f3a41047a 100644
--- a/src/tools/tidy/src/extdeps.rs
+++ b/src/tools/tidy/src/extdeps.rs
@@ -38,7 +38,7 @@ pub fn check(path: &Path, bad: &mut bool) {
         }
 
         // extract source value
-        let parts: Vec<&str> = line.splitn(2, "=").collect();
+        let parts: Vec<&str> = line.splitn(2, '=').collect();
         let source = parts[1].trim();
 
         // ensure source is whitelisted
diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs
index 74f66c0a051..c95f1c7b32a 100644
--- a/src/tools/tidy/src/features.rs
+++ b/src/tools/tidy/src/features.rs
@@ -75,7 +75,7 @@ pub fn check(path: &Path, bad: &mut bool, quiet: bool) {
             return;
         }
 
-        let filen_underscore = filename.replace("-","_").replace(".rs","");
+        let filen_underscore = filename.replace('-',"_").replace(".rs","");
         let filename_is_gate_test = test_filen_gate(&filen_underscore, &mut features);
 
         contents.truncate(0);
@@ -332,11 +332,11 @@ fn map_lib_features(base_src_path: &Path,
                     f.tracking_issue = find_attr_val(line, "issue")
                     .map(|s| s.parse().unwrap());
                 }
-                if line.ends_with("]") {
+                if line.ends_with(']') {
                     mf(Ok((name, f.clone())), file, i + 1);
-                } else if !line.ends_with(",") && !line.ends_with("\\") {
+                } else if !line.ends_with(',') && !line.ends_with('\\') {
                     // We need to bail here because we might have missed the
-                    // end of a stability attribute above because the "]"
+                    // end of a stability attribute above because the ']'
                     // might not have been at the end of the line.
                     // We could then get into the very unfortunate situation that
                     // we continue parsing the file assuming the current stability
@@ -394,7 +394,7 @@ fn map_lib_features(base_src_path: &Path,
                 has_gate_test: false,
                 tracking_issue,
             };
-            if line.contains("]") {
+            if line.contains(']') {
                 mf(Ok((feature_name, feature)), file, i + 1);
             } else {
                 becoming_feature = Some((feature_name.to_owned(), feature));
diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs
index 6b431ccda08..33cd8b5dcd9 100644
--- a/src/tools/tidy/src/style.rs
+++ b/src/tools/tidy/src/style.rs
@@ -69,7 +69,7 @@ fn line_is_url(line: &str) -> bool {
             (EXP_COMMENT_START, "//!") => state = EXP_LINK_LABEL_OR_URL,
 
             (EXP_LINK_LABEL_OR_URL, w)
-                if w.len() >= 4 && w.starts_with("[") && w.ends_with("]:")
+                if w.len() >= 4 && w.starts_with('[') && w.ends_with("]:")
                 => state = EXP_URL,
 
             (EXP_LINK_LABEL_OR_URL, w)
@@ -128,13 +128,13 @@ pub fn check(path: &Path, bad: &mut bool) {
                 && !long_line_is_ok(line) {
                     err(&format!("line longer than {} chars", COLS));
             }
-            if line.contains("\t") && !skip_tab {
+            if line.contains('\t') && !skip_tab {
                 err("tab character");
             }
-            if !skip_end_whitespace && (line.ends_with(" ") || line.ends_with("\t")) {
+            if !skip_end_whitespace && (line.ends_with(' ') || line.ends_with('\t')) {
                 err("trailing whitespace");
             }
-            if line.contains("\r") && !skip_cr {
+            if line.contains('\r') && !skip_cr {
                 err("CR character");
             }
             if filename != "style.rs" {