Skip to content

Commit 99f5d7c

Browse files
hir-def: Fix warnings about clippy str_to_string rule
1 parent a9a315f commit 99f5d7c

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

crates/hir-def/src/body/pretty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ pub(super) fn print_body_hir(db: &dyn DefDatabase, body: &Body, owner: DefWithBo
2929
"const {} = ",
3030
match &it.name {
3131
Some(name) => name.display(db.upcast()).to_string(),
32-
None => "_".to_string(),
32+
None => "_".to_owned(),
3333
}
3434
)
3535
}),
36-
DefWithBodyId::InTypeConstId(_) => "In type const = ".to_string(),
36+
DefWithBodyId::InTypeConstId(_) => "In type const = ".to_owned(),
3737
DefWithBodyId::VariantId(it) => {
3838
let loc = it.lookup(db);
3939
let enum_loc = loc.parent.lookup(db);
@@ -123,7 +123,7 @@ impl Printer<'_> {
123123
wln!(self);
124124
f(self);
125125
self.indent_level -= 1;
126-
self.buf = self.buf.trim_end_matches('\n').to_string();
126+
self.buf = self.buf.trim_end_matches('\n').to_owned();
127127
}
128128

129129
fn whitespace(&mut self) {

crates/hir-def/src/import_map.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ mod tests {
859859
check_search(
860860
ra_fixture,
861861
"main",
862-
Query::new("fmt".to_string()).fuzzy(),
862+
Query::new("fmt".to_owned()).fuzzy(),
863863
expect![[r#"
864864
dep::fmt (t)
865865
dep::fmt::Display::FMT_CONST (a)
@@ -888,9 +888,7 @@ mod tests {
888888
check_search(
889889
ra_fixture,
890890
"main",
891-
Query::new("fmt".to_string())
892-
.fuzzy()
893-
.assoc_search_mode(AssocSearchMode::AssocItemsOnly),
891+
Query::new("fmt".to_owned()).fuzzy().assoc_search_mode(AssocSearchMode::AssocItemsOnly),
894892
expect![[r#"
895893
dep::fmt::Display::FMT_CONST (a)
896894
dep::fmt::Display::format_function (a)
@@ -901,7 +899,7 @@ mod tests {
901899
check_search(
902900
ra_fixture,
903901
"main",
904-
Query::new("fmt".to_string()).fuzzy().assoc_search_mode(AssocSearchMode::Exclude),
902+
Query::new("fmt".to_owned()).fuzzy().assoc_search_mode(AssocSearchMode::Exclude),
905903
expect![[r#"
906904
dep::fmt (t)
907905
"#]],
@@ -937,7 +935,7 @@ pub mod fmt {
937935
check_search(
938936
ra_fixture,
939937
"main",
940-
Query::new("fmt".to_string()).fuzzy(),
938+
Query::new("fmt".to_owned()).fuzzy(),
941939
expect![[r#"
942940
dep::Fmt (m)
943941
dep::Fmt (t)
@@ -951,7 +949,7 @@ pub mod fmt {
951949
check_search(
952950
ra_fixture,
953951
"main",
954-
Query::new("fmt".to_string()),
952+
Query::new("fmt".to_owned()),
955953
expect![[r#"
956954
dep::Fmt (m)
957955
dep::Fmt (t)
@@ -991,7 +989,7 @@ pub mod fmt {
991989
check_search(
992990
ra_fixture,
993991
"main",
994-
Query::new("fmt".to_string()),
992+
Query::new("fmt".to_owned()),
995993
expect![[r#"
996994
dep::Fmt (m)
997995
dep::Fmt (t)
@@ -1015,7 +1013,7 @@ pub mod fmt {
10151013
check_search(
10161014
ra_fixture,
10171015
"main",
1018-
Query::new("FMT".to_string()),
1016+
Query::new("FMT".to_owned()),
10191017
expect![[r#"
10201018
dep::FMT (t)
10211019
dep::FMT (v)
@@ -1027,7 +1025,7 @@ pub mod fmt {
10271025
check_search(
10281026
ra_fixture,
10291027
"main",
1030-
Query::new("FMT".to_string()).case_sensitive(),
1028+
Query::new("FMT".to_owned()).case_sensitive(),
10311029
expect![[r#"
10321030
dep::FMT (t)
10331031
dep::FMT (v)

crates/hir-def/src/item_scope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ impl ItemScope {
672672
format_to!(
673673
buf,
674674
"{}:",
675-
name.map_or("_".to_string(), |name| name.display(db).to_string())
675+
name.map_or("_".to_owned(), |name| name.display(db).to_string())
676676
);
677677

678678
if let Some((.., i)) = def.types {

crates/hir-def/src/item_tree/pretty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(super) fn print_item_tree(db: &dyn DefDatabase, tree: &ItemTree) -> String {
2424
p.print_mod_item(*item);
2525
}
2626

27-
let mut s = p.buf.trim_end_matches('\n').to_string();
27+
let mut s = p.buf.trim_end_matches('\n').to_owned();
2828
s.push('\n');
2929
s
3030
}
@@ -58,7 +58,7 @@ impl Printer<'_> {
5858
wln!(self);
5959
f(self);
6060
self.indent_level -= 1;
61-
self.buf = self.buf.trim_end_matches('\n').to_string();
61+
self.buf = self.buf.trim_end_matches('\n').to_owned();
6262
}
6363

6464
/// Ensures that a blank line is output before the next text.

crates/hir-def/src/macro_expansion_tests/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ fn reindent(indent: IndentLevel, pp: String) -> String {
224224
return pp;
225225
}
226226
let mut lines = pp.split_inclusive('\n');
227-
let mut res = lines.next().unwrap().to_string();
227+
let mut res = lines.next().unwrap().to_owned();
228228
for line in lines {
229229
if line.trim().is_empty() {
230230
res.push_str(line)

0 commit comments

Comments
 (0)