Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide_completion/src/render/function.rs')
| -rw-r--r-- | crates/ide_completion/src/render/function.rs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs index f598b414a7..86dfbf7fc8 100644 --- a/crates/ide_completion/src/render/function.rs +++ b/crates/ide_completion/src/render/function.rs @@ -4,6 +4,7 @@ use either::Either; use hir::{AsAssocItem, HasSource, HirDisplay}; use ide_db::SymbolKind; use itertools::Itertools; +use stdx::format_to; use syntax::ast; use crate::{ @@ -122,14 +123,11 @@ impl<'a> FunctionRender<'a> { fn detail(&self) -> String { let ret_ty = self.func.ret_type(self.ctx.db()); - let ret = if ret_ty.is_unit() { - // Omit the return type if it is the unit type - String::new() - } else { - format!(" {}", self.ty_display()) - }; - - format!("fn({}){}", self.params_display(), ret) + let mut detail = format!("fn({})", self.params_display()); + if !ret_ty.is_unit() { + format_to!(detail, " -> {}", ret_ty.display(self.ctx.db())); + } + detail } fn params_display(&self) -> String { @@ -153,12 +151,6 @@ impl<'a> FunctionRender<'a> { } } - fn ty_display(&self) -> String { - let ret_ty = self.func.ret_type(self.ctx.db()); - - format!("-> {}", ret_ty.display(self.ctx.db())) - } - fn params(&self) -> Params { let ast_params = match self.ast_node.param_list() { Some(it) => it, |