aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-06-23 20:29:50 +0100
committerAleksey Kladov <[email protected]>2020-06-23 20:29:50 +0100
commitff687453a8a80da29ee7b0b4ad71871ff8b0523e (patch)
tree3799a6c66e23cfd5885ec074216af2ae2e8ac690 /crates
parent9caf810129589327cc614936a97a10cedc6f03a9 (diff)
Slightly better name
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/display/function_signature.rs4
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs4
-rw-r--r--crates/stdx/src/lib.rs2
-rw-r--r--crates/test_utils/src/fixture.rs8
4 files changed, 9 insertions, 9 deletions
diff --git a/crates/ra_ide/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs
index ca8a6a650..a98264fb3 100644
--- a/crates/ra_ide/src/display/function_signature.rs
+++ b/crates/ra_ide/src/display/function_signature.rs
@@ -10,7 +10,7 @@ use std::{
10use hir::{Docs, Documentation, HasSource, HirDisplay}; 10use hir::{Docs, Documentation, HasSource, HirDisplay};
11use ra_ide_db::RootDatabase; 11use ra_ide_db::RootDatabase;
12use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; 12use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner};
13use stdx::{split1, SepBy}; 13use stdx::{split_delim, SepBy};
14 14
15use crate::display::{generic_parameters, where_predicates}; 15use crate::display::{generic_parameters, where_predicates};
16 16
@@ -210,7 +210,7 @@ impl From<&'_ ast::FnDef> for FunctionSignature {
210 // macro-generated functions are missing whitespace 210 // macro-generated functions are missing whitespace
211 fn fmt_param(param: ast::Param) -> String { 211 fn fmt_param(param: ast::Param) -> String {
212 let text = param.syntax().text().to_string(); 212 let text = param.syntax().text().to_string();
213 match split1(&text, ':') { 213 match split_delim(&text, ':') {
214 Some((left, right)) => format!("{}: {}", left.trim(), right.trim()), 214 Some((left, right)) => format!("{}: {}", left.trim(), right.trim()),
215 _ => text, 215 _ => text,
216 } 216 }
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs
index a44959abe..221b902b2 100644
--- a/crates/rust-analyzer/src/main_loop/handlers.rs
+++ b/crates/rust-analyzer/src/main_loop/handlers.rs
@@ -26,7 +26,7 @@ use ra_project_model::TargetKind;
26use ra_syntax::{AstNode, SyntaxKind, TextRange, TextSize}; 26use ra_syntax::{AstNode, SyntaxKind, TextRange, TextSize};
27use serde::{Deserialize, Serialize}; 27use serde::{Deserialize, Serialize};
28use serde_json::to_value; 28use serde_json::to_value;
29use stdx::{format_to, split1}; 29use stdx::{format_to, split_delim};
30 30
31use crate::{ 31use crate::{
32 cargo_target_spec::CargoTargetSpec, 32 cargo_target_spec::CargoTargetSpec,
@@ -785,7 +785,7 @@ pub fn handle_resolve_code_action(
785 let frange = FileRange { file_id, range }; 785 let frange = FileRange { file_id, range };
786 786
787 let assists = snap.analysis().resolved_assists(&snap.config.assist, frange)?; 787 let assists = snap.analysis().resolved_assists(&snap.config.assist, frange)?;
788 let (id_string, index) = split1(&params.id, ':').unwrap(); 788 let (id_string, index) = split_delim(&params.id, ':').unwrap();
789 let index = index.parse::<usize>().unwrap(); 789 let index = index.parse::<usize>().unwrap();
790 let assist = &assists[index]; 790 let assist = &assists[index];
791 assert!(assist.assist.id.0 == id_string); 791 assert!(assist.assist.id.0 == id_string);
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs
index f2ff0e435..100db9d5d 100644
--- a/crates/stdx/src/lib.rs
+++ b/crates/stdx/src/lib.rs
@@ -124,7 +124,7 @@ pub fn replace(buf: &mut String, from: char, to: &str) {
124 *buf = buf.replace(from, to) 124 *buf = buf.replace(from, to)
125} 125}
126 126
127pub fn split1(haystack: &str, delim: char) -> Option<(&str, &str)> { 127pub fn split_delim(haystack: &str, delim: char) -> Option<(&str, &str)> {
128 let idx = haystack.find(delim)?; 128 let idx = haystack.find(delim)?;
129 Some((&haystack[..idx], &haystack[idx + delim.len_utf8()..])) 129 Some((&haystack[..idx], &haystack[idx + delim.len_utf8()..]))
130} 130}
diff --git a/crates/test_utils/src/fixture.rs b/crates/test_utils/src/fixture.rs
index 9108e49d9..0cd51ab3e 100644
--- a/crates/test_utils/src/fixture.rs
+++ b/crates/test_utils/src/fixture.rs
@@ -2,7 +2,7 @@
2//! rust-analyzer database from a single string. 2//! rust-analyzer database from a single string.
3 3
4use rustc_hash::FxHashMap; 4use rustc_hash::FxHashMap;
5use stdx::split1; 5use stdx::split_delim;
6 6
7#[derive(Debug, Eq, PartialEq)] 7#[derive(Debug, Eq, PartialEq)]
8pub struct Fixture { 8pub struct Fixture {
@@ -81,14 +81,14 @@ The offending line: {:?}"#,
81 let mut cfg_key_values = Vec::new(); 81 let mut cfg_key_values = Vec::new();
82 let mut env = FxHashMap::default(); 82 let mut env = FxHashMap::default();
83 for component in components[1..].iter() { 83 for component in components[1..].iter() {
84 let (key, value) = split1(component, ':').unwrap(); 84 let (key, value) = split_delim(component, ':').unwrap();
85 match key { 85 match key {
86 "crate" => krate = Some(value.to_string()), 86 "crate" => krate = Some(value.to_string()),
87 "deps" => deps = value.split(',').map(|it| it.to_string()).collect(), 87 "deps" => deps = value.split(',').map(|it| it.to_string()).collect(),
88 "edition" => edition = Some(value.to_string()), 88 "edition" => edition = Some(value.to_string()),
89 "cfg" => { 89 "cfg" => {
90 for entry in value.split(',') { 90 for entry in value.split(',') {
91 match split1(entry, '=') { 91 match split_delim(entry, '=') {
92 Some((k, v)) => cfg_key_values.push((k.to_string(), v.to_string())), 92 Some((k, v)) => cfg_key_values.push((k.to_string(), v.to_string())),
93 None => cfg_atoms.push(entry.to_string()), 93 None => cfg_atoms.push(entry.to_string()),
94 } 94 }
@@ -96,7 +96,7 @@ The offending line: {:?}"#,
96 } 96 }
97 "env" => { 97 "env" => {
98 for key in value.split(',') { 98 for key in value.split(',') {
99 if let Some((k, v)) = split1(key, '=') { 99 if let Some((k, v)) = split_delim(key, '=') {
100 env.insert(k.into(), v.into()); 100 env.insert(k.into(), v.into());
101 } 101 }
102 } 102 }