From f28c053c677203f4dd101222460081dd97c1f440 Mon Sep 17 00:00:00 2001 From: Jade Date: Tue, 11 May 2021 15:18:45 -0700 Subject: address review by @eddyb --- crates/hir_ty/src/consts.rs | 3 ++- crates/hir_ty/src/infer/expr.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'crates/hir_ty/src') diff --git a/crates/hir_ty/src/consts.rs b/crates/hir_ty/src/consts.rs index 77d2a7a05..0044b1cff 100644 --- a/crates/hir_ty/src/consts.rs +++ b/crates/hir_ty/src/consts.rs @@ -4,7 +4,8 @@ #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ConstScalar { // for now, we only support the trivial case of constant evaluating the length of an array - Usize(usize), + // Note that this is u64 because the target usize may be bigger than our usize + Usize(u64), /// Case of an unknown value that rustc might know but we don't Unknown, diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 9aec8a236..a7e720f88 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -746,7 +746,7 @@ impl<'a> InferenceContext<'a> { ty: TyKind::Scalar(Scalar::Uint(UintTy::Usize)).intern(&Interner), value: ConstValue::Concrete(chalk_ir::ConcreteConst { interned: len - .map(|len| ConstScalar::Usize(len)) + .map(|len| ConstScalar::Usize(len as u64)) .unwrap_or(ConstScalar::Unknown), }), }; -- cgit v1.2.3