1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::priv_prelude::*;
#[allow(clippy::large_enum_variant)]
#[derive(Clone, Debug)]
pub enum Statement {
Let(StatementLet),
Item(Item),
Expr {
expr: Expr,
semicolon_token_opt: Option<SemicolonToken>,
},
}
#[derive(Clone, Debug)]
pub struct StatementLet {
pub let_token: LetToken,
pub pattern: Pattern,
pub ty_opt: Option<(ColonToken, Ty)>,
pub eq_token: EqToken,
pub expr: Expr,
pub semicolon_token: SemicolonToken,
}
impl Spanned for Statement {
fn span(&self) -> Span {
match self {
Statement::Let(statement_let) => statement_let.span(),
Statement::Item(item) => item.span(),
Statement::Expr {
expr,
semicolon_token_opt,
} => match semicolon_token_opt {
None => expr.span(),
Some(semicolon_token) => Span::join(expr.span(), semicolon_token.span()),
},
}
}
}
impl Spanned for StatementLet {
fn span(&self) -> Span {
Span::join(self.let_token.span(), self.semicolon_token.span())
}
}