2020-11-01 13:48:42 +03:00
|
|
|
//! Renderer for function calls.
|
|
|
|
|
2021-07-04 20:57:45 +04:30
|
|
|
use hir::{AsAssocItem, HasSource, HirDisplay};
|
2021-01-20 18:38:12 +01:00
|
|
|
use ide_db::SymbolKind;
|
2021-03-06 16:56:07 -08:00
|
|
|
use itertools::Itertools;
|
2021-07-31 15:46:03 +03:00
|
|
|
use syntax::ast;
|
2020-11-01 12:35:04 +03:00
|
|
|
|
|
|
|
use crate::{
|
2021-03-12 15:06:17 -08:00
|
|
|
item::{CompletionItem, CompletionItemKind, CompletionKind, CompletionRelevance, ImportEdit},
|
2021-03-15 19:26:59 -07:00
|
|
|
render::{
|
2021-03-22 21:18:34 -07:00
|
|
|
builder_ext::Params, compute_exact_name_match, compute_ref_match, compute_type_match,
|
2021-03-15 19:26:59 -07:00
|
|
|
RenderContext,
|
|
|
|
},
|
2020-11-01 12:35:04 +03:00
|
|
|
};
|
|
|
|
|
2021-07-21 19:50:28 +02:00
|
|
|
pub(crate) fn render_fn(
|
|
|
|
ctx: RenderContext<'_>,
|
2020-12-03 11:13:28 +02:00
|
|
|
import_to_add: Option<ImportEdit>,
|
2021-05-31 14:13:09 +02:00
|
|
|
local_name: Option<hir::Name>,
|
2020-11-03 10:33:13 +03:00
|
|
|
fn_: hir::Function,
|
2021-01-01 17:26:39 +11:00
|
|
|
) -> Option<CompletionItem> {
|
2020-11-27 18:00:03 +02:00
|
|
|
let _p = profile::span("render_fn");
|
2021-05-28 14:02:53 +02:00
|
|
|
Some(FunctionRender::new(ctx, None, local_name, fn_, false)?.render(import_to_add))
|
2021-03-21 17:30:56 -07:00
|
|
|
}
|
|
|
|
|
2021-07-21 19:50:28 +02:00
|
|
|
pub(crate) fn render_method(
|
|
|
|
ctx: RenderContext<'_>,
|
2021-03-21 17:30:56 -07:00
|
|
|
import_to_add: Option<ImportEdit>,
|
2021-05-28 14:38:09 +02:00
|
|
|
receiver: Option<hir::Name>,
|
2021-05-31 14:13:09 +02:00
|
|
|
local_name: Option<hir::Name>,
|
2021-03-21 17:30:56 -07:00
|
|
|
fn_: hir::Function,
|
|
|
|
) -> Option<CompletionItem> {
|
|
|
|
let _p = profile::span("render_method");
|
2021-05-28 14:02:53 +02:00
|
|
|
Some(FunctionRender::new(ctx, receiver, local_name, fn_, true)?.render(import_to_add))
|
2020-11-03 10:33:13 +03:00
|
|
|
}
|
|
|
|
|
2020-11-01 12:35:04 +03:00
|
|
|
#[derive(Debug)]
|
2020-11-03 10:33:13 +03:00
|
|
|
struct FunctionRender<'a> {
|
2020-11-01 12:35:04 +03:00
|
|
|
ctx: RenderContext<'a>,
|
|
|
|
name: String,
|
2021-05-28 14:38:09 +02:00
|
|
|
receiver: Option<hir::Name>,
|
2020-12-01 13:53:12 +03:00
|
|
|
func: hir::Function,
|
2021-07-31 15:46:03 +03:00
|
|
|
ast_node: ast::Fn,
|
2021-03-21 17:30:56 -07:00
|
|
|
is_method: bool,
|
2020-11-01 12:35:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> FunctionRender<'a> {
|
2020-11-03 10:33:13 +03:00
|
|
|
fn new(
|
2020-11-01 12:35:04 +03:00
|
|
|
ctx: RenderContext<'a>,
|
2021-05-28 14:38:09 +02:00
|
|
|
receiver: Option<hir::Name>,
|
2021-05-31 14:13:09 +02:00
|
|
|
local_name: Option<hir::Name>,
|
2020-11-01 12:35:04 +03:00
|
|
|
fn_: hir::Function,
|
2021-03-21 17:30:56 -07:00
|
|
|
is_method: bool,
|
2021-01-01 17:26:39 +11:00
|
|
|
) -> Option<FunctionRender<'a>> {
|
2021-05-31 14:13:09 +02:00
|
|
|
let name = local_name.unwrap_or_else(|| fn_.name(ctx.db())).to_string();
|
2021-01-01 17:26:39 +11:00
|
|
|
let ast_node = fn_.source(ctx.db())?.value;
|
2020-11-01 12:35:04 +03:00
|
|
|
|
2021-05-28 14:02:53 +02:00
|
|
|
Some(FunctionRender { ctx, name, receiver, func: fn_, ast_node, is_method })
|
2020-11-01 12:35:04 +03:00
|
|
|
}
|
|
|
|
|
2021-06-11 18:26:52 +02:00
|
|
|
fn render(self, import_to_add: Option<ImportEdit>) -> CompletionItem {
|
2020-11-01 12:35:04 +03:00
|
|
|
let params = self.params();
|
2021-06-11 18:26:52 +02:00
|
|
|
let call = if let Some(receiver) = &self.receiver {
|
|
|
|
format!("{}.{}", receiver, &self.name)
|
|
|
|
} else {
|
|
|
|
self.name.clone()
|
|
|
|
};
|
|
|
|
let mut item =
|
|
|
|
CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), call.clone());
|
2021-03-12 12:12:32 +03:00
|
|
|
item.kind(self.kind())
|
2020-12-01 13:53:12 +03:00
|
|
|
.set_documentation(self.ctx.docs(self.func))
|
2021-01-19 01:08:59 +02:00
|
|
|
.set_deprecated(
|
|
|
|
self.ctx.is_deprecated(self.func) || self.ctx.is_deprecated_assoc_item(self.func),
|
|
|
|
)
|
2020-11-01 12:35:04 +03:00
|
|
|
.detail(self.detail())
|
2021-07-04 00:59:47 +04:30
|
|
|
.add_call_parens(self.ctx.completion, call.clone(), params);
|
|
|
|
|
|
|
|
if import_to_add.is_none() {
|
|
|
|
let db = self.ctx.db();
|
|
|
|
if let Some(actm) = self.func.as_assoc_item(db) {
|
|
|
|
if let Some(trt) = actm.containing_trait_or_trait_impl(db) {
|
2021-07-04 20:57:45 +04:30
|
|
|
item.trait_name(trt.name(db).to_string());
|
2021-07-04 00:59:47 +04:30
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
item.add_import(import_to_add).lookup_by(self.name);
|
2021-03-11 17:46:41 +02:00
|
|
|
|
2021-03-15 19:26:59 -07:00
|
|
|
let ret_type = self.func.ret_type(self.ctx.db());
|
|
|
|
item.set_relevance(CompletionRelevance {
|
2021-03-22 21:18:34 -07:00
|
|
|
type_match: compute_type_match(self.ctx.completion, &ret_type),
|
2021-06-11 18:26:52 +02:00
|
|
|
exact_name_match: compute_exact_name_match(self.ctx.completion, &call),
|
2021-03-15 19:26:59 -07:00
|
|
|
..CompletionRelevance::default()
|
|
|
|
});
|
2021-03-12 15:06:17 -08:00
|
|
|
|
2021-03-15 19:26:59 -07:00
|
|
|
if let Some(ref_match) = compute_ref_match(self.ctx.completion, &ret_type) {
|
2021-03-21 17:30:56 -07:00
|
|
|
// FIXME
|
|
|
|
// For now we don't properly calculate the edits for ref match
|
|
|
|
// completions on methods, so we've disabled them. See #8058.
|
|
|
|
if !self.is_method {
|
|
|
|
item.ref_match(ref_match);
|
|
|
|
}
|
2021-03-12 15:06:17 -08:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:12:32 +03:00
|
|
|
item.build()
|
2020-11-01 12:35:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn detail(&self) -> String {
|
2021-03-12 13:46:40 -08:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn params_display(&self) -> String {
|
|
|
|
if let Some(self_param) = self.func.self_param(self.ctx.db()) {
|
2021-03-06 16:56:07 -08:00
|
|
|
let params = self
|
|
|
|
.func
|
|
|
|
.assoc_fn_params(self.ctx.db())
|
|
|
|
.into_iter()
|
|
|
|
.skip(1) // skip the self param because we are manually handling that
|
|
|
|
.map(|p| p.ty().display(self.ctx.db()).to_string());
|
|
|
|
|
|
|
|
std::iter::once(self_param.display(self.ctx.db()).to_owned()).chain(params).join(", ")
|
|
|
|
} else {
|
|
|
|
let params = self
|
|
|
|
.func
|
|
|
|
.assoc_fn_params(self.ctx.db())
|
|
|
|
.into_iter()
|
|
|
|
.map(|p| p.ty().display(self.ctx.db()).to_string())
|
|
|
|
.join(", ");
|
|
|
|
params
|
2021-03-12 13:46:40 -08:00
|
|
|
}
|
|
|
|
}
|
2021-03-06 16:56:07 -08:00
|
|
|
|
2021-03-12 13:46:40 -08:00
|
|
|
fn ty_display(&self) -> String {
|
2021-03-06 16:56:07 -08:00
|
|
|
let ret_ty = self.func.ret_type(self.ctx.db());
|
|
|
|
|
2021-03-12 13:46:40 -08:00
|
|
|
format!("-> {}", ret_ty.display(self.ctx.db()))
|
2020-11-01 12:35:04 +03:00
|
|
|
}
|
|
|
|
|
2021-05-31 14:13:09 +02:00
|
|
|
fn add_arg(&self, arg: &str, ty: &hir::Type) -> String {
|
2020-11-01 12:35:04 +03:00
|
|
|
if let Some(derefed_ty) = ty.remove_ref() {
|
|
|
|
for (name, local) in self.ctx.completion.locals.iter() {
|
|
|
|
if name == arg && local.ty(self.ctx.db()) == derefed_ty {
|
2020-11-01 12:59:43 +03:00
|
|
|
let mutability = if ty.is_mutable_reference() { "&mut " } else { "&" };
|
|
|
|
return format!("{}{}", mutability, arg);
|
2020-11-01 12:35:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
arg.to_string()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn params(&self) -> Params {
|
2020-12-01 14:23:00 +03:00
|
|
|
let ast_params = match self.ast_node.param_list() {
|
|
|
|
Some(it) => it,
|
|
|
|
None => return Params::Named(Vec::new()),
|
|
|
|
};
|
|
|
|
|
|
|
|
let mut params_pats = Vec::new();
|
2021-06-02 15:21:18 +02:00
|
|
|
let params_ty = if self.ctx.completion.has_dot_receiver() || self.receiver.is_some() {
|
2020-12-01 13:53:12 +03:00
|
|
|
self.func.method_params(self.ctx.db()).unwrap_or_default()
|
|
|
|
} else {
|
2020-12-01 14:23:00 +03:00
|
|
|
if let Some(s) = ast_params.self_param() {
|
2021-03-08 22:19:44 +02:00
|
|
|
cov_mark::hit!(parens_for_method_call_as_assoc_fn);
|
2020-12-01 14:23:00 +03:00
|
|
|
params_pats.push(Some(s.to_string()));
|
|
|
|
}
|
2020-12-01 13:53:12 +03:00
|
|
|
self.func.assoc_fn_params(self.ctx.db())
|
|
|
|
};
|
2020-12-01 14:23:00 +03:00
|
|
|
params_pats
|
|
|
|
.extend(ast_params.params().into_iter().map(|it| it.pat().map(|it| it.to_string())));
|
|
|
|
|
|
|
|
let params = params_pats
|
2020-11-01 12:35:04 +03:00
|
|
|
.into_iter()
|
|
|
|
.zip(params_ty)
|
2020-12-01 14:23:00 +03:00
|
|
|
.flat_map(|(pat, param_ty)| {
|
|
|
|
let pat = pat?;
|
2020-12-12 12:27:09 -05:00
|
|
|
let name = pat;
|
2020-12-01 14:23:00 +03:00
|
|
|
let arg = name.trim_start_matches("mut ").trim_start_matches('_');
|
|
|
|
Some(self.add_arg(arg, param_ty.ty()))
|
2020-11-01 12:35:04 +03:00
|
|
|
})
|
|
|
|
.collect();
|
|
|
|
Params::Named(params)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn kind(&self) -> CompletionItemKind {
|
2020-12-01 13:53:12 +03:00
|
|
|
if self.func.self_param(self.ctx.db()).is_some() {
|
2020-11-01 12:35:04 +03:00
|
|
|
CompletionItemKind::Method
|
|
|
|
} else {
|
2021-01-20 18:38:12 +01:00
|
|
|
SymbolKind::Function.into()
|
2020-11-01 12:35:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-01 13:36:30 +03:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use crate::{
|
2021-06-16 21:45:02 +02:00
|
|
|
tests::{check_edit, check_edit_with_config, TEST_CONFIG},
|
2020-11-01 13:36:30 +03:00
|
|
|
CompletionConfig,
|
|
|
|
};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn inserts_parens_for_function_calls() {
|
2021-03-08 22:19:44 +02:00
|
|
|
cov_mark::check!(inserts_parens_for_function_calls);
|
2020-11-01 13:36:30 +03:00
|
|
|
check_edit(
|
|
|
|
"no_args",
|
|
|
|
r#"
|
|
|
|
fn no_args() {}
|
2021-01-06 20:15:48 +00:00
|
|
|
fn main() { no_$0 }
|
2020-11-01 13:36:30 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
fn no_args() {}
|
|
|
|
fn main() { no_args()$0 }
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
|
|
|
|
check_edit(
|
|
|
|
"with_args",
|
|
|
|
r#"
|
|
|
|
fn with_args(x: i32, y: String) {}
|
2021-01-06 20:15:48 +00:00
|
|
|
fn main() { with_$0 }
|
2020-11-01 13:36:30 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
fn with_args(x: i32, y: String) {}
|
|
|
|
fn main() { with_args(${1:x}, ${2:y})$0 }
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
|
|
|
|
check_edit(
|
|
|
|
"foo",
|
|
|
|
r#"
|
|
|
|
struct S;
|
|
|
|
impl S {
|
|
|
|
fn foo(&self) {}
|
|
|
|
}
|
2021-01-06 20:15:48 +00:00
|
|
|
fn bar(s: &S) { s.f$0 }
|
2020-11-01 13:36:30 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
struct S;
|
|
|
|
impl S {
|
|
|
|
fn foo(&self) {}
|
|
|
|
}
|
|
|
|
fn bar(s: &S) { s.foo()$0 }
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
|
|
|
|
check_edit(
|
|
|
|
"foo",
|
|
|
|
r#"
|
|
|
|
struct S {}
|
|
|
|
impl S {
|
|
|
|
fn foo(&self, x: i32) {}
|
|
|
|
}
|
|
|
|
fn bar(s: &S) {
|
2021-01-06 20:15:48 +00:00
|
|
|
s.f$0
|
2020-11-01 13:36:30 +03:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
struct S {}
|
|
|
|
impl S {
|
|
|
|
fn foo(&self, x: i32) {}
|
|
|
|
}
|
|
|
|
fn bar(s: &S) {
|
|
|
|
s.foo(${1:x})$0
|
|
|
|
}
|
2021-05-28 14:02:53 +02:00
|
|
|
"#,
|
|
|
|
);
|
|
|
|
|
|
|
|
check_edit(
|
2021-06-11 18:26:52 +02:00
|
|
|
"foo",
|
2021-05-28 14:02:53 +02:00
|
|
|
r#"
|
|
|
|
struct S {}
|
|
|
|
impl S {
|
|
|
|
fn foo(&self, x: i32) {
|
|
|
|
$0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
struct S {}
|
|
|
|
impl S {
|
|
|
|
fn foo(&self, x: i32) {
|
|
|
|
self.foo(${1:x})$0
|
|
|
|
}
|
|
|
|
}
|
2020-11-01 13:36:30 +03:00
|
|
|
"#,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-12-01 14:23:00 +03:00
|
|
|
#[test]
|
|
|
|
fn parens_for_method_call_as_assoc_fn() {
|
2021-03-08 22:19:44 +02:00
|
|
|
cov_mark::check!(parens_for_method_call_as_assoc_fn);
|
2020-12-01 14:23:00 +03:00
|
|
|
check_edit(
|
|
|
|
"foo",
|
|
|
|
r#"
|
|
|
|
struct S;
|
|
|
|
impl S {
|
|
|
|
fn foo(&self) {}
|
|
|
|
}
|
2021-01-06 20:15:48 +00:00
|
|
|
fn main() { S::f$0 }
|
2020-12-01 14:23:00 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
struct S;
|
|
|
|
impl S {
|
|
|
|
fn foo(&self) {}
|
|
|
|
}
|
|
|
|
fn main() { S::foo(${1:&self})$0 }
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-11-01 13:36:30 +03:00
|
|
|
#[test]
|
|
|
|
fn suppress_arg_snippets() {
|
2021-03-08 22:19:44 +02:00
|
|
|
cov_mark::check!(suppress_arg_snippets);
|
2020-11-01 13:36:30 +03:00
|
|
|
check_edit_with_config(
|
2021-01-06 20:43:46 +03:00
|
|
|
CompletionConfig { add_call_argument_snippets: false, ..TEST_CONFIG },
|
2020-11-01 13:36:30 +03:00
|
|
|
"with_args",
|
|
|
|
r#"
|
|
|
|
fn with_args(x: i32, y: String) {}
|
2021-01-06 20:15:48 +00:00
|
|
|
fn main() { with_$0 }
|
2020-11-01 13:36:30 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
fn with_args(x: i32, y: String) {}
|
|
|
|
fn main() { with_args($0) }
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn strips_underscores_from_args() {
|
|
|
|
check_edit(
|
|
|
|
"foo",
|
|
|
|
r#"
|
|
|
|
fn foo(_foo: i32, ___bar: bool, ho_ge_: String) {}
|
2021-01-06 20:15:48 +00:00
|
|
|
fn main() { f$0 }
|
2020-11-01 13:36:30 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
fn foo(_foo: i32, ___bar: bool, ho_ge_: String) {}
|
|
|
|
fn main() { foo(${1:foo}, ${2:bar}, ${3:ho_ge_})$0 }
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn insert_ref_when_matching_local_in_scope() {
|
|
|
|
check_edit(
|
|
|
|
"ref_arg",
|
|
|
|
r#"
|
|
|
|
struct Foo {}
|
|
|
|
fn ref_arg(x: &Foo) {}
|
|
|
|
fn main() {
|
|
|
|
let x = Foo {};
|
2021-01-06 20:15:48 +00:00
|
|
|
ref_ar$0
|
2020-11-01 13:36:30 +03:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
struct Foo {}
|
|
|
|
fn ref_arg(x: &Foo) {}
|
|
|
|
fn main() {
|
|
|
|
let x = Foo {};
|
|
|
|
ref_arg(${1:&x})$0
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn insert_mut_ref_when_matching_local_in_scope() {
|
|
|
|
check_edit(
|
|
|
|
"ref_arg",
|
|
|
|
r#"
|
|
|
|
struct Foo {}
|
|
|
|
fn ref_arg(x: &mut Foo) {}
|
|
|
|
fn main() {
|
|
|
|
let x = Foo {};
|
2021-01-06 20:15:48 +00:00
|
|
|
ref_ar$0
|
2020-11-01 13:36:30 +03:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
struct Foo {}
|
|
|
|
fn ref_arg(x: &mut Foo) {}
|
|
|
|
fn main() {
|
|
|
|
let x = Foo {};
|
|
|
|
ref_arg(${1:&mut x})$0
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn insert_ref_when_matching_local_in_scope_for_method() {
|
|
|
|
check_edit(
|
|
|
|
"apply_foo",
|
|
|
|
r#"
|
|
|
|
struct Foo {}
|
|
|
|
struct Bar {}
|
|
|
|
impl Bar {
|
|
|
|
fn apply_foo(&self, x: &Foo) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = Foo {};
|
|
|
|
let y = Bar {};
|
2021-01-06 20:15:48 +00:00
|
|
|
y.$0
|
2020-11-01 13:36:30 +03:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
struct Foo {}
|
|
|
|
struct Bar {}
|
|
|
|
impl Bar {
|
|
|
|
fn apply_foo(&self, x: &Foo) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = Foo {};
|
|
|
|
let y = Bar {};
|
|
|
|
y.apply_foo(${1:&x})$0
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn trim_mut_keyword_in_func_completion() {
|
|
|
|
check_edit(
|
|
|
|
"take_mutably",
|
|
|
|
r#"
|
|
|
|
fn take_mutably(mut x: &i32) {}
|
|
|
|
|
|
|
|
fn main() {
|
2021-01-06 20:15:48 +00:00
|
|
|
take_m$0
|
2020-11-01 13:36:30 +03:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
fn take_mutably(mut x: &i32) {}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
take_mutably(${1:x})$0
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|