use if let Some(x) = .. instead of ...map(|x|) to conditionally run fns that return () (clippy::option_map_unit_fn)
This commit is contained in:
parent
b7795e135a
commit
5833f74a9c
2 changed files with 23 additions and 23 deletions
|
@ -616,8 +616,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
debug!("stmt_expr Break val block_context.push(SubExpr)");
|
debug!("stmt_expr Break val block_context.push(SubExpr)");
|
||||||
self.block_context.push(BlockFrame::SubExpr);
|
self.block_context.push(BlockFrame::SubExpr);
|
||||||
unpack!(block = self.into(destination, dest_scope, block, value));
|
unpack!(block = self.into(destination, dest_scope, block, value));
|
||||||
dest_scope
|
if let Some(scope) = dest_scope {
|
||||||
.map(|scope| self.unschedule_drop(scope, destination.as_local().unwrap()));
|
self.unschedule_drop(scope, destination.as_local().unwrap())
|
||||||
|
};
|
||||||
self.block_context.pop();
|
self.block_context.pop();
|
||||||
} else {
|
} else {
|
||||||
self.cfg.push_assign_unit(block, source_info, destination, self.hir.tcx())
|
self.cfg.push_assign_unit(block, source_info, destination, self.hir.tcx())
|
||||||
|
|
|
@ -1448,31 +1448,30 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
typeck_results
|
if let Some(cause) = typeck_results
|
||||||
.generator_interior_types
|
.generator_interior_types
|
||||||
.iter()
|
.iter()
|
||||||
.find(|ty::GeneratorInteriorTypeCause { ty, .. }| ty_matches(ty))
|
.find(|ty::GeneratorInteriorTypeCause { ty, .. }| ty_matches(ty))
|
||||||
.map(|cause| {
|
{
|
||||||
// Check to see if any awaited expressions have the target type.
|
// Check to see if any awaited expressions have the target type.
|
||||||
let from_awaited_ty = visitor
|
let from_awaited_ty = visitor
|
||||||
.awaits
|
.awaits
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|id| hir.expect_expr(id))
|
.map(|id| hir.expect_expr(id))
|
||||||
.find(|await_expr| {
|
.find(|await_expr| {
|
||||||
let ty = typeck_results.expr_ty_adjusted(&await_expr);
|
let ty = typeck_results.expr_ty_adjusted(&await_expr);
|
||||||
debug!(
|
debug!(
|
||||||
"maybe_note_obligation_cause_for_async_await: await_expr={:?}",
|
"maybe_note_obligation_cause_for_async_await: await_expr={:?}",
|
||||||
await_expr
|
await_expr
|
||||||
);
|
);
|
||||||
ty_matches(ty)
|
ty_matches(ty)
|
||||||
})
|
})
|
||||||
.map(|expr| expr.span);
|
.map(|expr| expr.span);
|
||||||
let ty::GeneratorInteriorTypeCause { span, scope_span, yield_span, expr, .. } =
|
let ty::GeneratorInteriorTypeCause { span, scope_span, yield_span, expr, .. } = cause;
|
||||||
cause;
|
|
||||||
|
|
||||||
interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior(*span));
|
interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior(*span));
|
||||||
interior_extra_info = Some((*scope_span, *yield_span, *expr, from_awaited_ty));
|
interior_extra_info = Some((*scope_span, *yield_span, *expr, from_awaited_ty));
|
||||||
});
|
};
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
"maybe_note_obligation_cause_for_async_await: interior_or_upvar={:?} \
|
"maybe_note_obligation_cause_for_async_await: interior_or_upvar={:?} \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue