Skip to content

Commit ed37d80

Browse files
authored
Rollup merge of rust-lang#55476 - ljedrz:flat_map_to_filter_map, r=cramertj
Change a flat_map with 0/1-element vecs to a filter_map No need to use vectors in this case - `Option`s are quite sufficient.
2 parents 3176239 + bb3e77d commit ed37d80

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: src/librustc_traits/implied_outlives_bounds.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,14 @@ fn implied_bounds_from_components(
159159
) -> Vec<OutlivesBound<'tcx>> {
160160
sup_components
161161
.into_iter()
162-
.flat_map(|component| {
162+
.filter_map(|component| {
163163
match component {
164164
Component::Region(r) =>
165-
vec![OutlivesBound::RegionSubRegion(sub_region, r)],
165+
Some(OutlivesBound::RegionSubRegion(sub_region, r)),
166166
Component::Param(p) =>
167-
vec![OutlivesBound::RegionSubParam(sub_region, p)],
167+
Some(OutlivesBound::RegionSubParam(sub_region, p)),
168168
Component::Projection(p) =>
169-
vec![OutlivesBound::RegionSubProjection(sub_region, p)],
169+
Some(OutlivesBound::RegionSubProjection(sub_region, p)),
170170
Component::EscapingProjection(_) =>
171171
// If the projection has escaping regions, don't
172172
// try to infer any implied bounds even for its
@@ -176,9 +176,9 @@ fn implied_bounds_from_components(
176176
// idea is that the WAY that the caller proves
177177
// that may change in the future and we want to
178178
// give ourselves room to get smarter here.
179-
vec![],
179+
None,
180180
Component::UnresolvedInferenceVariable(..) =>
181-
vec![],
181+
None,
182182
}
183183
})
184184
.collect()

0 commit comments

Comments
 (0)