]> git.lizzy.rs Git - rust.git/commitdiff
Fix panic in FunctionSignature
authorAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 7 May 2020 12:29:01 +0000 (14:29 +0200)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 7 May 2020 12:29:01 +0000 (14:29 +0200)
crates/ra_ide/src/display/function_signature.rs

index db3907fe64e13afe8194abb13e1a209fda488b8f..f16d42276482f3e0ba181655d43f6206fa58f3ba 100644 (file)
@@ -1,5 +1,7 @@
 //! FIXME: write short doc here
 
+// FIXME: this modules relies on strings and AST way too much, and it should be
+// rewritten (matklad 2020-05-07)
 use std::{
     convert::From,
     fmt::{self, Display},
@@ -202,7 +204,11 @@ fn param_list(node: &ast::FnDef) -> (bool, Vec<String>, Vec<String>) {
 
                 res.extend(param_list.params().map(|param| param.syntax().text().to_string()));
                 res_types.extend(param_list.params().map(|param| {
-                    param.syntax().text().to_string().split(':').nth(1).unwrap()[1..].to_string()
+                    let param_text = param.syntax().text().to_string();
+                    match param_text.split(':').nth(1) {
+                        Some(it) => it[1..].to_string(),
+                        None => param_text,
+                    }
                 }));
             }
             (has_self_param, res, res_types)