mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Only complete type annotations for patterns in function params
This commit is contained in:
parent
d07f4e4c35
commit
bf918046fa
5 changed files with 67 additions and 19 deletions
|
@ -4,7 +4,10 @@ use hir::{db::HirDatabase, HasAttrs, HasVisibility, Name, StructKind};
|
|||
use ide_db::helpers::SnippetCap;
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::{item::CompletionKind, render::RenderContext, CompletionItem, CompletionItemKind};
|
||||
use crate::{
|
||||
context::ParamKind, item::CompletionKind, render::RenderContext, CompletionItem,
|
||||
CompletionItemKind,
|
||||
};
|
||||
|
||||
pub(crate) fn render_struct_pat(
|
||||
ctx: RenderContext<'_>,
|
||||
|
@ -83,7 +86,7 @@ fn render_pat(
|
|||
_ => return None,
|
||||
};
|
||||
|
||||
if ctx.completion.is_param {
|
||||
if ctx.completion.is_param == Some(ParamKind::Function) {
|
||||
pat.push(':');
|
||||
pat.push(' ');
|
||||
pat.push_str(name);
|
||||
|
|
|
@ -58,11 +58,6 @@ fn render_literal(
|
|||
_ => return None,
|
||||
};
|
||||
|
||||
if ctx.completion.is_param {
|
||||
literal.push(':');
|
||||
literal.push(' ');
|
||||
literal.push_str(name);
|
||||
}
|
||||
if ctx.snippet_cap().is_some() {
|
||||
literal.push_str("$0");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue