Vectors containing pinned kinds become pinned

Otherwise they could be copied
This commit is contained in:
Brian Anderson 2011-09-23 18:50:00 -07:00
parent e5d5682065
commit 856acbf66d
9 changed files with 23 additions and 24 deletions

View file

@ -385,7 +385,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer) ->
// Path and definition ID indexing
fn create_index<T>(index: [entry<T>], hash_fn: fn(T) -> uint) ->
fn create_index<@T>(index: [entry<T>], hash_fn: fn(T) -> uint) ->
[@[entry<T>]] {
let buckets: [@mutable [entry<T>]] = [];
for each i: uint in uint::range(0u, 256u) { buckets += [@mutable []]; }

View file

@ -1019,17 +1019,14 @@ fn type_kind(cx: ctxt, ty: t) -> ast::kind {
ty_box(mt) {
result = ast::kind_shared;
}
// Pointers and unique boxes / vecs raise pinned to shared,
// otherwise pass through their pointee kind.
ty_ptr(tm) | ty_vec(tm) {
// Pointers raise pinned to shared.
ty_ptr(tm) {
let k = type_kind(cx, tm.ty);
if k == ast::kind_pinned { k = ast::kind_shared; }
result = kind::lower_kind(result, k);
}
// Unique boxes pass through their pointee kind. FIXME: Shouldn't
// pointers and vecs do this too to avoid copying vectors of pinned
// things?
ty_uniq(tm) {
// Unique containers pass through their pointee kind.
ty_vec(tm) | ty_uniq(tm) {
let k = type_kind(cx, tm.ty);
result = kind::lower_kind(result, k);
}

View file

@ -104,7 +104,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) ->
}
}
fn option_flatten_map<T, U>(f: fn(T) -> option::t<U>, v: [T]) ->
fn option_flatten_map<T, @U>(f: fn(T) -> option::t<U>, v: [T]) ->
option::t<[U]> {
let res = [];
for elem: T in v {

View file

@ -609,8 +609,9 @@ fn parse_fn_block_arg(p: parser) -> ast::arg {
ret {mode: m, ty: t, ident: i, id: p.get_id()};
}
fn parse_seq_to_before_gt<T>(sep: option::t<token::token>, f: fn(parser) -> T,
p: parser) -> [T] {
fn parse_seq_to_before_gt<@T>(sep: option::t<token::token>,
f: fn(parser) -> T,
p: parser) -> [T] {
let first = true;
let v = [];
while p.peek() != token::GT && p.peek() != token::BINOP(token::LSR) &&
@ -625,7 +626,7 @@ fn parse_seq_to_before_gt<T>(sep: option::t<token::token>, f: fn(parser) -> T,
ret v;
}
fn parse_seq_to_gt<T>(sep: option::t<token::token>, f: fn(parser) -> T,
fn parse_seq_to_gt<@T>(sep: option::t<token::token>, f: fn(parser) -> T,
p: parser) -> [T] {
let v = parse_seq_to_before_gt(sep, f, p);
expect_gt(p);
@ -633,7 +634,7 @@ fn parse_seq_to_gt<T>(sep: option::t<token::token>, f: fn(parser) -> T,
ret v;
}
fn parse_seq_lt_gt<T>(sep: option::t<token::token>, f: fn(parser) -> T,
fn parse_seq_lt_gt<@T>(sep: option::t<token::token>, f: fn(parser) -> T,
p: parser) -> spanned<[T]> {
let lo = p.get_lo_pos();
expect(p, token::LT);
@ -643,15 +644,16 @@ fn parse_seq_lt_gt<T>(sep: option::t<token::token>, f: fn(parser) -> T,
ret spanned(lo, hi, result);
}
fn parse_seq_to_end<T>(ket: token::token, sep: option::t<token::token>,
fn parse_seq_to_end<@T>(ket: token::token, sep: option::t<token::token>,
f: fn(parser) -> T, p: parser) -> [T] {
let val = parse_seq_to_before_end(ket, sep, f, p);
p.bump();
ret val;
}
fn parse_seq_to_before_end<T>(ket: token::token, sep: option::t<token::token>,
f: fn(parser) -> T, p: parser) -> [T] {
fn parse_seq_to_before_end<@T>(ket: token::token,
sep: option::t<token::token>,
f: fn(parser) -> T, p: parser) -> [T] {
let first: bool = true;
let v: [T] = [];
while p.peek() != ket {
@ -665,7 +667,7 @@ fn parse_seq_to_before_end<T>(ket: token::token, sep: option::t<token::token>,
}
fn parse_seq<T>(bra: token::token, ket: token::token,
fn parse_seq<@T>(bra: token::token, ket: token::token,
sep: option::t<token::token>, f: fn(parser) -> T, p: parser)
-> spanned<[T]> {
let lo = p.get_lo_pos();