Skip to content

Commit 6c799da

Browse files
committed
Fix some clippy lints
1 parent 8ad7c04 commit 6c799da

File tree

8 files changed

+9
-14
lines changed

8 files changed

+9
-14
lines changed

crates/ide_assists/src/handlers/convert_comment_block.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ fn line_to_block(acc: &mut Assists, comment: ast::Comment) -> Option<()> {
9696
let block_prefix =
9797
CommentKind { shape: CommentShape::Block, ..comment.kind() }.prefix();
9898

99-
let output =
100-
format!("{}\n{}\n{}*/", block_prefix, block_comment_body, indentation.to_string());
99+
let output = format!("{}\n{}\n{}*/", block_prefix, block_comment_body, indentation);
101100

102101
edit.replace(target, output)
103102
},

crates/ide_assists/src/handlers/convert_into_to_from.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,7 @@ pub(crate) fn convert_into_to_from(acc: &mut Assists, ctx: &AssistContext) -> Op
9191
builder.replace(src_type.syntax().text_range(), dest_type.to_string());
9292
builder.replace(ast_trait.syntax().text_range(), format!("From<{}>", src_type));
9393
builder.replace(into_fn_return.syntax().text_range(), "-> Self");
94-
builder.replace(
95-
into_fn_params.syntax().text_range(),
96-
format!("(val: {})", src_type.to_string()),
97-
);
94+
builder.replace(into_fn_params.syntax().text_range(), format!("(val: {})", src_type));
9895
builder.replace(into_fn_name.syntax().text_range(), "from");
9996

10097
for s in selfs {

crates/ide_assists/src/handlers/destructure_tuple_binding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fn edit_tuple_assignment(
174174

175175
// with sub_pattern: keep original tuple and add subpattern: `tup @ (_0, _1)`
176176
if in_sub_pattern {
177-
let text = format!(" @ {}", tuple_pat.to_string());
177+
let text = format!(" @ {}", tuple_pat);
178178
match ctx.config.snippet_cap {
179179
Some(cap) => {
180180
let snip = add_cursor(&text);

crates/ide_assists/src/handlers/extract_module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ impl Module {
298298
if let Some(name_ref) = ast::NameRef::cast(desc) {
299299
return Some((
300300
name_ref.syntax().text_range(),
301-
format!("{}::{}", self.name, name_ref.to_string()),
301+
format!("{}::{}", self.name, name_ref),
302302
));
303303
}
304304
}

crates/ide_assists/src/handlers/generate_documentation_template.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ pub(crate) fn generate_documentation_template(
5959
"Generate a documentation template",
6060
text_range,
6161
|builder| {
62-
let mut doc_lines = Vec::new();
6362
// Introduction / short function description before the sections
64-
doc_lines.push(introduction_builder(&ast_func, ctx));
63+
let mut doc_lines = vec![introduction_builder(&ast_func, ctx)];
6564
// Then come the sections
6665
if let Some(mut lines) = examples_builder(&ast_func, ctx) {
6766
doc_lines.push("".into());
@@ -303,7 +302,7 @@ fn arguments_from_params(param_list: &ast::ParamList) -> String {
303302
// instance `TuplePat`) could be managed later.
304303
Some(ast::Pat::IdentPat(ident_pat)) => match ident_pat.name() {
305304
Some(name) => match is_a_ref_mut_param(&param) {
306-
true => format!("&mut {}", name.to_string()),
305+
true => format!("&mut {}", name),
307306
false => name.to_string(),
308307
},
309308
None => "_".to_string(),

crates/ide_assists/src/handlers/qualify_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl QualifyCandidate<'_> {
121121
}
122122
QualifyCandidate::UnqualifiedName(generics) => {
123123
let generics = generics.as_ref().map_or_else(String::new, ToString::to_string);
124-
replacer(format!("{}{}", import.to_string(), generics));
124+
replacer(format!("{}{}", import, generics));
125125
}
126126
QualifyCandidate::TraitAssocItem(qualifier, segment) => {
127127
replacer(format!("<{} as {}>::{}", qualifier, import, segment));

crates/ide_assists/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ fn generate_impl_text_inner(adt: &ast::Adt, trait_text: Option<&str>, code: &str
431431
buf.push_str("\n\n");
432432
adt.attrs()
433433
.filter(|attr| attr.as_simple_call().map(|(name, _arg)| name == "cfg").unwrap_or(false))
434-
.for_each(|attr| buf.push_str(format!("{}\n", attr.to_string()).as_str()));
434+
.for_each(|attr| buf.push_str(format!("{}\n", attr).as_str()));
435435
buf.push_str("impl");
436436
if let Some(generic_params) = &generic_params {
437437
let lifetimes = generic_params.lifetime_params().map(|lt| format!("{}", lt.syntax()));

crates/test_utils/src/fixture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl Fixture {
147147
if line.starts_with("// ")
148148
&& line.contains(':')
149149
&& !line.contains("::")
150-
&& !line.contains(".")
150+
&& !line.contains('.')
151151
&& line.chars().all(|it| !it.is_uppercase())
152152
{
153153
panic!("looks like invalid metadata line: {:?}", line);

0 commit comments

Comments
 (0)