use filter(|x| matches!(..)) instead of filter_map(|x| match x ... => Some(xy))
This commit is contained in:
parent
3cd3bbecc5
commit
ed7e438f87
2 changed files with 12 additions and 24 deletions
|
@ -887,10 +887,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||||
let (lifetimes, binders): (FxIndexMap<hir::ParamName, Region>, Vec<_>) = c
|
let (lifetimes, binders): (FxIndexMap<hir::ParamName, Region>, Vec<_>) = c
|
||||||
.generic_params
|
.generic_params
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|param| match param.kind {
|
.filter(|param| matches!(param.kind, GenericParamKind::Lifetime { .. }))
|
||||||
GenericParamKind::Lifetime { .. } => Some(param),
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(late_bound_idx, param)| {
|
.map(|(late_bound_idx, param)| {
|
||||||
let pair = Region::late(late_bound_idx as u32, &self.tcx.hir(), param);
|
let pair = Region::late(late_bound_idx as u32, &self.tcx.hir(), param);
|
||||||
|
@ -1370,9 +1367,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||||
let (lifetimes, binders): (FxIndexMap<hir::ParamName, Region>, Vec<_>) =
|
let (lifetimes, binders): (FxIndexMap<hir::ParamName, Region>, Vec<_>) =
|
||||||
bound_generic_params
|
bound_generic_params
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|param| match param.kind {
|
.filter(|param| {
|
||||||
GenericParamKind::Lifetime { .. } => Some(param),
|
matches!(param.kind, GenericParamKind::Lifetime { .. })
|
||||||
_ => None,
|
|
||||||
})
|
})
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(late_bound_idx, param)| {
|
.map(|(late_bound_idx, param)| {
|
||||||
|
@ -1469,10 +1465,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||||
let binders_iter = trait_ref
|
let binders_iter = trait_ref
|
||||||
.bound_generic_params
|
.bound_generic_params
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|param| match param.kind {
|
.filter(|param| matches!(param.kind, GenericParamKind::Lifetime { .. }))
|
||||||
GenericParamKind::Lifetime { .. } => Some(param),
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(late_bound_idx, param)| {
|
.map(|(late_bound_idx, param)| {
|
||||||
let pair = Region::late(
|
let pair = Region::late(
|
||||||
|
@ -2237,19 +2230,14 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
let binders: Vec<_> = generics
|
let binders: Vec<_> = generics
|
||||||
.params
|
.params
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|param| match param.kind {
|
.filter(|param| {
|
||||||
GenericParamKind::Lifetime { .. }
|
matches!(param.kind, GenericParamKind::Lifetime { .. })
|
||||||
if self.map.late_bound.contains(¶m.hir_id) =>
|
&& self.map.late_bound.contains(¶m.hir_id)
|
||||||
{
|
|
||||||
Some(param)
|
|
||||||
}
|
|
||||||
_ => None,
|
|
||||||
})
|
})
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(late_bound_idx, param)| {
|
.map(|(late_bound_idx, param)| {
|
||||||
let pair = Region::late(late_bound_idx as u32, &self.tcx.hir(), param);
|
let pair = Region::late(late_bound_idx as u32, &self.tcx.hir(), param);
|
||||||
let r = late_region_as_bound_region(self.tcx, &pair.1);
|
late_region_as_bound_region(self.tcx, &pair.1)
|
||||||
r
|
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
self.map.late_bound_vars.insert(hir_id, binders);
|
self.map.late_bound_vars.insert(hir_id, binders);
|
||||||
|
|
|
@ -180,14 +180,14 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
||||||
|
|
||||||
let coerced_fields = fields
|
let coerced_fields = fields
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|field| {
|
.filter(|field| {
|
||||||
let ty_a = field.ty(tcx, substs_a);
|
let ty_a = field.ty(tcx, substs_a);
|
||||||
let ty_b = field.ty(tcx, substs_b);
|
let ty_b = field.ty(tcx, substs_b);
|
||||||
|
|
||||||
if let Ok(layout) = tcx.layout_of(param_env.and(ty_a)) {
|
if let Ok(layout) = tcx.layout_of(param_env.and(ty_a)) {
|
||||||
if layout.is_zst() && layout.align.abi.bytes() == 1 {
|
if layout.is_zst() && layout.align.abi.bytes() == 1 {
|
||||||
// ignore ZST fields with alignment of 1 byte
|
// ignore ZST fields with alignment of 1 byte
|
||||||
return None;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,11 +204,11 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
||||||
))
|
))
|
||||||
.emit();
|
.emit();
|
||||||
|
|
||||||
return None;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(field)
|
return true;
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue