diff options
author | Marcus Klaas de Vries <[email protected]> | 2019-01-14 19:56:14 +0000 |
---|---|---|
committer | Marcus Klaas de Vries <[email protected]> | 2019-01-14 19:56:14 +0000 |
commit | d67eabb512a08a451a649c7f20e4e9ae1860a8a0 (patch) | |
tree | 99c5fb5004f3fb7a6b0855033855c439675cc0ff /crates/ra_syntax/src/ast | |
parent | 26893487722d07b3f31a6addfc88e6948620989c (diff) |
Fix type inference for raw (byte) strings
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index cad845ec0..3471d5226 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -1422,6 +1422,8 @@ unsafe impl TransparentNewType for LiteralExpr { | |||
1422 | pub enum LiteralExprKind<'a> { | 1422 | pub enum LiteralExprKind<'a> { |
1423 | String(&'a String), | 1423 | String(&'a String), |
1424 | ByteString(&'a ByteString), | 1424 | ByteString(&'a ByteString), |
1425 | RawString(&'a RawString), | ||
1426 | RawByteString(&'a RawByteString), | ||
1425 | Char(&'a Char), | 1427 | Char(&'a Char), |
1426 | Byte(&'a Byte), | 1428 | Byte(&'a Byte), |
1427 | IntNumber(&'a IntNumber), | 1429 | IntNumber(&'a IntNumber), |
@@ -1435,6 +1437,8 @@ impl AstNode for LiteralExpr { | |||
1435 | match syntax.kind() { | 1437 | match syntax.kind() { |
1436 | | STRING | 1438 | | STRING |
1437 | | BYTE_STRING | 1439 | | BYTE_STRING |
1440 | | RAW_STRING | ||
1441 | | RAW_BYTE_STRING | ||
1438 | | CHAR | 1442 | | CHAR |
1439 | | BYTE | 1443 | | BYTE |
1440 | | INT_NUMBER | 1444 | | INT_NUMBER |
@@ -1453,6 +1457,8 @@ impl LiteralExpr { | |||
1453 | match self.syntax.kind() { | 1457 | match self.syntax.kind() { |
1454 | STRING => LiteralExprKind::String(String::cast(&self.syntax).unwrap()), | 1458 | STRING => LiteralExprKind::String(String::cast(&self.syntax).unwrap()), |
1455 | BYTE_STRING => LiteralExprKind::ByteString(ByteString::cast(&self.syntax).unwrap()), | 1459 | BYTE_STRING => LiteralExprKind::ByteString(ByteString::cast(&self.syntax).unwrap()), |
1460 | RAW_STRING => LiteralExprKind::RawString(RawString::cast(&self.syntax).unwrap()), | ||
1461 | RAW_BYTE_STRING => LiteralExprKind::RawByteString(RawByteString::cast(&self.syntax).unwrap()), | ||
1456 | CHAR => LiteralExprKind::Char(Char::cast(&self.syntax).unwrap()), | 1462 | CHAR => LiteralExprKind::Char(Char::cast(&self.syntax).unwrap()), |
1457 | BYTE => LiteralExprKind::Byte(Byte::cast(&self.syntax).unwrap()), | 1463 | BYTE => LiteralExprKind::Byte(Byte::cast(&self.syntax).unwrap()), |
1458 | INT_NUMBER => LiteralExprKind::IntNumber(IntNumber::cast(&self.syntax).unwrap()), | 1464 | INT_NUMBER => LiteralExprKind::IntNumber(IntNumber::cast(&self.syntax).unwrap()), |
@@ -2543,6 +2549,56 @@ impl AstNode for RangePat { | |||
2543 | 2549 | ||
2544 | impl RangePat {} | 2550 | impl RangePat {} |
2545 | 2551 | ||
2552 | // RawByteString | ||
2553 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
2554 | #[repr(transparent)] | ||
2555 | pub struct RawByteString { | ||
2556 | pub(crate) syntax: SyntaxNode, | ||
2557 | } | ||
2558 | unsafe impl TransparentNewType for RawByteString { | ||
2559 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
2560 | } | ||
2561 | |||
2562 | impl AstNode for RawByteString { | ||
2563 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
2564 | match syntax.kind() { | ||
2565 | RAW_BYTE_STRING => Some(RawByteString::from_repr(syntax.into_repr())), | ||
2566 | _ => None, | ||
2567 | } | ||
2568 | } | ||
2569 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2570 | fn to_owned(&self) -> TreeArc<RawByteString> { TreeArc::cast(self.syntax.to_owned()) } | ||
2571 | } | ||
2572 | |||
2573 | |||
2574 | impl ast::AstToken for RawByteString {} | ||
2575 | impl RawByteString {} | ||
2576 | |||
2577 | // RawString | ||
2578 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
2579 | #[repr(transparent)] | ||
2580 | pub struct RawString { | ||
2581 | pub(crate) syntax: SyntaxNode, | ||
2582 | } | ||
2583 | unsafe impl TransparentNewType for RawString { | ||
2584 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
2585 | } | ||
2586 | |||
2587 | impl AstNode for RawString { | ||
2588 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
2589 | match syntax.kind() { | ||
2590 | RAW_STRING => Some(RawString::from_repr(syntax.into_repr())), | ||
2591 | _ => None, | ||
2592 | } | ||
2593 | } | ||
2594 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2595 | fn to_owned(&self) -> TreeArc<RawString> { TreeArc::cast(self.syntax.to_owned()) } | ||
2596 | } | ||
2597 | |||
2598 | |||
2599 | impl ast::AstToken for RawString {} | ||
2600 | impl RawString {} | ||
2601 | |||
2546 | // RefExpr | 2602 | // RefExpr |
2547 | #[derive(Debug, PartialEq, Eq, Hash)] | 2603 | #[derive(Debug, PartialEq, Eq, Hash)] |
2548 | #[repr(transparent)] | 2604 | #[repr(transparent)] |