mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 06:03:58 +00:00
Parse builtin# syntax
This commit is contained in:
parent
db4684ef6c
commit
9b8eb807a3
17 changed files with 264 additions and 88 deletions
|
@ -579,11 +579,6 @@ impl ExprCollector<'_> {
|
||||||
syntax_ptr,
|
syntax_ptr,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ast::Expr::BoxExpr(e) => {
|
|
||||||
let expr = self.collect_expr_opt(e.expr());
|
|
||||||
self.alloc_expr(Expr::Box { expr }, syntax_ptr)
|
|
||||||
}
|
|
||||||
|
|
||||||
ast::Expr::ArrayExpr(e) => {
|
ast::Expr::ArrayExpr(e) => {
|
||||||
let kind = e.kind();
|
let kind = e.kind();
|
||||||
|
|
||||||
|
@ -653,6 +648,9 @@ impl ExprCollector<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::Expr::UnderscoreExpr(_) => self.alloc_expr(Expr::Underscore, syntax_ptr),
|
ast::Expr::UnderscoreExpr(_) => self.alloc_expr(Expr::Underscore, syntax_ptr),
|
||||||
|
ast::Expr::AsmExpr(_) => self.missing_expr(),
|
||||||
|
ast::Expr::OffsetOfExpr(_) => self.missing_expr(),
|
||||||
|
ast::Expr::FormatArgsExpr(_) => self.missing_expr(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,6 +661,7 @@ impl ExprCollector<'_> {
|
||||||
let result_expr_id = self.alloc_expr(Expr::Missing, syntax_ptr);
|
let result_expr_id = self.alloc_expr(Expr::Missing, syntax_ptr);
|
||||||
let prev_binding_owner = self.current_binding_owner.take();
|
let prev_binding_owner = self.current_binding_owner.take();
|
||||||
self.current_binding_owner = Some(result_expr_id);
|
self.current_binding_owner = Some(result_expr_id);
|
||||||
|
|
||||||
(result_expr_id, prev_binding_owner)
|
(result_expr_id, prev_binding_owner)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,35 @@ fn main() { 0 as u32; }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_asm_expand() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
#[rustc_builtin_macro]
|
||||||
|
macro_rules! asm {() => {}}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let i: u64 = 3;
|
||||||
|
let o: u64;
|
||||||
|
unsafe {
|
||||||
|
asm!(
|
||||||
|
"mov {0}, {1}",
|
||||||
|
"add {0}, 5",
|
||||||
|
out(reg) o,
|
||||||
|
in(reg) i,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
#[rustc_builtin_macro]
|
||||||
|
macro_rules! column {() => {}}
|
||||||
|
|
||||||
|
fn main() { 0 as u32; }
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_line_expand() {
|
fn test_line_expand() {
|
||||||
check(
|
check(
|
||||||
|
|
|
@ -399,6 +399,8 @@ fn asm_expand(
|
||||||
_id: MacroCallId,
|
_id: MacroCallId,
|
||||||
tt: &tt::Subtree,
|
tt: &tt::Subtree,
|
||||||
) -> ExpandResult<tt::Subtree> {
|
) -> ExpandResult<tt::Subtree> {
|
||||||
|
// FIXME: parse asm here
|
||||||
|
|
||||||
// We expand all assembly snippets to `format_args!` invocations to get format syntax
|
// We expand all assembly snippets to `format_args!` invocations to get format syntax
|
||||||
// highlighting for them.
|
// highlighting for them.
|
||||||
|
|
||||||
|
@ -415,10 +417,12 @@ fn asm_expand(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let expanded = quote! {{
|
let pound = quote! {@PUNCT '#'};
|
||||||
##literals
|
let expanded = quote! {
|
||||||
loop {}
|
builtin #pound asm {
|
||||||
}};
|
##literals
|
||||||
|
}
|
||||||
|
};
|
||||||
ExpandResult::ok(expanded)
|
ExpandResult::ok(expanded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -620,6 +620,7 @@ impl InferenceContext<'_> {
|
||||||
| Expr::Tuple { exprs, is_assignee_expr: _ } => {
|
| Expr::Tuple { exprs, is_assignee_expr: _ } => {
|
||||||
self.consume_exprs(exprs.iter().copied())
|
self.consume_exprs(exprs.iter().copied())
|
||||||
}
|
}
|
||||||
|
|
||||||
Expr::Missing
|
Expr::Missing
|
||||||
| Expr::Continue { .. }
|
| Expr::Continue { .. }
|
||||||
| Expr::Path(_)
|
| Expr::Path(_)
|
||||||
|
|
|
@ -103,7 +103,6 @@ pub(crate) fn convert_if_to_bool_then(acc: &mut Assists, ctx: &AssistContext<'_>
|
||||||
cond,
|
cond,
|
||||||
ast::Expr::BinExpr(_)
|
ast::Expr::BinExpr(_)
|
||||||
| ast::Expr::BlockExpr(_)
|
| ast::Expr::BlockExpr(_)
|
||||||
| ast::Expr::BoxExpr(_)
|
|
||||||
| ast::Expr::BreakExpr(_)
|
| ast::Expr::BreakExpr(_)
|
||||||
| ast::Expr::CastExpr(_)
|
| ast::Expr::CastExpr(_)
|
||||||
| ast::Expr::ClosureExpr(_)
|
| ast::Expr::ClosureExpr(_)
|
||||||
|
|
|
@ -120,8 +120,7 @@ fn is_body_const(sema: &Semantics<'_, RootDatabase>, expr: &ast::Expr) -> bool {
|
||||||
is_const &=
|
is_const &=
|
||||||
sema.resolve_method_call(&call).map(|it| it.is_const(sema.db)).unwrap_or(true)
|
sema.resolve_method_call(&call).map(|it| it.is_const(sema.db)).unwrap_or(true)
|
||||||
}
|
}
|
||||||
ast::Expr::BoxExpr(_)
|
ast::Expr::ForExpr(_)
|
||||||
| ast::Expr::ForExpr(_)
|
|
||||||
| ast::Expr::ReturnExpr(_)
|
| ast::Expr::ReturnExpr(_)
|
||||||
| ast::Expr::TryExpr(_)
|
| ast::Expr::TryExpr(_)
|
||||||
| ast::Expr::YieldExpr(_)
|
| ast::Expr::YieldExpr(_)
|
||||||
|
|
|
@ -113,10 +113,7 @@ fn compute_dbg_replacement(macro_expr: ast::MacroExpr) -> Option<(TextRange, Opt
|
||||||
Some(parent) => match (expr, parent) {
|
Some(parent) => match (expr, parent) {
|
||||||
(ast::Expr::CastExpr(_), ast::Expr::CastExpr(_)) => false,
|
(ast::Expr::CastExpr(_), ast::Expr::CastExpr(_)) => false,
|
||||||
(
|
(
|
||||||
ast::Expr::BoxExpr(_)
|
ast::Expr::PrefixExpr(_) | ast::Expr::RefExpr(_) | ast::Expr::MacroExpr(_),
|
||||||
| ast::Expr::PrefixExpr(_)
|
|
||||||
| ast::Expr::RefExpr(_)
|
|
||||||
| ast::Expr::MacroExpr(_),
|
|
||||||
ast::Expr::AwaitExpr(_)
|
ast::Expr::AwaitExpr(_)
|
||||||
| ast::Expr::CallExpr(_)
|
| ast::Expr::CallExpr(_)
|
||||||
| ast::Expr::CastExpr(_)
|
| ast::Expr::CastExpr(_)
|
||||||
|
|
|
@ -103,7 +103,6 @@ pub(crate) fn for_variable(expr: &ast::Expr, sema: &Semantics<'_, RootDatabase>)
|
||||||
|
|
||||||
match expr {
|
match expr {
|
||||||
ast::Expr::RefExpr(inner) => next_expr = inner.expr(),
|
ast::Expr::RefExpr(inner) => next_expr = inner.expr(),
|
||||||
ast::Expr::BoxExpr(inner) => next_expr = inner.expr(),
|
|
||||||
ast::Expr::AwaitExpr(inner) => next_expr = inner.expr(),
|
ast::Expr::AwaitExpr(inner) => next_expr = inner.expr(),
|
||||||
// ast::Expr::BlockExpr(block) => expr = block.tail_expr(),
|
// ast::Expr::BlockExpr(block) => expr = block.tail_expr(),
|
||||||
ast::Expr::CastExpr(inner) => next_expr = inner.expr(),
|
ast::Expr::CastExpr(inner) => next_expr = inner.expr(),
|
||||||
|
|
|
@ -312,7 +312,6 @@ pub fn for_each_tail_expr(expr: &ast::Expr, cb: &mut dyn FnMut(&ast::Expr)) {
|
||||||
ast::Expr::ArrayExpr(_)
|
ast::Expr::ArrayExpr(_)
|
||||||
| ast::Expr::AwaitExpr(_)
|
| ast::Expr::AwaitExpr(_)
|
||||||
| ast::Expr::BinExpr(_)
|
| ast::Expr::BinExpr(_)
|
||||||
| ast::Expr::BoxExpr(_)
|
|
||||||
| ast::Expr::BreakExpr(_)
|
| ast::Expr::BreakExpr(_)
|
||||||
| ast::Expr::CallExpr(_)
|
| ast::Expr::CallExpr(_)
|
||||||
| ast::Expr::CastExpr(_)
|
| ast::Expr::CastExpr(_)
|
||||||
|
@ -335,7 +334,10 @@ pub fn for_each_tail_expr(expr: &ast::Expr, cb: &mut dyn FnMut(&ast::Expr)) {
|
||||||
| ast::Expr::LetExpr(_)
|
| ast::Expr::LetExpr(_)
|
||||||
| ast::Expr::UnderscoreExpr(_)
|
| ast::Expr::UnderscoreExpr(_)
|
||||||
| ast::Expr::YieldExpr(_)
|
| ast::Expr::YieldExpr(_)
|
||||||
| ast::Expr::YeetExpr(_) => cb(expr),
|
| ast::Expr::YeetExpr(_)
|
||||||
|
| ast::Expr::OffsetOfExpr(_)
|
||||||
|
| ast::Expr::FormatArgsExpr(_)
|
||||||
|
| ast::Expr::AsmExpr(_) => cb(expr),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -534,7 +534,15 @@ fn main() {
|
||||||
assert!(true, "{}", 1);
|
assert!(true, "{}", 1);
|
||||||
assert!(true, "{} asdasd", 1);
|
assert!(true, "{} asdasd", 1);
|
||||||
toho!("{}fmt", 0);
|
toho!("{}fmt", 0);
|
||||||
asm!("mov eax, {0}");
|
let i: u64 = 3;
|
||||||
|
let o: u64;
|
||||||
|
asm!(
|
||||||
|
"mov {0}, {1}",
|
||||||
|
"add {0}, 5",
|
||||||
|
out(reg) o,
|
||||||
|
in(reg) i,
|
||||||
|
);
|
||||||
|
|
||||||
format_args!(concat!("{}"), "{}");
|
format_args!(concat!("{}"), "{}");
|
||||||
format_args!("{} {} {} {} {} {}", backslash, format_args!("{}", 0), foo, "bar", toho!(), backslash);
|
format_args!("{} {} {} {} {} {}", backslash, format_args!("{}", 0), foo, "bar", toho!(), backslash);
|
||||||
}"#,
|
}"#,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use crate::grammar::types::type_;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
// test expr_literals
|
// test expr_literals
|
||||||
|
@ -73,6 +75,9 @@ pub(super) fn atom_expr(
|
||||||
if let Some(m) = literal(p) {
|
if let Some(m) = literal(p) {
|
||||||
return Some((m, BlockLike::NotBlock));
|
return Some((m, BlockLike::NotBlock));
|
||||||
}
|
}
|
||||||
|
if p.at_contextual_kw(T![builtin]) && p.nth_at(1, T![#]) {
|
||||||
|
return Some((builtin_expr(p)?, BlockLike::NotBlock));
|
||||||
|
}
|
||||||
if paths::is_path_start(p) {
|
if paths::is_path_start(p) {
|
||||||
return Some(path_expr(p, r));
|
return Some(path_expr(p, r));
|
||||||
}
|
}
|
||||||
|
@ -93,7 +98,6 @@ pub(super) fn atom_expr(
|
||||||
m.complete(p, UNDERSCORE_EXPR)
|
m.complete(p, UNDERSCORE_EXPR)
|
||||||
}
|
}
|
||||||
T![loop] => loop_expr(p, None),
|
T![loop] => loop_expr(p, None),
|
||||||
T![box] => box_expr(p, None),
|
|
||||||
T![while] => while_expr(p, None),
|
T![while] => while_expr(p, None),
|
||||||
T![try] => try_block_expr(p, None),
|
T![try] => try_block_expr(p, None),
|
||||||
T![match] => match_expr(p),
|
T![match] => match_expr(p),
|
||||||
|
@ -212,6 +216,38 @@ fn tuple_expr(p: &mut Parser<'_>) -> CompletedMarker {
|
||||||
m.complete(p, if saw_expr && !saw_comma { PAREN_EXPR } else { TUPLE_EXPR })
|
m.complete(p, if saw_expr && !saw_comma { PAREN_EXPR } else { TUPLE_EXPR })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test builtin_expr
|
||||||
|
// fn foo() {
|
||||||
|
// builtin#asm(0);
|
||||||
|
// builtin#format_args(0);
|
||||||
|
// builtin#builtin(0);
|
||||||
|
// }
|
||||||
|
fn builtin_expr(p: &mut Parser<'_>) -> Option<CompletedMarker> {
|
||||||
|
let m = p.start();
|
||||||
|
p.bump_remap(T![builtin]);
|
||||||
|
p.bump(T![#]);
|
||||||
|
if p.at_contextual_kw(T![offset_of]) {
|
||||||
|
p.expect(T!['(']);
|
||||||
|
type_(p);
|
||||||
|
p.bump(T![,]);
|
||||||
|
p.expect(T![')']);
|
||||||
|
Some(m.complete(p, OFFSET_OF_EXPR))
|
||||||
|
} else if p.at_contextual_kw(T![format_args]) {
|
||||||
|
p.expect(T!['(']);
|
||||||
|
expr(p);
|
||||||
|
p.expect(T![')']);
|
||||||
|
Some(m.complete(p, FORMAT_ARGS_EXPR))
|
||||||
|
} else if p.at_contextual_kw(T![asm]) {
|
||||||
|
p.expect(T!['(']);
|
||||||
|
expr(p);
|
||||||
|
p.expect(T![')']);
|
||||||
|
Some(m.complete(p, ASM_EXPR))
|
||||||
|
} else {
|
||||||
|
m.abandon(p);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// test array_expr
|
// test array_expr
|
||||||
// fn foo() {
|
// fn foo() {
|
||||||
// [];
|
// [];
|
||||||
|
@ -662,19 +698,3 @@ fn try_block_expr(p: &mut Parser<'_>, m: Option<Marker>) -> CompletedMarker {
|
||||||
}
|
}
|
||||||
m.complete(p, BLOCK_EXPR)
|
m.complete(p, BLOCK_EXPR)
|
||||||
}
|
}
|
||||||
|
|
||||||
// test box_expr
|
|
||||||
// fn foo() {
|
|
||||||
// let x = box 1i32;
|
|
||||||
// let y = (box 1i32, box 2i32);
|
|
||||||
// let z = Foo(box 1i32, box 2i32);
|
|
||||||
// }
|
|
||||||
fn box_expr(p: &mut Parser<'_>, m: Option<Marker>) -> CompletedMarker {
|
|
||||||
assert!(p.at(T![box]));
|
|
||||||
let m = m.unwrap_or_else(|| p.start());
|
|
||||||
p.bump(T![box]);
|
|
||||||
if p.at_ts(EXPR_FIRST) {
|
|
||||||
expr(p);
|
|
||||||
}
|
|
||||||
m.complete(p, BOX_EXPR)
|
|
||||||
}
|
|
||||||
|
|
|
@ -221,6 +221,7 @@ impl<'a> Converter<'a> {
|
||||||
rustc_lexer::TokenKind::Caret => T![^],
|
rustc_lexer::TokenKind::Caret => T![^],
|
||||||
rustc_lexer::TokenKind::Percent => T![%],
|
rustc_lexer::TokenKind::Percent => T![%],
|
||||||
rustc_lexer::TokenKind::Unknown => ERROR,
|
rustc_lexer::TokenKind::Unknown => ERROR,
|
||||||
|
rustc_lexer::TokenKind::UnknownPrefix if token_text == "builtin" => IDENT,
|
||||||
rustc_lexer::TokenKind::UnknownPrefix => {
|
rustc_lexer::TokenKind::UnknownPrefix => {
|
||||||
err = "unknown literal prefix";
|
err = "unknown literal prefix";
|
||||||
IDENT
|
IDENT
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -340,10 +340,10 @@ ExprStmt =
|
||||||
|
|
||||||
Expr =
|
Expr =
|
||||||
ArrayExpr
|
ArrayExpr
|
||||||
|
| AsmExpr
|
||||||
| AwaitExpr
|
| AwaitExpr
|
||||||
| BinExpr
|
| BinExpr
|
||||||
| BlockExpr
|
| BlockExpr
|
||||||
| BoxExpr
|
|
||||||
| BreakExpr
|
| BreakExpr
|
||||||
| CallExpr
|
| CallExpr
|
||||||
| CastExpr
|
| CastExpr
|
||||||
|
@ -351,6 +351,7 @@ Expr =
|
||||||
| ContinueExpr
|
| ContinueExpr
|
||||||
| FieldExpr
|
| FieldExpr
|
||||||
| ForExpr
|
| ForExpr
|
||||||
|
| FormatArgsExpr
|
||||||
| IfExpr
|
| IfExpr
|
||||||
| IndexExpr
|
| IndexExpr
|
||||||
| Literal
|
| Literal
|
||||||
|
@ -358,6 +359,7 @@ Expr =
|
||||||
| MacroExpr
|
| MacroExpr
|
||||||
| MatchExpr
|
| MatchExpr
|
||||||
| MethodCallExpr
|
| MethodCallExpr
|
||||||
|
| OffsetOfExpr
|
||||||
| ParenExpr
|
| ParenExpr
|
||||||
| PathExpr
|
| PathExpr
|
||||||
| PrefixExpr
|
| PrefixExpr
|
||||||
|
@ -373,6 +375,15 @@ Expr =
|
||||||
| LetExpr
|
| LetExpr
|
||||||
| UnderscoreExpr
|
| UnderscoreExpr
|
||||||
|
|
||||||
|
OffsetOfExpr =
|
||||||
|
Attr* 'builtin' '#' 'offset_of' '(' ')'
|
||||||
|
|
||||||
|
AsmExpr =
|
||||||
|
Attr* 'builtin' '#' 'asm' '(' ')'
|
||||||
|
|
||||||
|
FormatArgsExpr =
|
||||||
|
Attr* 'builtin' '#' 'format_args' '(' ')'
|
||||||
|
|
||||||
MacroExpr =
|
MacroExpr =
|
||||||
MacroCall
|
MacroCall
|
||||||
|
|
||||||
|
@ -526,9 +537,6 @@ UnderscoreExpr =
|
||||||
AwaitExpr =
|
AwaitExpr =
|
||||||
Attr* Expr '.' 'await'
|
Attr* Expr '.' 'await'
|
||||||
|
|
||||||
BoxExpr =
|
|
||||||
Attr* 'box' Expr
|
|
||||||
|
|
||||||
//*************************//
|
//*************************//
|
||||||
// Types //
|
// Types //
|
||||||
//*************************//
|
//*************************//
|
||||||
|
|
|
@ -804,6 +804,19 @@ impl ArrayExpr {
|
||||||
pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
|
pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
pub struct AsmExpr {
|
||||||
|
pub(crate) syntax: SyntaxNode,
|
||||||
|
}
|
||||||
|
impl ast::HasAttrs for AsmExpr {}
|
||||||
|
impl AsmExpr {
|
||||||
|
pub fn builtin_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![builtin]) }
|
||||||
|
pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
|
||||||
|
pub fn asm_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![asm]) }
|
||||||
|
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
|
||||||
|
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct AwaitExpr {
|
pub struct AwaitExpr {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
|
@ -822,16 +835,6 @@ pub struct BinExpr {
|
||||||
impl ast::HasAttrs for BinExpr {}
|
impl ast::HasAttrs for BinExpr {}
|
||||||
impl BinExpr {}
|
impl BinExpr {}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct BoxExpr {
|
|
||||||
pub(crate) syntax: SyntaxNode,
|
|
||||||
}
|
|
||||||
impl ast::HasAttrs for BoxExpr {}
|
|
||||||
impl BoxExpr {
|
|
||||||
pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
|
|
||||||
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct BreakExpr {
|
pub struct BreakExpr {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
|
@ -915,6 +918,21 @@ impl ForExpr {
|
||||||
pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
|
pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
pub struct FormatArgsExpr {
|
||||||
|
pub(crate) syntax: SyntaxNode,
|
||||||
|
}
|
||||||
|
impl ast::HasAttrs for FormatArgsExpr {}
|
||||||
|
impl FormatArgsExpr {
|
||||||
|
pub fn builtin_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![builtin]) }
|
||||||
|
pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
|
||||||
|
pub fn format_args_token(&self) -> Option<SyntaxToken> {
|
||||||
|
support::token(&self.syntax, T![format_args])
|
||||||
|
}
|
||||||
|
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
|
||||||
|
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct IfExpr {
|
pub struct IfExpr {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
|
@ -984,6 +1002,21 @@ impl MethodCallExpr {
|
||||||
pub fn generic_arg_list(&self) -> Option<GenericArgList> { support::child(&self.syntax) }
|
pub fn generic_arg_list(&self) -> Option<GenericArgList> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
pub struct OffsetOfExpr {
|
||||||
|
pub(crate) syntax: SyntaxNode,
|
||||||
|
}
|
||||||
|
impl ast::HasAttrs for OffsetOfExpr {}
|
||||||
|
impl OffsetOfExpr {
|
||||||
|
pub fn builtin_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![builtin]) }
|
||||||
|
pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
|
||||||
|
pub fn offset_of_token(&self) -> Option<SyntaxToken> {
|
||||||
|
support::token(&self.syntax, T![offset_of])
|
||||||
|
}
|
||||||
|
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
|
||||||
|
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct ParenExpr {
|
pub struct ParenExpr {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
|
@ -1555,10 +1588,10 @@ pub enum Type {
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum Expr {
|
pub enum Expr {
|
||||||
ArrayExpr(ArrayExpr),
|
ArrayExpr(ArrayExpr),
|
||||||
|
AsmExpr(AsmExpr),
|
||||||
AwaitExpr(AwaitExpr),
|
AwaitExpr(AwaitExpr),
|
||||||
BinExpr(BinExpr),
|
BinExpr(BinExpr),
|
||||||
BlockExpr(BlockExpr),
|
BlockExpr(BlockExpr),
|
||||||
BoxExpr(BoxExpr),
|
|
||||||
BreakExpr(BreakExpr),
|
BreakExpr(BreakExpr),
|
||||||
CallExpr(CallExpr),
|
CallExpr(CallExpr),
|
||||||
CastExpr(CastExpr),
|
CastExpr(CastExpr),
|
||||||
|
@ -1566,6 +1599,7 @@ pub enum Expr {
|
||||||
ContinueExpr(ContinueExpr),
|
ContinueExpr(ContinueExpr),
|
||||||
FieldExpr(FieldExpr),
|
FieldExpr(FieldExpr),
|
||||||
ForExpr(ForExpr),
|
ForExpr(ForExpr),
|
||||||
|
FormatArgsExpr(FormatArgsExpr),
|
||||||
IfExpr(IfExpr),
|
IfExpr(IfExpr),
|
||||||
IndexExpr(IndexExpr),
|
IndexExpr(IndexExpr),
|
||||||
Literal(Literal),
|
Literal(Literal),
|
||||||
|
@ -1573,6 +1607,7 @@ pub enum Expr {
|
||||||
MacroExpr(MacroExpr),
|
MacroExpr(MacroExpr),
|
||||||
MatchExpr(MatchExpr),
|
MatchExpr(MatchExpr),
|
||||||
MethodCallExpr(MethodCallExpr),
|
MethodCallExpr(MethodCallExpr),
|
||||||
|
OffsetOfExpr(OffsetOfExpr),
|
||||||
ParenExpr(ParenExpr),
|
ParenExpr(ParenExpr),
|
||||||
PathExpr(PathExpr),
|
PathExpr(PathExpr),
|
||||||
PrefixExpr(PrefixExpr),
|
PrefixExpr(PrefixExpr),
|
||||||
|
@ -2453,6 +2488,17 @@ impl AstNode for ArrayExpr {
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
|
impl AstNode for AsmExpr {
|
||||||
|
fn can_cast(kind: SyntaxKind) -> bool { kind == ASM_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 AwaitExpr {
|
impl AstNode for AwaitExpr {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_EXPR }
|
fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_EXPR }
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
|
@ -2475,17 +2521,6 @@ impl AstNode for BinExpr {
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl AstNode for BoxExpr {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_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 BreakExpr {
|
impl AstNode for BreakExpr {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_EXPR }
|
fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_EXPR }
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
|
@ -2563,6 +2598,17 @@ impl AstNode for ForExpr {
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
|
impl AstNode for FormatArgsExpr {
|
||||||
|
fn can_cast(kind: SyntaxKind) -> bool { kind == FORMAT_ARGS_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 IfExpr {
|
impl AstNode for IfExpr {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == IF_EXPR }
|
fn can_cast(kind: SyntaxKind) -> bool { kind == IF_EXPR }
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
|
@ -2640,6 +2686,17 @@ impl AstNode for MethodCallExpr {
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
|
impl AstNode for OffsetOfExpr {
|
||||||
|
fn can_cast(kind: SyntaxKind) -> bool { kind == OFFSET_OF_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 ParenExpr {
|
impl AstNode for ParenExpr {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_EXPR }
|
fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_EXPR }
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
|
@ -3373,6 +3430,9 @@ impl AstNode for Type {
|
||||||
impl From<ArrayExpr> for Expr {
|
impl From<ArrayExpr> for Expr {
|
||||||
fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) }
|
fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) }
|
||||||
}
|
}
|
||||||
|
impl From<AsmExpr> for Expr {
|
||||||
|
fn from(node: AsmExpr) -> Expr { Expr::AsmExpr(node) }
|
||||||
|
}
|
||||||
impl From<AwaitExpr> for Expr {
|
impl From<AwaitExpr> for Expr {
|
||||||
fn from(node: AwaitExpr) -> Expr { Expr::AwaitExpr(node) }
|
fn from(node: AwaitExpr) -> Expr { Expr::AwaitExpr(node) }
|
||||||
}
|
}
|
||||||
|
@ -3382,9 +3442,6 @@ impl From<BinExpr> for Expr {
|
||||||
impl From<BlockExpr> for Expr {
|
impl From<BlockExpr> for Expr {
|
||||||
fn from(node: BlockExpr) -> Expr { Expr::BlockExpr(node) }
|
fn from(node: BlockExpr) -> Expr { Expr::BlockExpr(node) }
|
||||||
}
|
}
|
||||||
impl From<BoxExpr> for Expr {
|
|
||||||
fn from(node: BoxExpr) -> Expr { Expr::BoxExpr(node) }
|
|
||||||
}
|
|
||||||
impl From<BreakExpr> for Expr {
|
impl From<BreakExpr> for Expr {
|
||||||
fn from(node: BreakExpr) -> Expr { Expr::BreakExpr(node) }
|
fn from(node: BreakExpr) -> Expr { Expr::BreakExpr(node) }
|
||||||
}
|
}
|
||||||
|
@ -3406,6 +3463,9 @@ impl From<FieldExpr> for Expr {
|
||||||
impl From<ForExpr> for Expr {
|
impl From<ForExpr> for Expr {
|
||||||
fn from(node: ForExpr) -> Expr { Expr::ForExpr(node) }
|
fn from(node: ForExpr) -> Expr { Expr::ForExpr(node) }
|
||||||
}
|
}
|
||||||
|
impl From<FormatArgsExpr> for Expr {
|
||||||
|
fn from(node: FormatArgsExpr) -> Expr { Expr::FormatArgsExpr(node) }
|
||||||
|
}
|
||||||
impl From<IfExpr> for Expr {
|
impl From<IfExpr> for Expr {
|
||||||
fn from(node: IfExpr) -> Expr { Expr::IfExpr(node) }
|
fn from(node: IfExpr) -> Expr { Expr::IfExpr(node) }
|
||||||
}
|
}
|
||||||
|
@ -3427,6 +3487,9 @@ impl From<MatchExpr> for Expr {
|
||||||
impl From<MethodCallExpr> for Expr {
|
impl From<MethodCallExpr> for Expr {
|
||||||
fn from(node: MethodCallExpr) -> Expr { Expr::MethodCallExpr(node) }
|
fn from(node: MethodCallExpr) -> Expr { Expr::MethodCallExpr(node) }
|
||||||
}
|
}
|
||||||
|
impl From<OffsetOfExpr> for Expr {
|
||||||
|
fn from(node: OffsetOfExpr) -> Expr { Expr::OffsetOfExpr(node) }
|
||||||
|
}
|
||||||
impl From<ParenExpr> for Expr {
|
impl From<ParenExpr> for Expr {
|
||||||
fn from(node: ParenExpr) -> Expr { Expr::ParenExpr(node) }
|
fn from(node: ParenExpr) -> Expr { Expr::ParenExpr(node) }
|
||||||
}
|
}
|
||||||
|
@ -3474,10 +3537,10 @@ impl AstNode for Expr {
|
||||||
matches!(
|
matches!(
|
||||||
kind,
|
kind,
|
||||||
ARRAY_EXPR
|
ARRAY_EXPR
|
||||||
|
| ASM_EXPR
|
||||||
| AWAIT_EXPR
|
| AWAIT_EXPR
|
||||||
| BIN_EXPR
|
| BIN_EXPR
|
||||||
| BLOCK_EXPR
|
| BLOCK_EXPR
|
||||||
| BOX_EXPR
|
|
||||||
| BREAK_EXPR
|
| BREAK_EXPR
|
||||||
| CALL_EXPR
|
| CALL_EXPR
|
||||||
| CAST_EXPR
|
| CAST_EXPR
|
||||||
|
@ -3485,6 +3548,7 @@ impl AstNode for Expr {
|
||||||
| CONTINUE_EXPR
|
| CONTINUE_EXPR
|
||||||
| FIELD_EXPR
|
| FIELD_EXPR
|
||||||
| FOR_EXPR
|
| FOR_EXPR
|
||||||
|
| FORMAT_ARGS_EXPR
|
||||||
| IF_EXPR
|
| IF_EXPR
|
||||||
| INDEX_EXPR
|
| INDEX_EXPR
|
||||||
| LITERAL
|
| LITERAL
|
||||||
|
@ -3492,6 +3556,7 @@ impl AstNode for Expr {
|
||||||
| MACRO_EXPR
|
| MACRO_EXPR
|
||||||
| MATCH_EXPR
|
| MATCH_EXPR
|
||||||
| METHOD_CALL_EXPR
|
| METHOD_CALL_EXPR
|
||||||
|
| OFFSET_OF_EXPR
|
||||||
| PAREN_EXPR
|
| PAREN_EXPR
|
||||||
| PATH_EXPR
|
| PATH_EXPR
|
||||||
| PREFIX_EXPR
|
| PREFIX_EXPR
|
||||||
|
@ -3511,10 +3576,10 @@ impl AstNode for Expr {
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
let res = match syntax.kind() {
|
let res = match syntax.kind() {
|
||||||
ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }),
|
ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }),
|
||||||
|
ASM_EXPR => Expr::AsmExpr(AsmExpr { syntax }),
|
||||||
AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }),
|
AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }),
|
||||||
BIN_EXPR => Expr::BinExpr(BinExpr { syntax }),
|
BIN_EXPR => Expr::BinExpr(BinExpr { syntax }),
|
||||||
BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
|
BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
|
||||||
BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }),
|
|
||||||
BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }),
|
BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }),
|
||||||
CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
|
CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
|
||||||
CAST_EXPR => Expr::CastExpr(CastExpr { syntax }),
|
CAST_EXPR => Expr::CastExpr(CastExpr { syntax }),
|
||||||
|
@ -3522,6 +3587,7 @@ impl AstNode for Expr {
|
||||||
CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }),
|
CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }),
|
||||||
FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }),
|
FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }),
|
||||||
FOR_EXPR => Expr::ForExpr(ForExpr { syntax }),
|
FOR_EXPR => Expr::ForExpr(ForExpr { syntax }),
|
||||||
|
FORMAT_ARGS_EXPR => Expr::FormatArgsExpr(FormatArgsExpr { syntax }),
|
||||||
IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
|
IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
|
||||||
INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
|
INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
|
||||||
LITERAL => Expr::Literal(Literal { syntax }),
|
LITERAL => Expr::Literal(Literal { syntax }),
|
||||||
|
@ -3529,6 +3595,7 @@ impl AstNode for Expr {
|
||||||
MACRO_EXPR => Expr::MacroExpr(MacroExpr { syntax }),
|
MACRO_EXPR => Expr::MacroExpr(MacroExpr { syntax }),
|
||||||
MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
|
MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
|
||||||
METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
|
METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
|
||||||
|
OFFSET_OF_EXPR => Expr::OffsetOfExpr(OffsetOfExpr { syntax }),
|
||||||
PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }),
|
PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }),
|
||||||
PATH_EXPR => Expr::PathExpr(PathExpr { syntax }),
|
PATH_EXPR => Expr::PathExpr(PathExpr { syntax }),
|
||||||
PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }),
|
PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }),
|
||||||
|
@ -3550,10 +3617,10 @@ impl AstNode for Expr {
|
||||||
fn syntax(&self) -> &SyntaxNode {
|
fn syntax(&self) -> &SyntaxNode {
|
||||||
match self {
|
match self {
|
||||||
Expr::ArrayExpr(it) => &it.syntax,
|
Expr::ArrayExpr(it) => &it.syntax,
|
||||||
|
Expr::AsmExpr(it) => &it.syntax,
|
||||||
Expr::AwaitExpr(it) => &it.syntax,
|
Expr::AwaitExpr(it) => &it.syntax,
|
||||||
Expr::BinExpr(it) => &it.syntax,
|
Expr::BinExpr(it) => &it.syntax,
|
||||||
Expr::BlockExpr(it) => &it.syntax,
|
Expr::BlockExpr(it) => &it.syntax,
|
||||||
Expr::BoxExpr(it) => &it.syntax,
|
|
||||||
Expr::BreakExpr(it) => &it.syntax,
|
Expr::BreakExpr(it) => &it.syntax,
|
||||||
Expr::CallExpr(it) => &it.syntax,
|
Expr::CallExpr(it) => &it.syntax,
|
||||||
Expr::CastExpr(it) => &it.syntax,
|
Expr::CastExpr(it) => &it.syntax,
|
||||||
|
@ -3561,6 +3628,7 @@ impl AstNode for Expr {
|
||||||
Expr::ContinueExpr(it) => &it.syntax,
|
Expr::ContinueExpr(it) => &it.syntax,
|
||||||
Expr::FieldExpr(it) => &it.syntax,
|
Expr::FieldExpr(it) => &it.syntax,
|
||||||
Expr::ForExpr(it) => &it.syntax,
|
Expr::ForExpr(it) => &it.syntax,
|
||||||
|
Expr::FormatArgsExpr(it) => &it.syntax,
|
||||||
Expr::IfExpr(it) => &it.syntax,
|
Expr::IfExpr(it) => &it.syntax,
|
||||||
Expr::IndexExpr(it) => &it.syntax,
|
Expr::IndexExpr(it) => &it.syntax,
|
||||||
Expr::Literal(it) => &it.syntax,
|
Expr::Literal(it) => &it.syntax,
|
||||||
|
@ -3568,6 +3636,7 @@ impl AstNode for Expr {
|
||||||
Expr::MacroExpr(it) => &it.syntax,
|
Expr::MacroExpr(it) => &it.syntax,
|
||||||
Expr::MatchExpr(it) => &it.syntax,
|
Expr::MatchExpr(it) => &it.syntax,
|
||||||
Expr::MethodCallExpr(it) => &it.syntax,
|
Expr::MethodCallExpr(it) => &it.syntax,
|
||||||
|
Expr::OffsetOfExpr(it) => &it.syntax,
|
||||||
Expr::ParenExpr(it) => &it.syntax,
|
Expr::ParenExpr(it) => &it.syntax,
|
||||||
Expr::PathExpr(it) => &it.syntax,
|
Expr::PathExpr(it) => &it.syntax,
|
||||||
Expr::PrefixExpr(it) => &it.syntax,
|
Expr::PrefixExpr(it) => &it.syntax,
|
||||||
|
@ -4028,9 +4097,9 @@ impl AstNode for AnyHasAttrs {
|
||||||
| TYPE_PARAM
|
| TYPE_PARAM
|
||||||
| LET_STMT
|
| LET_STMT
|
||||||
| ARRAY_EXPR
|
| ARRAY_EXPR
|
||||||
|
| ASM_EXPR
|
||||||
| AWAIT_EXPR
|
| AWAIT_EXPR
|
||||||
| BIN_EXPR
|
| BIN_EXPR
|
||||||
| BOX_EXPR
|
|
||||||
| BREAK_EXPR
|
| BREAK_EXPR
|
||||||
| CALL_EXPR
|
| CALL_EXPR
|
||||||
| CAST_EXPR
|
| CAST_EXPR
|
||||||
|
@ -4038,12 +4107,14 @@ impl AstNode for AnyHasAttrs {
|
||||||
| CONTINUE_EXPR
|
| CONTINUE_EXPR
|
||||||
| FIELD_EXPR
|
| FIELD_EXPR
|
||||||
| FOR_EXPR
|
| FOR_EXPR
|
||||||
|
| FORMAT_ARGS_EXPR
|
||||||
| IF_EXPR
|
| IF_EXPR
|
||||||
| INDEX_EXPR
|
| INDEX_EXPR
|
||||||
| LITERAL
|
| LITERAL
|
||||||
| LOOP_EXPR
|
| LOOP_EXPR
|
||||||
| MATCH_EXPR
|
| MATCH_EXPR
|
||||||
| METHOD_CALL_EXPR
|
| METHOD_CALL_EXPR
|
||||||
|
| OFFSET_OF_EXPR
|
||||||
| PAREN_EXPR
|
| PAREN_EXPR
|
||||||
| PATH_EXPR
|
| PATH_EXPR
|
||||||
| PREFIX_EXPR
|
| PREFIX_EXPR
|
||||||
|
@ -4620,6 +4691,11 @@ impl std::fmt::Display for ArrayExpr {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl std::fmt::Display for AsmExpr {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
|
}
|
||||||
|
}
|
||||||
impl std::fmt::Display for AwaitExpr {
|
impl std::fmt::Display for AwaitExpr {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
|
@ -4630,11 +4706,6 @@ impl std::fmt::Display for BinExpr {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl std::fmt::Display for BoxExpr {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for BreakExpr {
|
impl std::fmt::Display for BreakExpr {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
|
@ -4670,6 +4741,11 @@ impl std::fmt::Display for ForExpr {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl std::fmt::Display for FormatArgsExpr {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
|
}
|
||||||
|
}
|
||||||
impl std::fmt::Display for IfExpr {
|
impl std::fmt::Display for IfExpr {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
|
@ -4705,6 +4781,11 @@ impl std::fmt::Display for MethodCallExpr {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl std::fmt::Display for OffsetOfExpr {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
|
}
|
||||||
|
}
|
||||||
impl std::fmt::Display for ParenExpr {
|
impl std::fmt::Display for ParenExpr {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
|
|
|
@ -130,7 +130,8 @@ impl Expr {
|
||||||
//
|
//
|
||||||
ContinueExpr(_) => (0, 0),
|
ContinueExpr(_) => (0, 0),
|
||||||
|
|
||||||
ClosureExpr(_) | ReturnExpr(_) | YieldExpr(_) | YeetExpr(_) | BreakExpr(_) => (0, 1),
|
ClosureExpr(_) | ReturnExpr(_) | YieldExpr(_) | YeetExpr(_) | BreakExpr(_)
|
||||||
|
| OffsetOfExpr(_) | FormatArgsExpr(_) | AsmExpr(_) => (0, 1),
|
||||||
|
|
||||||
RangeExpr(_) => (5, 5),
|
RangeExpr(_) => (5, 5),
|
||||||
|
|
||||||
|
@ -160,7 +161,7 @@ impl Expr {
|
||||||
|
|
||||||
CastExpr(_) => (25, 26),
|
CastExpr(_) => (25, 26),
|
||||||
|
|
||||||
BoxExpr(_) | RefExpr(_) | LetExpr(_) | PrefixExpr(_) => (0, 27),
|
RefExpr(_) | LetExpr(_) | PrefixExpr(_) => (0, 27),
|
||||||
|
|
||||||
AwaitExpr(_) | CallExpr(_) | MethodCallExpr(_) | IndexExpr(_) | TryExpr(_)
|
AwaitExpr(_) | CallExpr(_) | MethodCallExpr(_) | IndexExpr(_) | TryExpr(_)
|
||||||
| MacroExpr(_) => (29, 0),
|
| MacroExpr(_) => (29, 0),
|
||||||
|
@ -202,7 +203,6 @@ impl Expr {
|
||||||
let rhs = match self {
|
let rhs = match self {
|
||||||
RefExpr(e) => e.expr(),
|
RefExpr(e) => e.expr(),
|
||||||
BinExpr(e) => e.rhs(),
|
BinExpr(e) => e.rhs(),
|
||||||
BoxExpr(e) => e.expr(),
|
|
||||||
BreakExpr(e) => e.expr(),
|
BreakExpr(e) => e.expr(),
|
||||||
LetExpr(e) => e.expr(),
|
LetExpr(e) => e.expr(),
|
||||||
RangeExpr(e) => e.end(),
|
RangeExpr(e) => e.end(),
|
||||||
|
@ -279,7 +279,6 @@ impl Expr {
|
||||||
CastExpr(e) => e.as_token(),
|
CastExpr(e) => e.as_token(),
|
||||||
FieldExpr(e) => e.dot_token(),
|
FieldExpr(e) => e.dot_token(),
|
||||||
AwaitExpr(e) => e.dot_token(),
|
AwaitExpr(e) => e.dot_token(),
|
||||||
BoxExpr(e) => e.box_token(),
|
|
||||||
BreakExpr(e) => e.break_token(),
|
BreakExpr(e) => e.break_token(),
|
||||||
CallExpr(e) => e.arg_list().and_then(|args| args.l_paren_token()),
|
CallExpr(e) => e.arg_list().and_then(|args| args.l_paren_token()),
|
||||||
ClosureExpr(e) => e.param_list().and_then(|params| params.l_paren_token()),
|
ClosureExpr(e) => e.param_list().and_then(|params| params.l_paren_token()),
|
||||||
|
@ -293,7 +292,9 @@ impl Expr {
|
||||||
YieldExpr(e) => e.yield_token(),
|
YieldExpr(e) => e.yield_token(),
|
||||||
YeetExpr(e) => e.do_token(),
|
YeetExpr(e) => e.do_token(),
|
||||||
LetExpr(e) => e.let_token(),
|
LetExpr(e) => e.let_token(),
|
||||||
|
OffsetOfExpr(e) => e.builtin_token(),
|
||||||
|
FormatArgsExpr(e) => e.builtin_token(),
|
||||||
|
AsmExpr(e) => e.builtin_token(),
|
||||||
ArrayExpr(_) | TupleExpr(_) | Literal(_) | PathExpr(_) | ParenExpr(_)
|
ArrayExpr(_) | TupleExpr(_) | Literal(_) | PathExpr(_) | ParenExpr(_)
|
||||||
| IfExpr(_) | WhileExpr(_) | ForExpr(_) | LoopExpr(_) | MatchExpr(_)
|
| IfExpr(_) | WhileExpr(_) | ForExpr(_) | LoopExpr(_) | MatchExpr(_)
|
||||||
| BlockExpr(_) | RecordExpr(_) | UnderscoreExpr(_) | MacroExpr(_) => None,
|
| BlockExpr(_) | RecordExpr(_) | UnderscoreExpr(_) | MacroExpr(_) => None,
|
||||||
|
@ -310,12 +311,12 @@ impl Expr {
|
||||||
ArrayExpr(_) | AwaitExpr(_) | BlockExpr(_) | CallExpr(_) | CastExpr(_)
|
ArrayExpr(_) | AwaitExpr(_) | BlockExpr(_) | CallExpr(_) | CastExpr(_)
|
||||||
| ClosureExpr(_) | FieldExpr(_) | IndexExpr(_) | Literal(_) | LoopExpr(_)
|
| ClosureExpr(_) | FieldExpr(_) | IndexExpr(_) | Literal(_) | LoopExpr(_)
|
||||||
| MacroExpr(_) | MethodCallExpr(_) | ParenExpr(_) | PathExpr(_) | RecordExpr(_)
|
| MacroExpr(_) | MethodCallExpr(_) | ParenExpr(_) | PathExpr(_) | RecordExpr(_)
|
||||||
| TryExpr(_) | TupleExpr(_) | UnderscoreExpr(_) => false,
|
| TryExpr(_) | TupleExpr(_) | UnderscoreExpr(_) | OffsetOfExpr(_)
|
||||||
|
| FormatArgsExpr(_) | AsmExpr(_) => false,
|
||||||
|
|
||||||
// For BinExpr and RangeExpr this is technically wrong -- the child can be on the left...
|
// For BinExpr and RangeExpr this is technically wrong -- the child can be on the left...
|
||||||
BinExpr(_) | RangeExpr(_) | BoxExpr(_) | BreakExpr(_) | ContinueExpr(_)
|
BinExpr(_) | RangeExpr(_) | BreakExpr(_) | ContinueExpr(_) | PrefixExpr(_)
|
||||||
| PrefixExpr(_) | RefExpr(_) | ReturnExpr(_) | YieldExpr(_) | YeetExpr(_)
|
| RefExpr(_) | ReturnExpr(_) | YieldExpr(_) | YeetExpr(_) | LetExpr(_) => self
|
||||||
| LetExpr(_) => self
|
|
||||||
.syntax()
|
.syntax()
|
||||||
.parent()
|
.parent()
|
||||||
.and_then(Expr::cast)
|
.and_then(Expr::cast)
|
||||||
|
|
|
@ -70,7 +70,19 @@ pub(crate) const KINDS_SRC: KindsSrc<'_> = KindsSrc {
|
||||||
"match", "mod", "move", "mut", "pub", "ref", "return", "self", "Self", "static", "struct",
|
"match", "mod", "move", "mut", "pub", "ref", "return", "self", "Self", "static", "struct",
|
||||||
"super", "trait", "true", "try", "type", "unsafe", "use", "where", "while", "yield",
|
"super", "trait", "true", "try", "type", "unsafe", "use", "where", "while", "yield",
|
||||||
],
|
],
|
||||||
contextual_keywords: &["auto", "default", "existential", "union", "raw", "macro_rules", "yeet"],
|
contextual_keywords: &[
|
||||||
|
"auto",
|
||||||
|
"builtin",
|
||||||
|
"default",
|
||||||
|
"existential",
|
||||||
|
"union",
|
||||||
|
"raw",
|
||||||
|
"macro_rules",
|
||||||
|
"yeet",
|
||||||
|
"offset_of",
|
||||||
|
"asm",
|
||||||
|
"format_args",
|
||||||
|
],
|
||||||
literals: &["INT_NUMBER", "FLOAT_NUMBER", "CHAR", "BYTE", "STRING", "BYTE_STRING", "C_STRING"],
|
literals: &["INT_NUMBER", "FLOAT_NUMBER", "CHAR", "BYTE", "STRING", "BYTE_STRING", "C_STRING"],
|
||||||
tokens: &["ERROR", "IDENT", "WHITESPACE", "LIFETIME_IDENT", "COMMENT", "SHEBANG"],
|
tokens: &["ERROR", "IDENT", "WHITESPACE", "LIFETIME_IDENT", "COMMENT", "SHEBANG"],
|
||||||
nodes: &[
|
nodes: &[
|
||||||
|
@ -154,7 +166,9 @@ pub(crate) const KINDS_SRC: KindsSrc<'_> = KindsSrc {
|
||||||
"RECORD_EXPR",
|
"RECORD_EXPR",
|
||||||
"RECORD_EXPR_FIELD_LIST",
|
"RECORD_EXPR_FIELD_LIST",
|
||||||
"RECORD_EXPR_FIELD",
|
"RECORD_EXPR_FIELD",
|
||||||
"BOX_EXPR",
|
"OFFSET_OF_EXPR",
|
||||||
|
"ASM_EXPR",
|
||||||
|
"FORMAT_ARGS_EXPR",
|
||||||
// postfix
|
// postfix
|
||||||
"CALL_EXPR",
|
"CALL_EXPR",
|
||||||
"INDEX_EXPR",
|
"INDEX_EXPR",
|
||||||
|
|
Loading…
Reference in a new issue