Unnamed repository; edit this file 'description' to name the repository.
Merge #11041
11041: minor: Fix some clippy lints r=lnicola a=lnicola bors r+ Co-authored-by: LaurenČ›iu Nicola <[email protected]>
bors[bot] 2021-12-17
parent 04b0b19 · parent 6c799da · commit 6674756
-rw-r--r--crates/hir_def/src/item_tree.rs2
-rw-r--r--crates/ide/src/highlight_related.rs2
-rw-r--r--crates/ide_assists/src/handlers/convert_comment_block.rs3
-rw-r--r--crates/ide_assists/src/handlers/convert_into_to_from.rs5
-rw-r--r--crates/ide_assists/src/handlers/destructure_tuple_binding.rs2
-rw-r--r--crates/ide_assists/src/handlers/extract_module.rs66
-rw-r--r--crates/ide_assists/src/handlers/generate_documentation_template.rs5
-rw-r--r--crates/ide_assists/src/handlers/qualify_path.rs2
-rw-r--r--crates/ide_assists/src/utils.rs2
-rw-r--r--crates/ide_completion/src/completions/attribute.rs2
-rw-r--r--crates/test_utils/src/fixture.rs2
-rw-r--r--docs/user/manual.adoc4
12 files changed, 37 insertions, 60 deletions
diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs
index 5e260880ff..2449e4f3e2 100644
--- a/crates/hir_def/src/item_tree.rs
+++ b/crates/hir_def/src/item_tree.rs
@@ -148,7 +148,7 @@ impl ItemTree {
let loc = db.lookup_intern_block(block);
let block = loc.ast_id.to_node(db.upcast());
let hygiene = Hygiene::new(db.upcast(), loc.ast_id.file_id);
- let ctx = lower::Ctx::new(db, hygiene.clone(), loc.ast_id.file_id);
+ let ctx = lower::Ctx::new(db, hygiene, loc.ast_id.file_id);
Arc::new(ctx.lower_block(&block))
}
diff --git a/crates/ide/src/highlight_related.rs b/crates/ide/src/highlight_related.rs
index aac23be777..de6afaef8e 100644
--- a/crates/ide/src/highlight_related.rs
+++ b/crates/ide/src/highlight_related.rs
@@ -78,7 +78,7 @@ fn highlight_references(
token: SyntaxToken,
file_id: FileId,
) -> Option<Vec<HighlightedRange>> {
- let defs = find_defs(sema, token.clone());
+ let defs = find_defs(sema, token);
let usages = defs
.iter()
.filter_map(|&d| {
diff --git a/crates/ide_assists/src/handlers/convert_comment_block.rs b/crates/ide_assists/src/handlers/convert_comment_block.rs
index 472aef2648..3261f56525 100644
--- a/crates/ide_assists/src/handlers/convert_comment_block.rs
+++ b/crates/ide_assists/src/handlers/convert_comment_block.rs
@@ -96,8 +96,7 @@ fn line_to_block(acc: &mut Assists, comment: ast::Comment) -> Option<()> {
let block_prefix =
CommentKind { shape: CommentShape::Block, ..comment.kind() }.prefix();
- let output =
- format!("{}\n{}\n{}*/", block_prefix, block_comment_body, indentation.to_string());
+ let output = format!("{}\n{}\n{}*/", block_prefix, block_comment_body, indentation);
edit.replace(target, output)
},
diff --git a/crates/ide_assists/src/handlers/convert_into_to_from.rs b/crates/ide_assists/src/handlers/convert_into_to_from.rs
index 29555a5111..7f27b507ba 100644
--- a/crates/ide_assists/src/handlers/convert_into_to_from.rs
+++ b/crates/ide_assists/src/handlers/convert_into_to_from.rs
@@ -91,10 +91,7 @@ pub(crate) fn convert_into_to_from(acc: &mut Assists, ctx: &AssistContext) -> Op
builder.replace(src_type.syntax().text_range(), dest_type.to_string());
builder.replace(ast_trait.syntax().text_range(), format!("From<{}>", src_type));
builder.replace(into_fn_return.syntax().text_range(), "-> Self");
- builder.replace(
- into_fn_params.syntax().text_range(),
- format!("(val: {})", src_type.to_string()),
- );
+ builder.replace(into_fn_params.syntax().text_range(), format!("(val: {})", src_type));
builder.replace(into_fn_name.syntax().text_range(), "from");
for s in selfs {
diff --git a/crates/ide_assists/src/handlers/destructure_tuple_binding.rs b/crates/ide_assists/src/handlers/destructure_tuple_binding.rs
index fa85e48c66..c21badb1e1 100644
--- a/crates/ide_assists/src/handlers/destructure_tuple_binding.rs
+++ b/crates/ide_assists/src/handlers/destructure_tuple_binding.rs
@@ -174,7 +174,7 @@ fn edit_tuple_assignment(
// with sub_pattern: keep original tuple and add subpattern: `tup @ (_0, _1)`
if in_sub_pattern {
- let text = format!(" @ {}", tuple_pat.to_string());
+ let text = format!(" @ {}", tuple_pat);
match ctx.config.snippet_cap {
Some(cap) => {
let snip = add_cursor(&text);
diff --git a/crates/ide_assists/src/handlers/extract_module.rs b/crates/ide_assists/src/handlers/extract_module.rs
index 80fc7946ce..4bbfdae1d2 100644
--- a/crates/ide_assists/src/handlers/extract_module.rs
+++ b/crates/ide_assists/src/handlers/extract_module.rs
@@ -151,7 +151,7 @@ fn extract_target(node: &SyntaxNode, selection_range: TextRange) -> Option<Modul
let mut body_items: Vec<ast::Item> = node
.children()
.filter_map(|child| {
- if let Some(item) = ast::Item::cast(child.clone()) {
+ if let Some(item) = ast::Item::cast(child) {
if selection_range.contains_range(item.syntax().text_range()) {
return Some(item);
}
@@ -298,7 +298,7 @@ impl Module {
if let Some(name_ref) = ast::NameRef::cast(desc) {
return Some((
name_ref.syntax().text_range(),
- format!("{}::{}", self.name, name_ref.to_string()),
+ format!("{}::{}", self.name, name_ref),
));
}
}
@@ -312,20 +312,20 @@ impl Module {
get_replacements_for_visibilty_change(self.body_items.clone(), false);
let impl_items = impls.into_iter().fold(Vec::new(), |mut impl_items, x| {
- let this_impl_items =
+ let mut this_impl_items =
x.syntax().descendants().fold(Vec::new(), |mut this_impl_items, x| {
- if let Some(item) = ast::Item::cast(x.clone()) {
+ if let Some(item) = ast::Item::cast(x) {
this_impl_items.push(item);
}
return this_impl_items;
});
- impl_items.append(&mut this_impl_items.clone());
+ impl_items.append(&mut this_impl_items);
return impl_items;
});
let (_, mut impl_item_replacements, _, _) =
- get_replacements_for_visibilty_change(impl_items.clone(), true);
+ get_replacements_for_visibilty_change(impl_items, true);
replacements.append(&mut impl_item_replacements);
@@ -337,7 +337,7 @@ impl Module {
.find(|x| x.to_string() == desc.to_string())
.is_some();
if is_record_field_present {
- replacements.push((desc.visibility().clone(), desc.syntax().clone()));
+ replacements.push((desc.visibility(), desc.syntax().clone()));
}
});
});
@@ -472,7 +472,7 @@ impl Module {
(&x.1).into_iter().for_each(|x| {
let node_opt: Option<ast::Use> = find_node_at_range(file.syntax(), x.range);
if let Some(node) = node_opt {
- use_opt = Some(node.clone());
+ use_opt = Some(node);
}
});
}
@@ -529,7 +529,7 @@ impl Module {
}
if let Some(use_tree_str) = use_tree_str_opt {
- let mut use_tree_str = use_tree_str.clone();
+ let mut use_tree_str = use_tree_str;
use_tree_str.reverse();
if use_tree_str[0].to_string().contains("super") {
let super_path = make::ext::ident_path("super");
@@ -776,42 +776,24 @@ fn get_replacements_for_visibilty_change(
body_items.push(item.clone());
//Use stmts are ignored
match item {
- ast::Item::Const(it) => {
- replacements.push((it.visibility().clone(), it.syntax().clone()))
- }
- ast::Item::Enum(it) => {
- replacements.push((it.visibility().clone(), it.syntax().clone()))
- }
- ast::Item::ExternCrate(it) => {
- replacements.push((it.visibility().clone(), it.syntax().clone()))
- }
- ast::Item::Fn(it) => replacements.push((it.visibility().clone(), it.syntax().clone())),
+ ast::Item::Const(it) => replacements.push((it.visibility(), it.syntax().clone())),
+ ast::Item::Enum(it) => replacements.push((it.visibility(), it.syntax().clone())),
+ ast::Item::ExternCrate(it) => replacements.push((it.visibility(), it.syntax().clone())),
+ ast::Item::Fn(it) => replacements.push((it.visibility(), it.syntax().clone())),
ast::Item::Impl(it) => impls.push(it),
- ast::Item::MacroRules(it) => {
- replacements.push((it.visibility().clone(), it.syntax().clone()))
- }
- ast::Item::MacroDef(it) => {
- replacements.push((it.visibility().clone(), it.syntax().clone()))
- }
- ast::Item::Module(it) => {
- replacements.push((it.visibility().clone(), it.syntax().clone()))
- }
- ast::Item::Static(it) => {
- replacements.push((it.visibility().clone(), it.syntax().clone()))
- }
+ ast::Item::MacroRules(it) => replacements.push((it.visibility(), it.syntax().clone())),
+ ast::Item::MacroDef(it) => replacements.push((it.visibility(), it.syntax().clone())),
+ ast::Item::Module(it) => replacements.push((it.visibility(), it.syntax().clone())),
+ ast::Item::Static(it) => replacements.push((it.visibility(), it.syntax().clone())),
ast::Item::Struct(it) => {
- replacements.push((it.visibility().clone(), it.syntax().clone()));
- record_field_parents.push((it.visibility().clone(), it.syntax().clone()));
- }
- ast::Item::Trait(it) => {
- replacements.push((it.visibility().clone(), it.syntax().clone()))
- }
- ast::Item::TypeAlias(it) => {
- replacements.push((it.visibility().clone(), it.syntax().clone()))
+ replacements.push((it.visibility(), it.syntax().clone()));
+ record_field_parents.push((it.visibility(), it.syntax().clone()));
}
+ ast::Item::Trait(it) => replacements.push((it.visibility(), it.syntax().clone())),
+ ast::Item::TypeAlias(it) => replacements.push((it.visibility(), it.syntax().clone())),
ast::Item::Union(it) => {
- replacements.push((it.visibility().clone(), it.syntax().clone()));
- record_field_parents.push((it.visibility().clone(), it.syntax().clone()));
+ replacements.push((it.visibility(), it.syntax().clone()));
+ record_field_parents.push((it.visibility(), it.syntax().clone()));
}
_ => (),
}
@@ -825,7 +807,7 @@ fn get_use_tree_paths_from_path(
use_tree_str: &mut Vec<ast::Path>,
) -> Option<&mut Vec<ast::Path>> {
path.syntax().ancestors().filter(|x| x.to_string() != path.to_string()).find_map(|x| {
- if let Some(use_tree) = ast::UseTree::cast(x.clone()) {
+ if let Some(use_tree) = ast::UseTree::cast(x) {
if let Some(upper_tree_path) = use_tree.path() {
if upper_tree_path.to_string() != path.to_string() {
use_tree_str.push(upper_tree_path.clone());
diff --git a/crates/ide_assists/src/handlers/generate_documentation_template.rs b/crates/ide_assists/src/handlers/generate_documentation_template.rs
index cfc7e9d043..1481eadb51 100644
--- a/crates/ide_assists/src/handlers/generate_documentation_template.rs
+++ b/crates/ide_assists/src/handlers/generate_documentation_template.rs
@@ -59,9 +59,8 @@ pub(crate) fn generate_documentation_template(
"Generate a documentation template",
text_range,
|builder| {
- let mut doc_lines = Vec::new();
// Introduction / short function description before the sections
- doc_lines.push(introduction_builder(&ast_func, ctx));
+ let mut doc_lines = vec![introduction_builder(&ast_func, ctx)];
// Then come the sections
if let Some(mut lines) = examples_builder(&ast_func, ctx) {
doc_lines.push("".into());
@@ -303,7 +302,7 @@ fn arguments_from_params(param_list: &ast::ParamList) -> String {
// instance `TuplePat`) could be managed later.
Some(ast::Pat::IdentPat(ident_pat)) => match ident_pat.name() {
Some(name) => match is_a_ref_mut_param(&param) {
- true => format!("&mut {}", name.to_string()),
+ true => format!("&mut {}", name),
false => name.to_string(),
},
None => "_".to_string(),
diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs
index 23b642fcb1..ae29068bd7 100644
--- a/crates/ide_assists/src/handlers/qualify_path.rs
+++ b/crates/ide_assists/src/handlers/qualify_path.rs
@@ -121,7 +121,7 @@ impl QualifyCandidate<'_> {
}
QualifyCandidate::UnqualifiedName(generics) => {
let generics = generics.as_ref().map_or_else(String::new, ToString::to_string);
- replacer(format!("{}{}", import.to_string(), generics));
+ replacer(format!("{}{}", import, generics));
}
QualifyCandidate::TraitAssocItem(qualifier, segment) => {
replacer(format!("<{} as {}>::{}", qualifier, import, segment));
diff --git a/crates/ide_assists/src/utils.rs b/crates/ide_assists/src/utils.rs
index 90ec710c8e..8a443ab089 100644
--- a/crates/ide_assists/src/utils.rs
+++ b/crates/ide_assists/src/utils.rs
@@ -431,7 +431,7 @@ fn generate_impl_text_inner(adt: &ast::Adt, trait_text: Option<&str>, code: &str
buf.push_str("\n\n");
adt.attrs()
.filter(|attr| attr.as_simple_call().map(|(name, _arg)| name == "cfg").unwrap_or(false))
- .for_each(|attr| buf.push_str(format!("{}\n", attr.to_string()).as_str()));
+ .for_each(|attr| buf.push_str(format!("{}\n", attr).as_str()));
buf.push_str("impl");
if let Some(generic_params) = &generic_params {
let lifetimes = generic_params.lifetime_params().map(|lt| format!("{}", lt.syntax()));
diff --git a/crates/ide_completion/src/completions/attribute.rs b/crates/ide_completion/src/completions/attribute.rs
index d642c8bc4d..8222d3cbf4 100644
--- a/crates/ide_completion/src/completions/attribute.rs
+++ b/crates/ide_completion/src/completions/attribute.rs
@@ -2,7 +2,7 @@
//!
//! This module uses a bit of static metadata to provide completions
//! for built-in attributes.
-//! Non-builtin attribute(excluding derives attributes) completions are done in [`super::unqualified_path`].
+//! Non-built-in attribute (excluding derives attributes) completions are done in [`super::unqualified_path`].
use ide_db::{
helpers::{
diff --git a/crates/test_utils/src/fixture.rs b/crates/test_utils/src/fixture.rs
index 3d303a1237..8c806e7925 100644
--- a/crates/test_utils/src/fixture.rs
+++ b/crates/test_utils/src/fixture.rs
@@ -147,7 +147,7 @@ impl Fixture {
if line.starts_with("// ")
&& line.contains(':')
&& !line.contains("::")
- && !line.contains(".")
+ && !line.contains('.')
&& line.chars().all(|it| !it.is_uppercase())
{
panic!("looks like invalid metadata line: {:?}", line);
diff --git a/docs/user/manual.adoc b/docs/user/manual.adoc
index 1db6cb5cd4..4fbe2379c3 100644
--- a/docs/user/manual.adoc
+++ b/docs/user/manual.adoc
@@ -445,7 +445,7 @@ If the date is more than a week ago, it's better to update rust-analyzer version
The next thing to check would be panic messages in rust-analyzer's log.
Log messages are printed to stderr, in VS Code you can see then in the `Output > Rust Analyzer Language Server` tab of the panel.
-To see more logs, set `RA_LOG=info` environmental variable.
+To see more logs, set the `RA_LOG=info` environment variable.
To fully capture LSP messages between the editor and the server, set `"rust-analyzer.trace.server": "verbose"` config and check
`Output > Rust Analyzer Language Server Trace`.
@@ -624,7 +624,7 @@ Relative paths are interpreted relative to `rust-project.json` file location or
See https://github.com/rust-analyzer/rust-project.json-example for a small example.
-You can set `RA_LOG` environmental variable to `rust_analyzer=info` to inspect how rust-analyzer handles config and project loading.
+You can set the `RA_LOG` environment variable to `rust_analyzer=info` to inspect how rust-analyzer handles config and project loading.
Note that calls to `cargo check` are disabled when using `rust-project.json` by default, so compilation errors and warnings will no longer be sent to your LSP client. To enable these compilation errors you will need to specify explicitly what command rust-analyzer should run to perform the checks using the `checkOnSave.overrideCommand` configuration. As an example, the following configuration explicitly sets `cargo check` as the `checkOnSave` command.