From 43cedecf68a6686b61fbd244b76c592726d1f211 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 7 May 2020 14:29:01 +0200 Subject: Fix panic in FunctionSignature --- crates/ra_ide/src/display/function_signature.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide') 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 @@ //! 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 @@ impl From<&'_ ast::FnDef> for FunctionSignature { 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) -- cgit v1.2.3