about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-03-12 13:22:12 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2022-03-12 16:50:49 +0100
commit1f70886b152d7c46afe3f6aae9ec41f00d32ac00 (patch)
tree601e200be78dc6c03551251e49ddd0c784ef5d66
parent7912e33ed66beb0976715207cdaa308c9b38c719 (diff)
downloadrust-1f70886b152d7c46afe3f6aae9ec41f00d32ac00.tar.gz
rust-1f70886b152d7c46afe3f6aae9ec41f00d32ac00.zip
fix clippy::single_char_pattern
-rw-r--r--crates/base_db/src/fixture.rs6
-rw-r--r--crates/hir_def/src/macro_expansion_tests.rs2
-rw-r--r--crates/hir_ty/src/tests.rs2
-rw-r--r--crates/ide/src/syntax_highlighting/html.rs2
-rw-r--r--crates/ide_assists/src/handlers/number_representation.rs2
-rw-r--r--crates/ide_db/src/tests/sourcegen_lints.rs14
-rw-r--r--crates/rust-analyzer/src/config.rs6
-rw-r--r--crates/rust-analyzer/tests/slow-tests/main.rs4
-rw-r--r--crates/rust-analyzer/tests/slow-tests/support.rs4
-rw-r--r--crates/syntax/src/ast/token_ext.rs2
10 files changed, 22 insertions, 22 deletions
diff --git a/crates/base_db/src/fixture.rs b/crates/base_db/src/fixture.rs
index ccf2bf76009..d1e2d74a987 100644
--- a/crates/base_db/src/fixture.rs
+++ b/crates/base_db/src/fixture.rs
@@ -394,9 +394,9 @@ struct FileMeta {
 }
 
 fn parse_crate(crate_str: String) -> (String, CrateOrigin, Option<String>) {
-    if let Some((a, b)) = crate_str.split_once("@") {
-        let (version, origin) = match b.split_once(":") {
-            Some(("CratesIo", data)) => match data.split_once(",") {
+    if let Some((a, b)) = crate_str.split_once('@') {
+        let (version, origin) = match b.split_once(':') {
+            Some(("CratesIo", data)) => match data.split_once(',') {
                 Some((version, url)) => {
                     (version, CrateOrigin::CratesIo { repo: Some(url.to_owned()) })
                 }
diff --git a/crates/hir_def/src/macro_expansion_tests.rs b/crates/hir_def/src/macro_expansion_tests.rs
index 489a3c67e54..9d9b925bd2d 100644
--- a/crates/hir_def/src/macro_expansion_tests.rs
+++ b/crates/hir_def/src/macro_expansion_tests.rs
@@ -178,7 +178,7 @@ pub fn identity_when_valid(_attr: TokenStream, item: TokenStream) -> TokenStream
 
             if tree {
                 let tree = format!("{:#?}", parse.syntax_node())
-                    .split_inclusive("\n")
+                    .split_inclusive('\n')
                     .map(|line| format!("// {}", line))
                     .collect::<String>();
                 format_to!(expn_text, "\n{}", tree)
diff --git a/crates/hir_ty/src/tests.rs b/crates/hir_ty/src/tests.rs
index 7385da56622..18523d2db59 100644
--- a/crates/hir_ty/src/tests.rs
+++ b/crates/hir_ty/src/tests.rs
@@ -337,7 +337,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
             let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.value.clone()) {
                 (self_param.name().unwrap().syntax().text_range(), "self".to_string())
             } else {
-                (node.value.text_range(), node.value.text().to_string().replace("\n", " "))
+                (node.value.text_range(), node.value.text().to_string().replace('\n', " "))
             };
             let macro_prefix = if node.file_id != file_id.into() { "!" } else { "" };
             format_to!(
diff --git a/crates/ide/src/syntax_highlighting/html.rs b/crates/ide/src/syntax_highlighting/html.rs
index 46c55da1f98..0491ce36350 100644
--- a/crates/ide/src/syntax_highlighting/html.rs
+++ b/crates/ide/src/syntax_highlighting/html.rs
@@ -47,7 +47,7 @@ pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: boo
 
 //FIXME: like, real html escaping
 fn html_escape(text: &str) -> String {
-    text.replace("<", "&lt;").replace(">", "&gt;")
+    text.replace('<', "&lt;").replace('>', "&gt;")
 }
 
 const STYLE: &str = "
diff --git a/crates/ide_assists/src/handlers/number_representation.rs b/crates/ide_assists/src/handlers/number_representation.rs
index f3738a790cf..f77471d80cb 100644
--- a/crates/ide_assists/src/handlers/number_representation.rs
+++ b/crates/ide_assists/src/handlers/number_representation.rs
@@ -57,7 +57,7 @@ fn remove_separators(acc: &mut Assists, literal: ast::IntNumber) -> Option<()> {
         AssistId("reformat_number_literal", AssistKind::RefactorInline),
         "Remove digit separators",
         range,
-        |builder| builder.replace(range, literal.text().replace("_", "")),
+        |builder| builder.replace(range, literal.text().replace('_', "")),
     )
 }
 
diff --git a/crates/ide_db/src/tests/sourcegen_lints.rs b/crates/ide_db/src/tests/sourcegen_lints.rs
index 1555bad54e8..61c05c7ffd1 100644
--- a/crates/ide_db/src/tests/sourcegen_lints.rs
+++ b/crates/ide_db/src/tests/sourcegen_lints.rs
@@ -75,7 +75,7 @@ fn generate_lint_descriptor(buf: &mut String) {
                 format!("lint group for: {}", lints.trim()).into(),
                 lints
                     .split_ascii_whitespace()
-                    .map(|s| s.trim().trim_matches(',').replace("-", "_"))
+                    .map(|s| s.trim().trim_matches(',').replace('-', "_"))
                     .collect(),
             )
         });
@@ -85,7 +85,7 @@ fn generate_lint_descriptor(buf: &mut String) {
         .sorted_by(|(ident, ..), (ident2, ..)| ident.cmp(ident2))
         .collect::<Vec<_>>();
     for (name, description, ..) in &lints {
-        push_lint_completion(buf, &name.replace("-", "_"), description);
+        push_lint_completion(buf, &name.replace('-', "_"), description);
     }
     buf.push_str("];\n");
     buf.push_str(r#"pub const DEFAULT_LINT_GROUPS: &[LintGroup] = &["#);
@@ -96,7 +96,7 @@ fn generate_lint_descriptor(buf: &mut String) {
                 push_lint_group(buf, name, description, &Vec::new());
                 continue;
             }
-            push_lint_group(buf, &name.replace("-", "_"), description, children);
+            push_lint_group(buf, &name.replace('-', "_"), description, children);
         }
     }
     buf.push('\n');
@@ -124,7 +124,7 @@ fn generate_lint_descriptor(buf: &mut String) {
                     format!("lint group for: {}", lints.trim()).into(),
                     lints
                         .split_ascii_whitespace()
-                        .map(|s| s.trim().trim_matches(',').replace("-", "_"))
+                        .map(|s| s.trim().trim_matches(',').replace('-', "_"))
                         .collect(),
                 )
             },
@@ -136,14 +136,14 @@ fn generate_lint_descriptor(buf: &mut String) {
         .collect::<Vec<_>>();
 
     for (name, description, ..) in &lints_rustdoc {
-        push_lint_completion(buf, &name.replace("-", "_"), description)
+        push_lint_completion(buf, &name.replace('-', "_"), description)
     }
     buf.push_str("];\n");
 
     buf.push_str(r#"pub const RUSTDOC_LINT_GROUPS: &[LintGroup] = &["#);
     for (name, description, children) in &lints_rustdoc {
         if !children.is_empty() {
-            push_lint_group(buf, &name.replace("-", "_"), description, children);
+            push_lint_group(buf, &name.replace('-', "_"), description, children);
         }
     }
     buf.push('\n');
@@ -159,7 +159,7 @@ fn generate_feature_descriptor(buf: &mut String, src_dir: &Path) {
             path.extension().unwrap_or_default().to_str().unwrap_or_default() == "md"
         })
         .map(|path| {
-            let feature_ident = path.file_stem().unwrap().to_str().unwrap().replace("-", "_");
+            let feature_ident = path.file_stem().unwrap().to_str().unwrap().replace('-', "_");
             let doc = fs::read_to_string(path).unwrap();
             (feature_ident, doc)
         })
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index e50bcbb690a..a93e18a9b09 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -1238,7 +1238,7 @@ fn schema(fields: &[(&'static str, &'static str, &[&str], &str)]) -> serde_json:
     let map = fields
         .iter()
         .map(|(field, ty, doc, default)| {
-            let name = field.replace("_", ".");
+            let name = field.replace('_', ".");
             let name = format!("rust-analyzer.{}", name);
             let props = field_props(field, ty, doc, default);
             (name, props)
@@ -1385,7 +1385,7 @@ fn manual(fields: &[(&'static str, &'static str, &[&str], &str)]) -> String {
     fields
         .iter()
         .map(|(field, _ty, doc, default)| {
-            let name = format!("rust-analyzer.{}", field.replace("_", "."));
+            let name = format!("rust-analyzer.{}", field.replace('_', "."));
             let doc = doc_comment_to_string(*doc);
             if default.contains('\n') {
                 format!(
@@ -1428,7 +1428,7 @@ mod tests {
             .trim_start_matches('{')
             .trim_end_matches('}')
             .replace("  ", "    ")
-            .replace("\n", "\n            ")
+            .replace('\n', "\n            ")
             .trim_start_matches('\n')
             .trim_end()
             .to_string();
diff --git a/crates/rust-analyzer/tests/slow-tests/main.rs b/crates/rust-analyzer/tests/slow-tests/main.rs
index 9e839954847..a55d3c2405b 100644
--- a/crates/rust-analyzer/tests/slow-tests/main.rs
+++ b/crates/rust-analyzer/tests/slow-tests/main.rs
@@ -972,7 +972,7 @@ fn main() {}
           "documentChanges": [
             {
               "textDocument": {
-                "uri": format!("file://{}", tmp_dir_path.join("src").join("lib.rs").to_str().unwrap().to_string().replace("C:\\", "/c:/").replace("\\", "/")),
+                "uri": format!("file://{}", tmp_dir_path.join("src").join("lib.rs").to_str().unwrap().to_string().replace("C:\\", "/c:/").replace('\\', "/")),
                 "version": null
               },
               "edits": [
@@ -1029,7 +1029,7 @@ fn main() {}
           "documentChanges": [
             {
               "textDocument": {
-                "uri": format!("file://{}", tmp_dir_path.join("src").join("lib.rs").to_str().unwrap().to_string().replace("C:\\", "/c:/").replace("\\", "/")),
+                "uri": format!("file://{}", tmp_dir_path.join("src").join("lib.rs").to_str().unwrap().to_string().replace("C:\\", "/c:/").replace('\\', "/")),
                 "version": null
               },
               "edits": [
diff --git a/crates/rust-analyzer/tests/slow-tests/support.rs b/crates/rust-analyzer/tests/slow-tests/support.rs
index 78aa4119159..515cdfdc7c6 100644
--- a/crates/rust-analyzer/tests/slow-tests/support.rs
+++ b/crates/rust-analyzer/tests/slow-tests/support.rs
@@ -374,8 +374,8 @@ fn lines_match(expected: &str, actual: &str) -> bool {
     // Let's not deal with / vs \ (windows...)
     // First replace backslash-escaped backslashes with forward slashes
     // which can occur in, for example, JSON output
-    let expected = expected.replace(r"\\", "/").replace(r"\", "/");
-    let mut actual: &str = &actual.replace(r"\\", "/").replace(r"\", "/");
+    let expected = expected.replace(r"\\", "/").replace('\\', "/");
+    let mut actual: &str = &actual.replace(r"\\", "/").replace('\\', "/");
     for (i, part) in expected.split("[..]").enumerate() {
         match actual.find(part) {
             Some(j) => {
diff --git a/crates/syntax/src/ast/token_ext.rs b/crates/syntax/src/ast/token_ext.rs
index 16ac35b3991..f1e5c2136f3 100644
--- a/crates/syntax/src/ast/token_ext.rs
+++ b/crates/syntax/src/ast/token_ext.rs
@@ -307,7 +307,7 @@ impl ast::IntNumber {
 
     pub fn value(&self) -> Option<u128> {
         let (_, text, _) = self.split_into_parts();
-        let value = u128::from_str_radix(&text.replace("_", ""), self.radix() as u32).ok()?;
+        let value = u128::from_str_radix(&text.replace('_', ""), self.radix() as u32).ok()?;
         Some(value)
     }