Make ExprKind::Closure
a struct variant.
This commit is contained in:
parent
fa68e73e99
commit
3039cfeb6a
75 changed files with 251 additions and 216 deletions
|
@ -991,22 +991,24 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
if let Some(node_ty) = self.opt_node_type(expr.hir_id) {
|
||||
if let (&ExprKind::Closure(_, decl, body_id, span, _), ty::Closure(_, substs)) =
|
||||
(&expr.kind, node_ty.kind())
|
||||
if let (
|
||||
&ExprKind::Closure { fn_decl, body, fn_decl_span, .. },
|
||||
ty::Closure(_, substs),
|
||||
) = (&expr.kind, node_ty.kind())
|
||||
{
|
||||
let output = substs.as_closure().sig().output().skip_binder();
|
||||
if self.generic_arg_contains_target(output.into()) {
|
||||
let body = self.infcx.tcx.hir().body(body_id);
|
||||
let body = self.infcx.tcx.hir().body(body);
|
||||
let should_wrap_expr = if matches!(body.value.kind, ExprKind::Block(..)) {
|
||||
None
|
||||
} else {
|
||||
Some(body.value.span.shrink_to_hi())
|
||||
};
|
||||
self.update_infer_source(InferSource {
|
||||
span,
|
||||
span: fn_decl_span,
|
||||
kind: InferSourceKind::ClosureReturn {
|
||||
ty: output,
|
||||
data: &decl.output,
|
||||
data: &fn_decl.output,
|
||||
should_wrap_expr,
|
||||
},
|
||||
})
|
||||
|
|
|
@ -55,7 +55,7 @@ pub fn find_param_with_region<'tcx>(
|
|||
|
||||
// Don't perform this on closures
|
||||
match hir.get(hir_id) {
|
||||
hir::Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(..), .. }) => {
|
||||
hir::Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure { .. }, .. }) => {
|
||||
return None;
|
||||
}
|
||||
_ => {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue