parent
dff4986f9e
commit
30a4eab380
@ -2305,7 +2305,12 @@ fn autoderef(cx: @block_ctxt, v: ValueRef, t: ty::t) -> result_t {
|
||||
v1 = PointerCast(cx, body, T_ptr(llty));
|
||||
} else { v1 = body; }
|
||||
}
|
||||
ty::ty_uniq(t) { fail "autoderef uniq unimplemented"; }
|
||||
ty::ty_uniq(_) {
|
||||
check trans_uniq::type_is_unique_box(cx, t1);
|
||||
let derefed = trans_uniq::autoderef(cx, v1, t1);
|
||||
t1 = derefed.t;
|
||||
v1 = derefed.v;
|
||||
}
|
||||
ty::ty_res(did, inner, tps) {
|
||||
t1 = ty::substitute_type_params(ccx.tcx, tps, inner);
|
||||
v1 = GEP(cx, v1, [C_int(0), C_int(1)]);
|
||||
|
@ -15,7 +15,7 @@ import trans::{
|
||||
new_sub_block_ctxt
|
||||
};
|
||||
|
||||
export trans_uniq, make_free_glue, type_is_unique_box, copy_val;
|
||||
export trans_uniq, make_free_glue, type_is_unique_box, copy_val, autoderef;
|
||||
|
||||
pure fn type_is_unique_box(bcx: @block_ctxt, ty: ty::t) -> bool {
|
||||
unchecked {
|
||||
@ -100,4 +100,11 @@ fn copy_val(cx: @block_ctxt, dst: ValueRef, src: ValueRef,
|
||||
let bcx = trans::copy_val(bcx, INIT, dst, src, content_ty);
|
||||
Store(bcx, src, llptr);
|
||||
ret bcx;
|
||||
}
|
||||
|
||||
fn autoderef(bcx: @block_ctxt, v: ValueRef, t: ty::t)
|
||||
: type_is_unique_box(bcx, t) -> {v: ValueRef, t: ty::t} {
|
||||
|
||||
let content_ty = content_ty(bcx, t);
|
||||
ret {v: v, t: content_ty};
|
||||
}
|
@ -845,7 +845,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t {
|
||||
let t1 = t;
|
||||
while true {
|
||||
alt structure_of(fcx, sp, t1) {
|
||||
ty::ty_box(inner) {
|
||||
ty::ty_box(inner) | ty::ty_uniq(inner) {
|
||||
alt ty::struct(fcx.ccx.tcx, t1) {
|
||||
ty::ty_var(v1) {
|
||||
if ty::occurs_check_fails(fcx.ccx.tcx, some(sp), v1,
|
||||
|
6
src/test/run-pass/unique-autoderef-field.rs
Normal file
6
src/test/run-pass/unique-autoderef-field.rs
Normal file
@ -0,0 +1,6 @@
|
||||
fn main() {
|
||||
let i = ~{
|
||||
j: 100
|
||||
};
|
||||
assert i.j == 100;
|
||||
}
|
4
src/test/run-pass/unique-autoderef-index.rs
Normal file
4
src/test/run-pass/unique-autoderef-index.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
let i = ~[100];
|
||||
assert i[0] == 100;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user