From 5db789df9c767985a564a31cc593ce7f5964100e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 6 Nov 2020 22:52:22 +0100 Subject: Cleanup API --- crates/hir_def/src/body/lower.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'crates/hir_def/src/body') diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs index 1deaa90f2..cd7958746 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs @@ -953,18 +953,19 @@ impl From for BinaryOp { impl From for Literal { fn from(ast_lit_kind: ast::LiteralKind) -> Self { match ast_lit_kind { - LiteralKind::IntNumber { suffix } => { - let known_name = suffix.and_then(|it| BuiltinInt::from_suffix(&it)); - - Literal::Int(Default::default(), known_name) + LiteralKind::IntNumber(lit) => { + if let Some(float_suffix) = lit.suffix().and_then(BuiltinFloat::from_suffix) { + return Literal::Float(Default::default(), Some(float_suffix)); + } + let ty = lit.suffix().and_then(|it| BuiltinInt::from_suffix(&it)); + Literal::Int(Default::default(), ty) } - LiteralKind::FloatNumber { suffix } => { - let known_name = suffix.and_then(|it| BuiltinFloat::from_suffix(&it)); - - Literal::Float(Default::default(), known_name) + LiteralKind::FloatNumber(lit) => { + let ty = lit.suffix().and_then(|it| BuiltinFloat::from_suffix(&it)); + Literal::Float(Default::default(), ty) } - LiteralKind::ByteString => Literal::ByteString(Default::default()), - LiteralKind::String => Literal::String(Default::default()), + LiteralKind::ByteString(_) => Literal::ByteString(Default::default()), + LiteralKind::String(_) => Literal::String(Default::default()), LiteralKind::Byte => Literal::Int(Default::default(), Some(BuiltinInt::U8)), LiteralKind::Bool(val) => Literal::Bool(val), LiteralKind::Char => Literal::Char(Default::default()), -- cgit v1.2.3