diff options
author | Aleksey Kladov <[email protected]> | 2020-05-07 13:29:01 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-05-07 13:29:01 +0100 |
commit | 43cedecf68a6686b61fbd244b76c592726d1f211 (patch) | |
tree | bd8f5a835ae2dd0dd8c73261c8ef6f331ab4711e /crates/ra_ide | |
parent | 9cb55966fe0fee791072f275ac55b90b8ee13e32 (diff) |
Fix panic in FunctionSignature
Diffstat (limited to 'crates/ra_ide')
-rw-r--r-- | crates/ra_ide/src/display/function_signature.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/ra_ide/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs index db3907fe6..f16d42276 100644 --- a/crates/ra_ide/src/display/function_signature.rs +++ b/crates/ra_ide/src/display/function_signature.rs | |||
@@ -1,5 +1,7 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | // FIXME: this modules relies on strings and AST way too much, and it should be | ||
4 | // rewritten (matklad 2020-05-07) | ||
3 | use std::{ | 5 | use std::{ |
4 | convert::From, | 6 | convert::From, |
5 | fmt::{self, Display}, | 7 | fmt::{self, Display}, |
@@ -202,7 +204,11 @@ impl From<&'_ ast::FnDef> for FunctionSignature { | |||
202 | 204 | ||
203 | res.extend(param_list.params().map(|param| param.syntax().text().to_string())); | 205 | res.extend(param_list.params().map(|param| param.syntax().text().to_string())); |
204 | res_types.extend(param_list.params().map(|param| { | 206 | res_types.extend(param_list.params().map(|param| { |
205 | param.syntax().text().to_string().split(':').nth(1).unwrap()[1..].to_string() | 207 | let param_text = param.syntax().text().to_string(); |
208 | match param_text.split(':').nth(1) { | ||
209 | Some(it) => it[1..].to_string(), | ||
210 | None => param_text, | ||
211 | } | ||
206 | })); | 212 | })); |
207 | } | 213 | } |
208 | (has_self_param, res, res_types) | 214 | (has_self_param, res, res_types) |