diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-21 15:49:31 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-21 15:49:31 +0000 |
commit | d51cf133f68eec63eee27a8666c7590d2e8b4ef8 (patch) | |
tree | cd74909ed13e4a697459bf66afffcb06d89820cd /crates/mbe | |
parent | 5bb65bb4962cfad613e9744a340ae23b533f479e (diff) | |
parent | 202b51bc7b6999900e06ec2cfb8d72fe9aa4af29 (diff) |
Merge #8135
8135: more clippy::{perf, complexity, style} fixes r=Veykril a=matthiaskrgr
Co-authored-by: Matthias Krüger <[email protected]>
Diffstat (limited to 'crates/mbe')
-rw-r--r-- | crates/mbe/src/expander/matcher.rs | 9 | ||||
-rw-r--r-- | crates/mbe/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/mbe/src/parser.rs | 2 | ||||
-rw-r--r-- | crates/mbe/src/syntax_bridge.rs | 2 | ||||
-rw-r--r-- | crates/mbe/src/tests/expand.rs | 3 |
5 files changed, 8 insertions, 10 deletions
diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs index 1682b21b0..75d2f2eed 100644 --- a/crates/mbe/src/expander/matcher.rs +++ b/crates/mbe/src/expander/matcher.rs | |||
@@ -304,7 +304,7 @@ impl BindingsBuilder { | |||
304 | link_nodes: &'a Vec<LinkNode<Rc<BindingKind>>>, | 304 | link_nodes: &'a Vec<LinkNode<Rc<BindingKind>>>, |
305 | nodes: &mut Vec<&'a Rc<BindingKind>>, | 305 | nodes: &mut Vec<&'a Rc<BindingKind>>, |
306 | ) { | 306 | ) { |
307 | link_nodes.into_iter().for_each(|it| match it { | 307 | link_nodes.iter().for_each(|it| match it { |
308 | LinkNode::Node(it) => nodes.push(it), | 308 | LinkNode::Node(it) => nodes.push(it), |
309 | LinkNode::Parent { idx, len } => self.collect_nodes_ref(*idx, *len, nodes), | 309 | LinkNode::Parent { idx, len } => self.collect_nodes_ref(*idx, *len, nodes), |
310 | }); | 310 | }); |
@@ -713,10 +713,9 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen | |||
713 | .map(|ident| Some(tt::Leaf::from(ident.clone()).into())) | 713 | .map(|ident| Some(tt::Leaf::from(ident.clone()).into())) |
714 | .map_err(|()| err!("expected ident")), | 714 | .map_err(|()| err!("expected ident")), |
715 | "tt" => input.expect_tt().map(Some).map_err(|()| err!()), | 715 | "tt" => input.expect_tt().map(Some).map_err(|()| err!()), |
716 | "lifetime" => input | 716 | "lifetime" => { |
717 | .expect_lifetime() | 717 | input.expect_lifetime().map(Some).map_err(|()| err!("expected lifetime")) |
718 | .map(|tt| Some(tt)) | 718 | } |
719 | .map_err(|()| err!("expected lifetime")), | ||
720 | "literal" => { | 719 | "literal" => { |
721 | let neg = input.eat_char('-'); | 720 | let neg = input.eat_char('-'); |
722 | input | 721 | input |
diff --git a/crates/mbe/src/lib.rs b/crates/mbe/src/lib.rs index 33b85e23d..e74f8cf3f 100644 --- a/crates/mbe/src/lib.rs +++ b/crates/mbe/src/lib.rs | |||
@@ -356,6 +356,6 @@ impl<T> ExpandResult<T> { | |||
356 | 356 | ||
357 | impl<T: Default> From<Result<T, ExpandError>> for ExpandResult<T> { | 357 | impl<T: Default> From<Result<T, ExpandError>> for ExpandResult<T> { |
358 | fn from(result: Result<T, ExpandError>) -> Self { | 358 | fn from(result: Result<T, ExpandError>) -> Self { |
359 | result.map_or_else(|e| Self::only_err(e), |it| Self::ok(it)) | 359 | result.map_or_else(Self::only_err, Self::ok) |
360 | } | 360 | } |
361 | } | 361 | } |
diff --git a/crates/mbe/src/parser.rs b/crates/mbe/src/parser.rs index c88387653..61b2a4955 100644 --- a/crates/mbe/src/parser.rs +++ b/crates/mbe/src/parser.rs | |||
@@ -57,7 +57,7 @@ impl<'a> Iterator for OpDelimitedIter<'a> { | |||
57 | 57 | ||
58 | fn size_hint(&self) -> (usize, Option<usize>) { | 58 | fn size_hint(&self) -> (usize, Option<usize>) { |
59 | let len = self.inner.len() + if self.delimited.is_some() { 2 } else { 0 }; | 59 | let len = self.inner.len() + if self.delimited.is_some() { 2 } else { 0 }; |
60 | let remain = len.checked_sub(self.idx).unwrap_or(0); | 60 | let remain = len.saturating_sub(self.idx); |
61 | (remain, Some(remain)) | 61 | (remain, Some(remain)) |
62 | } | 62 | } |
63 | } | 63 | } |
diff --git a/crates/mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs index 8bba3d3d5..9d433b3b0 100644 --- a/crates/mbe/src/syntax_bridge.rs +++ b/crates/mbe/src/syntax_bridge.rs | |||
@@ -362,7 +362,7 @@ trait TokenConvertor { | |||
362 | if let Some((kind, closed)) = delim { | 362 | if let Some((kind, closed)) = delim { |
363 | let mut subtree = tt::Subtree::default(); | 363 | let mut subtree = tt::Subtree::default(); |
364 | let (id, idx) = self.id_alloc().open_delim(range); | 364 | let (id, idx) = self.id_alloc().open_delim(range); |
365 | subtree.delimiter = Some(tt::Delimiter { kind, id }); | 365 | subtree.delimiter = Some(tt::Delimiter { id, kind }); |
366 | 366 | ||
367 | while self.peek().map(|it| it.kind() != closed).unwrap_or(false) { | 367 | while self.peek().map(|it| it.kind() != closed).unwrap_or(false) { |
368 | self.collect_leaf(&mut subtree.token_trees); | 368 | self.collect_leaf(&mut subtree.token_trees); |
diff --git a/crates/mbe/src/tests/expand.rs b/crates/mbe/src/tests/expand.rs index 2cce62781..8951f3813 100644 --- a/crates/mbe/src/tests/expand.rs +++ b/crates/mbe/src/tests/expand.rs | |||
@@ -1225,8 +1225,7 @@ macro_rules! m { | |||
1225 | ) | 1225 | ) |
1226 | .expand_statements(r#"m!(C("0"))"#) | 1226 | .expand_statements(r#"m!(C("0"))"#) |
1227 | .descendants() | 1227 | .descendants() |
1228 | .find(|token| token.kind() == ERROR) | 1228 | .any(|token| token.kind() == ERROR)); |
1229 | .is_some()); | ||
1230 | } | 1229 | } |
1231 | 1230 | ||
1232 | #[test] | 1231 | #[test] |