Skip to content

Commit 196650d

Browse files
committed
don't to_string() format args
1 parent b22bd36 commit 196650d

File tree

6 files changed

+13
-23
lines changed

6 files changed

+13
-23
lines changed

crates/hir-ty/src/mir/eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ impl MirEvalError {
386386
write!(
387387
f,
388388
"Layout for type `{}` is not available due {err:?}",
389-
ty.display(db).with_closure_style(ClosureStyle::ClosureWithId).to_string()
389+
ty.display(db).with_closure_style(ClosureStyle::ClosureWithId)
390390
)?;
391391
}
392392
MirEvalError::MirLowerError(func, err) => {

crates/hir-ty/src/mir/lower.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl MirLowerError {
177177
)?;
178178
writeln!(f, "Provided args: [")?;
179179
for g in subst.iter(Interner) {
180-
write!(f, " {},", g.display(db).to_string())?;
180+
write!(f, " {},", g.display(db))?;
181181
}
182182
writeln!(f, "]")?;
183183
}

crates/ide-assists/src/handlers/generate_delegate_trait.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,8 @@ fn generate_impl(
266266
.clone_for_update();
267267

268268
// Goto link : https://doc.rust-lang.org/reference/paths.html#qualified-paths
269-
let qualified_path_type = make::path_from_text(&format!(
270-
"<{} as {}>",
271-
field_ty.to_string(),
272-
delegate.trait_()?.to_string()
273-
));
269+
let qualified_path_type =
270+
make::path_from_text(&format!("<{} as {}>", field_ty, delegate.trait_()?));
274271

275272
let delegate_assoc_items = delegate.get_or_create_assoc_item_list();
276273
match bound_def.assoc_item_list() {
@@ -373,11 +370,8 @@ fn generate_impl(
373370
.clone_for_update();
374371

375372
// Goto link : https://doc.rust-lang.org/reference/paths.html#qualified-paths
376-
let qualified_path_type = make::path_from_text(&format!(
377-
"<{} as {}>",
378-
field_ty.to_string(),
379-
delegate.trait_()?.to_string()
380-
));
373+
let qualified_path_type =
374+
make::path_from_text(&format!("<{} as {}>", field_ty, delegate.trait_()?));
381375

382376
// 4) Transform associated items in delegte trait impl
383377
let delegate_assoc_items = delegate.get_or_create_assoc_item_list();
@@ -759,7 +753,7 @@ fn ty_assoc_item(item: syntax::ast::TypeAlias, qual_path_ty: Path) -> Option<Ass
759753
}
760754

761755
fn qualified_path(qual_path_ty: ast::Path, path_expr_seg: ast::Path) -> ast::Path {
762-
make::path_from_text(&format!("{}::{}", qual_path_ty.to_string(), path_expr_seg.to_string()))
756+
make::path_from_text(&format!("{}::{}", qual_path_ty, path_expr_seg))
763757
}
764758

765759
#[cfg(test)]

crates/ide-assists/src/handlers/generate_mut_trait_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub(crate) fn generate_mut_trait_impl(acc: &mut Assists, ctx: &AssistContext<'_>
105105
"Generate `IndexMut` impl from this `Index` trait",
106106
target,
107107
|edit| {
108-
edit.insert(target.start(), format!("$0{}\n\n", impl_def.to_string()));
108+
edit.insert(target.start(), format!("$0{}\n\n", impl_def));
109109
},
110110
)
111111
}

crates/ide-assists/src/handlers/generate_trait_from_impl.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub(crate) fn generate_trait_from_impl(acc: &mut Assists, ctx: &AssistContext<'_
128128
builder.replace_snippet(
129129
snippet_cap,
130130
impl_name.syntax().text_range(),
131-
format!("${{0:TraitName}}{} for {}", arg_list, impl_name.to_string()),
131+
format!("${{0:TraitName}}{} for {}", arg_list, impl_name),
132132
);
133133

134134
// Insert trait before TraitImpl
@@ -144,17 +144,13 @@ pub(crate) fn generate_trait_from_impl(acc: &mut Assists, ctx: &AssistContext<'_
144144
} else {
145145
builder.replace(
146146
impl_name.syntax().text_range(),
147-
format!("NewTrait{} for {}", arg_list, impl_name.to_string()),
147+
format!("NewTrait{} for {}", arg_list, impl_name),
148148
);
149149

150150
// Insert trait before TraitImpl
151151
builder.insert(
152152
impl_ast.syntax().text_range().start(),
153-
format!(
154-
"{}\n\n{}",
155-
trait_ast.to_string(),
156-
IndentLevel::from_node(impl_ast.syntax())
157-
),
153+
format!("{}\n\n{}", trait_ast, IndentLevel::from_node(impl_ast.syntax())),
158154
);
159155
}
160156

crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub(crate) fn trait_impl_redundant_assoc_item(
3232
.source(db)
3333
.map(|it| it.syntax().value.text_range())
3434
.unwrap_or(default_range),
35-
format!("\n {};", function.display(db).to_string()),
35+
format!("\n {};", function.display(db)),
3636
)
3737
}
3838
hir::AssocItem::Const(id) => {
@@ -43,7 +43,7 @@ pub(crate) fn trait_impl_redundant_assoc_item(
4343
.source(db)
4444
.map(|it| it.syntax().value.text_range())
4545
.unwrap_or(default_range),
46-
format!("\n {};", constant.display(db).to_string()),
46+
format!("\n {};", constant.display(db)),
4747
)
4848
}
4949
hir::AssocItem::TypeAlias(id) => {

0 commit comments

Comments
 (0)