Skip to content

Commit 633aace

Browse files
committed
Rename LambdaExpr -> ClosureExpr
1 parent bfcee63 commit 633aace

File tree

19 files changed

+59
-54
lines changed

19 files changed

+59
-54
lines changed

crates/ra_assists/src/handlers/extract_variable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use ra_syntax::{
22
ast::{self, AstNode},
33
SyntaxKind::{
4-
BLOCK_EXPR, BREAK_EXPR, COMMENT, LAMBDA_EXPR, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR,
4+
BLOCK_EXPR, BREAK_EXPR, CLOSURE_EXPR, COMMENT, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR,
55
},
66
SyntaxNode,
77
};
@@ -148,7 +148,7 @@ impl Anchor {
148148
}
149149

150150
if let Some(parent) = node.parent() {
151-
if parent.kind() == MATCH_ARM || parent.kind() == LAMBDA_EXPR {
151+
if parent.kind() == MATCH_ARM || parent.kind() == CLOSURE_EXPR {
152152
return Some(Anchor::WrapInBlock(node));
153153
}
154154
}

crates/ra_hir_def/src/body/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ impl ExprCollector<'_> {
473473
self.alloc_expr(Expr::Missing, syntax_ptr)
474474
}
475475
}
476-
ast::Expr::LambdaExpr(e) => {
476+
ast::Expr::ClosureExpr(e) => {
477477
let mut args = Vec::new();
478478
let mut arg_types = Vec::new();
479479
if let Some(pl) = e.param_list() {

crates/ra_hir_expand/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ fn to_fragment_kind(db: &dyn AstDatabase, id: MacroCallId) -> FragmentKind {
379379

380380
FOR_EXPR => FragmentKind::Expr,
381381
PATH_EXPR => FragmentKind::Expr,
382-
LAMBDA_EXPR => FragmentKind::Expr,
382+
CLOSURE_EXPR => FragmentKind::Expr,
383383
CONDITION => FragmentKind::Expr,
384384
BREAK_EXPR => FragmentKind::Expr,
385385
RETURN_EXPR => FragmentKind::Expr,

crates/ra_ide/src/completion/patterns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub(crate) fn is_in_loop_body(element: SyntaxElement) -> bool {
134134
NodeOrToken::Token(token) => token.parent(),
135135
};
136136
for node in leaf.ancestors() {
137-
if node.kind() == FN || node.kind() == LAMBDA_EXPR {
137+
if node.kind() == FN || node.kind() == CLOSURE_EXPR {
138138
break;
139139
}
140140
let loop_body = match_ast! {

crates/ra_parser/src/grammar/expressions/atom.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker {
250250
p.error("expected expression");
251251
}
252252
}
253-
m.complete(p, LAMBDA_EXPR)
253+
m.complete(p, CLOSURE_EXPR)
254254
}
255255

256256
// test if_expr

crates/ra_parser/src/syntax_kind/generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub enum SyntaxKind {
173173
ARRAY_EXPR,
174174
PAREN_EXPR,
175175
PATH_EXPR,
176-
LAMBDA_EXPR,
176+
CLOSURE_EXPR,
177177
IF_EXPR,
178178
WHILE_EXPR,
179179
CONDITION,

crates/ra_syntax/src/ast/generated/nodes.rs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,7 @@ pub struct BinExpr {
582582
pub(crate) syntax: SyntaxNode,
583583
}
584584
impl ast::AttrsOwner for BinExpr {}
585-
impl BinExpr {
586-
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
587-
}
585+
impl BinExpr {}
588586
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
589587
pub struct BoxExpr {
590588
pub(crate) syntax: SyntaxNode,
@@ -680,17 +678,14 @@ impl ast::AttrsOwner for IfExpr {}
680678
impl IfExpr {
681679
pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
682680
pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
683-
pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
684681
pub fn else_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![else]) }
685-
pub fn if_expr(&self) -> Option<IfExpr> { support::child(&self.syntax) }
686682
}
687683
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
688684
pub struct IndexExpr {
689685
pub(crate) syntax: SyntaxNode,
690686
}
691687
impl ast::AttrsOwner for IndexExpr {}
692688
impl IndexExpr {
693-
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
694689
pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
695690
pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
696691
}
@@ -704,11 +699,11 @@ impl Label {
704699
}
705700
}
706701
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
707-
pub struct LambdaExpr {
702+
pub struct ClosureExpr {
708703
pub(crate) syntax: SyntaxNode,
709704
}
710-
impl ast::AttrsOwner for LambdaExpr {}
711-
impl LambdaExpr {
705+
impl ast::AttrsOwner for ClosureExpr {}
706+
impl ClosureExpr {
712707
pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
713708
pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
714709
pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) }
@@ -778,9 +773,7 @@ pub struct RangeExpr {
778773
pub(crate) syntax: SyntaxNode,
779774
}
780775
impl ast::AttrsOwner for RangeExpr {}
781-
impl RangeExpr {
782-
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
783-
}
776+
impl RangeExpr {}
784777
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
785778
pub struct RecordExpr {
786779
pub(crate) syntax: SyntaxNode,
@@ -1351,7 +1344,7 @@ pub enum Expr {
13511344
IfExpr(IfExpr),
13521345
IndexExpr(IndexExpr),
13531346
Label(Label),
1354-
LambdaExpr(LambdaExpr),
1347+
ClosureExpr(ClosureExpr),
13551348
Literal(Literal),
13561349
LoopExpr(LoopExpr),
13571350
MacroCall(MacroCall),
@@ -2101,8 +2094,8 @@ impl AstNode for Label {
21012094
}
21022095
fn syntax(&self) -> &SyntaxNode { &self.syntax }
21032096
}
2104-
impl AstNode for LambdaExpr {
2105-
fn can_cast(kind: SyntaxKind) -> bool { kind == LAMBDA_EXPR }
2097+
impl AstNode for ClosureExpr {
2098+
fn can_cast(kind: SyntaxKind) -> bool { kind == CLOSURE_EXPR }
21062099
fn cast(syntax: SyntaxNode) -> Option<Self> {
21072100
if Self::can_cast(syntax.kind()) {
21082101
Some(Self { syntax })
@@ -3114,8 +3107,8 @@ impl From<IndexExpr> for Expr {
31143107
impl From<Label> for Expr {
31153108
fn from(node: Label) -> Expr { Expr::Label(node) }
31163109
}
3117-
impl From<LambdaExpr> for Expr {
3118-
fn from(node: LambdaExpr) -> Expr { Expr::LambdaExpr(node) }
3110+
impl From<ClosureExpr> for Expr {
3111+
fn from(node: ClosureExpr) -> Expr { Expr::ClosureExpr(node) }
31193112
}
31203113
impl From<Literal> for Expr {
31213114
fn from(node: Literal) -> Expr { Expr::Literal(node) }
@@ -3167,7 +3160,7 @@ impl AstNode for Expr {
31673160
match kind {
31683161
ARRAY_EXPR | AWAIT_EXPR | BIN_EXPR | BLOCK_EXPR | BOX_EXPR | BREAK_EXPR | CALL_EXPR
31693162
| CAST_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR | IF_EXPR
3170-
| INDEX_EXPR | LABEL | LAMBDA_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR
3163+
| INDEX_EXPR | LABEL | CLOSURE_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR
31713164
| METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR
31723165
| RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true,
31733166
_ => false,
@@ -3190,7 +3183,7 @@ impl AstNode for Expr {
31903183
IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
31913184
INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
31923185
LABEL => Expr::Label(Label { syntax }),
3193-
LAMBDA_EXPR => Expr::LambdaExpr(LambdaExpr { syntax }),
3186+
CLOSURE_EXPR => Expr::ClosureExpr(ClosureExpr { syntax }),
31943187
LITERAL => Expr::Literal(Literal { syntax }),
31953188
LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }),
31963189
MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
@@ -3227,7 +3220,7 @@ impl AstNode for Expr {
32273220
Expr::IfExpr(it) => &it.syntax,
32283221
Expr::IndexExpr(it) => &it.syntax,
32293222
Expr::Label(it) => &it.syntax,
3230-
Expr::LambdaExpr(it) => &it.syntax,
3223+
Expr::ClosureExpr(it) => &it.syntax,
32313224
Expr::Literal(it) => &it.syntax,
32323225
Expr::LoopExpr(it) => &it.syntax,
32333226
Expr::MacroCall(it) => &it.syntax,
@@ -3757,7 +3750,7 @@ impl std::fmt::Display for Label {
37573750
std::fmt::Display::fmt(self.syntax(), f)
37583751
}
37593752
}
3760-
impl std::fmt::Display for LambdaExpr {
3753+
impl std::fmt::Display for ClosureExpr {
37613754
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37623755
std::fmt::Display::fmt(self.syntax(), f)
37633756
}

crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ SOURCE_FILE@0..42
1212
L_CURLY@10..11 "{"
1313
WHITESPACE@11..16 "\n "
1414
EXPR_STMT@16..24
15-
LAMBDA_EXPR@16..24
15+
CLOSURE_EXPR@16..24
1616
PARAM_LIST@16..18
1717
PIPE@16..17 "|"
1818
PIPE@17..18 "|"

crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ SOURCE_FILE@0..389
117117
WHITESPACE@140..141
118118
EQ@141..142
119119
WHITESPACE@142..143
120-
LAMBDA_EXPR@143..389
120+
CLOSURE_EXPR@143..389
121121
PARAM_LIST@143..388
122122
PIPE@143..144
123123
PARAM@144..159

crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ SOURCE_FILE@0..83
4949
IDENT@48..51 "map"
5050
ARG_LIST@51..57
5151
L_PAREN@51..52 "("
52-
LAMBDA_EXPR@52..56
52+
CLOSURE_EXPR@52..56
5353
PARAM_LIST@52..56
5454
PIPE@52..53 "|"
5555
PARAM@53..55

0 commit comments

Comments
 (0)