Skip to content

Commit

Permalink
clippy::filter_map_identity
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Jul 25, 2021
1 parent 066eb6a commit 053aedc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ impl<T> PerNS<Option<T>> {

/// Returns an iterator over the items which are `Some`.
pub fn present_items(self) -> impl Iterator<Item = T> {
IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).filter_map(|it| it)
IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).flatten()
}
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,8 +1107,7 @@ impl<'a> Parser<'a> {
e
})?;

let enum_definition =
EnumDef { variants: variants.into_iter().filter_map(|v| v).collect() };
let enum_definition = EnumDef { variants: variants.into_iter().flatten().collect() };
Ok((id, ItemKind::Enum(enum_definition, generics)))
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ fn fn_sig_suggestion<'tcx>(
})
})
.chain(std::iter::once(if sig.c_variadic { Some("...".to_string()) } else { None }))
.filter_map(|arg| arg)
.flatten()
.collect::<Vec<String>>()
.join(", ");
let output = sig.output();
Expand Down

0 comments on commit 053aedc

Please sign in to comment.