Skip to content

Commit f646c1e

Browse files
committed
Explain why we do not allow const_to_valtree to read from statics
1 parent bc8641a commit f646c1e

File tree

1 file changed

+6
-1
lines changed
  • compiler/rustc_mir/src/const_eval

1 file changed

+6
-1
lines changed

compiler/rustc_mir/src/const_eval/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ pub(crate) fn const_to_valtree<'tcx>(
4444
param_env: ty::ParamEnv<'tcx>,
4545
raw: ConstAlloc<'tcx>,
4646
) -> Option<ty::ValTree<'tcx>> {
47-
let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, false);
47+
let ecx = mk_eval_cx(
48+
tcx, DUMMY_SP, param_env,
49+
// It is absolutely crucial for soundness that
50+
// we do not read from static items or other mutable memory.
51+
false,
52+
);
4853
let place = ecx.raw_const_to_mplace(raw).unwrap();
4954
const_to_valtree_inner(&ecx, &place)
5055
}

0 commit comments

Comments
 (0)