mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
hir-def: Fix warnings about clippy str_to_string
rule
This commit is contained in:
parent
a9a315fd73
commit
99f5d7ca4c
5 changed files with 15 additions and 17 deletions
|
@ -29,11 +29,11 @@ pub(super) fn print_body_hir(db: &dyn DefDatabase, body: &Body, owner: DefWithBo
|
|||
"const {} = ",
|
||||
match &it.name {
|
||||
Some(name) => name.display(db.upcast()).to_string(),
|
||||
None => "_".to_string(),
|
||||
None => "_".to_owned(),
|
||||
}
|
||||
)
|
||||
}),
|
||||
DefWithBodyId::InTypeConstId(_) => "In type const = ".to_string(),
|
||||
DefWithBodyId::InTypeConstId(_) => "In type const = ".to_owned(),
|
||||
DefWithBodyId::VariantId(it) => {
|
||||
let loc = it.lookup(db);
|
||||
let enum_loc = loc.parent.lookup(db);
|
||||
|
@ -123,7 +123,7 @@ impl Printer<'_> {
|
|||
wln!(self);
|
||||
f(self);
|
||||
self.indent_level -= 1;
|
||||
self.buf = self.buf.trim_end_matches('\n').to_string();
|
||||
self.buf = self.buf.trim_end_matches('\n').to_owned();
|
||||
}
|
||||
|
||||
fn whitespace(&mut self) {
|
||||
|
|
|
@ -859,7 +859,7 @@ mod tests {
|
|||
check_search(
|
||||
ra_fixture,
|
||||
"main",
|
||||
Query::new("fmt".to_string()).fuzzy(),
|
||||
Query::new("fmt".to_owned()).fuzzy(),
|
||||
expect![[r#"
|
||||
dep::fmt (t)
|
||||
dep::fmt::Display::FMT_CONST (a)
|
||||
|
@ -888,9 +888,7 @@ mod tests {
|
|||
check_search(
|
||||
ra_fixture,
|
||||
"main",
|
||||
Query::new("fmt".to_string())
|
||||
.fuzzy()
|
||||
.assoc_search_mode(AssocSearchMode::AssocItemsOnly),
|
||||
Query::new("fmt".to_owned()).fuzzy().assoc_search_mode(AssocSearchMode::AssocItemsOnly),
|
||||
expect![[r#"
|
||||
dep::fmt::Display::FMT_CONST (a)
|
||||
dep::fmt::Display::format_function (a)
|
||||
|
@ -901,7 +899,7 @@ mod tests {
|
|||
check_search(
|
||||
ra_fixture,
|
||||
"main",
|
||||
Query::new("fmt".to_string()).fuzzy().assoc_search_mode(AssocSearchMode::Exclude),
|
||||
Query::new("fmt".to_owned()).fuzzy().assoc_search_mode(AssocSearchMode::Exclude),
|
||||
expect![[r#"
|
||||
dep::fmt (t)
|
||||
"#]],
|
||||
|
@ -937,7 +935,7 @@ pub mod fmt {
|
|||
check_search(
|
||||
ra_fixture,
|
||||
"main",
|
||||
Query::new("fmt".to_string()).fuzzy(),
|
||||
Query::new("fmt".to_owned()).fuzzy(),
|
||||
expect![[r#"
|
||||
dep::Fmt (m)
|
||||
dep::Fmt (t)
|
||||
|
@ -951,7 +949,7 @@ pub mod fmt {
|
|||
check_search(
|
||||
ra_fixture,
|
||||
"main",
|
||||
Query::new("fmt".to_string()),
|
||||
Query::new("fmt".to_owned()),
|
||||
expect![[r#"
|
||||
dep::Fmt (m)
|
||||
dep::Fmt (t)
|
||||
|
@ -991,7 +989,7 @@ pub mod fmt {
|
|||
check_search(
|
||||
ra_fixture,
|
||||
"main",
|
||||
Query::new("fmt".to_string()),
|
||||
Query::new("fmt".to_owned()),
|
||||
expect![[r#"
|
||||
dep::Fmt (m)
|
||||
dep::Fmt (t)
|
||||
|
@ -1015,7 +1013,7 @@ pub mod fmt {
|
|||
check_search(
|
||||
ra_fixture,
|
||||
"main",
|
||||
Query::new("FMT".to_string()),
|
||||
Query::new("FMT".to_owned()),
|
||||
expect![[r#"
|
||||
dep::FMT (t)
|
||||
dep::FMT (v)
|
||||
|
@ -1027,7 +1025,7 @@ pub mod fmt {
|
|||
check_search(
|
||||
ra_fixture,
|
||||
"main",
|
||||
Query::new("FMT".to_string()).case_sensitive(),
|
||||
Query::new("FMT".to_owned()).case_sensitive(),
|
||||
expect![[r#"
|
||||
dep::FMT (t)
|
||||
dep::FMT (v)
|
||||
|
|
|
@ -672,7 +672,7 @@ impl ItemScope {
|
|||
format_to!(
|
||||
buf,
|
||||
"{}:",
|
||||
name.map_or("_".to_string(), |name| name.display(db).to_string())
|
||||
name.map_or("_".to_owned(), |name| name.display(db).to_string())
|
||||
);
|
||||
|
||||
if let Some((.., i)) = def.types {
|
||||
|
|
|
@ -24,7 +24,7 @@ pub(super) fn print_item_tree(db: &dyn DefDatabase, tree: &ItemTree) -> String {
|
|||
p.print_mod_item(*item);
|
||||
}
|
||||
|
||||
let mut s = p.buf.trim_end_matches('\n').to_string();
|
||||
let mut s = p.buf.trim_end_matches('\n').to_owned();
|
||||
s.push('\n');
|
||||
s
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ impl Printer<'_> {
|
|||
wln!(self);
|
||||
f(self);
|
||||
self.indent_level -= 1;
|
||||
self.buf = self.buf.trim_end_matches('\n').to_string();
|
||||
self.buf = self.buf.trim_end_matches('\n').to_owned();
|
||||
}
|
||||
|
||||
/// Ensures that a blank line is output before the next text.
|
||||
|
|
|
@ -224,7 +224,7 @@ fn reindent(indent: IndentLevel, pp: String) -> String {
|
|||
return pp;
|
||||
}
|
||||
let mut lines = pp.split_inclusive('\n');
|
||||
let mut res = lines.next().unwrap().to_string();
|
||||
let mut res = lines.next().unwrap().to_owned();
|
||||
for line in lines {
|
||||
if line.trim().is_empty() {
|
||||
res.push_str(line)
|
||||
|
|
Loading…
Reference in a new issue