From 202b51bc7b6999900e06ec2cfb8d72fe9aa4af29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 21 Mar 2021 15:33:18 +0100 Subject: a lot of clippy::style fixes --- crates/mbe/src/expander/matcher.rs | 9 ++++----- crates/mbe/src/lib.rs | 2 +- crates/mbe/src/parser.rs | 2 +- crates/mbe/src/syntax_bridge.rs | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) (limited to 'crates/mbe') 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 { link_nodes: &'a Vec>>, nodes: &mut Vec<&'a Rc>, ) { - link_nodes.into_iter().for_each(|it| match it { + link_nodes.iter().for_each(|it| match it { LinkNode::Node(it) => nodes.push(it), LinkNode::Parent { idx, len } => self.collect_nodes_ref(*idx, *len, nodes), }); @@ -713,10 +713,9 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult input.expect_tt().map(Some).map_err(|()| err!()), - "lifetime" => input - .expect_lifetime() - .map(|tt| Some(tt)) - .map_err(|()| err!("expected lifetime")), + "lifetime" => { + input.expect_lifetime().map(Some).map_err(|()| err!("expected lifetime")) + } "literal" => { let neg = input.eat_char('-'); 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 ExpandResult { impl From> for ExpandResult { fn from(result: Result) -> Self { - result.map_or_else(|e| Self::only_err(e), |it| Self::ok(it)) + result.map_or_else(Self::only_err, Self::ok) } } 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> { fn size_hint(&self) -> (usize, Option) { let len = self.inner.len() + if self.delimited.is_some() { 2 } else { 0 }; - let remain = len.checked_sub(self.idx).unwrap_or(0); + let remain = len.saturating_sub(self.idx); (remain, Some(remain)) } } 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 { if let Some((kind, closed)) = delim { let mut subtree = tt::Subtree::default(); let (id, idx) = self.id_alloc().open_delim(range); - subtree.delimiter = Some(tt::Delimiter { kind, id }); + subtree.delimiter = Some(tt::Delimiter { id, kind }); while self.peek().map(|it| it.kind() != closed).unwrap_or(false) { self.collect_leaf(&mut subtree.token_trees); -- cgit v1.2.3