diff options
author | Marcus Klaas de Vries <[email protected]> | 2019-01-14 18:46:10 +0000 |
---|---|---|
committer | Marcus Klaas de Vries <[email protected]> | 2019-01-14 18:46:10 +0000 |
commit | 26893487722d07b3f31a6addfc88e6948620989c (patch) | |
tree | 9e4c52766f6939c20debbc39629880471ab877cf /crates | |
parent | a9a6a50c759302e8a8d59bf6c53c72ec804324b3 (diff) |
Give literal expression default values for now
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 2f3432870..2696592a4 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -654,7 +654,6 @@ impl ExprCollector { | |||
654 | } else { | 654 | } else { |
655 | return self.alloc_expr(Expr::Missing, syntax_ptr); | 655 | return self.alloc_expr(Expr::Missing, syntax_ptr); |
656 | }; | 656 | }; |
657 | let c = child.syntax(); | ||
658 | 657 | ||
659 | let lit = match child.flavor() { | 658 | let lit = match child.flavor() { |
660 | LiteralFlavor::IntNumber { suffix } => { | 659 | LiteralFlavor::IntNumber { suffix } => { |
@@ -663,9 +662,9 @@ impl ExprCollector { | |||
663 | .and_then(|name| UncertainIntTy::from_name(&name)); | 662 | .and_then(|name| UncertainIntTy::from_name(&name)); |
664 | 663 | ||
665 | if let Some(kn) = known_name { | 664 | if let Some(kn) = known_name { |
666 | Literal::Int(0u64, kn) | 665 | Literal::Int(Default::default(), kn) |
667 | } else { | 666 | } else { |
668 | Literal::Int(0u64, UncertainIntTy::Unknown) | 667 | Literal::Int(Default::default(), UncertainIntTy::Unknown) |
669 | } | 668 | } |
670 | } | 669 | } |
671 | LiteralFlavor::FloatNumber { suffix } => { | 670 | LiteralFlavor::FloatNumber { suffix } => { |
@@ -674,31 +673,18 @@ impl ExprCollector { | |||
674 | .and_then(|name| UncertainFloatTy::from_name(&name)); | 673 | .and_then(|name| UncertainFloatTy::from_name(&name)); |
675 | 674 | ||
676 | if let Some(kn) = known_name { | 675 | if let Some(kn) = known_name { |
677 | Literal::Float(0u64, kn) | 676 | Literal::Float(Default::default(), kn) |
678 | } else { | 677 | } else { |
679 | Literal::Float(0u64, UncertainFloatTy::Unknown) | 678 | Literal::Float(Default::default(), UncertainFloatTy::Unknown) |
680 | } | 679 | } |
681 | } | 680 | } |
682 | LiteralFlavor::ByteString => { | 681 | LiteralFlavor::ByteString => Literal::ByteString(Default::default()), |
683 | // FIXME: this is completely incorrect for a variety | 682 | LiteralFlavor::String => Literal::String(Default::default()), |
684 | // of reasons, but at least it gives the right type | ||
685 | let bytes = c.text().to_string().into_bytes(); | ||
686 | Literal::ByteString(bytes) | ||
687 | } | ||
688 | LiteralFlavor::String => { | ||
689 | // FIXME: this likely includes the " characters | ||
690 | let text = c.text().to_string(); | ||
691 | Literal::String(text) | ||
692 | } | ||
693 | LiteralFlavor::Byte => { | 683 | LiteralFlavor::Byte => { |
694 | let character = c.text().char_at(1).unwrap_or('X'); | 684 | Literal::Int(Default::default(), UncertainIntTy::Unsigned(UintTy::U8)) |
695 | Literal::Int(character as u8 as u64, UncertainIntTy::Unsigned(UintTy::U8)) | ||
696 | } | ||
697 | LiteralFlavor::Bool => Literal::Bool(true), | ||
698 | LiteralFlavor::Char => { | ||
699 | let character = c.text().char_at(1).unwrap_or('X'); | ||
700 | Literal::Char(character) | ||
701 | } | 685 | } |
686 | LiteralFlavor::Bool => Literal::Bool(Default::default()), | ||
687 | LiteralFlavor::Char => Literal::Char(Default::default()), | ||
702 | }; | 688 | }; |
703 | self.alloc_expr(Expr::Literal(lit), syntax_ptr) | 689 | self.alloc_expr(Expr::Literal(lit), syntax_ptr) |
704 | } | 690 | } |