about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/consts.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs
index fe57c300a34..0e1c1e60178 100644
--- a/clippy_lints/src/consts.rs
+++ b/clippy_lints/src/consts.rs
@@ -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,