aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_assists/src/handlers/add_explicit_type.rs4
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs28
-rw-r--r--crates/ra_syntax/src/ast/generated/tokens.rs202
-rw-r--r--xtask/src/ast_src.rs66
-rw-r--r--xtask/src/codegen/gen_syntax.rs2
5 files changed, 34 insertions, 268 deletions
diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs
index e7dcfb44e..d86d804b2 100644
--- a/crates/ra_assists/src/handlers/add_explicit_type.rs
+++ b/crates/ra_assists/src/handlers/add_explicit_type.rs
@@ -1,6 +1,6 @@
1use hir::HirDisplay; 1use hir::HirDisplay;
2use ra_syntax::{ 2use ra_syntax::{
3 ast::{self, AstNode, AstToken, LetStmt, NameOwner, TypeAscriptionOwner}, 3 ast::{self, AstNode, LetStmt, NameOwner, TypeAscriptionOwner},
4 TextRange, 4 TextRange,
5}; 5};
6 6
@@ -35,7 +35,7 @@ pub(crate) fn add_explicit_type(ctx: AssistCtx) -> Option<Assist> {
35 let name = pat.name()?; 35 let name = pat.name()?;
36 let name_range = name.syntax().text_range(); 36 let name_range = name.syntax().text_range();
37 let stmt_range = stmt.syntax().text_range(); 37 let stmt_range = stmt.syntax().text_range();
38 let eq_range = stmt.eq_token()?.syntax().text_range(); 38 let eq_range = stmt.eq_token()?.text_range();
39 // Assist should only be applicable if cursor is between 'let' and '=' 39 // Assist should only be applicable if cursor is between 'let' and '='
40 let let_range = TextRange::from_to(stmt_range.start(), eq_range.start()); 40 let let_range = TextRange::from_to(stmt_range.start(), eq_range.start());
41 let cursor_in_range = ctx.frange.range.is_subrange(&let_range); 41 let cursor_in_range = ctx.frange.range.is_subrange(&let_range);
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 0ae5db9fc..106a91c12 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -276,7 +276,7 @@ impl ast::DocCommentsOwner for EnumVariant {}
276impl ast::AttrsOwner for EnumVariant {} 276impl ast::AttrsOwner for EnumVariant {}
277impl EnumVariant { 277impl EnumVariant {
278 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } 278 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
279 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 279 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
280 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 280 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
281} 281}
282#[derive(Debug, Clone, PartialEq, Eq, Hash)] 282#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -377,7 +377,7 @@ impl ConstDef {
377 support::token2(&self.syntax, T![default]) 377 support::token2(&self.syntax, T![default])
378 } 378 }
379 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![const]) } 379 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![const]) }
380 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 380 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
381 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 381 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
382 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } 382 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
383} 383}
@@ -405,7 +405,7 @@ impl ast::TypeAscriptionOwner for StaticDef {}
405impl StaticDef { 405impl StaticDef {
406 pub fn static_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![static]) } 406 pub fn static_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![static]) }
407 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) } 407 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) }
408 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 408 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
409 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 409 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
410 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } 410 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
411} 411}
@@ -435,7 +435,7 @@ impl TypeAliasDef {
435 support::token2(&self.syntax, T![default]) 435 support::token2(&self.syntax, T![default])
436 } 436 }
437 pub fn type_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![type]) } 437 pub fn type_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![type]) }
438 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 438 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
439 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 439 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
440 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } 440 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
441} 441}
@@ -1278,9 +1278,7 @@ impl AstNode for BinExpr {
1278 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1278 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1279} 1279}
1280impl ast::AttrsOwner for BinExpr {} 1280impl ast::AttrsOwner for BinExpr {}
1281impl BinExpr { 1281impl BinExpr {}
1282 pub fn bin_op_token(&self) -> Option<BinOp> { support::token(&self.syntax) }
1283}
1284#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1282#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1285pub struct Literal { 1283pub struct Literal {
1286 pub(crate) syntax: SyntaxNode, 1284 pub(crate) syntax: SyntaxNode,
@@ -1881,7 +1879,7 @@ impl Attr {
1881 pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) } 1879 pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) }
1882 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T!['[']) } 1880 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T!['[']) }
1883 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1881 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1884 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 1882 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
1885 pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) } 1883 pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
1886 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![']']) } 1884 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![']']) }
1887} 1885}
@@ -1943,7 +1941,7 @@ impl ast::NameOwner for TypeParam {}
1943impl ast::AttrsOwner for TypeParam {} 1941impl ast::AttrsOwner for TypeParam {}
1944impl ast::TypeBoundsOwner for TypeParam {} 1942impl ast::TypeBoundsOwner for TypeParam {}
1945impl TypeParam { 1943impl TypeParam {
1946 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 1944 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
1947 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1945 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1948} 1946}
1949#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1947#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1965,7 +1963,7 @@ impl ast::NameOwner for ConstParam {}
1965impl ast::AttrsOwner for ConstParam {} 1963impl ast::AttrsOwner for ConstParam {}
1966impl ast::TypeAscriptionOwner for ConstParam {} 1964impl ast::TypeAscriptionOwner for ConstParam {}
1967impl ConstParam { 1965impl ConstParam {
1968 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 1966 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
1969 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) } 1967 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
1970} 1968}
1971#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1969#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -2122,7 +2120,7 @@ impl ast::TypeAscriptionOwner for LetStmt {}
2122impl LetStmt { 2120impl LetStmt {
2123 pub fn let_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![let]) } 2121 pub fn let_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![let]) }
2124 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 2122 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2125 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 2123 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
2126 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } 2124 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
2127 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } 2125 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
2128} 2126}
@@ -2144,7 +2142,7 @@ impl AstNode for Condition {
2144impl Condition { 2142impl Condition {
2145 pub fn let_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![let]) } 2143 pub fn let_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![let]) }
2146 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 2144 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2147 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 2145 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
2148 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 2146 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2149} 2147}
2150#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2148#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -2463,7 +2461,7 @@ impl AstNode for AssocTypeArg {
2463impl ast::TypeBoundsOwner for AssocTypeArg {} 2461impl ast::TypeBoundsOwner for AssocTypeArg {}
2464impl AssocTypeArg { 2462impl AssocTypeArg {
2465 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 2463 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2466 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 2464 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
2467 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 2465 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2468} 2466}
2469#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2467#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -2501,7 +2499,7 @@ impl AstNode for ConstArg {
2501} 2499}
2502impl ConstArg { 2500impl ConstArg {
2503 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } 2501 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
2504 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 2502 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
2505 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 2503 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
2506} 2504}
2507#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2505#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -2597,7 +2595,7 @@ impl AstNode for MetaItem {
2597} 2595}
2598impl MetaItem { 2596impl MetaItem {
2599 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 2597 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2600 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 2598 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
2601 pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) } 2599 pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
2602 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) } 2600 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) }
2603} 2601}
diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs
index 4cbc1d793..7611ce4cb 100644
--- a/crates/ra_syntax/src/ast/generated/tokens.rs
+++ b/crates/ra_syntax/src/ast/generated/tokens.rs
@@ -1410,208 +1410,6 @@ impl AstToken for RangeSeparator {
1410 } 1410 }
1411} 1411}
1412#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1412#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1413pub enum BinOp {
1414 Pipepipe(Pipepipe),
1415 Ampamp(Ampamp),
1416 Eqeq(Eqeq),
1417 Neq(Neq),
1418 Lteq(Lteq),
1419 Gteq(Gteq),
1420 LAngle(LAngle),
1421 RAngle(RAngle),
1422 Plus(Plus),
1423 Star(Star),
1424 Minus(Minus),
1425 Slash(Slash),
1426 Percent(Percent),
1427 Shl(Shl),
1428 Shr(Shr),
1429 Caret(Caret),
1430 Pipe(Pipe),
1431 Amp(Amp),
1432 Eq(Eq),
1433 Pluseq(Pluseq),
1434 Slasheq(Slasheq),
1435 Stareq(Stareq),
1436 Percenteq(Percenteq),
1437 Shreq(Shreq),
1438 Shleq(Shleq),
1439 Minuseq(Minuseq),
1440 Pipeeq(Pipeeq),
1441 Ampeq(Ampeq),
1442 Careteq(Careteq),
1443}
1444impl From<Pipepipe> for BinOp {
1445 fn from(node: Pipepipe) -> BinOp { BinOp::Pipepipe(node) }
1446}
1447impl From<Ampamp> for BinOp {
1448 fn from(node: Ampamp) -> BinOp { BinOp::Ampamp(node) }
1449}
1450impl From<Eqeq> for BinOp {
1451 fn from(node: Eqeq) -> BinOp { BinOp::Eqeq(node) }
1452}
1453impl From<Neq> for BinOp {
1454 fn from(node: Neq) -> BinOp { BinOp::Neq(node) }
1455}
1456impl From<Lteq> for BinOp {
1457 fn from(node: Lteq) -> BinOp { BinOp::Lteq(node) }
1458}
1459impl From<Gteq> for BinOp {
1460 fn from(node: Gteq) -> BinOp { BinOp::Gteq(node) }
1461}
1462impl From<LAngle> for BinOp {
1463 fn from(node: LAngle) -> BinOp { BinOp::LAngle(node) }
1464}
1465impl From<RAngle> for BinOp {
1466 fn from(node: RAngle) -> BinOp { BinOp::RAngle(node) }
1467}
1468impl From<Plus> for BinOp {
1469 fn from(node: Plus) -> BinOp { BinOp::Plus(node) }
1470}
1471impl From<Star> for BinOp {
1472 fn from(node: Star) -> BinOp { BinOp::Star(node) }
1473}
1474impl From<Minus> for BinOp {
1475 fn from(node: Minus) -> BinOp { BinOp::Minus(node) }
1476}
1477impl From<Slash> for BinOp {
1478 fn from(node: Slash) -> BinOp { BinOp::Slash(node) }
1479}
1480impl From<Percent> for BinOp {
1481 fn from(node: Percent) -> BinOp { BinOp::Percent(node) }
1482}
1483impl From<Shl> for BinOp {
1484 fn from(node: Shl) -> BinOp { BinOp::Shl(node) }
1485}
1486impl From<Shr> for BinOp {
1487 fn from(node: Shr) -> BinOp { BinOp::Shr(node) }
1488}
1489impl From<Caret> for BinOp {
1490 fn from(node: Caret) -> BinOp { BinOp::Caret(node) }
1491}
1492impl From<Pipe> for BinOp {
1493 fn from(node: Pipe) -> BinOp { BinOp::Pipe(node) }
1494}
1495impl From<Amp> for BinOp {
1496 fn from(node: Amp) -> BinOp { BinOp::Amp(node) }
1497}
1498impl From<Eq> for BinOp {
1499 fn from(node: Eq) -> BinOp { BinOp::Eq(node) }
1500}
1501impl From<Pluseq> for BinOp {
1502 fn from(node: Pluseq) -> BinOp { BinOp::Pluseq(node) }
1503}
1504impl From<Slasheq> for BinOp {
1505 fn from(node: Slasheq) -> BinOp { BinOp::Slasheq(node) }
1506}
1507impl From<Stareq> for BinOp {
1508 fn from(node: Stareq) -> BinOp { BinOp::Stareq(node) }
1509}
1510impl From<Percenteq> for BinOp {
1511 fn from(node: Percenteq) -> BinOp { BinOp::Percenteq(node) }
1512}
1513impl From<Shreq> for BinOp {
1514 fn from(node: Shreq) -> BinOp { BinOp::Shreq(node) }
1515}
1516impl From<Shleq> for BinOp {
1517 fn from(node: Shleq) -> BinOp { BinOp::Shleq(node) }
1518}
1519impl From<Minuseq> for BinOp {
1520 fn from(node: Minuseq) -> BinOp { BinOp::Minuseq(node) }
1521}
1522impl From<Pipeeq> for BinOp {
1523 fn from(node: Pipeeq) -> BinOp { BinOp::Pipeeq(node) }
1524}
1525impl From<Ampeq> for BinOp {
1526 fn from(node: Ampeq) -> BinOp { BinOp::Ampeq(node) }
1527}
1528impl From<Careteq> for BinOp {
1529 fn from(node: Careteq) -> BinOp { BinOp::Careteq(node) }
1530}
1531impl std::fmt::Display for BinOp {
1532 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1533 std::fmt::Display::fmt(self.syntax(), f)
1534 }
1535}
1536impl AstToken for BinOp {
1537 fn can_cast(kind: SyntaxKind) -> bool {
1538 match kind {
1539 PIPEPIPE | AMPAMP | EQEQ | NEQ | LTEQ | GTEQ | L_ANGLE | R_ANGLE | PLUS | STAR
1540 | MINUS | SLASH | PERCENT | SHL | SHR | CARET | PIPE | AMP | EQ | PLUSEQ | SLASHEQ
1541 | STAREQ | PERCENTEQ | SHREQ | SHLEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ => true,
1542 _ => false,
1543 }
1544 }
1545 fn cast(syntax: SyntaxToken) -> Option<Self> {
1546 let res = match syntax.kind() {
1547 PIPEPIPE => BinOp::Pipepipe(Pipepipe { syntax }),
1548 AMPAMP => BinOp::Ampamp(Ampamp { syntax }),
1549 EQEQ => BinOp::Eqeq(Eqeq { syntax }),
1550 NEQ => BinOp::Neq(Neq { syntax }),
1551 LTEQ => BinOp::Lteq(Lteq { syntax }),
1552 GTEQ => BinOp::Gteq(Gteq { syntax }),
1553 L_ANGLE => BinOp::LAngle(LAngle { syntax }),
1554 R_ANGLE => BinOp::RAngle(RAngle { syntax }),
1555 PLUS => BinOp::Plus(Plus { syntax }),
1556 STAR => BinOp::Star(Star { syntax }),
1557 MINUS => BinOp::Minus(Minus { syntax }),
1558 SLASH => BinOp::Slash(Slash { syntax }),
1559 PERCENT => BinOp::Percent(Percent { syntax }),
1560 SHL => BinOp::Shl(Shl { syntax }),
1561 SHR => BinOp::Shr(Shr { syntax }),
1562 CARET => BinOp::Caret(Caret { syntax }),
1563 PIPE => BinOp::Pipe(Pipe { syntax }),
1564 AMP => BinOp::Amp(Amp { syntax }),
1565 EQ => BinOp::Eq(Eq { syntax }),
1566 PLUSEQ => BinOp::Pluseq(Pluseq { syntax }),
1567 SLASHEQ => BinOp::Slasheq(Slasheq { syntax }),
1568 STAREQ => BinOp::Stareq(Stareq { syntax }),
1569 PERCENTEQ => BinOp::Percenteq(Percenteq { syntax }),
1570 SHREQ => BinOp::Shreq(Shreq { syntax }),
1571 SHLEQ => BinOp::Shleq(Shleq { syntax }),
1572 MINUSEQ => BinOp::Minuseq(Minuseq { syntax }),
1573 PIPEEQ => BinOp::Pipeeq(Pipeeq { syntax }),
1574 AMPEQ => BinOp::Ampeq(Ampeq { syntax }),
1575 CARETEQ => BinOp::Careteq(Careteq { syntax }),
1576 _ => return None,
1577 };
1578 Some(res)
1579 }
1580 fn syntax(&self) -> &SyntaxToken {
1581 match self {
1582 BinOp::Pipepipe(it) => &it.syntax,
1583 BinOp::Ampamp(it) => &it.syntax,
1584 BinOp::Eqeq(it) => &it.syntax,
1585 BinOp::Neq(it) => &it.syntax,
1586 BinOp::Lteq(it) => &it.syntax,
1587 BinOp::Gteq(it) => &it.syntax,
1588 BinOp::LAngle(it) => &it.syntax,
1589 BinOp::RAngle(it) => &it.syntax,
1590 BinOp::Plus(it) => &it.syntax,
1591 BinOp::Star(it) => &it.syntax,
1592 BinOp::Minus(it) => &it.syntax,
1593 BinOp::Slash(it) => &it.syntax,
1594 BinOp::Percent(it) => &it.syntax,
1595 BinOp::Shl(it) => &it.syntax,
1596 BinOp::Shr(it) => &it.syntax,
1597 BinOp::Caret(it) => &it.syntax,
1598 BinOp::Pipe(it) => &it.syntax,
1599 BinOp::Amp(it) => &it.syntax,
1600 BinOp::Eq(it) => &it.syntax,
1601 BinOp::Pluseq(it) => &it.syntax,
1602 BinOp::Slasheq(it) => &it.syntax,
1603 BinOp::Stareq(it) => &it.syntax,
1604 BinOp::Percenteq(it) => &it.syntax,
1605 BinOp::Shreq(it) => &it.syntax,
1606 BinOp::Shleq(it) => &it.syntax,
1607 BinOp::Minuseq(it) => &it.syntax,
1608 BinOp::Pipeeq(it) => &it.syntax,
1609 BinOp::Ampeq(it) => &it.syntax,
1610 BinOp::Careteq(it) => &it.syntax,
1611 }
1612 }
1613}
1614#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1615pub enum PrefixOp { 1413pub enum PrefixOp {
1616 Minus(Minus), 1414 Minus(Minus),
1617 Excl(Excl), 1415 Excl(Excl),
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs
index 943c91e23..f9cd12d0d 100644
--- a/xtask/src/ast_src.rs
+++ b/xtask/src/ast_src.rs
@@ -354,7 +354,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
354 } 354 }
355 struct EnumVariant: VisibilityOwner, NameOwner, DocCommentsOwner, AttrsOwner { 355 struct EnumVariant: VisibilityOwner, NameOwner, DocCommentsOwner, AttrsOwner {
356 FieldDefList, 356 FieldDefList,
357 Eq, 357 T![=],
358 Expr 358 Expr
359 } 359 }
360 360
@@ -380,7 +380,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
380 struct ConstDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { 380 struct ConstDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner {
381 T![default], 381 T![default],
382 T![const], 382 T![const],
383 Eq, 383 T![=],
384 body: Expr, 384 body: Expr,
385 T![;] 385 T![;]
386 } 386 }
@@ -388,7 +388,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
388 struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { 388 struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner {
389 T![static], 389 T![static],
390 T![mut], 390 T![mut],
391 Eq, 391 T![=],
392 body: Expr, 392 body: Expr,
393 T![;] 393 T![;]
394 } 394 }
@@ -396,7 +396,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
396 struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner { 396 struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner {
397 T![default], 397 T![default],
398 T![type], 398 T![type],
399 Eq, 399 T![=],
400 TypeRef, 400 TypeRef,
401 T![;] 401 T![;]
402 } 402 }
@@ -406,14 +406,14 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
406 T![const], 406 T![const],
407 T![unsafe], 407 T![unsafe],
408 T![impl], 408 T![impl],
409 Excl, 409 T![!],
410 T![for], 410 T![for],
411 ItemList, 411 ItemList,
412 } 412 }
413 413
414 struct ParenType { T!['('], TypeRef, T![')'] } 414 struct ParenType { T!['('], TypeRef, T![')'] }
415 struct TupleType { T!['('], fields: [TypeRef], T![')'] } 415 struct TupleType { T!['('], fields: [TypeRef], T![')'] }
416 struct NeverType { Excl } 416 struct NeverType { T![!] }
417 struct PathType { Path } 417 struct PathType { Path }
418 struct PointerType { Star, T![const], T![mut], TypeRef } 418 struct PointerType { Star, T![const], T![mut], TypeRef }
419 struct ArrayType { T!['['], TypeRef, T![;], Expr, T![']'] } 419 struct ArrayType { T!['['], TypeRef, T![;], Expr, T![']'] }
@@ -465,7 +465,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
465 struct PrefixExpr: AttrsOwner { PrefixOp, Expr } 465 struct PrefixExpr: AttrsOwner { PrefixOp, Expr }
466 struct BoxExpr: AttrsOwner { T![box], Expr } 466 struct BoxExpr: AttrsOwner { T![box], Expr }
467 struct RangeExpr: AttrsOwner { RangeOp } 467 struct RangeExpr: AttrsOwner { RangeOp }
468 struct BinExpr: AttrsOwner { BinOp } 468 struct BinExpr: AttrsOwner { /*BinOp*/ }
469 struct Literal { LiteralToken } 469 struct Literal { LiteralToken }
470 470
471 struct MatchExpr: AttrsOwner { T![match], Expr, MatchArmList } 471 struct MatchExpr: AttrsOwner { T![match], Expr, MatchArmList }
@@ -520,9 +520,9 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
520 struct NameRef { NameRefToken } 520 struct NameRef { NameRefToken }
521 521
522 struct MacroCall: NameOwner, AttrsOwner,DocCommentsOwner { 522 struct MacroCall: NameOwner, AttrsOwner,DocCommentsOwner {
523 Path, Excl, TokenTree, T![;] 523 Path, T![!], TokenTree, T![;]
524 } 524 }
525 struct Attr { Pound, Excl, T!['['], Path, Eq, input: AttrInput, T![']'] } 525 struct Attr { Pound, T![!], T!['['], Path, T![=], input: AttrInput, T![']'] }
526 struct TokenTree {} 526 struct TokenTree {}
527 struct TypeParamList { 527 struct TypeParamList {
528 LAngle, 528 LAngle,
@@ -533,11 +533,11 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
533 RAngle 533 RAngle
534 } 534 }
535 struct TypeParam: NameOwner, AttrsOwner, TypeBoundsOwner { 535 struct TypeParam: NameOwner, AttrsOwner, TypeBoundsOwner {
536 Eq, 536 T![=],
537 default_type: TypeRef, 537 default_type: TypeRef,
538 } 538 }
539 struct ConstParam: NameOwner, AttrsOwner, TypeAscriptionOwner { 539 struct ConstParam: NameOwner, AttrsOwner, TypeAscriptionOwner {
540 Eq, 540 T![=],
541 default_val: Expr, 541 default_val: Expr,
542 } 542 }
543 struct LifetimeParam: AttrsOwner { Lifetime} 543 struct LifetimeParam: AttrsOwner { Lifetime}
@@ -550,11 +550,11 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
550 struct LetStmt: AttrsOwner, TypeAscriptionOwner { 550 struct LetStmt: AttrsOwner, TypeAscriptionOwner {
551 T![let], 551 T![let],
552 Pat, 552 Pat,
553 Eq, 553 T![=],
554 initializer: Expr, 554 initializer: Expr,
555 T![;], 555 T![;],
556 } 556 }
557 struct Condition { T![let], Pat, Eq, Expr } 557 struct Condition { T![let], Pat, T![=], Expr }
558 struct Block: AttrsOwner, ModuleItemOwner { 558 struct Block: AttrsOwner, ModuleItemOwner {
559 T!['{'], 559 T!['{'],
560 statements: [Stmt], 560 statements: [Stmt],
@@ -607,9 +607,9 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
607 RAngle 607 RAngle
608 } 608 }
609 struct TypeArg { TypeRef } 609 struct TypeArg { TypeRef }
610 struct AssocTypeArg : TypeBoundsOwner { NameRef, Eq, TypeRef } 610 struct AssocTypeArg : TypeBoundsOwner { NameRef, T![=], TypeRef }
611 struct LifetimeArg { Lifetime } 611 struct LifetimeArg { Lifetime }
612 struct ConstArg { Literal, Eq, BlockExpr } 612 struct ConstArg { Literal, T![=], BlockExpr }
613 613
614 struct MacroItems: ModuleItemOwner{ } 614 struct MacroItems: ModuleItemOwner{ }
615 615
@@ -630,7 +630,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
630 } 630 }
631 631
632 struct MetaItem { 632 struct MetaItem {
633 Path, Eq, AttrInput, nested_meta_items: [MetaItem] 633 Path, T![=], AttrInput, nested_meta_items: [MetaItem]
634 } 634 }
635 635
636 struct MacroDef { 636 struct MacroDef {
@@ -771,41 +771,9 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
771 token_enums: &ast_enums! { 771 token_enums: &ast_enums! {
772 enum RangeSeparator { Dotdot, Dotdotdot, Dotdoteq} 772 enum RangeSeparator { Dotdot, Dotdotdot, Dotdoteq}
773 773
774 enum BinOp {
775 Pipepipe,
776 Ampamp,
777 Eqeq,
778 Neq,
779 Lteq,
780 Gteq,
781 LAngle,
782 RAngle,
783 Plus,
784 Star,
785 Minus,
786 Slash,
787 Percent,
788 Shl,
789 Shr,
790 Caret,
791 Pipe,
792 Amp,
793 Eq,
794 Pluseq,
795 Slasheq,
796 Stareq,
797 Percenteq,
798 Shreq,
799 Shleq,
800 Minuseq,
801 Pipeeq,
802 Ampeq,
803 Careteq,
804 }
805
806 enum PrefixOp { 774 enum PrefixOp {
807 Minus, 775 Minus,
808 Excl, 776 T![!],
809 Star 777 Star
810 } 778 }
811 779
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs
index a903d1da7..4c9e447a3 100644
--- a/xtask/src/codegen/gen_syntax.rs
+++ b/xtask/src/codegen/gen_syntax.rs
@@ -535,6 +535,8 @@ impl Field<'_> {
535 "')'" => "r_paren", 535 "')'" => "r_paren",
536 "'['" => "l_brack", 536 "'['" => "l_brack",
537 "']'" => "r_brack", 537 "']'" => "r_brack",
538 "=" => "eq",
539 "!" => "excl",
538 _ => name, 540 _ => name,
539 }; 541 };
540 format_ident!("{}_token", name) 542 format_ident!("{}_token", name)