Minor
This commit is contained in:
parent
c1e53d668f
commit
7980a7e19a
@ -241,7 +241,6 @@ fn get_tail_expr_from_block(expr: &Expr) -> Option<Vec<NodeType>> {
|
||||
Expr::ArrayExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
||||
Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
||||
Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
||||
Expr::Label(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
||||
Expr::RecordExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
||||
Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
||||
Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
||||
|
@ -569,9 +569,6 @@ fn collect_expr(&mut self, expr: ast::Expr) -> ExprId {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME implement HIR for these:
|
||||
ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -624,6 +624,19 @@ pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![
|
||||
pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ClosureExpr {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl ast::AttrsOwner for ClosureExpr {}
|
||||
impl ClosureExpr {
|
||||
pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
|
||||
pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
|
||||
pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) }
|
||||
pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
|
||||
pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
|
||||
pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ContinueExpr {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
@ -690,28 +703,6 @@ pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax
|
||||
pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Label {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl Label {
|
||||
pub fn lifetime_token(&self) -> Option<SyntaxToken> {
|
||||
support::token(&self.syntax, T![lifetime])
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ClosureExpr {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl ast::AttrsOwner for ClosureExpr {}
|
||||
impl ClosureExpr {
|
||||
pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
|
||||
pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
|
||||
pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) }
|
||||
pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
|
||||
pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
|
||||
pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct LoopExpr {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
@ -835,6 +826,15 @@ pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax,
|
||||
pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Label {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl Label {
|
||||
pub fn lifetime_token(&self) -> Option<SyntaxToken> {
|
||||
support::token(&self.syntax, T![lifetime])
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct RecordExprFieldList {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
@ -1337,14 +1337,13 @@ pub enum Expr {
|
||||
BreakExpr(BreakExpr),
|
||||
CallExpr(CallExpr),
|
||||
CastExpr(CastExpr),
|
||||
ClosureExpr(ClosureExpr),
|
||||
ContinueExpr(ContinueExpr),
|
||||
EffectExpr(EffectExpr),
|
||||
FieldExpr(FieldExpr),
|
||||
ForExpr(ForExpr),
|
||||
IfExpr(IfExpr),
|
||||
IndexExpr(IndexExpr),
|
||||
Label(Label),
|
||||
ClosureExpr(ClosureExpr),
|
||||
Literal(Literal),
|
||||
LoopExpr(LoopExpr),
|
||||
MacroCall(MacroCall),
|
||||
@ -2017,6 +2016,17 @@ fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for ClosureExpr {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == CLOSURE_EXPR }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for ContinueExpr {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
@ -2083,28 +2093,6 @@ fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for Label {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for ClosureExpr {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == CLOSURE_EXPR }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for LoopExpr {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
@ -2248,6 +2236,17 @@ fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for Label {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for RecordExprFieldList {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD_LIST }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
@ -3086,6 +3085,9 @@ fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) }
|
||||
impl From<CastExpr> for Expr {
|
||||
fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) }
|
||||
}
|
||||
impl From<ClosureExpr> for Expr {
|
||||
fn from(node: ClosureExpr) -> Expr { Expr::ClosureExpr(node) }
|
||||
}
|
||||
impl From<ContinueExpr> for Expr {
|
||||
fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) }
|
||||
}
|
||||
@ -3104,12 +3106,6 @@ fn from(node: IfExpr) -> Expr { Expr::IfExpr(node) }
|
||||
impl From<IndexExpr> for Expr {
|
||||
fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) }
|
||||
}
|
||||
impl From<Label> for Expr {
|
||||
fn from(node: Label) -> Expr { Expr::Label(node) }
|
||||
}
|
||||
impl From<ClosureExpr> for Expr {
|
||||
fn from(node: ClosureExpr) -> Expr { Expr::ClosureExpr(node) }
|
||||
}
|
||||
impl From<Literal> for Expr {
|
||||
fn from(node: Literal) -> Expr { Expr::Literal(node) }
|
||||
}
|
||||
@ -3159,8 +3155,8 @@ impl AstNode for Expr {
|
||||
fn can_cast(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
ARRAY_EXPR | AWAIT_EXPR | BIN_EXPR | BLOCK_EXPR | BOX_EXPR | BREAK_EXPR | CALL_EXPR
|
||||
| CAST_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR | IF_EXPR
|
||||
| INDEX_EXPR | LABEL | CLOSURE_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR
|
||||
| CAST_EXPR | CLOSURE_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR
|
||||
| IF_EXPR | INDEX_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR
|
||||
| METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR
|
||||
| RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true,
|
||||
_ => false,
|
||||
@ -3176,14 +3172,13 @@ fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }),
|
||||
CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
|
||||
CAST_EXPR => Expr::CastExpr(CastExpr { syntax }),
|
||||
CLOSURE_EXPR => Expr::ClosureExpr(ClosureExpr { syntax }),
|
||||
CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }),
|
||||
EFFECT_EXPR => Expr::EffectExpr(EffectExpr { syntax }),
|
||||
FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }),
|
||||
FOR_EXPR => Expr::ForExpr(ForExpr { syntax }),
|
||||
IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
|
||||
INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
|
||||
LABEL => Expr::Label(Label { syntax }),
|
||||
CLOSURE_EXPR => Expr::ClosureExpr(ClosureExpr { syntax }),
|
||||
LITERAL => Expr::Literal(Literal { syntax }),
|
||||
LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }),
|
||||
MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
|
||||
@ -3213,14 +3208,13 @@ fn syntax(&self) -> &SyntaxNode {
|
||||
Expr::BreakExpr(it) => &it.syntax,
|
||||
Expr::CallExpr(it) => &it.syntax,
|
||||
Expr::CastExpr(it) => &it.syntax,
|
||||
Expr::ClosureExpr(it) => &it.syntax,
|
||||
Expr::ContinueExpr(it) => &it.syntax,
|
||||
Expr::EffectExpr(it) => &it.syntax,
|
||||
Expr::FieldExpr(it) => &it.syntax,
|
||||
Expr::ForExpr(it) => &it.syntax,
|
||||
Expr::IfExpr(it) => &it.syntax,
|
||||
Expr::IndexExpr(it) => &it.syntax,
|
||||
Expr::Label(it) => &it.syntax,
|
||||
Expr::ClosureExpr(it) => &it.syntax,
|
||||
Expr::Literal(it) => &it.syntax,
|
||||
Expr::LoopExpr(it) => &it.syntax,
|
||||
Expr::MacroCall(it) => &it.syntax,
|
||||
@ -3715,6 +3709,11 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for ClosureExpr {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for ContinueExpr {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
@ -3745,16 +3744,6 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for Label {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for ClosureExpr {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for LoopExpr {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
@ -3820,6 +3809,11 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for Label {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for RecordExprFieldList {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
|
@ -215,14 +215,13 @@ Expr =
|
||||
| BreakExpr
|
||||
| CallExpr
|
||||
| CastExpr
|
||||
| ClosureExpr
|
||||
| ContinueExpr
|
||||
| EffectExpr
|
||||
| FieldExpr
|
||||
| ForExpr
|
||||
| IfExpr
|
||||
| IndexExpr
|
||||
| Label
|
||||
| ClosureExpr
|
||||
| Literal
|
||||
| LoopExpr
|
||||
| MacroCall
|
||||
@ -340,7 +339,7 @@ ForExpr =
|
||||
|
||||
WhileExpr =
|
||||
Attr* Label? 'while' Condition
|
||||
loop_body:BlockExpr?
|
||||
loop_body:BlockExpr
|
||||
|
||||
Label =
|
||||
'lifetime'
|
||||
@ -418,13 +417,13 @@ SliceType =
|
||||
'[' Type ']'
|
||||
|
||||
InferType =
|
||||
'_'
|
||||
'_'
|
||||
|
||||
FnPointerType =
|
||||
'const'? 'async'? 'unsafe'? Abi? 'fn' ParamList RetType?
|
||||
'const'? 'async'? 'unsafe'? Abi? 'fn' ParamList RetType?
|
||||
|
||||
ForType =
|
||||
'for' GenericParamList Type
|
||||
'for' GenericParamList Type
|
||||
|
||||
ImplTraitType =
|
||||
'impl' TypeBoundList
|
||||
@ -433,7 +432,7 @@ DynTraitType =
|
||||
'dyn' TypeBoundList
|
||||
|
||||
TypeBoundList =
|
||||
bounds:(TypeBound ('+' TypeBound)* '+'?)
|
||||
bounds:(TypeBound ('+' TypeBound)* '+'?)
|
||||
|
||||
TypeBound =
|
||||
'lifetime'
|
||||
|
Loading…
Reference in New Issue
Block a user