Skip to content

Commit 224e2e5

Browse files
committed
explain ty == None
1 parent 3424811 commit 224e2e5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/librustc_mir/interpret/intern.rs

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ struct IsStaticOrFn;
5757
/// `mode` is the mode of the environment where we found this pointer.
5858
/// `mutablity` is the mutability of the place to be interned; even if that says
5959
/// `immutable` things might become mutable if `ty` is not frozen.
60+
/// `ty` can be `None` if there is no potential interior mutability
61+
/// to account for (e.g. for vtables).
6062
fn intern_shallow<'rt, 'mir, 'tcx>(
6163
ecx: &'rt mut CompileTimeEvalContext<'mir, 'tcx>,
6264
leftover_allocations: &'rt mut FxHashSet<AllocId>,
@@ -97,6 +99,7 @@ fn intern_shallow<'rt, 'mir, 'tcx>(
9799
// read-only memory, and also by Miri when evluating other constants/statics that
98100
// access this one.
99101
if mode == InternMode::Static {
102+
// When `ty` is `None`, we assume no interior mutability.
100103
let frozen = ty.map_or(true, |ty| ty.is_freeze(
101104
ecx.tcx.tcx,
102105
ecx.param_env,

0 commit comments

Comments
 (0)