about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/flycheck/src/lib.rs8
-rw-r--r--crates/ide_assists/src/handlers/generate_function.rs6
-rw-r--r--crates/parser/src/grammar.rs3
-rw-r--r--crates/parser/src/grammar/expressions.rs2
-rw-r--r--crates/parser/src/grammar/patterns.rs2
-rw-r--r--crates/paths/src/lib.rs2
-rw-r--r--crates/proc_macro_api/src/msg/flat.rs2
-rw-r--r--crates/profile/src/hprof.rs2
-rw-r--r--crates/syntax/src/algo.rs7
-rw-r--r--crates/syntax/src/ast/edit_in_place.rs2
-rw-r--r--crates/syntax/src/ast/node_ext.rs6
-rw-r--r--crates/syntax/src/ast/token_ext.rs2
-rw-r--r--crates/syntax/src/parsing/text_token_source.rs6
-rw-r--r--crates/syntax/src/tests/sourcegen_ast.rs15
-rw-r--r--crates/test_utils/src/fixture.rs2
-rw-r--r--crates/text_edit/src/lib.rs6
-rw-r--r--crates/tt/src/buffer.rs3
-rw-r--r--crates/tt/src/lib.rs4
-rw-r--r--crates/vfs-notify/src/lib.rs2
-rw-r--r--crates/vfs/src/vfs_path.rs3
-rw-r--r--xtask/src/release.rs6
21 files changed, 40 insertions, 51 deletions
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs
index e2645d9e5f3..0661d776f17 100644
--- a/crates/flycheck/src/lib.rs
+++ b/crates/flycheck/src/lib.rs
@@ -260,7 +260,7 @@ impl FlycheckActor {
 struct CargoHandle {
     child: JodChild,
     #[allow(unused)]
-    thread: jod_thread::JoinHandle<io::Result<bool>>,
+    thread: jod_thread::JoinHandle<bool>,
     receiver: Receiver<CargoMessage>,
 }
 
@@ -279,7 +279,7 @@ impl CargoHandle {
         // It is okay to ignore the result, as it only errors if the process is already dead
         let _ = self.child.kill();
         let exit_status = self.child.wait()?;
-        let read_at_least_one_message = self.thread.join()?;
+        let read_at_least_one_message = self.thread.join();
         if !exit_status.success() && !read_at_least_one_message {
             // FIXME: Read the stderr to display the reason, see `read2()` reference in PR comment:
             // https://github.com/rust-analyzer/rust-analyzer/pull/3632#discussion_r395605298
@@ -304,7 +304,7 @@ impl CargoActor {
     fn new(child_stdout: process::ChildStdout, sender: Sender<CargoMessage>) -> CargoActor {
         CargoActor { child_stdout, sender }
     }
-    fn run(self) -> io::Result<bool> {
+    fn run(self) -> bool {
         // We manually read a line at a time, instead of using serde's
         // stream deserializers, because the deserializer cannot recover
         // from an error, resulting in it getting stuck, because we try to
@@ -347,7 +347,7 @@ impl CargoActor {
                 }
             }
         }
-        Ok(read_at_least_one_message)
+        read_at_least_one_message
     }
 }
 
diff --git a/crates/ide_assists/src/handlers/generate_function.rs b/crates/ide_assists/src/handlers/generate_function.rs
index 8a115087da6..5e57cb76ebc 100644
--- a/crates/ide_assists/src/handlers/generate_function.rs
+++ b/crates/ide_assists/src/handlers/generate_function.rs
@@ -542,11 +542,7 @@ fn fn_arg_type(
         return None;
     }
 
-    if let Ok(rendered) = ty.display_source_code(ctx.db(), target_module.into()) {
-        Some(rendered)
-    } else {
-        None
-    }
+    ty.display_source_code(ctx.db(), target_module.into()).ok()
 }
 
 /// Returns the position inside the current mod or file
diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs
index 2b874d6e1c3..991955fca6d 100644
--- a/crates/parser/src/grammar.rs
+++ b/crates/parser/src/grammar.rs
@@ -128,8 +128,7 @@ pub(crate) fn reparser(
         EXTERN_ITEM_LIST => items::extern_item_list,
         TOKEN_TREE if first_child? == T!['{'] => items::token_tree,
         ASSOC_ITEM_LIST => match parent? {
-            IMPL => items::assoc_item_list,
-            TRAIT => items::assoc_item_list,
+            IMPL | TRAIT => items::assoc_item_list,
             _ => return None,
         },
         ITEM_LIST => items::item_list,
diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs
index 23727d1e9bc..aa171674ed9 100644
--- a/crates/parser/src/grammar/expressions.rs
+++ b/crates/parser/src/grammar/expressions.rs
@@ -311,7 +311,7 @@ fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)>
         _ => {
             // test full_range_expr
             // fn foo() { xs[..]; }
-            for &op in [T![..=], T![..]].iter() {
+            for op in [T![..=], T![..]] {
                 if p.at(op) {
                     m = p.start();
                     p.bump(op);
diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs
index 3ed63bd437a..7e96823b1da 100644
--- a/crates/parser/src/grammar/patterns.rs
+++ b/crates/parser/src/grammar/patterns.rs
@@ -73,7 +73,7 @@ fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) {
 
         // FIXME: support half_open_range_patterns (`..=2`),
         // exclusive_range_pattern (`..5`) with missing lhs
-        for &range_op in [T![...], T![..=], T![..]].iter() {
+        for range_op in [T![...], T![..=], T![..]] {
             if p.at(range_op) {
                 let m = lhs.precede(p);
                 p.bump(range_op);
diff --git a/crates/paths/src/lib.rs b/crates/paths/src/lib.rs
index 90909f4e8ea..41731c8d27b 100644
--- a/crates/paths/src/lib.rs
+++ b/crates/paths/src/lib.rs
@@ -271,7 +271,7 @@ impl RelPath {
 /// Taken from <https://github.com/rust-lang/cargo/blob/79c769c3d7b4c2cf6a93781575b7f592ef974255/src/cargo/util/paths.rs#L60-L85>
 fn normalize_path(path: &Path) -> PathBuf {
     let mut components = path.components().peekable();
-    let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().cloned() {
+    let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().copied() {
         components.next();
         PathBuf::from(c.as_os_str())
     } else {
diff --git a/crates/proc_macro_api/src/msg/flat.rs b/crates/proc_macro_api/src/msg/flat.rs
index 01a8345bdf7..8437444e183 100644
--- a/crates/proc_macro_api/src/msg/flat.rs
+++ b/crates/proc_macro_api/src/msg/flat.rs
@@ -246,7 +246,7 @@ impl<'a> Writer<'a> {
 
     fn enqueue(&mut self, subtree: &'a tt::Subtree) -> u32 {
         let idx = self.subtree.len();
-        let delimiter_id = subtree.delimiter.map(|it| it.id).unwrap_or_else(TokenId::unspecified);
+        let delimiter_id = subtree.delimiter.map_or(TokenId::unspecified(), |it| it.id);
         let delimiter_kind = subtree.delimiter.map(|it| it.kind);
         self.subtree.push(SubtreeRepr { id: delimiter_id, kind: delimiter_kind, tt: [!0, !0] });
         self.work.push_back((idx, subtree));
diff --git a/crates/profile/src/hprof.rs b/crates/profile/src/hprof.rs
index db2f33d0650..b562c193e71 100644
--- a/crates/profile/src/hprof.rs
+++ b/crates/profile/src/hprof.rs
@@ -301,7 +301,7 @@ fn print(
         }
     }
 
-    for (child_msg, (duration, count)) in short_children.iter() {
+    for (child_msg, (duration, count)) in &short_children {
         writeln!(out, "    {}{} - {} ({} calls)", current_indent, ms(*duration), child_msg, count)
             .expect("printing profiling info");
     }
diff --git a/crates/syntax/src/algo.rs b/crates/syntax/src/algo.rs
index 7043d2e35ab..bce02971c61 100644
--- a/crates/syntax/src/algo.rs
+++ b/crates/syntax/src/algo.rs
@@ -112,14 +112,14 @@ impl TreeDiff {
     pub fn into_text_edit(&self, builder: &mut TextEditBuilder) {
         let _p = profile::span("into_text_edit");
 
-        for (anchor, to) in self.insertions.iter() {
+        for (anchor, to) in &self.insertions {
             let offset = match anchor {
                 TreeDiffInsertPos::After(it) => it.text_range().end(),
                 TreeDiffInsertPos::AsFirstChild(it) => it.text_range().start(),
             };
             to.iter().for_each(|to| builder.insert(offset, to.to_string()));
         }
-        for (from, to) in self.replacements.iter() {
+        for (from, to) in &self.replacements {
             builder.replace(from.text_range(), to.to_string());
         }
         for text_range in self.deletions.iter().map(SyntaxElement::text_range) {
@@ -217,9 +217,8 @@ pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff {
                             cov_mark::hit!(diff_insertions);
                             insert = true;
                             break;
-                        } else {
-                            look_ahead_scratch.push(rhs_child);
                         }
+                        look_ahead_scratch.push(rhs_child);
                     }
                     let drain = look_ahead_scratch.drain(..);
                     if insert {
diff --git a/crates/syntax/src/ast/edit_in_place.rs b/crates/syntax/src/ast/edit_in_place.rs
index 61f1265290a..c20b81d7e95 100644
--- a/crates/syntax/src/ast/edit_in_place.rs
+++ b/crates/syntax/src/ast/edit_in_place.rs
@@ -275,7 +275,7 @@ impl ast::PathSegment {
 
 impl ast::UseTree {
     pub fn remove(&self) {
-        for &dir in [Direction::Next, Direction::Prev].iter() {
+        for dir in [Direction::Next, Direction::Prev] {
             if let Some(next_use_tree) = neighbor(self, dir) {
                 let separators = self
                     .syntax()
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs
index 800befb04bd..00babfd394f 100644
--- a/crates/syntax/src/ast/node_ext.rs
+++ b/crates/syntax/src/ast/node_ext.rs
@@ -276,9 +276,9 @@ impl ast::Path {
 
 impl ast::Use {
     pub fn is_simple_glob(&self) -> bool {
-        self.use_tree()
-            .map(|use_tree| use_tree.use_tree_list().is_none() && use_tree.star_token().is_some())
-            .unwrap_or(false)
+        self.use_tree().map_or(false, |use_tree| {
+            use_tree.use_tree_list().is_none() && use_tree.star_token().is_some()
+        })
     }
 }
 
diff --git a/crates/syntax/src/ast/token_ext.rs b/crates/syntax/src/ast/token_ext.rs
index 003c90533e9..6946f35ea5d 100644
--- a/crates/syntax/src/ast/token_ext.rs
+++ b/crates/syntax/src/ast/token_ext.rs
@@ -688,7 +688,7 @@ impl Radix {
     pub const ALL: &'static [Radix] =
         &[Radix::Binary, Radix::Octal, Radix::Decimal, Radix::Hexadecimal];
 
-    const fn prefix_len(&self) -> usize {
+    const fn prefix_len(self) -> usize {
         match self {
             Self::Decimal => 0,
             _ => 2,
diff --git a/crates/syntax/src/parsing/text_token_source.rs b/crates/syntax/src/parsing/text_token_source.rs
index 0614194a56b..11dfc63a65b 100644
--- a/crates/syntax/src/parsing/text_token_source.rs
+++ b/crates/syntax/src/parsing/text_token_source.rs
@@ -44,8 +44,7 @@ impl<'t> TokenSource for TextTokenSource<'t> {
     fn is_keyword(&self, kw: &str) -> bool {
         self.token_offset_pairs
             .get(self.curr.1)
-            .map(|(token, offset)| &self.text[TextRange::at(*offset, token.len)] == kw)
-            .unwrap_or(false)
+            .map_or(false, |(token, offset)| &self.text[TextRange::at(*offset, token.len)] == kw)
     }
 }
 
@@ -55,8 +54,7 @@ fn mk_token(pos: usize, token_offset_pairs: &[(Token, TextSize)]) -> parser::Tok
             token.kind,
             token_offset_pairs
                 .get(pos + 1)
-                .map(|(_, next_offset)| offset + token.len == *next_offset)
-                .unwrap_or(false),
+                .map_or(false, |(_, next_offset)| offset + token.len == *next_offset),
         ),
         None => (EOF, false),
     };
diff --git a/crates/syntax/src/tests/sourcegen_ast.rs b/crates/syntax/src/tests/sourcegen_ast.rs
index c9f3c2cb8e1..d2b58774903 100644
--- a/crates/syntax/src/tests/sourcegen_ast.rs
+++ b/crates/syntax/src/tests/sourcegen_ast.rs
@@ -215,7 +215,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> String {
         .flat_map(|node| node.traits.iter().map(move |t| (t, node)))
         .into_group_map()
         .into_iter()
-        .sorted_by_key(|(k, _)| k.clone())
+        .sorted_by_key(|(k, _)| *k)
         .map(|(trait_name, nodes)| {
             let name = format_ident!("Any{}", trait_name);
             let trait_name = format_ident!("{}", trait_name);
@@ -558,12 +558,13 @@ impl Field {
 }
 
 fn lower(grammar: &Grammar) -> AstSrc {
-    let mut res = AstSrc::default();
-
-    res.tokens = "Whitespace Comment String ByteString IntNumber FloatNumber"
-        .split_ascii_whitespace()
-        .map(|it| it.to_string())
-        .collect::<Vec<_>>();
+    let mut res = AstSrc {
+        tokens: "Whitespace Comment String ByteString IntNumber FloatNumber"
+            .split_ascii_whitespace()
+            .map(|it| it.to_string())
+            .collect::<Vec<_>>(),
+        ..Default::default()
+    };
 
     let nodes = grammar.iter().collect::<Vec<_>>();
 
diff --git a/crates/test_utils/src/fixture.rs b/crates/test_utils/src/fixture.rs
index 7c5c18df742..5ea7a994b4f 100644
--- a/crates/test_utils/src/fixture.rs
+++ b/crates/test_utils/src/fixture.rs
@@ -310,7 +310,7 @@ impl MiniCore {
         // Fixed point loop to compute transitive closure of flags.
         loop {
             let mut changed = false;
-            for &(u, v) in implications.iter() {
+            for &(u, v) in &implications {
                 if self.has_flag(u) && !self.has_flag(v) {
                     self.activated_flags.push(v.to_string());
                     changed = true;
diff --git a/crates/text_edit/src/lib.rs b/crates/text_edit/src/lib.rs
index 4270d1e3081..e9700c560ad 100644
--- a/crates/text_edit/src/lib.rs
+++ b/crates/text_edit/src/lib.rs
@@ -90,13 +90,13 @@ impl TextEdit {
         }
 
         let mut total_len = TextSize::of(&*text);
-        for indel in self.indels.iter() {
+        for indel in &self.indels {
             total_len += TextSize::of(&indel.insert);
             total_len -= indel.delete.end() - indel.delete.start();
         }
         let mut buf = String::with_capacity(total_len.into());
         let mut prev = 0;
-        for indel in self.indels.iter() {
+        for indel in &self.indels {
             let start: usize = indel.delete.start().into();
             let end: usize = indel.delete.end().into();
             if start > prev {
@@ -126,7 +126,7 @@ impl TextEdit {
 
     pub fn apply_to_offset(&self, offset: TextSize) -> Option<TextSize> {
         let mut res = offset;
-        for indel in self.indels.iter() {
+        for indel in &self.indels {
             if indel.delete.start() >= offset {
                 break;
             }
diff --git a/crates/tt/src/buffer.rs b/crates/tt/src/buffer.rs
index dc577700fdd..3ce72fea854 100644
--- a/crates/tt/src/buffer.rs
+++ b/crates/tt/src/buffer.rs
@@ -194,8 +194,7 @@ impl<'a> Cursor<'a> {
                 TokenTree::Subtree(subtree) => Some(TokenTreeRef::Subtree(subtree, Some(tt))),
             },
             Some(Entry::Subtree(tt, subtree, _)) => Some(TokenTreeRef::Subtree(subtree, *tt)),
-            Some(Entry::End(_)) => None,
-            None => None,
+            Some(Entry::End(_)) | None => None,
         }
     }
 
diff --git a/crates/tt/src/lib.rs b/crates/tt/src/lib.rs
index 7e147b3fa92..9eca970ee21 100644
--- a/crates/tt/src/lib.rs
+++ b/crates/tt/src/lib.rs
@@ -161,7 +161,7 @@ impl fmt::Display for Subtree {
         };
         f.write_str(l)?;
         let mut needs_space = false;
-        for tt in self.token_trees.iter() {
+        for tt in &self.token_trees {
             if needs_space {
                 f.write_str(" ")?;
             }
@@ -215,7 +215,7 @@ impl Subtree {
             .iter()
             .map(|c| match c {
                 TokenTree::Subtree(c) => c.count(),
-                _ => 0,
+                TokenTree::Leaf(_) => 0,
             })
             .sum::<usize>();
 
diff --git a/crates/vfs-notify/src/lib.rs b/crates/vfs-notify/src/lib.rs
index bcad0edf642..a2a53cdc9eb 100644
--- a/crates/vfs-notify/src/lib.rs
+++ b/crates/vfs-notify/src/lib.rs
@@ -174,7 +174,7 @@ impl NotifyActor {
             loader::Entry::Directories(dirs) => {
                 let mut res = Vec::new();
 
-                for root in dirs.include.iter() {
+                for root in &dirs.include {
                     let walkdir =
                         WalkDir::new(root).follow_links(true).into_iter().filter_entry(|entry| {
                             if !entry.file_type().is_dir() {
diff --git a/crates/vfs/src/vfs_path.rs b/crates/vfs/src/vfs_path.rs
index 75dca8a57e5..39a16664211 100644
--- a/crates/vfs/src/vfs_path.rs
+++ b/crates/vfs/src/vfs_path.rs
@@ -73,9 +73,8 @@ impl VfsPath {
     pub fn starts_with(&self, other: &VfsPath) -> bool {
         match (&self.0, &other.0) {
             (VfsPathRepr::PathBuf(lhs), VfsPathRepr::PathBuf(rhs)) => lhs.starts_with(rhs),
-            (VfsPathRepr::PathBuf(_), _) => false,
             (VfsPathRepr::VirtualPath(lhs), VfsPathRepr::VirtualPath(rhs)) => lhs.starts_with(rhs),
-            (VfsPathRepr::VirtualPath(_), _) => false,
+            (VfsPathRepr::PathBuf(_) | VfsPathRepr::VirtualPath(_), _) => false,
         }
     }
 
diff --git a/xtask/src/release.rs b/xtask/src/release.rs
index e4f540d27f5..d0ddf27b4df 100644
--- a/xtask/src/release.rs
+++ b/xtask/src/release.rs
@@ -33,15 +33,13 @@ impl flags::Release {
         let commit = cmd!("git rev-parse HEAD").read()?;
         let changelog_n = read_dir(changelog_dir.as_path())?.len();
 
-        for &adoc in [
+        for adoc in [
             "manual.adoc",
             "generated_assists.adoc",
             "generated_config.adoc",
             "generated_diagnostic.adoc",
             "generated_features.adoc",
-        ]
-        .iter()
-        {
+        ] {
             let src = project_root().join("./docs/user/").join(adoc);
             let dst = website_root.join(adoc);