From d0b6b2ee2f4a447f4c3827f87ebaf5216de6f226 Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Wed, 1 Apr 2020 04:47:41 -0700 Subject: [PATCH] lower bool literal with the value from source code rather than default bool value --- crates/ra_hir_def/src/body/lower.rs | 2 +- crates/ra_syntax/src/ast/expr_extensions.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 7b809cf4fa..28c570c769 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 for Literal { LiteralKind::ByteString => Literal::ByteString(Default::default()), LiteralKind::String => Literal::String(Default::default()), LiteralKind::Byte => Literal::Int(Default::default(), Some(BuiltinInt::U8)), - LiteralKind::Bool => Literal::Bool(Default::default()), + LiteralKind::Bool(val) => Literal::Bool(val), LiteralKind::Char => Literal::Char(Default::default()), } } diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs index 77cceb3825..8bbd946c07 100644 --- a/crates/ra_syntax/src/ast/expr_extensions.rs +++ b/crates/ra_syntax/src/ast/expr_extensions.rs @@ -308,7 +308,7 @@ pub enum LiteralKind { Byte, IntNumber { suffix: Option }, FloatNumber { suffix: Option }, - Bool, + Bool(bool), } impl ast::Literal { @@ -355,7 +355,8 @@ impl ast::Literal { LiteralKind::FloatNumber { suffix: Self::find_suffix(&text, &FLOAT_SUFFIXES) } } STRING | RAW_STRING => LiteralKind::String, - T![true] | T![false] => LiteralKind::Bool, + T![true] => LiteralKind::Bool(true), + T![false] => LiteralKind::Bool(false), BYTE_STRING | RAW_BYTE_STRING => LiteralKind::ByteString, CHAR => LiteralKind::Char, BYTE => LiteralKind::Byte,