Skip to content

Commit d96bbb9

Browse files
committed
auto merge of #5556 : nikomatsakis/rust/issues-4904-and-4855, r=nikomatsakis
Two small fixes. r? @catamorphism
2 parents 7f5d7e1 + 0dc6c41 commit d96bbb9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/libcore/unstable/lang.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ pub unsafe fn borrow_as_imm(a: *u8) {
9999
#[lang="return_to_mut"]
100100
#[inline(always)]
101101
pub unsafe fn return_to_mut(a: *u8) {
102-
let a: *mut BoxRepr = transmute(a);
103-
(*a).header.ref_count &= !FROZEN_BIT;
102+
// Sometimes the box is null, if it is conditionally frozen.
103+
// See e.g. #4904.
104+
if !a.is_null() {
105+
let a: *mut BoxRepr = transmute(a);
106+
(*a).header.ref_count &= !FROZEN_BIT;
107+
}
104108
}
105109

106110
#[lang="check_not_borrowed"]

src/librustc/middle/typeck/check/regionck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ pub mod guarantor {
615615
// expressions, both of which always yield a region variable, so
616616
// mk_subr should never fail.
617617
let rptr_ty = rcx.resolve_node_type(id);
618-
if !ty::type_is_error(rptr_ty) {
618+
if !ty::type_is_error(rptr_ty) && !ty::type_is_bot(rptr_ty) {
619619
let tcx = rcx.fcx.ccx.tcx;
620620
debug!("rptr_ty=%s", ty_to_str(tcx, rptr_ty));
621621
let r = ty::ty_region(tcx, span, rptr_ty);

0 commit comments

Comments
 (0)