Skip to content

Commit 98cda6c

Browse files
committed
freeze -> static
1 parent fd3bbfd commit 98cda6c

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ impl<'tcx> Error for EvalError<'tcx> {
119119
EvalError::TypeNotPrimitive(_) =>
120120
"expected primitive type, got nonprimitive",
121121
EvalError::ReallocatedStaticMemory =>
122-
"tried to reallocate frozen memory",
122+
"tried to reallocate static memory",
123123
EvalError::DeallocatedStaticMemory =>
124-
"tried to deallocate frozen memory",
124+
"tried to deallocate static memory",
125125
EvalError::Layout(_) =>
126126
"rustc layout computation failed",
127127
EvalError::UnterminatedCString(_) =>

src/eval_context.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
314314
match frame.return_to_block {
315315
StackPopCleanup::MarkStatic(mutable) => if let Lvalue::Global(id) = frame.return_lvalue {
316316
let global_value = self.globals.get_mut(&id)
317-
.expect("global should have been cached (freeze/static)");
317+
.expect("global should have been cached (static)");
318318
match global_value.value {
319319
Value::ByRef(ptr) => self.memory.mark_static(ptr.alloc_id, mutable)?,
320320
Value::ByVal(val) => if let PrimVal::Ptr(ptr) = val {
@@ -332,7 +332,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
332332
assert!(global_value.mutable);
333333
global_value.mutable = mutable;
334334
} else {
335-
bug!("StackPopCleanup::Freeze on: {:?}", frame.return_lvalue);
335+
bug!("StackPopCleanup::MarkStatic on: {:?}", frame.return_lvalue);
336336
},
337337
StackPopCleanup::Goto(target) => self.goto_block(target),
338338
StackPopCleanup::None => {},
@@ -343,10 +343,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
343343
trace!("deallocating local");
344344
self.memory.dump_alloc(ptr.alloc_id);
345345
match self.memory.deallocate(ptr) {
346-
// Any frozen memory means that it belongs to a constant or something referenced
347-
// by a constant. We could alternatively check whether the alloc_id is frozen
348-
// before calling deallocate, but this is much simpler and is probably the
349-
// rare case.
346+
// We could alternatively check whether the alloc_id is static before calling
347+
// deallocate, but this is much simpler and is probably the rare case.
350348
Ok(()) | Err(EvalError::DeallocatedStaticMemory) => {},
351349
other => return other,
352350
}

src/memory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub struct Allocation {
3939
pub align: u64,
4040
/// Whether the allocation may be modified.
4141
/// Use the `mark_static` method of `Memory` to ensure that an error occurs, if the memory of this
42-
/// allocation is modified in the future.
42+
/// allocation is modified or deallocated in the future.
4343
pub static_kind: StaticKind,
4444
}
4545

@@ -626,7 +626,7 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
626626
impl<'a, 'tcx> Memory<'a, 'tcx> {
627627
/// mark an allocation as static, either mutable or not
628628
pub fn mark_static(&mut self, alloc_id: AllocId, mutable: bool) -> EvalResult<'tcx> {
629-
// do not use `self.get_mut(alloc_id)` here, because we might have already frozen a
629+
// do not use `self.get_mut(alloc_id)` here, because we might have already marked a
630630
// sub-element or have circular pointers (e.g. `Rc`-cycles)
631631
let relocations = match self.alloc_map.get_mut(&alloc_id) {
632632
Some(&mut Allocation { ref mut relocations, static_kind: ref mut kind @ StaticKind::NotStatic, .. }) => {
@@ -636,7 +636,7 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
636636
StaticKind::Immutable
637637
};
638638
// take out the relocations vector to free the borrow on self, so we can call
639-
// freeze recursively
639+
// mark recursively
640640
mem::replace(relocations, Default::default())
641641
},
642642
None if alloc_id == NEVER_ALLOC_ID || alloc_id == ZST_ALLOC_ID => return Ok(()),

tests/compile-fail/modifying_constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fn main() {
2-
let x = &1; // the `&1` is promoted to a constant, but it used to be that only the pointer is frozen, not the pointee
2+
let x = &1; // the `&1` is promoted to a constant, but it used to be that only the pointer is marked static, not the pointee
33
let y = unsafe { &mut *(x as *const i32 as *mut i32) };
44
*y = 42; //~ ERROR tried to modify constant memory
55
assert_eq!(*x, 42);

0 commit comments

Comments
 (0)