Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Enable `clippy::single_char_pattern` (#8727)
Marshall Bowers5935681c5c84
diff --git a/crates/assistant/src/codegen.rs b/crates/assistant/src/codegen.rsindex c1a663d7efe..04d08a3315f 100644--- a/crates/assistant/src/codegen.rs+++ b/crates/assistant/src/codegen.rs@@ -297,7 +297,7 @@ fn strip_invalid_spans_from_codeblock(} else if buffer.starts_with("<|")|| buffer.starts_with("<|S")|| buffer.starts_with("<|S|")- || buffer.ends_with("|")+ || buffer.ends_with('|')|| buffer.ends_with("|E")|| buffer.ends_with("|E|"){@@ -335,7 +335,7 @@ fn strip_invalid_spans_from_codeblock(.strip_suffix("|E|>").or_else(|| text.strip_suffix("E|>")).or_else(|| text.strip_prefix("|>"))- .or_else(|| text.strip_prefix(">"))+ .or_else(|| text.strip_prefix('>')).unwrap_or(&text).to_string();};diff --git a/crates/channel/src/channel_store.rs b/crates/channel/src/channel_store.rsindex 63b4fba1093..ecda9481f22 100644--- a/crates/channel/src/channel_store.rs+++ b/crates/channel/src/channel_store.rs@@ -592,7 +592,7 @@ impl ChannelStore {cx: &mut ModelContext<Self>,) -> Task<Result<ChannelId>> {let client = self.client.clone();- let name = name.trim_start_matches("#").to_owned();+ let name = name.trim_start_matches('#').to_owned();cx.spawn(move |this, mut cx| async move {let response = client.request(proto::CreateChannel {diff --git a/crates/collab/src/db/tests.rs b/crates/collab/src/db/tests.rsindex 7790b951b28..b6116c2e77b 100644--- a/crates/collab/src/db/tests.rs+++ b/crates/collab/src/db/tests.rs@@ -168,7 +168,7 @@ async fn new_test_user(db: &Arc<Database>, email: &str) -> UserId {email,false,NewUserParams {- github_login: email[0..email.find("@").unwrap()].to_string(),+ github_login: email[0..email.find('@').unwrap()].to_string(),github_user_id: GITHUB_USER_ID.fetch_add(1, SeqCst),},)diff --git a/crates/collab_ui/src/chat_panel/message_editor.rs b/crates/collab_ui/src/chat_panel/message_editor.rsindex 76c355f3f8c..5e95cdc450d 100644--- a/crates/collab_ui/src/chat_panel/message_editor.rs+++ b/crates/collab_ui/src/chat_panel/message_editor.rs@@ -310,7 +310,7 @@ impl MessageEditor {for range in ranges {text.clear();text.extend(buffer.text_for_range(range.clone()));- if let Some(username) = text.strip_prefix("@") {+ if let Some(username) = text.strip_prefix('@') {if let Some(user_id) = this.channel_members.get(username) {let start = multi_buffer.anchor_after(range.start);let end = multi_buffer.anchor_after(range.end);diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex c93df92042e..730e4181cd3 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -4845,7 +4845,7 @@ impl Editor {.text_for_range(start_point..end_point).collect::<String>();- let mut lines = text.split("\n").collect_vec();+ let mut lines = text.split('\n').collect_vec();let lines_before = lines.len();callback(&mut lines);@@ -4913,7 +4913,7 @@ impl Editor {self.manipulate_text(cx, |text| {// Hack to get around the fact that to_case crate doesn't support '\n' as a word boundary// https://github.com/rutrum/convert-case/issues/16- text.split("\n")+ text.split('\n').map(|line| line.to_case(Case::Title)).join("\n")})@@ -4935,7 +4935,7 @@ impl Editor {self.manipulate_text(cx, |text| {// Hack to get around the fact that to_case crate doesn't support '\n' as a word boundary// https://github.com/rutrum/convert-case/issues/16- text.split("\n")+ text.split('\n').map(|line| line.to_case(Case::UpperCamel)).join("\n")})@@ -9387,7 +9387,7 @@ impl Editor {let highlight = chunk.syntax_highlight_id.and_then(|id| id.name(&style.syntax));- let mut chunk_lines = chunk.text.split("\n").peekable();+ let mut chunk_lines = chunk.text.split('\n').peekable();while let Some(text) = chunk_lines.next() {let mut merged_with_last_token = false;if let Some(last_token) = line.back_mut() {diff --git a/crates/editor/src/git/permalink.rs b/crates/editor/src/git/permalink.rsindex ec2a925d1b4..90704b43d0a 100644--- a/crates/editor/src/git/permalink.rs+++ b/crates/editor/src/git/permalink.rs@@ -105,7 +105,7 @@ fn parse_git_remote_url(url: &str) -> Option<ParsedGitRemote> {.trim_start_matches("https://github.com/").trim_end_matches(".git");- let (owner, repo) = repo_with_owner.split_once("/")?;+ let (owner, repo) = repo_with_owner.split_once('/')?;return Some(ParsedGitRemote {provider: GitHostingProvider::Github,@@ -120,7 +120,7 @@ fn parse_git_remote_url(url: &str) -> Option<ParsedGitRemote> {.trim_start_matches("https://gitlab.com/").trim_end_matches(".git");- let (owner, repo) = repo_with_owner.split_once("/")?;+ let (owner, repo) = repo_with_owner.split_once('/')?;return Some(ParsedGitRemote {provider: GitHostingProvider::Gitlab,@@ -135,7 +135,7 @@ fn parse_git_remote_url(url: &str) -> Option<ParsedGitRemote> {.trim_start_matches("https://gitee.com/").trim_end_matches(".git");- let (owner, repo) = repo_with_owner.split_once("/")?;+ let (owner, repo) = repo_with_owner.split_once('/')?;return Some(ParsedGitRemote {provider: GitHostingProvider::Gitee,@@ -147,9 +147,9 @@ fn parse_git_remote_url(url: &str) -> Option<ParsedGitRemote> {if url.contains("bitbucket.org") {let (_, repo_with_owner) = url.trim_end_matches(".git").split_once("bitbucket.org")?;let (owner, repo) = repo_with_owner- .trim_start_matches("/")- .trim_start_matches(":")- .split_once("/")?;+ .trim_start_matches('/')+ .trim_start_matches(':')+ .split_once('/')?;return Some(ParsedGitRemote {provider: GitHostingProvider::Bitbucket,@@ -166,7 +166,7 @@ fn parse_git_remote_url(url: &str) -> Option<ParsedGitRemote> {.trim_start_matches("[email protected]:~").trim_start_matches("https://git.sr.ht/~");- let (owner, repo) = repo_with_owner.split_once("/")?;+ let (owner, repo) = repo_with_owner.split_once('/')?;return Some(ParsedGitRemote {provider: GitHostingProvider::Sourcehut,@@ -181,7 +181,7 @@ fn parse_git_remote_url(url: &str) -> Option<ParsedGitRemote> {.trim_start_matches("https://codeberg.org/").trim_end_matches(".git");- let (owner, repo) = repo_with_owner.split_once("/")?;+ let (owner, repo) = repo_with_owner.split_once('/')?;return Some(ParsedGitRemote {provider: GitHostingProvider::Codeberg,diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rsindex dcade2781e9..a8349a63357 100644--- a/crates/file_finder/src/file_finder.rs+++ b/crates/file_finder/src/file_finder.rs@@ -701,7 +701,7 @@ impl PickerDelegate for FileFinderDelegate {raw_query: String,cx: &mut ViewContext<Picker<Self>>,) -> Task<()> {- let raw_query = raw_query.replace(" ", "");+ let raw_query = raw_query.replace(' ', "");let raw_query = raw_query.trim();if raw_query.is_empty() {let project = self.project.read(cx);diff --git a/crates/gpui/src/app/test_context.rs b/crates/gpui/src/app/test_context.rsindex 3a99bec94d9..e2f4808ca54 100644--- a/crates/gpui/src/app/test_context.rs+++ b/crates/gpui/src/app/test_context.rs@@ -331,7 +331,7 @@ impl TestAppContext {/// This will also run the background executor until it's parked.pub fn simulate_keystrokes(&mut self, window: AnyWindowHandle, keystrokes: &str) {for keystroke in keystrokes- .split(" ")+ .split(' ').map(Keystroke::parse).map(Result::unwrap){diff --git a/crates/language/src/buffer_tests.rs b/crates/language/src/buffer_tests.rsindex 9750cec9bf2..bc3eb692fa1 100644--- a/crates/language/src/buffer_tests.rs+++ b/crates/language/src/buffer_tests.rs@@ -1110,7 +1110,7 @@ fn test_autoindent_does_not_adjust_lines_with_unchanged_suggestion(cx: &mut AppCb();|"- .replace("|", "") // marker to preserve trailing whitespace+ .replace('|', "") // marker to preserve trailing whitespace.unindent(),).with_language(Arc::new(rust_lang()), cx);@@ -1787,7 +1787,7 @@ fn test_language_scope_at_with_javascript(cx: &mut AppContext) {// In a JSX expression: use the default config.let expression_in_element_config = snapshot- .language_scope_at(text.find("{").unwrap() + 1)+ .language_scope_at(text.find('{').unwrap() + 1).unwrap();assert_eq!(expression_in_element_config@@ -2321,7 +2321,7 @@ fn test_trailing_whitespace_ranges(mut rng: StdRng) {actual_ranges,expected_ranges,"wrong ranges for text lines:\n{:?}",- text.split("\n").collect::<Vec<_>>()+ text.split('\n').collect::<Vec<_>>());}diff --git a/crates/languages/src/ocaml.rs b/crates/languages/src/ocaml.rsindex 3b965b9ba0a..f355bcb965a 100644--- a/crates/languages/src/ocaml.rs+++ b/crates/languages/src/ocaml.rs@@ -62,7 +62,7 @@ impl LspAdapter for OCamlLspAdapter {language: &Arc<language::Language>,) -> Option<CodeLabel> {let name = &completion.label;- let detail = completion.detail.as_ref().map(|s| s.replace("\n", " "));+ let detail = completion.detail.as_ref().map(|s| s.replace('\n', " "));match completion.kind.zip(detail) {// Error of 'b : ('a, 'b) result@@ -124,7 +124,7 @@ impl LspAdapter for OCamlLspAdapter {// version : string// NOTE: (~|?) are omitted as we don't use them in the fuzzy filteringSome((CompletionItemKind::FIELD, detail))- if name.starts_with("~") || name.starts_with("?") =>+ if name.starts_with('~') || name.starts_with('?') =>{let label = name.trim_start_matches(&['~', '?']);let text = format!("{} : {}", label, detail);diff --git a/crates/languages/src/terraform.rs b/crates/languages/src/terraform.rsindex 6d685ca55c4..d201b8aeffe 100644--- a/crates/languages/src/terraform.rs+++ b/crates/languages/src/terraform.rs@@ -129,7 +129,7 @@ impl LspAdapter for TerraformLspAdapter {}fn build_download_url(version: String) -> Result<String> {- let v = version.strip_prefix("v").unwrap_or(&version);+ let v = version.strip_prefix('v').unwrap_or(&version);let os = match std::env::consts::OS {"linux" => "linux","macos" => "darwin",diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rsindex ce021abf45a..25db2d6e690 100644--- a/crates/lsp/src/lsp.rs+++ b/crates/lsp/src/lsp.rs@@ -377,7 +377,7 @@ impl LanguageServer {let headers = std::str::from_utf8(&buffer)?;let message_len = headers- .split("\n")+ .split('\n').find(|line| line.starts_with(CONTENT_LEN_HEADER)).and_then(|line| line.strip_prefix(CONTENT_LEN_HEADER)).ok_or_else(|| anyhow!("invalid LSP message header {headers:?}"))?diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rsindex 96117be2a46..17e0e75e156 100644--- a/crates/project_panel/src/project_panel.rs+++ b/crates/project_panel/src/project_panel.rs@@ -607,7 +607,7 @@ impl ProjectPanel {worktree_id,entry_id: NEW_ENTRY_ID,});- let new_path = entry.path.join(&filename.trim_start_matches("/"));+ let new_path = entry.path.join(&filename.trim_start_matches('/'));if path_already_exists(new_path.as_path()) {return None;}diff --git a/crates/semantic_index/src/semantic_index_tests.rs b/crates/semantic_index/src/semantic_index_tests.rsindex 23ed45ff1d5..f660aa8fb37 100644--- a/crates/semantic_index/src/semantic_index_tests.rs+++ b/crates/semantic_index/src/semantic_index_tests.rs@@ -414,7 +414,7 @@ async fn test_code_context_retrieval_json() {}}"#.unindent(),- text.find("{").unwrap(),+ text.find('{').unwrap(),)],);@@ -443,7 +443,7 @@ async fn test_code_context_retrieval_json() {"age": 42}]"#.unindent(),- text.find("[").unwrap(),+ text.find('[').unwrap(),)],);}diff --git a/crates/vim/src/command.rs b/crates/vim/src/command.rsindex af571dd632f..0b138129c94 100644--- a/crates/vim/src/command.rs+++ b/crates/vim/src/command.rs@@ -41,7 +41,7 @@ pub fn command_interceptor(mut query: &str, cx: &AppContext) -> Option<CommandIn//// For now, you can only do a replace on the % range, and you can// only use a specific line number range to "go to line"- while query.starts_with(":") {+ while query.starts_with(':') {query = &query[1..];}@@ -321,16 +321,16 @@ pub fn command_interceptor(mut query: &str, cx: &AppContext) -> Option<CommandIn"0" => ("0", StartOfDocument.boxed_clone()),_ => {- if query.starts_with("/") || query.starts_with("?") {+ if query.starts_with('/') || query.starts_with('?') {(query,FindCommand {query: query[1..].to_string(),- backwards: query.starts_with("?"),+ backwards: query.starts_with('?'),}.boxed_clone(),)- } else if query.starts_with("%") {+ } else if query.starts_with('%') {(query,ReplaceCommand {diff --git a/crates/vim/src/normal/paste.rs b/crates/vim/src/normal/paste.rsindex 9c15cc0cf44..b56bb33b5c1 100644--- a/crates/vim/src/normal/paste.rs+++ b/crates/vim/src/normal/paste.rs@@ -135,8 +135,8 @@ fn paste(_: &mut Workspace, action: &Paste, cx: &mut ViewContext<Workspace>) {} else {(clipboard_text.to_string(), first_selection_indent_column)};- let line_mode = to_insert.ends_with("\n");- let is_multiline = to_insert.contains("\n");+ let line_mode = to_insert.ends_with('\n');+ let is_multiline = to_insert.contains('\n');if line_mode && !before {if selection.is_empty() {@@ -480,7 +480,7 @@ mod test {the_ˇfox jumps over_dog"}- .replace("_", " "), // Hack for trailing whitespace+ .replace('_', " "), // Hack for trailing whitespace).await;cx.assert_shared_clipboard("lazy").await;diff --git a/crates/vim/src/test/neovim_backed_test_context.rs b/crates/vim/src/test/neovim_backed_test_context.rsindex 0a01a627428..f94770307bc 100644--- a/crates/vim/src/test/neovim_backed_test_context.rs+++ b/crates/vim/src/test/neovim_backed_test_context.rs@@ -72,7 +72,7 @@ impl NeovimBackedTestContext {let test_name = thread.name().expect("thread is not named")- .split(":")+ .split(':').last().unwrap().to_string();@@ -122,7 +122,7 @@ impl NeovimBackedTestContext {}pub async fn set_shared_state(&mut self, marked_text: &str) {- let mode = if marked_text.contains("»") {+ let mode = if marked_text.contains('»') {Mode::Visual} else {Mode::Normal@@ -188,7 +188,7 @@ impl NeovimBackedTestContext {pub async fn assert_shared_state(&mut self, marked_text: &str) {self.is_dirty = false;- let marked_text = marked_text.replace("•", " ");+ let marked_text = marked_text.replace('•', " ");let neovim = self.neovim_state().await;let neovim_mode = self.neovim_mode().await;let editor = self.editor_state();diff --git a/crates/vim/src/test/neovim_connection.rs b/crates/vim/src/test/neovim_connection.rsindex 5ea82e36619..63951f73d0a 100644--- a/crates/vim/src/test/neovim_connection.rs+++ b/crates/vim/src/test/neovim_connection.rs@@ -392,7 +392,7 @@ impl NeovimConnection {// the content of the selection via the "a register to get the shape correctly.self.nvim.input("\"aygv").await.unwrap();let content = self.nvim.command_output("echo getreg('a')").await.unwrap();- let lines = content.split("\n").collect::<Vec<_>>();+ let lines = content.split('\n').collect::<Vec<_>>();let top = cmp::min(selection_row, cursor_row);let left = cmp::min(selection_col, cursor_col);for row in top..=cmp::max(selection_row, cursor_row) {diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rsindex 65315aec02a..ec03afe05c2 100644--- a/crates/workspace/src/pane.rs+++ b/crates/workspace/src/pane.rs@@ -2586,8 +2586,8 @@ mod tests {let mut index = 0;let items = labels.map(|mut label| {- if label.ends_with("*") {- label = label.trim_end_matches("*");+ if label.ends_with('*') {+ label = label.trim_end_matches('*');active_item_index = index;}diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex 0cb3ff99129..123096b2289 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -1260,7 +1260,7 @@ impl Workspace {fn send_keystrokes(&mut self, action: &SendKeystrokes, cx: &mut ViewContext<Self>) {let mut keystrokes: Vec<Keystroke> = action.0- .split(" ")+ .split(' ').flat_map(|k| Keystroke::parse(k).log_err()).collect();keystrokes.reverse();diff --git a/crates/zed/src/open_listener.rs b/crates/zed/src/open_listener.rsindex d6fec52df8d..61d0839ae60 100644--- a/crates/zed/src/open_listener.rs+++ b/crates/zed/src/open_listener.rs@@ -95,10 +95,10 @@ impl OpenListener {}fn handle_zed_url_scheme(&self, request_path: &str) -> Option<OpenRequest> {- let mut parts = request_path.split("/");+ let mut parts = request_path.split('/');if parts.next() == Some("channel") {if let Some(slug) = parts.next() {- if let Some(id_str) = slug.split("-").last() {+ if let Some(id_str) = slug.split('-').last() {if let Ok(channel_id) = id_str.parse::<u64>() {let Some(next) = parts.next() else {return Some(OpenRequest::JoinChannel { channel_id });diff --git a/tooling/xtask/src/main.rs b/tooling/xtask/src/main.rsindex 037071ff7e4..253250998d9 100644--- a/tooling/xtask/src/main.rs+++ b/tooling/xtask/src/main.rs@@ -124,7 +124,6 @@ fn run_clippy(args: ClippyArgs) -> Result<()> {"clippy::redundant_locals","clippy::reversed_empty_ranges","clippy::search_is_some",- "clippy::single_char_pattern","clippy::single_range_in_vec_init","clippy::suspicious_to_owned","clippy::to_string_in_format_args",