mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
hir-def: Fix warnings about clippy str_to_string
rule
This commit is contained in:
parent
a9a315fd73
commit
99f5d7ca4c
@ -29,11 +29,11 @@ pub(super) fn print_body_hir(db: &dyn DefDatabase, body: &Body, owner: DefWithBo
|
|||||||
"const {} = ",
|
"const {} = ",
|
||||||
match &it.name {
|
match &it.name {
|
||||||
Some(name) => name.display(db.upcast()).to_string(),
|
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) => {
|
DefWithBodyId::VariantId(it) => {
|
||||||
let loc = it.lookup(db);
|
let loc = it.lookup(db);
|
||||||
let enum_loc = loc.parent.lookup(db);
|
let enum_loc = loc.parent.lookup(db);
|
||||||
@ -123,7 +123,7 @@ impl Printer<'_> {
|
|||||||
wln!(self);
|
wln!(self);
|
||||||
f(self);
|
f(self);
|
||||||
self.indent_level -= 1;
|
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) {
|
fn whitespace(&mut self) {
|
||||||
|
@ -859,7 +859,7 @@ mod tests {
|
|||||||
check_search(
|
check_search(
|
||||||
ra_fixture,
|
ra_fixture,
|
||||||
"main",
|
"main",
|
||||||
Query::new("fmt".to_string()).fuzzy(),
|
Query::new("fmt".to_owned()).fuzzy(),
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
dep::fmt (t)
|
dep::fmt (t)
|
||||||
dep::fmt::Display::FMT_CONST (a)
|
dep::fmt::Display::FMT_CONST (a)
|
||||||
@ -888,9 +888,7 @@ mod tests {
|
|||||||
check_search(
|
check_search(
|
||||||
ra_fixture,
|
ra_fixture,
|
||||||
"main",
|
"main",
|
||||||
Query::new("fmt".to_string())
|
Query::new("fmt".to_owned()).fuzzy().assoc_search_mode(AssocSearchMode::AssocItemsOnly),
|
||||||
.fuzzy()
|
|
||||||
.assoc_search_mode(AssocSearchMode::AssocItemsOnly),
|
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
dep::fmt::Display::FMT_CONST (a)
|
dep::fmt::Display::FMT_CONST (a)
|
||||||
dep::fmt::Display::format_function (a)
|
dep::fmt::Display::format_function (a)
|
||||||
@ -901,7 +899,7 @@ mod tests {
|
|||||||
check_search(
|
check_search(
|
||||||
ra_fixture,
|
ra_fixture,
|
||||||
"main",
|
"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#"
|
expect![[r#"
|
||||||
dep::fmt (t)
|
dep::fmt (t)
|
||||||
"#]],
|
"#]],
|
||||||
@ -937,7 +935,7 @@ pub mod fmt {
|
|||||||
check_search(
|
check_search(
|
||||||
ra_fixture,
|
ra_fixture,
|
||||||
"main",
|
"main",
|
||||||
Query::new("fmt".to_string()).fuzzy(),
|
Query::new("fmt".to_owned()).fuzzy(),
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
dep::Fmt (m)
|
dep::Fmt (m)
|
||||||
dep::Fmt (t)
|
dep::Fmt (t)
|
||||||
@ -951,7 +949,7 @@ pub mod fmt {
|
|||||||
check_search(
|
check_search(
|
||||||
ra_fixture,
|
ra_fixture,
|
||||||
"main",
|
"main",
|
||||||
Query::new("fmt".to_string()),
|
Query::new("fmt".to_owned()),
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
dep::Fmt (m)
|
dep::Fmt (m)
|
||||||
dep::Fmt (t)
|
dep::Fmt (t)
|
||||||
@ -991,7 +989,7 @@ pub mod fmt {
|
|||||||
check_search(
|
check_search(
|
||||||
ra_fixture,
|
ra_fixture,
|
||||||
"main",
|
"main",
|
||||||
Query::new("fmt".to_string()),
|
Query::new("fmt".to_owned()),
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
dep::Fmt (m)
|
dep::Fmt (m)
|
||||||
dep::Fmt (t)
|
dep::Fmt (t)
|
||||||
@ -1015,7 +1013,7 @@ pub mod fmt {
|
|||||||
check_search(
|
check_search(
|
||||||
ra_fixture,
|
ra_fixture,
|
||||||
"main",
|
"main",
|
||||||
Query::new("FMT".to_string()),
|
Query::new("FMT".to_owned()),
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
dep::FMT (t)
|
dep::FMT (t)
|
||||||
dep::FMT (v)
|
dep::FMT (v)
|
||||||
@ -1027,7 +1025,7 @@ pub mod fmt {
|
|||||||
check_search(
|
check_search(
|
||||||
ra_fixture,
|
ra_fixture,
|
||||||
"main",
|
"main",
|
||||||
Query::new("FMT".to_string()).case_sensitive(),
|
Query::new("FMT".to_owned()).case_sensitive(),
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
dep::FMT (t)
|
dep::FMT (t)
|
||||||
dep::FMT (v)
|
dep::FMT (v)
|
||||||
|
@ -672,7 +672,7 @@ impl ItemScope {
|
|||||||
format_to!(
|
format_to!(
|
||||||
buf,
|
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 {
|
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);
|
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.push('\n');
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ impl Printer<'_> {
|
|||||||
wln!(self);
|
wln!(self);
|
||||||
f(self);
|
f(self);
|
||||||
self.indent_level -= 1;
|
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.
|
/// Ensures that a blank line is output before the next text.
|
||||||
|
@ -224,7 +224,7 @@ fn reindent(indent: IndentLevel, pp: String) -> String {
|
|||||||
return pp;
|
return pp;
|
||||||
}
|
}
|
||||||
let mut lines = pp.split_inclusive('\n');
|
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 {
|
for line in lines {
|
||||||
if line.trim().is_empty() {
|
if line.trim().is_empty() {
|
||||||
res.push_str(line)
|
res.push_str(line)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user