diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-17 08:12:34 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-17 08:12:34 +0000 |
commit | f7fbea509f1e5f840e715c912ee38aa997d1bfbc (patch) | |
tree | 2b4932678fc83624c278ca93cdf0f1d3a28346c2 /crates/mbe/src/benchmark.rs | |
parent | 6fcb5d772f16af0d1f62dad55fbde75072fb9e89 (diff) | |
parent | ff5f90d8ae2da8e4856d5c78f55e5cd02b178325 (diff) |
Merge #8063
8063: couple clippy::complexity fixes r=matklad a=matthiaskrgr
avoid redundant `.into()` calls to convert T into identical T (`let x: String = String::from("hello").into();`)
use `if let Some(x)` instead of `.is_some()` + `.unwrap()`
don't clone Copy types
remove redundant wrapped ?s: `Some(Some(3)?)` can just be `Some(3)`
use `.map(|x| y)` instead of `and_then(|x| Some(y)` on `Option`s
Co-authored-by: Matthias Krüger <[email protected]>
Diffstat (limited to 'crates/mbe/src/benchmark.rs')
-rw-r--r-- | crates/mbe/src/benchmark.rs | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/crates/mbe/src/benchmark.rs b/crates/mbe/src/benchmark.rs index 503ad1355..ba814a2e1 100644 --- a/crates/mbe/src/benchmark.rs +++ b/crates/mbe/src/benchmark.rs | |||
@@ -120,7 +120,7 @@ fn invocation_fixtures(rules: &FxHashMap<String, MacroRules>) -> Vec<(String, tt | |||
120 | Some("pat") => parent.token_trees.push(make_ident("foo")), | 120 | Some("pat") => parent.token_trees.push(make_ident("foo")), |
121 | Some("path") => parent.token_trees.push(make_ident("foo")), | 121 | Some("path") => parent.token_trees.push(make_ident("foo")), |
122 | Some("literal") => parent.token_trees.push(make_literal("1")), | 122 | Some("literal") => parent.token_trees.push(make_literal("1")), |
123 | Some("expr") => parent.token_trees.push(make_ident("foo").into()), | 123 | Some("expr") => parent.token_trees.push(make_ident("foo")), |
124 | Some("lifetime") => { | 124 | Some("lifetime") => { |
125 | parent.token_trees.push(make_punct('\'')); | 125 | parent.token_trees.push(make_punct('\'')); |
126 | parent.token_trees.push(make_ident("a")); | 126 | parent.token_trees.push(make_ident("a")); |
@@ -157,17 +157,15 @@ fn invocation_fixtures(rules: &FxHashMap<String, MacroRules>) -> Vec<(String, tt | |||
157 | if i + 1 != cnt { | 157 | if i + 1 != cnt { |
158 | if let Some(sep) = separator { | 158 | if let Some(sep) = separator { |
159 | match sep { | 159 | match sep { |
160 | Separator::Literal(it) => parent | 160 | Separator::Literal(it) => { |
161 | .token_trees | 161 | parent.token_trees.push(tt::Leaf::Literal(it.clone()).into()) |
162 | .push(tt::Leaf::Literal(it.clone().into()).into()), | 162 | } |
163 | Separator::Ident(it) => parent | 163 | Separator::Ident(it) => { |
164 | .token_trees | 164 | parent.token_trees.push(tt::Leaf::Ident(it.clone()).into()) |
165 | .push(tt::Leaf::Ident(it.clone().into()).into()), | 165 | } |
166 | Separator::Puncts(puncts) => { | 166 | Separator::Puncts(puncts) => { |
167 | for it in puncts { | 167 | for it in puncts { |
168 | parent | 168 | parent.token_trees.push(tt::Leaf::Punct(*it).into()) |
169 | .token_trees | ||
170 | .push(tt::Leaf::Punct(it.clone().into()).into()) | ||
171 | } | 169 | } |
172 | } | 170 | } |
173 | }; | 171 | }; |
@@ -176,8 +174,7 @@ fn invocation_fixtures(rules: &FxHashMap<String, MacroRules>) -> Vec<(String, tt | |||
176 | } | 174 | } |
177 | } | 175 | } |
178 | Op::Subtree { tokens, delimiter } => { | 176 | Op::Subtree { tokens, delimiter } => { |
179 | let mut subtree = | 177 | let mut subtree = tt::Subtree { delimiter: *delimiter, token_trees: Vec::new() }; |
180 | tt::Subtree { delimiter: delimiter.clone(), token_trees: Vec::new() }; | ||
181 | tokens.iter().for_each(|it| { | 178 | tokens.iter().for_each(|it| { |
182 | collect_from_op(it, &mut subtree, seed); | 179 | collect_from_op(it, &mut subtree, seed); |
183 | }); | 180 | }); |