mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Inline all format arguments where possible
This makes code more readale and concise, moving all format arguments like `format!("{}", foo)` into the more compact `format!("{foo}")` form. The change was automatically created with, so there are far less change of an accidental typo. ``` cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args ```
This commit is contained in:
parent
1927c2e1d8
commit
e16c76e3c3
180 changed files with 487 additions and 501 deletions
|
@ -133,7 +133,7 @@ impl Completions {
|
|||
if incomplete_let && snippet.ends_with('}') {
|
||||
// complete block expression snippets with a trailing semicolon, if inside an incomplete let
|
||||
cov_mark::hit!(let_semi);
|
||||
item.insert_snippet(cap, format!("{};", snippet));
|
||||
item.insert_snippet(cap, format!("{snippet};"));
|
||||
} else {
|
||||
item.insert_snippet(cap, snippet);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::{completions::Completions, context::CompletionContext, CompletionItem
|
|||
pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext<'_>) {
|
||||
let add_completion = |item: &str| {
|
||||
let mut completion = CompletionItem::new(SymbolKind::BuiltinAttr, ctx.source_range(), item);
|
||||
completion.insert_text(format!(r#""{}""#, item));
|
||||
completion.insert_text(format!(r#""{item}""#));
|
||||
acc.add(completion.build());
|
||||
};
|
||||
|
||||
|
@ -29,7 +29,7 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext<'_>) {
|
|||
Some("target_vendor") => KNOWN_VENDOR.iter().copied().for_each(add_completion),
|
||||
Some("target_endian") => ["little", "big"].into_iter().for_each(add_completion),
|
||||
Some(name) => ctx.krate.potential_cfg(ctx.db).get_cfg_values(name).cloned().for_each(|s| {
|
||||
let insert_text = format!(r#""{}""#, s);
|
||||
let insert_text = format!(r#""{s}""#);
|
||||
let mut item = CompletionItem::new(SymbolKind::BuiltinAttr, ctx.source_range(), s);
|
||||
item.insert_text(insert_text);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ pub(super) fn complete_lint(
|
|||
continue;
|
||||
}
|
||||
let label = match qual {
|
||||
Some(qual) if !is_qualified => format!("{}::{}", qual, name),
|
||||
Some(qual) if !is_qualified => format!("{qual}::{name}"),
|
||||
_ => name.to_owned(),
|
||||
};
|
||||
let mut item = CompletionItem::new(SymbolKind::Attribute, ctx.source_range(), label);
|
||||
|
|
|
@ -112,7 +112,7 @@ mod tests {
|
|||
"#;
|
||||
|
||||
let completions = completion_list(fixture);
|
||||
assert!(completions.is_empty(), "Completions weren't empty: {}", completions);
|
||||
assert!(completions.is_empty(), "Completions weren't empty: {completions}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -129,7 +129,7 @@ mod tests {
|
|||
"#;
|
||||
|
||||
let completions = completion_list(fixture);
|
||||
assert!(completions.is_empty(), "Completions weren't empty: {}", completions);
|
||||
assert!(completions.is_empty(), "Completions weren't empty: {completions}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -145,6 +145,6 @@ mod tests {
|
|||
"#;
|
||||
|
||||
let completions = completion_list(fixture);
|
||||
assert!(completions.is_empty(), "Completions weren't empty: {}", completions)
|
||||
assert!(completions.is_empty(), "Completions weren't empty: {completions}")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,5 +192,5 @@ fn comma_wrapper(ctx: &CompletionContext<'_>) -> Option<(impl Fn(&str) -> String
|
|||
matches!(prev_token_kind, SyntaxKind::COMMA | SyntaxKind::L_PAREN | SyntaxKind::PIPE);
|
||||
let leading = if has_leading_comma { "" } else { ", " };
|
||||
|
||||
Some((move |label: &_| (format!("{}{}{}", leading, label, trailing)), param.text_range()))
|
||||
Some((move |label: &_| (format!("{leading}{label}{trailing}")), param.text_range()))
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ fn add_function_impl(
|
|||
};
|
||||
|
||||
let mut item = CompletionItem::new(completion_kind, replacement_range, label);
|
||||
item.lookup_by(format!("fn {}", fn_name))
|
||||
item.lookup_by(format!("fn {fn_name}"))
|
||||
.set_documentation(func.docs(ctx.db))
|
||||
.set_relevance(CompletionRelevance { is_item_from_trait: true, ..Default::default() });
|
||||
|
||||
|
@ -205,11 +205,11 @@ fn add_function_impl(
|
|||
let function_decl = function_declaration(&transformed_fn, source.file_id.is_macro());
|
||||
match ctx.config.snippet_cap {
|
||||
Some(cap) => {
|
||||
let snippet = format!("{} {{\n $0\n}}", function_decl);
|
||||
let snippet = format!("{function_decl} {{\n $0\n}}");
|
||||
item.snippet_edit(cap, TextEdit::replace(replacement_range, snippet));
|
||||
}
|
||||
None => {
|
||||
let header = format!("{} {{", function_decl);
|
||||
let header = format!("{function_decl} {{");
|
||||
item.text_edit(TextEdit::replace(replacement_range, header));
|
||||
}
|
||||
};
|
||||
|
@ -249,10 +249,10 @@ fn add_type_alias_impl(
|
|||
) {
|
||||
let alias_name = type_alias.name(ctx.db).unescaped().to_smol_str();
|
||||
|
||||
let label = format!("type {} =", alias_name);
|
||||
let label = format!("type {alias_name} =");
|
||||
|
||||
let mut item = CompletionItem::new(SymbolKind::TypeAlias, replacement_range, label);
|
||||
item.lookup_by(format!("type {}", alias_name))
|
||||
item.lookup_by(format!("type {alias_name}"))
|
||||
.set_documentation(type_alias.docs(ctx.db))
|
||||
.set_relevance(CompletionRelevance { is_item_from_trait: true, ..Default::default() });
|
||||
|
||||
|
@ -290,7 +290,7 @@ fn add_type_alias_impl(
|
|||
|
||||
match ctx.config.snippet_cap {
|
||||
Some(cap) => {
|
||||
let snippet = format!("{}$0;", decl);
|
||||
let snippet = format!("{decl}$0;");
|
||||
item.snippet_edit(cap, TextEdit::replace(replacement_range, snippet));
|
||||
}
|
||||
None => {
|
||||
|
@ -321,10 +321,10 @@ fn add_const_impl(
|
|||
};
|
||||
|
||||
let label = make_const_compl_syntax(&transformed_const, source.file_id.is_macro());
|
||||
let replacement = format!("{} ", label);
|
||||
let replacement = format!("{label} ");
|
||||
|
||||
let mut item = CompletionItem::new(SymbolKind::Const, replacement_range, label);
|
||||
item.lookup_by(format!("const {}", const_name))
|
||||
item.lookup_by(format!("const {const_name}"))
|
||||
.set_documentation(const_.docs(ctx.db))
|
||||
.set_relevance(CompletionRelevance {
|
||||
is_item_from_trait: true,
|
||||
|
@ -333,7 +333,7 @@ fn add_const_impl(
|
|||
match ctx.config.snippet_cap {
|
||||
Some(cap) => item.snippet_edit(
|
||||
cap,
|
||||
TextEdit::replace(replacement_range, format!("{}$0;", replacement)),
|
||||
TextEdit::replace(replacement_range, format!("{replacement}$0;")),
|
||||
),
|
||||
None => item.text_edit(TextEdit::replace(replacement_range, replacement)),
|
||||
};
|
||||
|
|
|
@ -61,7 +61,7 @@ pub(crate) fn complete_postfix(
|
|||
let mut item = postfix_snippet(
|
||||
"drop",
|
||||
"fn drop(&mut self)",
|
||||
&format!("drop($0{})", receiver_text),
|
||||
&format!("drop($0{receiver_text})"),
|
||||
);
|
||||
item.set_documentation(drop_fn.docs(ctx.db));
|
||||
item.add_to(acc);
|
||||
|
@ -76,14 +76,14 @@ pub(crate) fn complete_postfix(
|
|||
postfix_snippet(
|
||||
"ifl",
|
||||
"if let Ok {}",
|
||||
&format!("if let Ok($1) = {} {{\n $0\n}}", receiver_text),
|
||||
&format!("if let Ok($1) = {receiver_text} {{\n $0\n}}"),
|
||||
)
|
||||
.add_to(acc);
|
||||
|
||||
postfix_snippet(
|
||||
"while",
|
||||
"while let Ok {}",
|
||||
&format!("while let Ok($1) = {} {{\n $0\n}}", receiver_text),
|
||||
&format!("while let Ok($1) = {receiver_text} {{\n $0\n}}"),
|
||||
)
|
||||
.add_to(acc);
|
||||
}
|
||||
|
@ -91,41 +91,37 @@ pub(crate) fn complete_postfix(
|
|||
postfix_snippet(
|
||||
"ifl",
|
||||
"if let Some {}",
|
||||
&format!("if let Some($1) = {} {{\n $0\n}}", receiver_text),
|
||||
&format!("if let Some($1) = {receiver_text} {{\n $0\n}}"),
|
||||
)
|
||||
.add_to(acc);
|
||||
|
||||
postfix_snippet(
|
||||
"while",
|
||||
"while let Some {}",
|
||||
&format!("while let Some($1) = {} {{\n $0\n}}", receiver_text),
|
||||
&format!("while let Some($1) = {receiver_text} {{\n $0\n}}"),
|
||||
)
|
||||
.add_to(acc);
|
||||
}
|
||||
}
|
||||
} else if receiver_ty.is_bool() || receiver_ty.is_unknown() {
|
||||
postfix_snippet("if", "if expr {}", &format!("if {} {{\n $0\n}}", receiver_text))
|
||||
postfix_snippet("if", "if expr {}", &format!("if {receiver_text} {{\n $0\n}}"))
|
||||
.add_to(acc);
|
||||
postfix_snippet(
|
||||
"while",
|
||||
"while expr {}",
|
||||
&format!("while {} {{\n $0\n}}", receiver_text),
|
||||
)
|
||||
.add_to(acc);
|
||||
postfix_snippet("not", "!expr", &format!("!{}", receiver_text)).add_to(acc);
|
||||
postfix_snippet("while", "while expr {}", &format!("while {receiver_text} {{\n $0\n}}"))
|
||||
.add_to(acc);
|
||||
postfix_snippet("not", "!expr", &format!("!{receiver_text}")).add_to(acc);
|
||||
} else if let Some(trait_) = ctx.famous_defs().core_iter_IntoIterator() {
|
||||
if receiver_ty.impls_trait(ctx.db, trait_, &[]) {
|
||||
postfix_snippet(
|
||||
"for",
|
||||
"for ele in expr {}",
|
||||
&format!("for ele in {} {{\n $0\n}}", receiver_text),
|
||||
&format!("for ele in {receiver_text} {{\n $0\n}}"),
|
||||
)
|
||||
.add_to(acc);
|
||||
}
|
||||
}
|
||||
|
||||
postfix_snippet("ref", "&expr", &format!("&{}", receiver_text)).add_to(acc);
|
||||
postfix_snippet("refm", "&mut expr", &format!("&mut {}", receiver_text)).add_to(acc);
|
||||
postfix_snippet("ref", "&expr", &format!("&{receiver_text}")).add_to(acc);
|
||||
postfix_snippet("refm", "&mut expr", &format!("&mut {receiver_text}")).add_to(acc);
|
||||
|
||||
// The rest of the postfix completions create an expression that moves an argument,
|
||||
// so it's better to consider references now to avoid breaking the compilation
|
||||
|
@ -148,7 +144,7 @@ pub(crate) fn complete_postfix(
|
|||
postfix_snippet(
|
||||
"match",
|
||||
"match expr {}",
|
||||
&format!("match {} {{\n Ok(${{1:_}}) => {{$2}},\n Err(${{3:_}}) => {{$0}},\n}}", receiver_text),
|
||||
&format!("match {receiver_text} {{\n Ok(${{1:_}}) => {{$2}},\n Err(${{3:_}}) => {{$0}},\n}}"),
|
||||
)
|
||||
.add_to(acc);
|
||||
}
|
||||
|
@ -168,21 +164,21 @@ pub(crate) fn complete_postfix(
|
|||
postfix_snippet(
|
||||
"match",
|
||||
"match expr {}",
|
||||
&format!("match {} {{\n ${{1:_}} => {{$0}},\n}}", receiver_text),
|
||||
&format!("match {receiver_text} {{\n ${{1:_}} => {{$0}},\n}}"),
|
||||
)
|
||||
.add_to(acc);
|
||||
}
|
||||
}
|
||||
|
||||
postfix_snippet("box", "Box::new(expr)", &format!("Box::new({})", receiver_text)).add_to(acc);
|
||||
postfix_snippet("dbg", "dbg!(expr)", &format!("dbg!({})", receiver_text)).add_to(acc); // fixme
|
||||
postfix_snippet("dbgr", "dbg!(&expr)", &format!("dbg!(&{})", receiver_text)).add_to(acc);
|
||||
postfix_snippet("call", "function(expr)", &format!("${{1}}({})", receiver_text)).add_to(acc);
|
||||
postfix_snippet("box", "Box::new(expr)", &format!("Box::new({receiver_text})")).add_to(acc);
|
||||
postfix_snippet("dbg", "dbg!(expr)", &format!("dbg!({receiver_text})")).add_to(acc); // fixme
|
||||
postfix_snippet("dbgr", "dbg!(&expr)", &format!("dbg!(&{receiver_text})")).add_to(acc);
|
||||
postfix_snippet("call", "function(expr)", &format!("${{1}}({receiver_text})")).add_to(acc);
|
||||
|
||||
if let Some(parent) = dot_receiver.syntax().parent().and_then(|p| p.parent()) {
|
||||
if matches!(parent.kind(), STMT_LIST | EXPR_STMT) {
|
||||
postfix_snippet("let", "let", &format!("let $0 = {};", receiver_text)).add_to(acc);
|
||||
postfix_snippet("letm", "let mut", &format!("let mut $0 = {};", receiver_text))
|
||||
postfix_snippet("let", "let", &format!("let $0 = {receiver_text};")).add_to(acc);
|
||||
postfix_snippet("letm", "let mut", &format!("let mut $0 = {receiver_text};"))
|
||||
.add_to(acc);
|
||||
}
|
||||
}
|
||||
|
@ -300,7 +296,7 @@ fn add_custom_postfix_completions(
|
|||
let body = snippet.postfix_snippet(receiver_text);
|
||||
let mut builder =
|
||||
postfix_snippet(trigger, snippet.description.as_deref().unwrap_or_default(), &body);
|
||||
builder.documentation(Documentation::new(format!("```rust\n{}\n```", body)));
|
||||
builder.documentation(Documentation::new(format!("```rust\n{body}\n```")));
|
||||
for import in imports.into_iter() {
|
||||
builder.add_import(import);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ pub(crate) fn add_format_like_completions(
|
|||
if let Ok((out, exprs)) = parse_format_exprs(receiver_text.text()) {
|
||||
let exprs = with_placeholders(exprs);
|
||||
for (label, macro_name) in KINDS {
|
||||
let snippet = format!(r#"{}({}, {})"#, macro_name, out, exprs.join(", "));
|
||||
let snippet = format!(r#"{macro_name}({out}, {})"#, exprs.join(", "));
|
||||
|
||||
postfix_snippet(label, macro_name, &snippet).add_to(acc);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ mod tests {
|
|||
for (kind, input, output) in test_vector {
|
||||
let (parsed_string, exprs) = parse_format_exprs(input).unwrap();
|
||||
let exprs = with_placeholders(exprs);
|
||||
let snippet = format!(r#"{}("{}", {})"#, kind, parsed_string, exprs.join(", "));
|
||||
let snippet = format!(r#"{kind}("{parsed_string}", {})"#, exprs.join(", "));
|
||||
assert_eq!(&snippet, output);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ fn add_custom_completions(
|
|||
};
|
||||
let body = snip.snippet();
|
||||
let mut builder = snippet(ctx, cap, trigger, &body);
|
||||
builder.documentation(Documentation::new(format!("```rust\n{}\n```", body)));
|
||||
builder.documentation(Documentation::new(format!("```rust\n{body}\n```")));
|
||||
for import in imports.into_iter() {
|
||||
builder.add_import(import);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ fn check_expected_type_and_name(ra_fixture: &str, expect: Expect) {
|
|||
let name =
|
||||
completion_context.expected_name.map_or_else(|| "?".to_owned(), |name| name.to_string());
|
||||
|
||||
expect.assert_eq(&format!("ty: {}, name: {}", ty, name));
|
||||
expect.assert_eq(&format!("ty: {ty}, name: {name}"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -453,10 +453,10 @@ impl Builder {
|
|||
// snippets can have multiple imports, but normal completions only have up to one
|
||||
if let Some(original_path) = import_edit.original_path.as_ref() {
|
||||
lookup = lookup.or_else(|| Some(label.clone()));
|
||||
label = SmolStr::from(format!("{} (use {})", label, original_path));
|
||||
label = SmolStr::from(format!("{label} (use {original_path})"));
|
||||
}
|
||||
} else if let Some(trait_name) = self.trait_name {
|
||||
label = SmolStr::from(format!("{} (as {})", label, trait_name));
|
||||
label = SmolStr::from(format!("{label} (as {trait_name})"));
|
||||
}
|
||||
|
||||
let text_edit = match self.text_edit {
|
||||
|
|
|
@ -144,8 +144,7 @@ pub(crate) fn render_field(
|
|||
}
|
||||
|
||||
fn field_with_receiver(receiver: Option<&hir::Name>, field_name: &str) -> SmolStr {
|
||||
receiver
|
||||
.map_or_else(|| field_name.into(), |receiver| format!("{}.{}", receiver, field_name).into())
|
||||
receiver.map_or_else(|| field_name.into(), |receiver| format!("{receiver}.{field_name}").into())
|
||||
}
|
||||
|
||||
pub(crate) fn render_tuple_field(
|
||||
|
@ -306,7 +305,7 @@ fn render_resolution_path(
|
|||
item.lookup_by(name.clone())
|
||||
.label(SmolStr::from_iter([&name, "<…>"]))
|
||||
.trigger_call_info()
|
||||
.insert_snippet(cap, format!("{}<$0>", local_name));
|
||||
.insert_snippet(cap, format!("{local_name}<$0>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -528,13 +527,13 @@ mod tests {
|
|||
|
||||
let tag = it.kind().tag();
|
||||
let relevance = display_relevance(it.relevance());
|
||||
items.push(format!("{} {} {}\n", tag, it.label(), relevance));
|
||||
items.push(format!("{tag} {} {relevance}\n", it.label()));
|
||||
|
||||
if let Some((mutability, _offset, relevance)) = it.ref_match() {
|
||||
let label = format!("&{}{}", mutability.as_keyword_for_ref(), it.label());
|
||||
let relevance = display_relevance(relevance);
|
||||
|
||||
items.push(format!("{} {} {}\n", tag, label, relevance));
|
||||
items.push(format!("{tag} {label} {relevance}\n"));
|
||||
}
|
||||
|
||||
items
|
||||
|
@ -563,7 +562,7 @@ mod tests {
|
|||
.filter_map(|(cond, desc)| if cond { Some(desc) } else { None })
|
||||
.join("+");
|
||||
|
||||
format!("[{}]", relevance_factors)
|
||||
format!("[{relevance_factors}]")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ fn render(
|
|||
let (call, escaped_call) = match &func_kind {
|
||||
FuncKind::Method(_, Some(receiver)) => (
|
||||
format!("{}.{}", receiver.unescaped(), name.unescaped()).into(),
|
||||
format!("{}.{}", receiver, name).into(),
|
||||
format!("{receiver}.{name}").into(),
|
||||
),
|
||||
_ => (name.unescaped().to_smol_str(), name.to_smol_str()),
|
||||
};
|
||||
|
@ -162,7 +162,7 @@ pub(super) fn add_call_parens<'b>(
|
|||
cov_mark::hit!(inserts_parens_for_function_calls);
|
||||
|
||||
let (snippet, label_suffix) = if self_param.is_none() && params.is_empty() {
|
||||
(format!("{}()$0", escaped_name), "()")
|
||||
(format!("{escaped_name}()$0"), "()")
|
||||
} else {
|
||||
builder.trigger_call_info();
|
||||
let snippet = if let Some(CallableSnippets::FillArguments) = ctx.config.callable {
|
||||
|
@ -174,7 +174,7 @@ pub(super) fn add_call_parens<'b>(
|
|||
let smol_str = n.to_smol_str();
|
||||
let text = smol_str.as_str().trim_start_matches('_');
|
||||
let ref_ = ref_of_param(ctx, text, param.ty());
|
||||
f(&format_args!("${{{}:{}{}}}", index + offset, ref_, text))
|
||||
f(&format_args!("${{{}:{ref_}{text}}}", index + offset))
|
||||
}
|
||||
None => {
|
||||
let name = match param.ty().as_adt() {
|
||||
|
@ -185,7 +185,7 @@ pub(super) fn add_call_parens<'b>(
|
|||
.map(|s| to_lower_snake_case(s.as_str()))
|
||||
.unwrap_or_else(|| "_".to_string()),
|
||||
};
|
||||
f(&format_args!("${{{}:{}}}", index + offset, name))
|
||||
f(&format_args!("${{{}:{name}}}", index + offset))
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -200,12 +200,12 @@ pub(super) fn add_call_parens<'b>(
|
|||
)
|
||||
}
|
||||
None => {
|
||||
format!("{}({})$0", escaped_name, function_params_snippet)
|
||||
format!("{escaped_name}({function_params_snippet})$0")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cov_mark::hit!(suppress_arg_snippets);
|
||||
format!("{}($0)", escaped_name)
|
||||
format!("{escaped_name}($0)")
|
||||
};
|
||||
|
||||
(snippet, "(…)")
|
||||
|
|
|
@ -66,7 +66,7 @@ fn render(
|
|||
|
||||
match ctx.snippet_cap() {
|
||||
Some(cap) if needs_bang && !has_call_parens => {
|
||||
let snippet = format!("{}!{}$0{}", escaped_name, bra, ket);
|
||||
let snippet = format!("{escaped_name}!{bra}$0{ket}");
|
||||
let lookup = banged_name(&name);
|
||||
item.insert_snippet(cap, snippet).lookup_by(lookup);
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ pub(crate) fn render_record_lit(
|
|||
});
|
||||
|
||||
RenderedLiteral {
|
||||
literal: format!("{} {{ {} }}", path, completions),
|
||||
detail: format!("{} {{ {} }}", path, types),
|
||||
literal: format!("{path} {{ {completions} }}"),
|
||||
detail: format!("{path} {{ {types} }}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ pub(crate) fn render_tuple_lit(
|
|||
path: &str,
|
||||
) -> RenderedLiteral {
|
||||
if snippet_cap.is_none() {
|
||||
return RenderedLiteral { literal: format!("{}", path), detail: format!("{}", path) };
|
||||
return RenderedLiteral { literal: format!("{path}"), detail: format!("{path}") };
|
||||
}
|
||||
let completions = fields.iter().enumerate().format_with(", ", |(idx, _), f| {
|
||||
if snippet_cap.is_some() {
|
||||
|
@ -62,8 +62,8 @@ pub(crate) fn render_tuple_lit(
|
|||
let types = fields.iter().format_with(", ", |field, f| f(&field.ty(db).display(db)));
|
||||
|
||||
RenderedLiteral {
|
||||
literal: format!("{}({})", path, completions),
|
||||
detail: format!("{}({})", path, types),
|
||||
literal: format!("{path}({completions})"),
|
||||
detail: format!("{path}({types})"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ fn validate_snippet(
|
|||
) -> Option<(Box<[GreenNode]>, String, Option<Box<str>>)> {
|
||||
let mut imports = Vec::with_capacity(requires.len());
|
||||
for path in requires.iter() {
|
||||
let use_path = ast::SourceFile::parse(&format!("use {};", path))
|
||||
let use_path = ast::SourceFile::parse(&format!("use {path};"))
|
||||
.syntax_node()
|
||||
.descendants()
|
||||
.find_map(ast::Path::cast)?;
|
||||
|
|
|
@ -153,7 +153,7 @@ fn render_completion_list(completions: Vec<CompletionItem>) -> String {
|
|||
.into_iter()
|
||||
.map(|it| {
|
||||
let tag = it.kind().tag();
|
||||
let var_name = format!("{} {}", tag, it.label());
|
||||
let var_name = format!("{tag} {}", it.label());
|
||||
let mut buf = var_name;
|
||||
if let Some(detail) = it.detail() {
|
||||
let width = label_width.saturating_sub(monospace_width(it.label()));
|
||||
|
@ -188,7 +188,7 @@ pub(crate) fn check_edit_with_config(
|
|||
.iter()
|
||||
.filter(|it| it.lookup() == what)
|
||||
.collect_tuple()
|
||||
.unwrap_or_else(|| panic!("can't find {:?} completion in {:#?}", what, completions));
|
||||
.unwrap_or_else(|| panic!("can't find {what:?} completion in {completions:#?}"));
|
||||
let mut actual = db.file_text(position.file_id).to_string();
|
||||
|
||||
let mut combined_edit = completion.text_edit().to_owned();
|
||||
|
|
|
@ -4,7 +4,7 @@ use expect_test::{expect, Expect};
|
|||
use crate::tests::{check_edit, completion_list, BASE_ITEMS_FIXTURE};
|
||||
|
||||
fn check(ra_fixture: &str, expect: Expect) {
|
||||
let actual = completion_list(&format!("{}{}", BASE_ITEMS_FIXTURE, ra_fixture));
|
||||
let actual = completion_list(&format!("{BASE_ITEMS_FIXTURE}{ra_fixture}"));
|
||||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use expect_test::{expect, Expect};
|
|||
use crate::tests::{completion_list, BASE_ITEMS_FIXTURE};
|
||||
|
||||
fn check(ra_fixture: &str, expect: Expect) {
|
||||
let actual = completion_list(&format!("{}{}", BASE_ITEMS_FIXTURE, ra_fixture));
|
||||
let actual = completion_list(&format!("{BASE_ITEMS_FIXTURE}{ra_fixture}"));
|
||||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use expect_test::{expect, Expect};
|
|||
use crate::tests::{check_edit, completion_list, BASE_ITEMS_FIXTURE};
|
||||
|
||||
fn check(ra_fixture: &str, expect: Expect) {
|
||||
let actual = completion_list(&format!("{}{}", BASE_ITEMS_FIXTURE, ra_fixture));
|
||||
let actual = completion_list(&format!("{BASE_ITEMS_FIXTURE}{ra_fixture}"));
|
||||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ fn check_empty(ra_fixture: &str, expect: Expect) {
|
|||
}
|
||||
|
||||
fn check(ra_fixture: &str, expect: Expect) {
|
||||
let actual = completion_list(&format!("{}\n{}", BASE_ITEMS_FIXTURE, ra_fixture));
|
||||
let actual = completion_list(&format!("{BASE_ITEMS_FIXTURE}\n{ra_fixture}"));
|
||||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use expect_test::{expect, Expect};
|
|||
use crate::tests::{completion_list, BASE_ITEMS_FIXTURE};
|
||||
|
||||
fn check(ra_fixture: &str, expect: Expect) {
|
||||
let actual = completion_list(&format!("{}\n{}", BASE_ITEMS_FIXTURE, ra_fixture));
|
||||
let actual = completion_list(&format!("{BASE_ITEMS_FIXTURE}\n{ra_fixture}"));
|
||||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use expect_test::{expect, Expect};
|
|||
use crate::tests::{completion_list, BASE_ITEMS_FIXTURE};
|
||||
|
||||
fn check(ra_fixture: &str, expect: Expect) {
|
||||
let actual = completion_list(&format!("{}\n{}", BASE_ITEMS_FIXTURE, ra_fixture));
|
||||
let actual = completion_list(&format!("{BASE_ITEMS_FIXTURE}\n{ra_fixture}"));
|
||||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue