diff options
author | Igor Aleksanov <[email protected]> | 2020-08-10 13:05:01 +0100 |
---|---|---|
committer | Igor Aleksanov <[email protected]> | 2020-08-10 13:05:01 +0100 |
commit | 6344a7f362b19eaf71547766135ece160aa3389e (patch) | |
tree | 53dc390d807291f62c1f249f571b36b760e096f5 /crates | |
parent | f3336509e52187a7a70a8043557a7317872e3a2f (diff) |
Fix clippy warnings
Diffstat (limited to 'crates')
-rw-r--r-- | crates/expect/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/flycheck/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_arena/src/map.rs | 10 | ||||
-rw-r--r-- | crates/ra_mbe/src/mbe_expander/matcher.rs | 2 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/expressions/atom.rs | 8 | ||||
-rw-r--r-- | crates/ra_proc_macro/src/process.rs | 2 | ||||
-rw-r--r-- | crates/ra_text_edit/src/lib.rs | 13 | ||||
-rw-r--r-- | crates/ra_tt/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/stdx/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/vfs/src/file_set.rs | 3 |
10 files changed, 29 insertions, 23 deletions
diff --git a/crates/expect/src/lib.rs b/crates/expect/src/lib.rs index 21a458d47..bd83895f7 100644 --- a/crates/expect/src/lib.rs +++ b/crates/expect/src/lib.rs | |||
@@ -74,7 +74,7 @@ impl fmt::Display for Position { | |||
74 | impl Expect { | 74 | impl Expect { |
75 | pub fn assert_eq(&self, actual: &str) { | 75 | pub fn assert_eq(&self, actual: &str) { |
76 | let trimmed = self.trimmed(); | 76 | let trimmed = self.trimmed(); |
77 | if &trimmed == actual { | 77 | if trimmed == actual { |
78 | return; | 78 | return; |
79 | } | 79 | } |
80 | Runtime::fail_expect(self, &trimmed, actual); | 80 | Runtime::fail_expect(self, &trimmed, actual); |
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 7c38f5ef9..36e0e085a 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs | |||
@@ -108,7 +108,7 @@ struct FlycheckActor { | |||
108 | 108 | ||
109 | enum Event { | 109 | enum Event { |
110 | Restart(Restart), | 110 | Restart(Restart), |
111 | CheckEvent(Option<cargo_metadata::Message>), | 111 | CheckEvent(Option<Box<cargo_metadata::Message>>), |
112 | } | 112 | } |
113 | 113 | ||
114 | impl FlycheckActor { | 114 | impl FlycheckActor { |
@@ -123,7 +123,7 @@ impl FlycheckActor { | |||
123 | let check_chan = self.cargo_handle.as_ref().map(|cargo| &cargo.receiver); | 123 | let check_chan = self.cargo_handle.as_ref().map(|cargo| &cargo.receiver); |
124 | select! { | 124 | select! { |
125 | recv(inbox) -> msg => msg.ok().map(Event::Restart), | 125 | recv(inbox) -> msg => msg.ok().map(Event::Restart), |
126 | recv(check_chan.unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok())), | 126 | recv(check_chan.unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok().map(Box::new))), |
127 | } | 127 | } |
128 | } | 128 | } |
129 | fn run(mut self, inbox: Receiver<Restart>) { | 129 | fn run(mut self, inbox: Receiver<Restart>) { |
@@ -149,7 +149,7 @@ impl FlycheckActor { | |||
149 | let res = cargo_handle.join(); | 149 | let res = cargo_handle.join(); |
150 | self.send(Message::Progress(Progress::DidFinish(res))); | 150 | self.send(Message::Progress(Progress::DidFinish(res))); |
151 | } | 151 | } |
152 | Event::CheckEvent(Some(message)) => match message { | 152 | Event::CheckEvent(Some(message)) => match *message { |
153 | cargo_metadata::Message::CompilerArtifact(msg) => { | 153 | cargo_metadata::Message::CompilerArtifact(msg) => { |
154 | self.send(Message::Progress(Progress::DidCheckCrate(msg.target.name))); | 154 | self.send(Message::Progress(Progress::DidCheckCrate(msg.target.name))); |
155 | } | 155 | } |
diff --git a/crates/ra_arena/src/map.rs b/crates/ra_arena/src/map.rs index 0f33907c0..c1b58712c 100644 --- a/crates/ra_arena/src/map.rs +++ b/crates/ra_arena/src/map.rs | |||
@@ -13,18 +13,18 @@ pub struct ArenaMap<ID, V> { | |||
13 | 13 | ||
14 | impl<T, V> ArenaMap<Idx<T>, V> { | 14 | impl<T, V> ArenaMap<Idx<T>, V> { |
15 | pub fn insert(&mut self, id: Idx<T>, t: V) { | 15 | pub fn insert(&mut self, id: Idx<T>, t: V) { |
16 | let idx = Self::to_idx(id); | 16 | let idx = Self::into_idx(id); |
17 | 17 | ||
18 | self.v.resize_with((idx + 1).max(self.v.len()), || None); | 18 | self.v.resize_with((idx + 1).max(self.v.len()), || None); |
19 | self.v[idx] = Some(t); | 19 | self.v[idx] = Some(t); |
20 | } | 20 | } |
21 | 21 | ||
22 | pub fn get(&self, id: Idx<T>) -> Option<&V> { | 22 | pub fn get(&self, id: Idx<T>) -> Option<&V> { |
23 | self.v.get(Self::to_idx(id)).and_then(|it| it.as_ref()) | 23 | self.v.get(Self::into_idx(id)).and_then(|it| it.as_ref()) |
24 | } | 24 | } |
25 | 25 | ||
26 | pub fn get_mut(&mut self, id: Idx<T>) -> Option<&mut V> { | 26 | pub fn get_mut(&mut self, id: Idx<T>) -> Option<&mut V> { |
27 | self.v.get_mut(Self::to_idx(id)).and_then(|it| it.as_mut()) | 27 | self.v.get_mut(Self::into_idx(id)).and_then(|it| it.as_mut()) |
28 | } | 28 | } |
29 | 29 | ||
30 | pub fn values(&self) -> impl Iterator<Item = &V> { | 30 | pub fn values(&self) -> impl Iterator<Item = &V> { |
@@ -39,7 +39,7 @@ impl<T, V> ArenaMap<Idx<T>, V> { | |||
39 | self.v.iter().enumerate().filter_map(|(idx, o)| Some((Self::from_idx(idx), o.as_ref()?))) | 39 | self.v.iter().enumerate().filter_map(|(idx, o)| Some((Self::from_idx(idx), o.as_ref()?))) |
40 | } | 40 | } |
41 | 41 | ||
42 | fn to_idx(id: Idx<T>) -> usize { | 42 | fn into_idx(id: Idx<T>) -> usize { |
43 | u32::from(id.into_raw()) as usize | 43 | u32::from(id.into_raw()) as usize |
44 | } | 44 | } |
45 | 45 | ||
@@ -51,7 +51,7 @@ impl<T, V> ArenaMap<Idx<T>, V> { | |||
51 | impl<T, V> std::ops::Index<Idx<V>> for ArenaMap<Idx<V>, T> { | 51 | impl<T, V> std::ops::Index<Idx<V>> for ArenaMap<Idx<V>, T> { |
52 | type Output = T; | 52 | type Output = T; |
53 | fn index(&self, id: Idx<V>) -> &T { | 53 | fn index(&self, id: Idx<V>) -> &T { |
54 | self.v[Self::to_idx(id)].as_ref().unwrap() | 54 | self.v[Self::into_idx(id)].as_ref().unwrap() |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
diff --git a/crates/ra_mbe/src/mbe_expander/matcher.rs b/crates/ra_mbe/src/mbe_expander/matcher.rs index f9e515b81..933a3a3b5 100644 --- a/crates/ra_mbe/src/mbe_expander/matcher.rs +++ b/crates/ra_mbe/src/mbe_expander/matcher.rs | |||
@@ -276,7 +276,7 @@ impl<'a> TtIter<'a> { | |||
276 | Ok(tt::Subtree { | 276 | Ok(tt::Subtree { |
277 | delimiter: None, | 277 | delimiter: None, |
278 | token_trees: vec![ | 278 | token_trees: vec![ |
279 | tt::Leaf::Punct(punct.clone()).into(), | 279 | tt::Leaf::Punct(*punct).into(), |
280 | tt::Leaf::Ident(ident.clone()).into(), | 280 | tt::Leaf::Ident(ident.clone()).into(), |
281 | ], | 281 | ], |
282 | } | 282 | } |
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index 0b01d3bc6..ca6569c9f 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs | |||
@@ -243,12 +243,10 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker { | |||
243 | // test lambda_ret_block | 243 | // test lambda_ret_block |
244 | // fn main() { || -> i32 { 92 }(); } | 244 | // fn main() { || -> i32 { 92 }(); } |
245 | block_expr(p); | 245 | block_expr(p); |
246 | } else if p.at_ts(EXPR_FIRST) { | ||
247 | expr(p); | ||
246 | } else { | 248 | } else { |
247 | if p.at_ts(EXPR_FIRST) { | 249 | p.error("expected expression"); |
248 | expr(p); | ||
249 | } else { | ||
250 | p.error("expected expression"); | ||
251 | } | ||
252 | } | 250 | } |
253 | m.complete(p, CLOSURE_EXPR) | 251 | m.complete(p, CLOSURE_EXPR) |
254 | } | 252 | } |
diff --git a/crates/ra_proc_macro/src/process.rs b/crates/ra_proc_macro/src/process.rs index 5bcdacb48..37dd3f496 100644 --- a/crates/ra_proc_macro/src/process.rs +++ b/crates/ra_proc_macro/src/process.rs | |||
@@ -90,7 +90,7 @@ impl ProcMacroProcessSrv { | |||
90 | } | 90 | } |
91 | Some(it) => it, | 91 | Some(it) => it, |
92 | }; | 92 | }; |
93 | sender.send(Task { req: req.into(), result_tx }).unwrap(); | 93 | sender.send(Task { req, result_tx }).unwrap(); |
94 | let res = result_rx | 94 | let res = result_rx |
95 | .recv() | 95 | .recv() |
96 | .map_err(|_| ra_tt::ExpansionError::Unknown("Proc macro thread is closed.".into()))?; | 96 | .map_err(|_| ra_tt::ExpansionError::Unknown("Proc macro thread is closed.".into()))?; |
diff --git a/crates/ra_text_edit/src/lib.rs b/crates/ra_text_edit/src/lib.rs index 25554f583..d68791cf1 100644 --- a/crates/ra_text_edit/src/lib.rs +++ b/crates/ra_text_edit/src/lib.rs | |||
@@ -76,10 +76,6 @@ impl TextEdit { | |||
76 | self.indels.iter() | 76 | self.indels.iter() |
77 | } | 77 | } |
78 | 78 | ||
79 | pub fn into_iter(self) -> vec::IntoIter<Indel> { | ||
80 | self.indels.into_iter() | ||
81 | } | ||
82 | |||
83 | pub fn apply(&self, text: &mut String) { | 79 | pub fn apply(&self, text: &mut String) { |
84 | match self.len() { | 80 | match self.len() { |
85 | 0 => return, | 81 | 0 => return, |
@@ -141,6 +137,15 @@ impl TextEdit { | |||
141 | } | 137 | } |
142 | } | 138 | } |
143 | 139 | ||
140 | impl IntoIterator for TextEdit { | ||
141 | type Item = Indel; | ||
142 | type IntoIter = vec::IntoIter<Self::Item>; | ||
143 | |||
144 | fn into_iter(self) -> Self::IntoIter { | ||
145 | self.indels.into_iter() | ||
146 | } | ||
147 | } | ||
148 | |||
144 | impl TextEditBuilder { | 149 | impl TextEditBuilder { |
145 | pub fn replace(&mut self, range: TextRange, replace_with: String) { | 150 | pub fn replace(&mut self, range: TextRange, replace_with: String) { |
146 | self.indels.push(Indel::replace(range, replace_with)) | 151 | self.indels.push(Indel::replace(range, replace_with)) |
diff --git a/crates/ra_tt/src/lib.rs b/crates/ra_tt/src/lib.rs index 8faf1cc67..20c3f5eab 100644 --- a/crates/ra_tt/src/lib.rs +++ b/crates/ra_tt/src/lib.rs | |||
@@ -107,7 +107,7 @@ fn print_debug_subtree(f: &mut fmt::Formatter<'_>, subtree: &Subtree, level: usi | |||
107 | for (idx, child) in subtree.token_trees.iter().enumerate() { | 107 | for (idx, child) in subtree.token_trees.iter().enumerate() { |
108 | print_debug_token(f, child, level + 1)?; | 108 | print_debug_token(f, child, level + 1)?; |
109 | if idx != subtree.token_trees.len() - 1 { | 109 | if idx != subtree.token_trees.len() - 1 { |
110 | writeln!(f, "")?; | 110 | writeln!(f)?; |
111 | } | 111 | } |
112 | } | 112 | } |
113 | } | 113 | } |
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index b65875c96..00bfcd29e 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs | |||
@@ -10,7 +10,7 @@ pub fn is_ci() -> bool { | |||
10 | 10 | ||
11 | pub trait SepBy: Sized { | 11 | pub trait SepBy: Sized { |
12 | /// Returns an `impl fmt::Display`, which joins elements via a separator. | 12 | /// Returns an `impl fmt::Display`, which joins elements via a separator. |
13 | fn sep_by<'a>(self, sep: &'a str) -> SepByBuilder<'a, Self>; | 13 | fn sep_by(self, sep: &str) -> SepByBuilder<'_, Self>; |
14 | } | 14 | } |
15 | 15 | ||
16 | impl<I> SepBy for I | 16 | impl<I> SepBy for I |
@@ -18,7 +18,7 @@ where | |||
18 | I: Iterator, | 18 | I: Iterator, |
19 | I::Item: fmt::Display, | 19 | I::Item: fmt::Display, |
20 | { | 20 | { |
21 | fn sep_by<'a>(self, sep: &'a str) -> SepByBuilder<'a, Self> { | 21 | fn sep_by(self, sep: &str) -> SepByBuilder<'_, Self> { |
22 | SepByBuilder::new(sep, self) | 22 | SepByBuilder::new(sep, self) |
23 | } | 23 | } |
24 | } | 24 | } |
diff --git a/crates/vfs/src/file_set.rs b/crates/vfs/src/file_set.rs index e9196fcd2..9f11268ee 100644 --- a/crates/vfs/src/file_set.rs +++ b/crates/vfs/src/file_set.rs | |||
@@ -19,6 +19,9 @@ impl FileSet { | |||
19 | pub fn len(&self) -> usize { | 19 | pub fn len(&self) -> usize { |
20 | self.files.len() | 20 | self.files.len() |
21 | } | 21 | } |
22 | pub fn is_empty(&self) -> bool { | ||
23 | self.len() == 0 | ||
24 | } | ||
22 | pub fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> { | 25 | pub fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> { |
23 | let mut base = self.paths[&anchor].clone(); | 26 | let mut base = self.paths[&anchor].clone(); |
24 | base.pop(); | 27 | base.pop(); |