]> git.lizzy.rs Git - rust.git/commitdiff
address review by @eddyb
authorJade <software@lfcode.ca>
Tue, 11 May 2021 22:18:45 +0000 (15:18 -0700)
committerJade <software@lfcode.ca>
Tue, 11 May 2021 22:18:45 +0000 (15:18 -0700)
crates/hir_ty/src/consts.rs
crates/hir_ty/src/infer/expr.rs

index 77d2a7a055e82061d63163a077bb89c616c578d2..0044b1cffc25bc784f2854b188156cd5c564a7ce 100644 (file)
@@ -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,
index 9aec8a236f3179188dab3cd3b6d8533f2799c6a2..a7e720f880252061d55dd13205aba2ec9dc94edc 100644 (file)
@@ -746,7 +746,7 @@ fn infer_expr_inner(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty {
                     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),
                     }),
                 };