From e666589e63fd4de16baa5f1ebda4ab07aa5a5437 Mon Sep 17 00:00:00 2001 From: Jade Date: Wed, 12 May 2021 05:59:35 -0700 Subject: Add support for lengths in array repeats, if they are literals Now we will get the type of `[0u8; 4]`. --- crates/hir_def/src/body/lower.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 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 b00dcbdf0..2a7e0205f 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs @@ -1006,16 +1006,17 @@ impl From for BinaryOp { impl From for Literal { fn from(ast_lit_kind: ast::LiteralKind) -> Self { match ast_lit_kind { + // FIXME: these should have actual values filled in, but unsure on perf impact LiteralKind::IntNumber(lit) => { if let builtin @ Some(_) = lit.suffix().and_then(BuiltinFloat::from_suffix) { return Literal::Float(Default::default(), builtin); } else if let builtin @ Some(_) = lit.suffix().and_then(|it| BuiltinInt::from_suffix(&it)) { - Literal::Int(Default::default(), builtin) + Literal::Int(lit.value().unwrap_or(0) as i128, builtin) } else { let builtin = lit.suffix().and_then(|it| BuiltinUint::from_suffix(&it)); - Literal::Uint(Default::default(), builtin) + Literal::Uint(lit.value().unwrap_or(0), builtin) } } LiteralKind::FloatNumber(lit) => { -- cgit v1.2.3