Make ExprKind::Closure
a struct variant.
This commit is contained in:
parent
fa68e73e99
commit
3039cfeb6a
75 changed files with 251 additions and 216 deletions
|
@ -1084,11 +1084,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
let hir = self.tcx.hir();
|
||||
Some(match node {
|
||||
Node::Expr(&hir::Expr {
|
||||
kind: hir::ExprKind::Closure(_, ref _decl, id, span, _),
|
||||
kind: hir::ExprKind::Closure { body, fn_decl_span, .. },
|
||||
..
|
||||
}) => (
|
||||
sm.guess_head_span(span),
|
||||
hir.body(id)
|
||||
sm.guess_head_span(fn_decl_span),
|
||||
hir.body(body)
|
||||
.params
|
||||
.iter()
|
||||
.map(|arg| {
|
||||
|
|
|
@ -103,10 +103,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
})
|
||||
}),
|
||||
hir::Node::Expr(hir::Expr {
|
||||
kind: hir::ExprKind::Closure(_is_move, _, body_id, _, gen_movability),
|
||||
kind: hir::ExprKind::Closure { body, movability, .. },
|
||||
..
|
||||
}) => self.describe_generator(*body_id).or_else(|| {
|
||||
Some(if gen_movability.is_some() { "an async closure" } else { "a closure" })
|
||||
}) => self.describe_generator(*body).or_else(|| {
|
||||
Some(if movability.is_some() { "an async closure" } else { "a closure" })
|
||||
}),
|
||||
hir::Node::Expr(hir::Expr { .. }) => {
|
||||
let parent_hid = hir.get_parent_node(hir_id);
|
||||
|
|
|
@ -775,14 +775,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
// Get the name of the callable and the arguments to be used in the suggestion.
|
||||
let (snippet, sugg) = match hir.get_if_local(def_id) {
|
||||
Some(hir::Node::Expr(hir::Expr {
|
||||
kind: hir::ExprKind::Closure(_, decl, _, span, ..),
|
||||
kind: hir::ExprKind::Closure { fn_decl, fn_decl_span, .. },
|
||||
..
|
||||
})) => {
|
||||
err.span_label(*span, "consider calling this closure");
|
||||
err.span_label(*fn_decl_span, "consider calling this closure");
|
||||
let Some(name) = self.get_closure_name(def_id, err, &msg) else {
|
||||
return false;
|
||||
};
|
||||
let args = decl.inputs.iter().map(|_| "_").collect::<Vec<_>>().join(", ");
|
||||
let args = fn_decl.inputs.iter().map(|_| "_").collect::<Vec<_>>().join(", ");
|
||||
let sugg = format!("({})", args);
|
||||
(format!("{}{}", name, sugg), sugg)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue