Skip to content

Commit 2f24923

Browse files
authored
Rollup merge of rust-lang#95222 - RalfJung:validity, r=Dylan-DPC
interpret/validity: improve clarity I was confused by my own (ancient) comment in `validity.rs` so I figured I'd clarify. (And I don't think ZST-ness is relevant at all inside that branch, no idea where that comment comes from.) Also `extend` seems more clear than `clone_from`.
2 parents e1f2d35 + 8a1f928 commit 2f24923

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Diff for: compiler/rustc_const_eval/src/interpret/validity.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,8 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
432432
if let Some(ref mut ref_tracking) = self.ref_tracking {
433433
// Proceed recursively even for ZST, no reason to skip them!
434434
// `!` is a ZST and we want to validate it.
435-
// Skip validation entirely for some external statics
436435
if let Ok((alloc_id, _offset, _ptr)) = self.ecx.memory.ptr_try_get_alloc(place.ptr) {
437-
// not a ZST
436+
// Special handling for pointers to statics (irrespective of their type).
438437
let alloc_kind = self.ecx.tcx.get_global_alloc(alloc_id);
439438
if let Some(GlobalAlloc::Static(did)) = alloc_kind {
440439
assert!(!self.ecx.tcx.is_thread_local_static(did));
@@ -469,7 +468,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
469468
// We need to clone the path anyway, make sure it gets created
470469
// with enough space for the additional `Deref`.
471470
let mut new_path = Vec::with_capacity(path.len() + 1);
472-
new_path.clone_from(path);
471+
new_path.extend(path);
473472
new_path.push(PathElem::Deref);
474473
new_path
475474
});

0 commit comments

Comments
 (0)