Skip to content

Commit 19ec5a4

Browse files
committed
allow region ptrs to be cast to uints
1 parent f1a4691 commit 19ec5a4

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/rustc/middle/trans/base.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,11 +2620,16 @@ fn float_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef,
26202620
enum cast_kind { cast_pointer, cast_integral, cast_float,
26212621
cast_enum, cast_other, }
26222622
fn cast_type_kind(t: ty::t) -> cast_kind {
2623-
if ty::type_is_fp(t) { cast_float }
2624-
else if ty::type_is_unsafe_ptr(t) { cast_pointer }
2625-
else if ty::type_is_integral(t) { cast_integral }
2626-
else if ty::type_is_enum(t) { cast_enum }
2627-
else { cast_other }
2623+
alt ty::get(t).struct {
2624+
ty::ty_float(*) {cast_float}
2625+
ty::ty_ptr(*) {cast_pointer}
2626+
ty::ty_rptr(*) {cast_pointer}
2627+
ty::ty_int(*) {cast_integral}
2628+
ty::ty_uint(*) {cast_integral}
2629+
ty::ty_bool {cast_integral}
2630+
ty::ty_enum(*) {cast_enum}
2631+
_ {cast_other}
2632+
}
26282633
}
26292634

26302635

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
let x = 3;
3+
#debug["&x=%x", &x as uint];
4+
}

0 commit comments

Comments
 (0)