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)));
|
||||
let body = self.collect_expr_opt(e.body());
|
||||
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,
|
||||
)
|
||||
}
|
||||
|
@ -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));
|
||||
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);
|
||||
scopes.add_params_bindings(body, scope, args);
|
||||
compute_expr_scopes(*body_expr, body, scopes, &mut scope);
|
||||
|
@ -165,7 +165,7 @@ pub enum Expr {
|
||||
base: ExprId,
|
||||
index: ExprId,
|
||||
},
|
||||
Lambda {
|
||||
Closure {
|
||||
args: Box<[PatId]>,
|
||||
arg_types: Box<[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);
|
||||
}
|
||||
}
|
||||
Expr::Lambda { body, .. } => {
|
||||
Expr::Closure { body, .. } => {
|
||||
f(*body);
|
||||
}
|
||||
Expr::BinaryOp { lhs, rhs, .. } => {
|
||||
|
@ -218,7 +218,7 @@ fn infer_expr_inner(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty {
|
||||
self.diverges = Diverges::Maybe;
|
||||
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());
|
||||
|
||||
let mut sig_tys = Vec::new();
|
||||
@ -1058,7 +1058,7 @@ fn check_call_arguments(
|
||||
for (idx, ((&arg, param_ty), expected_ty)) in
|
||||
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 {
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user