diff --git a/crates/base_db/src/fixture.rs b/crates/base_db/src/fixture.rs index ccf2bf7600..d1e2d74a98 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) { - 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 489a3c67e5..9d9b925bd2 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::(); format_to!(expn_text, "\n{}", tree) diff --git a/crates/hir_ty/src/tests.rs b/crates/hir_ty/src/tests.rs index 7385da5662..18523d2db5 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 46c55da1f9..0491ce3635 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("<", "<").replace(">", ">") + text.replace('<', "<").replace('>', ">") } const STYLE: &str = " diff --git a/crates/ide_assists/src/handlers/number_representation.rs b/crates/ide_assists/src/handlers/number_representation.rs index f3738a790c..f77471d80c 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 1555bad54e..61c05c7ffd 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::>(); 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::>(); 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 e50bcbb690..a93e18a9b0 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 9e83995484..a55d3c2405 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 78aa411915..515cdfdc7c 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 16ac35b399..f1e5c2136f 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 { 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) }