mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +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
|
@ -148,7 +148,7 @@ fn resolve_doc_path(
|
|||
|
||||
let modpath = {
|
||||
// FIXME: this is not how we should get a mod path here
|
||||
let ast_path = ast::SourceFile::parse(&format!("type T = {};", link))
|
||||
let ast_path = ast::SourceFile::parse(&format!("type T = {link};"))
|
||||
.syntax_node()
|
||||
.descendants()
|
||||
.find_map(ast::Path::cast)?;
|
||||
|
|
|
@ -79,7 +79,7 @@ impl HirDisplay for Function {
|
|||
}
|
||||
}
|
||||
match name {
|
||||
Some(name) => write!(f, "{}: ", name)?,
|
||||
Some(name) => write!(f, "{name}: ")?,
|
||||
None => f.write_str("_: ")?,
|
||||
}
|
||||
// FIXME: Use resolved `param.ty` or raw `type_ref`?
|
||||
|
@ -327,7 +327,7 @@ fn write_generic_params(
|
|||
continue;
|
||||
}
|
||||
delim(f)?;
|
||||
write!(f, "{}", name)?;
|
||||
write!(f, "{name}")?;
|
||||
if let Some(default) = &ty.default {
|
||||
f.write_str(" = ")?;
|
||||
default.hir_fmt(f)?;
|
||||
|
@ -335,7 +335,7 @@ fn write_generic_params(
|
|||
}
|
||||
TypeOrConstParamData::ConstParamData(c) => {
|
||||
delim(f)?;
|
||||
write!(f, "const {}: ", name)?;
|
||||
write!(f, "const {name}: ")?;
|
||||
c.ty.hir_fmt(f)?;
|
||||
}
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ fn write_where_clause(def: GenericDefId, f: &mut HirFormatter<'_>) -> Result<(),
|
|||
WherePredicateTypeTarget::TypeRef(ty) => ty.hir_fmt(f),
|
||||
WherePredicateTypeTarget::TypeOrConstParam(id) => {
|
||||
match ¶ms.type_or_consts[*id].name() {
|
||||
Some(name) => write!(f, "{}", name),
|
||||
Some(name) => write!(f, "{name}"),
|
||||
None => f.write_str("{unnamed}"),
|
||||
}
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ fn write_where_clause(def: GenericDefId, f: &mut HirFormatter<'_>) -> Result<(),
|
|||
if idx != 0 {
|
||||
f.write_str(", ")?;
|
||||
}
|
||||
write!(f, "{}", lifetime)?;
|
||||
write!(f, "{lifetime}")?;
|
||||
}
|
||||
f.write_str("> ")?;
|
||||
write_target(target, f)?;
|
||||
|
@ -447,7 +447,7 @@ impl HirDisplay for Const {
|
|||
let data = f.db.const_data(self.id);
|
||||
f.write_str("const ")?;
|
||||
match &data.name {
|
||||
Some(name) => write!(f, "{}: ", name)?,
|
||||
Some(name) => write!(f, "{name}: ")?,
|
||||
None => f.write_str("_: ")?,
|
||||
}
|
||||
data.type_ref.hir_fmt(f)?;
|
||||
|
@ -511,9 +511,9 @@ impl HirDisplay for Module {
|
|||
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
|
||||
// FIXME: Module doesn't have visibility saved in data.
|
||||
match self.name(f.db) {
|
||||
Some(name) => write!(f, "mod {}", name),
|
||||
Some(name) => write!(f, "mod {name}"),
|
||||
None if self.is_crate_root(f.db) => match self.krate(f.db).display_name(f.db) {
|
||||
Some(name) => write!(f, "extern crate {}", name),
|
||||
Some(name) => write!(f, "extern crate {name}"),
|
||||
None => f.write_str("extern crate {unknown}"),
|
||||
},
|
||||
None => f.write_str("mod {unnamed}"),
|
||||
|
|
|
@ -813,7 +813,7 @@ fn precise_macro_call_location(
|
|||
.doc_comments_and_attrs()
|
||||
.nth((*invoc_attr_index) as usize)
|
||||
.and_then(Either::left)
|
||||
.unwrap_or_else(|| panic!("cannot find attribute #{}", invoc_attr_index));
|
||||
.unwrap_or_else(|| panic!("cannot find attribute #{invoc_attr_index}"));
|
||||
|
||||
(
|
||||
ast_id.with_value(SyntaxNodePtr::from(AstPtr::new(&attr))),
|
||||
|
|
|
@ -1378,7 +1378,7 @@ impl<'db> SemanticsImpl<'db> {
|
|||
self.cache
|
||||
.borrow()
|
||||
.keys()
|
||||
.map(|it| format!("{:?}", it))
|
||||
.map(|it| format!("{it:?}"))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue