rustc: Implement type walking and comparison glue for unsafe pointers
This commit is contained in:
parent
b84fffaa4e
commit
e50c918e6b
@ -2314,6 +2314,9 @@ fn make_scalar_cmp_glue(&@block_ctxt cx, ValueRef lhs, ValueRef rhs, &ty::t t,
|
||||
trans_fail(cx, none[common::span],
|
||||
"attempt to compare values of type native");
|
||||
}
|
||||
case (ty::ty_ptr(_)) {
|
||||
f(unsigned_int);
|
||||
}
|
||||
case (_) {
|
||||
// Should never get here, because t is scalar.
|
||||
|
||||
|
@ -505,6 +505,7 @@ fn walk_ty(&ctxt cx, ty_walk walker, t ty) {
|
||||
case (ty_box(?tm)) { walk_ty(cx, walker, tm.ty); }
|
||||
case (ty_vec(?tm)) { walk_ty(cx, walker, tm.ty); }
|
||||
case (ty_ivec(?tm)) { walk_ty(cx, walker, tm.ty); }
|
||||
case (ty_ptr(?tm)) { walk_ty(cx, walker, tm.ty); }
|
||||
case (ty_port(?subty)) { walk_ty(cx, walker, subty); }
|
||||
case (ty_chan(?subty)) { walk_ty(cx, walker, subty); }
|
||||
case (ty_tag(?tid, ?subtys)) {
|
||||
@ -2088,6 +2089,27 @@ mod unify {
|
||||
case (_) { ret ures_err(terr_mismatch); }
|
||||
}
|
||||
}
|
||||
case (ty::ty_ptr(?expected_mt)) {
|
||||
alt (struct(cx.tcx, actual)) {
|
||||
case (ty::ty_ptr(?actual_mt)) {
|
||||
auto mut;
|
||||
alt (unify_mut(expected_mt.mut, actual_mt.mut)) {
|
||||
case (none) { ret ures_err(terr_vec_mutability); }
|
||||
case (some(?m)) { mut = m; }
|
||||
}
|
||||
auto result =
|
||||
unify_step(cx, expected_mt.ty, actual_mt.ty);
|
||||
alt (result) {
|
||||
case (ures_ok(?result_sub)) {
|
||||
auto mt = rec(ty=result_sub, mut=mut);
|
||||
ret ures_ok(mk_ptr(cx.tcx, mt));
|
||||
}
|
||||
case (_) { ret result; }
|
||||
}
|
||||
}
|
||||
case (_) { ret ures_err(terr_mismatch); }
|
||||
}
|
||||
}
|
||||
case (ty::ty_port(?expected_sub)) {
|
||||
alt (struct(cx.tcx, actual)) {
|
||||
case (ty::ty_port(?actual_sub)) {
|
||||
|
Loading…
Reference in New Issue
Block a user