Skip to content

Commit

Permalink
explain ty == None
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Sep 15, 2019
1 parent 3424811 commit 224e2e5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/librustc_mir/interpret/intern.rs
Expand Up @@ -57,6 +57,8 @@ struct IsStaticOrFn;
/// `mode` is the mode of the environment where we found this pointer.
/// `mutablity` is the mutability of the place to be interned; even if that says
/// `immutable` things might become mutable if `ty` is not frozen.
/// `ty` can be `None` if there is no potential interior mutability
/// to account for (e.g. for vtables).
fn intern_shallow<'rt, 'mir, 'tcx>(
ecx: &'rt mut CompileTimeEvalContext<'mir, 'tcx>,
leftover_allocations: &'rt mut FxHashSet<AllocId>,
Expand Down Expand Up @@ -97,6 +99,7 @@ fn intern_shallow<'rt, 'mir, 'tcx>(
// read-only memory, and also by Miri when evluating other constants/statics that
// access this one.
if mode == InternMode::Static {
// When `ty` is `None`, we assume no interior mutability.
let frozen = ty.map_or(true, |ty| ty.is_freeze(
ecx.tcx.tcx,
ecx.param_env,
Expand Down

0 comments on commit 224e2e5

Please sign in to comment.