Skip to content

Commit 9e0aab7

Browse files
committed
Use filter_map instead of flat_map in configure_tokens.
All the branches produce either zero or one elements.
1 parent 9f16f1f commit 9e0aab7

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

compiler/rustc_expand/src/config.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -185,22 +185,22 @@ impl<'a> StripUnconfigured<'a> {
185185
let trees: Vec<_> = stream
186186
.0
187187
.iter()
188-
.flat_map(|tree| match tree.clone() {
188+
.filter_map(|tree| match tree.clone() {
189189
AttrTokenTree::AttrsTarget(mut target) => {
190190
target.attrs.flat_map_in_place(|attr| self.process_cfg_attr(&attr));
191191

192192
if self.in_cfg(&target.attrs) {
193193
target.tokens = LazyAttrTokenStream::new(
194194
self.configure_tokens(&target.tokens.to_attr_token_stream()),
195195
);
196-
Some(AttrTokenTree::AttrsTarget(target)).into_iter()
196+
Some(AttrTokenTree::AttrsTarget(target))
197197
} else {
198-
None.into_iter()
198+
None
199199
}
200200
}
201201
AttrTokenTree::Delimited(sp, spacing, delim, mut inner) => {
202202
inner = self.configure_tokens(&inner);
203-
Some(AttrTokenTree::Delimited(sp, spacing, delim, inner)).into_iter()
203+
Some(AttrTokenTree::Delimited(sp, spacing, delim, inner))
204204
}
205205
AttrTokenTree::Token(
206206
Token {
@@ -220,9 +220,7 @@ impl<'a> StripUnconfigured<'a> {
220220
) => {
221221
panic!("Should be `AttrTokenTree::Delimited`, not delim tokens: {:?}", tree);
222222
}
223-
AttrTokenTree::Token(token, spacing) => {
224-
Some(AttrTokenTree::Token(token, spacing)).into_iter()
225-
}
223+
AttrTokenTree::Token(token, spacing) => Some(AttrTokenTree::Token(token, spacing)),
226224
})
227225
.collect();
228226
AttrTokenStream::new(trees)

0 commit comments

Comments
 (0)