4359: Fix panic in FunctionSignature r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-05-07 12:32:21 +00:00 committed by GitHub
commit f4cd75ac06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,7 @@
//! FIXME: write short doc here //! 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::{ use std::{
convert::From, convert::From,
fmt::{self, Display}, 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.extend(param_list.params().map(|param| param.syntax().text().to_string()));
res_types.extend(param_list.params().map(|param| { 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) (has_self_param, res, res_types)