Auto merge of #12327 - jonas-schievink:lambda-to-closure, r=jonas-schievink
internal: Rename `Expr::Lambda` to `Expr::Closure` They're never really called "Lambda"s in Rust, so let's call them "Closures" consistently.
This commit is contained in:
commit
c8d9a2dbdb
@ -452,7 +452,12 @@ fn maybe_collect_expr(&mut self, expr: ast::Expr) -> Option<ExprId> {
|
|||||||
.map(|it| Interned::new(TypeRef::from_ast(&self.ctx(), it)));
|
.map(|it| Interned::new(TypeRef::from_ast(&self.ctx(), it)));
|
||||||
let body = self.collect_expr_opt(e.body());
|
let body = self.collect_expr_opt(e.body());
|
||||||
self.alloc_expr(
|
self.alloc_expr(
|
||||||
Expr::Lambda { args: args.into(), arg_types: arg_types.into(), ret_type, body },
|
Expr::Closure {
|
||||||
|
args: args.into(),
|
||||||
|
arg_types: arg_types.into(),
|
||||||
|
ret_type,
|
||||||
|
body,
|
||||||
|
},
|
||||||
syntax_ptr,
|
syntax_ptr,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope
|
|||||||
let mut scope = scopes.new_labeled_scope(*scope, make_label(label));
|
let mut scope = scopes.new_labeled_scope(*scope, make_label(label));
|
||||||
compute_expr_scopes(*body_expr, body, scopes, &mut scope);
|
compute_expr_scopes(*body_expr, body, scopes, &mut scope);
|
||||||
}
|
}
|
||||||
Expr::Lambda { args, body: body_expr, .. } => {
|
Expr::Closure { args, body: body_expr, .. } => {
|
||||||
let mut scope = scopes.new_scope(*scope);
|
let mut scope = scopes.new_scope(*scope);
|
||||||
scopes.add_params_bindings(body, scope, args);
|
scopes.add_params_bindings(body, scope, args);
|
||||||
compute_expr_scopes(*body_expr, body, scopes, &mut scope);
|
compute_expr_scopes(*body_expr, body, scopes, &mut scope);
|
||||||
|
@ -165,7 +165,7 @@ pub enum Expr {
|
|||||||
base: ExprId,
|
base: ExprId,
|
||||||
index: ExprId,
|
index: ExprId,
|
||||||
},
|
},
|
||||||
Lambda {
|
Closure {
|
||||||
args: Box<[PatId]>,
|
args: Box<[PatId]>,
|
||||||
arg_types: Box<[Option<Interned<TypeRef>>]>,
|
arg_types: Box<[Option<Interned<TypeRef>>]>,
|
||||||
ret_type: Option<Interned<TypeRef>>,
|
ret_type: Option<Interned<TypeRef>>,
|
||||||
@ -286,7 +286,7 @@ pub fn walk_child_exprs(&self, mut f: impl FnMut(ExprId)) {
|
|||||||
f(expr);
|
f(expr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expr::Lambda { body, .. } => {
|
Expr::Closure { body, .. } => {
|
||||||
f(*body);
|
f(*body);
|
||||||
}
|
}
|
||||||
Expr::BinaryOp { lhs, rhs, .. } => {
|
Expr::BinaryOp { lhs, rhs, .. } => {
|
||||||
|
@ -218,7 +218,7 @@ fn infer_expr_inner(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty {
|
|||||||
self.diverges = Diverges::Maybe;
|
self.diverges = Diverges::Maybe;
|
||||||
TyBuilder::unit()
|
TyBuilder::unit()
|
||||||
}
|
}
|
||||||
Expr::Lambda { body, args, ret_type, arg_types } => {
|
Expr::Closure { body, args, ret_type, arg_types } => {
|
||||||
assert_eq!(args.len(), arg_types.len());
|
assert_eq!(args.len(), arg_types.len());
|
||||||
|
|
||||||
let mut sig_tys = Vec::new();
|
let mut sig_tys = Vec::new();
|
||||||
@ -1058,7 +1058,7 @@ fn check_call_arguments(
|
|||||||
for (idx, ((&arg, param_ty), expected_ty)) in
|
for (idx, ((&arg, param_ty), expected_ty)) in
|
||||||
args.iter().zip(param_iter).zip(expected_iter).enumerate()
|
args.iter().zip(param_iter).zip(expected_iter).enumerate()
|
||||||
{
|
{
|
||||||
let is_closure = matches!(&self.body[arg], Expr::Lambda { .. });
|
let is_closure = matches!(&self.body[arg], Expr::Closure { .. });
|
||||||
if is_closure != check_closures {
|
if is_closure != check_closures {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user