encode the borrowing table, add a simple cross-crate borrowing test

This commit is contained in:
Niko Matsakis 2012-04-23 15:23:20 -07:00
parent 7d05bea7b9
commit b04b415e0d
5 changed files with 30 additions and 1 deletions

View File

@ -844,6 +844,12 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
}
option::iter(tcx.borrowings.find(id)) {|_i|
ebml_w.tag(c::tag_table_borrowings) {||
ebml_w.id(id);
}
}
}
impl decoder for ebml::doc {
@ -914,6 +920,8 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
dcx.maps.copy_map.insert(id, ());
} else if tag == (c::tag_table_spill as uint) {
dcx.maps.spill_map.insert(id, ());
} else if tag == (c::tag_table_borrowings as uint) {
dcx.tcx.borrowings.insert(id, ());
} else {
let val_doc = entry_doc[c::tag_table_val];
let val_dsr = ebml::ebml_deserializer(val_doc);

View File

@ -109,7 +109,8 @@ enum astencode_tag { // Reserves 0x50 -- 0x6f
tag_table_last_use,
tag_table_spill,
tag_table_method_map,
tag_table_vtable_map
tag_table_vtable_map,
tag_table_borrowings
}
// djb's cdb hashes.

View File

@ -307,6 +307,11 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
'@' { ret ty::mk_box(st.tcx, parse_mt(st, conv)); }
'~' { ret ty::mk_uniq(st.tcx, parse_mt(st, conv)); }
'*' { ret ty::mk_ptr(st.tcx, parse_mt(st, conv)); }
'&' {
let r = parse_region(st);
let mt = parse_mt(st, conv);
ret ty::mk_rptr(st.tcx, r, mt);
}
'I' { ret ty::mk_vec(st.tcx, parse_mt(st, conv)); }
'V' {
let mt = parse_mt(st, conv);

View File

@ -0,0 +1,3 @@
fn foo(x: &uint) -> uint {
*x
}

View File

@ -0,0 +1,12 @@
// xfail-fast - check-fast doesn't understand aux-build
// aux-build:cci_borrow_lib.rs
use cci_borrow_lib;
import cci_borrow_lib::foo;
fn main() {
let p = @22u;
let r = foo(p);
#debug["r=%u", r];
assert r == 22u;
}