aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/body/lower.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-04-01 18:38:00 +0100
committerGitHub <[email protected]>2020-04-01 18:38:00 +0100
commit0a41412ced3784363580ddaef089605250d6398e (patch)
treeddc82aaaf8e35fa652feb04400fd31bc9af4749e /crates/ra_hir_def/src/body/lower.rs
parentf39b51d025c080682a35706ffcb86c2aeb28044b (diff)
parentd0b6b2ee2f4a447f4c3827f87ebaf5216de6f226 (diff)
Merge #3806
3806: lower bool literal value r=flodiebold a=JoshMcguigan Following up on #3805, this PR adds the literal value to `ast::LiteralKind` so when we lower we can use the actual value from the source code rather than the default value for the type. Ultimately I plan to use this for exhaustiveness checking in #3706. I didn't include this in the previous PR because I wasn't sure if it made sense to add this information to `ast::LiteralKind` or provide some other mechanism to get this from `ast::Literal`. For now I've only implemented this for boolean literals, but I think it could be easily extended to other types. A possible exception to this are string literals, since we may not want to clone around an owned string to hold onto in `ast::LiteralKind`, and it'd be nice to avoid adding a generic lifetime as well. Perhaps we won't ever care about the actual value of a string literal? Co-authored-by: Josh Mcguigan <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/body/lower.rs')
-rw-r--r--crates/ra_hir_def/src/body/lower.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index 7b809cf4f..28c570c76 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -748,7 +748,7 @@ impl From<ast::LiteralKind> for Literal {
748 LiteralKind::ByteString => Literal::ByteString(Default::default()), 748 LiteralKind::ByteString => Literal::ByteString(Default::default()),
749 LiteralKind::String => Literal::String(Default::default()), 749 LiteralKind::String => Literal::String(Default::default()),
750 LiteralKind::Byte => Literal::Int(Default::default(), Some(BuiltinInt::U8)), 750 LiteralKind::Byte => Literal::Int(Default::default(), Some(BuiltinInt::U8)),
751 LiteralKind::Bool => Literal::Bool(Default::default()), 751 LiteralKind::Bool(val) => Literal::Bool(val),
752 LiteralKind::Char => Literal::Char(Default::default()), 752 LiteralKind::Char => Literal::Char(Default::default()),
753 } 753 }
754 } 754 }