We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5f52669 commit 0dc6c41Copy full SHA for 0dc6c41
src/libcore/unstable/lang.rs
@@ -99,8 +99,12 @@ pub unsafe fn borrow_as_imm(a: *u8) {
99
#[lang="return_to_mut"]
100
#[inline(always)]
101
pub unsafe fn return_to_mut(a: *u8) {
102
- let a: *mut BoxRepr = transmute(a);
103
- (*a).header.ref_count &= !FROZEN_BIT;
+ // Sometimes the box is null, if it is conditionally frozen.
+ // See e.g. #4904.
104
+ if !a.is_null() {
105
+ let a: *mut BoxRepr = transmute(a);
106
+ (*a).header.ref_count &= !FROZEN_BIT;
107
+ }
108
}
109
110
#[lang="check_not_borrowed"]
0 commit comments