]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/consts.rs
Auto merge of #4551 - mikerite:fix-ice-reporting, r=llogiq
[rust.git] / clippy_lints / src / consts.rs
index 9d1cc110e5d4f584210039b42907d296610dbe29..0e1c1e60178f93f24464b61c0fa99fe2fdd8300b 100644 (file)
@@ -230,7 +230,7 @@ pub fn expr(&mut self, e: &Expr) -> Option<Constant> {
             ExprKind::Tup(ref tup) => self.multi(tup).map(Constant::Tuple),
             ExprKind::Repeat(ref value, _) => {
                 let n = match self.tables.expr_ty(e).sty {
-                    ty::Array(_, n) => n.assert_usize(self.lcx.tcx).expect("array length"),
+                    ty::Array(_, n) => n.eval_usize(self.lcx.tcx, self.lcx.param_env),
                     _ => span_bug!(e.span, "typeck error"),
                 };
                 self.expr(value).map(|v| Constant::Repeat(Box::new(v), n))
@@ -490,9 +490,12 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
         },
         ConstValue::Slice { data, start, end } => match result.ty.sty {
             ty::Ref(_, tam, _) => match tam.sty {
-                ty::Str => String::from_utf8(data.bytes[start..end].to_owned())
-                    .ok()
-                    .map(Constant::Str),
+                ty::Str => String::from_utf8(
+                    data.inspect_with_undef_and_ptr_outside_interpreter(start..end)
+                        .to_owned(),
+                )
+                .ok()
+                .map(Constant::Str),
                 _ => None,
             },
             _ => None,