diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-02-18 14:37:34 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-18 14:37:34 +0000 |
commit | cecf25b72f2af84fc1535cf52d6f3c1b52802565 (patch) | |
tree | 37c8dde0a459caacae6629da08d86be270469ef5 /crates/ra_ide | |
parent | eab80cd961919b9321e1d34343ae3f3adb0502e5 (diff) | |
parent | f6816c253b96e8436f1156d6bd6b0942ee9fb4d3 (diff) |
Merge #3220
3220: Fix clippy warnings, update Cargo.toml versions r=matklad a=SomeoneToIgnore
In the `cargo xtask lint` ouptut, there were two interesting Clippy warnings that might be interesting to investigate further:
* warning: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
* warning: large size difference between variants
Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/ra_ide')
-rw-r--r-- | crates/ra_ide/Cargo.toml | 20 | ||||
-rw-r--r-- | crates/ra_ide/src/call_info.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/complete_trait_impl.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/completion_item.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/display/function_signature.rs | 5 | ||||
-rw-r--r-- | crates/ra_ide/src/display/navigation_target.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/references.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/ssr.rs | 14 |
8 files changed, 33 insertions, 26 deletions
diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index 97dea5ffd..3407d2598 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml | |||
@@ -11,15 +11,19 @@ doctest = false | |||
11 | wasm = [] | 11 | wasm = [] |
12 | 12 | ||
13 | [dependencies] | 13 | [dependencies] |
14 | either = "1.5" | 14 | either = "1.5.3" |
15 | format-buf = "1.0.0" | 15 | format-buf = "1.0.0" |
16 | indexmap = "1.3.0" | 16 | indexmap = "1.3.2" |
17 | itertools = "0.8.0" | 17 | itertools = "0.8.2" |
18 | join_to_string = "0.1.3" | 18 | join_to_string = "0.1.3" |
19 | log = "0.4.5" | 19 | log = "0.4.8" |
20 | rustc-hash = "1.0" | 20 | rayon = "1.3.0" |
21 | rand = { version = "0.7.0", features = ["small_rng"] } | 21 | fst = { version = "0.3.5", default-features = false } |
22 | once_cell = "1.2.0" | 22 | rustc-hash = "1.1.0" |
23 | unicase = "2.6.0" | ||
24 | superslice = "1.0.0" | ||
25 | rand = { version = "0.7.3", features = ["small_rng"] } | ||
26 | once_cell = "1.3.1" | ||
23 | 27 | ||
24 | ra_syntax = { path = "../ra_syntax" } | 28 | ra_syntax = { path = "../ra_syntax" } |
25 | ra_text_edit = { path = "../ra_text_edit" } | 29 | ra_text_edit = { path = "../ra_text_edit" } |
@@ -36,4 +40,4 @@ ra_assists = { path = "../ra_assists" } | |||
36 | hir = { path = "../ra_hir", package = "ra_hir" } | 40 | hir = { path = "../ra_hir", package = "ra_hir" } |
37 | 41 | ||
38 | [dev-dependencies] | 42 | [dev-dependencies] |
39 | insta = "0.13.0" | 43 | insta = "0.13.1" |
diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs index f2b29306e..7c6322cb4 100644 --- a/crates/ra_ide/src/call_info.rs +++ b/crates/ra_ide/src/call_info.rs | |||
@@ -128,7 +128,7 @@ impl FnCallNode { | |||
128 | }), | 128 | }), |
129 | 129 | ||
130 | FnCallNode::MethodCallExpr(call_expr) => { | 130 | FnCallNode::MethodCallExpr(call_expr) => { |
131 | call_expr.syntax().children().filter_map(ast::NameRef::cast).nth(0) | 131 | call_expr.syntax().children().filter_map(ast::NameRef::cast).next() |
132 | } | 132 | } |
133 | 133 | ||
134 | FnCallNode::MacroCallExpr(call_expr) => call_expr.path()?.segment()?.name_ref(), | 134 | FnCallNode::MacroCallExpr(call_expr) => call_expr.path()?.segment()?.name_ref(), |
diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs index 6ff10c017..83628e35c 100644 --- a/crates/ra_ide/src/completion/complete_trait_impl.rs +++ b/crates/ra_ide/src/completion/complete_trait_impl.rs | |||
@@ -59,7 +59,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext | |||
59 | .as_ref() | 59 | .as_ref() |
60 | .and_then(|node| node.parent()) | 60 | .and_then(|node| node.parent()) |
61 | .and_then(|node| node.parent()) | 61 | .and_then(|node| node.parent()) |
62 | .and_then(|node| ast::ImplBlock::cast(node)); | 62 | .and_then(ast::ImplBlock::cast); |
63 | 63 | ||
64 | if let (Some(trigger), Some(impl_block)) = (trigger, impl_block) { | 64 | if let (Some(trigger), Some(impl_block)) = (trigger, impl_block) { |
65 | match trigger.kind() { | 65 | match trigger.kind() { |
@@ -110,17 +110,17 @@ fn add_function_impl( | |||
110 | ctx: &CompletionContext, | 110 | ctx: &CompletionContext, |
111 | func: &hir::Function, | 111 | func: &hir::Function, |
112 | ) { | 112 | ) { |
113 | let display = FunctionSignature::from_hir(ctx.db, func.clone()); | 113 | let display = FunctionSignature::from_hir(ctx.db, *func); |
114 | 114 | ||
115 | let fn_name = func.name(ctx.db).to_string(); | 115 | let fn_name = func.name(ctx.db).to_string(); |
116 | 116 | ||
117 | let label = if func.params(ctx.db).len() > 0 { | 117 | let label = if !func.params(ctx.db).is_empty() { |
118 | format!("fn {}(..)", fn_name) | 118 | format!("fn {}(..)", fn_name) |
119 | } else { | 119 | } else { |
120 | format!("fn {}()", fn_name) | 120 | format!("fn {}()", fn_name) |
121 | }; | 121 | }; |
122 | 122 | ||
123 | let builder = CompletionItem::new(CompletionKind::Magic, ctx.source_range(), label.clone()) | 123 | let builder = CompletionItem::new(CompletionKind::Magic, ctx.source_range(), label) |
124 | .lookup_by(fn_name) | 124 | .lookup_by(fn_name) |
125 | .set_documentation(func.docs(ctx.db)); | 125 | .set_documentation(func.docs(ctx.db)); |
126 | 126 | ||
diff --git a/crates/ra_ide/src/completion/completion_item.rs b/crates/ra_ide/src/completion/completion_item.rs index 93f336370..61867c0ff 100644 --- a/crates/ra_ide/src/completion/completion_item.rs +++ b/crates/ra_ide/src/completion/completion_item.rs | |||
@@ -159,7 +159,7 @@ impl CompletionItem { | |||
159 | 159 | ||
160 | /// Short one-line additional information, like a type | 160 | /// Short one-line additional information, like a type |
161 | pub fn detail(&self) -> Option<&str> { | 161 | pub fn detail(&self) -> Option<&str> { |
162 | self.detail.as_ref().map(|it| it.as_str()) | 162 | self.detail.as_deref() |
163 | } | 163 | } |
164 | /// A doc-comment | 164 | /// A doc-comment |
165 | pub fn documentation(&self) -> Option<Documentation> { | 165 | pub fn documentation(&self) -> Option<Documentation> { |
@@ -167,7 +167,7 @@ impl CompletionItem { | |||
167 | } | 167 | } |
168 | /// What string is used for filtering. | 168 | /// What string is used for filtering. |
169 | pub fn lookup(&self) -> &str { | 169 | pub fn lookup(&self) -> &str { |
170 | self.lookup.as_ref().map(|it| it.as_str()).unwrap_or_else(|| self.label()) | 170 | self.lookup.as_deref().unwrap_or_else(|| self.label()) |
171 | } | 171 | } |
172 | 172 | ||
173 | pub fn kind(&self) -> Option<CompletionItemKind> { | 173 | pub fn kind(&self) -> Option<CompletionItemKind> { |
diff --git a/crates/ra_ide/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs index c23e08e9a..b85fd8075 100644 --- a/crates/ra_ide/src/display/function_signature.rs +++ b/crates/ra_ide/src/display/function_signature.rs | |||
@@ -54,9 +54,8 @@ impl FunctionSignature { | |||
54 | 54 | ||
55 | pub(crate) fn from_struct(db: &RootDatabase, st: hir::Struct) -> Option<Self> { | 55 | pub(crate) fn from_struct(db: &RootDatabase, st: hir::Struct) -> Option<Self> { |
56 | let node: ast::StructDef = st.source(db).value; | 56 | let node: ast::StructDef = st.source(db).value; |
57 | match node.kind() { | 57 | if let ast::StructKind::Record(_) = node.kind() { |
58 | ast::StructKind::Record(_) => return None, | 58 | return None; |
59 | _ => (), | ||
60 | }; | 59 | }; |
61 | 60 | ||
62 | let params = st | 61 | let params = st |
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 906aab1eb..096c41c81 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs | |||
@@ -64,11 +64,11 @@ impl NavigationTarget { | |||
64 | } | 64 | } |
65 | 65 | ||
66 | pub fn docs(&self) -> Option<&str> { | 66 | pub fn docs(&self) -> Option<&str> { |
67 | self.docs.as_ref().map(String::as_str) | 67 | self.docs.as_deref() |
68 | } | 68 | } |
69 | 69 | ||
70 | pub fn description(&self) -> Option<&str> { | 70 | pub fn description(&self) -> Option<&str> { |
71 | self.description.as_ref().map(String::as_str) | 71 | self.description.as_deref() |
72 | } | 72 | } |
73 | 73 | ||
74 | /// A "most interesting" range withing the `full_range`. | 74 | /// A "most interesting" range withing the `full_range`. |
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index de924fad2..97c08ade5 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs | |||
@@ -268,7 +268,7 @@ fn decl_access( | |||
268 | }; | 268 | }; |
269 | 269 | ||
270 | let stmt = find_node_at_offset::<ast::LetStmt>(syntax, range.start())?; | 270 | let stmt = find_node_at_offset::<ast::LetStmt>(syntax, range.start())?; |
271 | if let Some(_) = stmt.initializer() { | 271 | if stmt.initializer().is_some() { |
272 | let pat = stmt.pat()?; | 272 | let pat = stmt.pat()?; |
273 | if let ast::Pat::BindPat(it) = pat { | 273 | if let ast::Pat::BindPat(it) = pat { |
274 | if it.name()?.text().as_str() == name { | 274 | if it.name()?.text().as_str() == name { |
diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs index 14eb0b8b2..902c29fc6 100644 --- a/crates/ra_ide/src/ssr.rs +++ b/crates/ra_ide/src/ssr.rs | |||
@@ -85,8 +85,11 @@ impl FromStr for SsrQuery { | |||
85 | fn from_str(query: &str) -> Result<SsrQuery, SsrError> { | 85 | fn from_str(query: &str) -> Result<SsrQuery, SsrError> { |
86 | let mut it = query.split("==>>"); | 86 | let mut it = query.split("==>>"); |
87 | let pattern = it.next().expect("at least empty string").trim(); | 87 | let pattern = it.next().expect("at least empty string").trim(); |
88 | let mut template = | 88 | let mut template = it |
89 | it.next().ok_or(SsrError("Cannot find delemiter `==>>`".into()))?.trim().to_string(); | 89 | .next() |
90 | .ok_or_else(|| SsrError("Cannot find delemiter `==>>`".into()))? | ||
91 | .trim() | ||
92 | .to_string(); | ||
90 | if it.next().is_some() { | 93 | if it.next().is_some() { |
91 | return Err(SsrError("More than one delimiter found".into())); | 94 | return Err(SsrError("More than one delimiter found".into())); |
92 | } | 95 | } |
@@ -131,11 +134,12 @@ fn traverse(node: &SyntaxNode, go: &mut impl FnMut(&SyntaxNode) -> bool) { | |||
131 | } | 134 | } |
132 | 135 | ||
133 | fn split_by_var(s: &str) -> Result<(&str, &str, &str), SsrError> { | 136 | fn split_by_var(s: &str) -> Result<(&str, &str, &str), SsrError> { |
134 | let end_of_name = s.find(":").ok_or(SsrError("Use $<name>:expr".into()))?; | 137 | let end_of_name = s.find(':').ok_or_else(|| SsrError("Use $<name>:expr".into()))?; |
135 | let name = &s[0..end_of_name]; | 138 | let name = &s[0..end_of_name]; |
136 | is_name(name)?; | 139 | is_name(name)?; |
137 | let type_begin = end_of_name + 1; | 140 | let type_begin = end_of_name + 1; |
138 | let type_length = s[type_begin..].find(|c| !char::is_ascii_alphanumeric(&c)).unwrap_or(s.len()); | 141 | let type_length = |
142 | s[type_begin..].find(|c| !char::is_ascii_alphanumeric(&c)).unwrap_or_else(|| s.len()); | ||
139 | let type_name = &s[type_begin..type_begin + type_length]; | 143 | let type_name = &s[type_begin..type_begin + type_length]; |
140 | Ok((name, type_name, &s[type_begin + type_length..])) | 144 | Ok((name, type_name, &s[type_begin + type_length..])) |
141 | } | 145 | } |
@@ -182,7 +186,7 @@ fn find(pattern: &SsrPattern, code: &SyntaxNode) -> SsrMatches { | |||
182 | pattern.text() == code.text() | 186 | pattern.text() == code.text() |
183 | } | 187 | } |
184 | (SyntaxElement::Node(ref pattern), SyntaxElement::Node(ref code)) => { | 188 | (SyntaxElement::Node(ref pattern), SyntaxElement::Node(ref code)) => { |
185 | if placeholders.iter().find(|&n| n.0.as_str() == pattern.text()).is_some() { | 189 | if placeholders.iter().any(|n| n.0.as_str() == pattern.text()) { |
186 | match_.binding.insert(Var(pattern.text().to_string()), code.clone()); | 190 | match_.binding.insert(Var(pattern.text().to_string()), code.clone()); |
187 | true | 191 | true |
188 | } else { | 192 | } else { |