Skip to content

Commit 856acbf

Browse files
committed
Vectors containing pinned kinds become pinned
Otherwise they could be copied
1 parent e5d5682 commit 856acbf

File tree

9 files changed

+23
-24
lines changed

9 files changed

+23
-24
lines changed

src/comp/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer) ->
385385

386386
// Path and definition ID indexing
387387

388-
fn create_index<T>(index: [entry<T>], hash_fn: fn(T) -> uint) ->
388+
fn create_index<@T>(index: [entry<T>], hash_fn: fn(T) -> uint) ->
389389
[@[entry<T>]] {
390390
let buckets: [@mutable [entry<T>]] = [];
391391
for each i: uint in uint::range(0u, 256u) { buckets += [@mutable []]; }

src/comp/middle/ty.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,17 +1019,14 @@ fn type_kind(cx: ctxt, ty: t) -> ast::kind {
10191019
ty_box(mt) {
10201020
result = ast::kind_shared;
10211021
}
1022-
// Pointers and unique boxes / vecs raise pinned to shared,
1023-
// otherwise pass through their pointee kind.
1024-
ty_ptr(tm) | ty_vec(tm) {
1022+
// Pointers raise pinned to shared.
1023+
ty_ptr(tm) {
10251024
let k = type_kind(cx, tm.ty);
10261025
if k == ast::kind_pinned { k = ast::kind_shared; }
10271026
result = kind::lower_kind(result, k);
10281027
}
1029-
// Unique boxes pass through their pointee kind. FIXME: Shouldn't
1030-
// pointers and vecs do this too to avoid copying vectors of pinned
1031-
// things?
1032-
ty_uniq(tm) {
1028+
// Unique containers pass through their pointee kind.
1029+
ty_vec(tm) | ty_uniq(tm) {
10331030
let k = type_kind(cx, tm.ty);
10341031
result = kind::lower_kind(result, k);
10351032
}

src/comp/syntax/ext/simplext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) ->
104104
}
105105
}
106106

107-
fn option_flatten_map<T, U>(f: fn(T) -> option::t<U>, v: [T]) ->
107+
fn option_flatten_map<T, @U>(f: fn(T) -> option::t<U>, v: [T]) ->
108108
option::t<[U]> {
109109
let res = [];
110110
for elem: T in v {

src/comp/syntax/parse/parser.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,9 @@ fn parse_fn_block_arg(p: parser) -> ast::arg {
609609
ret {mode: m, ty: t, ident: i, id: p.get_id()};
610610
}
611611

612-
fn parse_seq_to_before_gt<T>(sep: option::t<token::token>, f: fn(parser) -> T,
613-
p: parser) -> [T] {
612+
fn parse_seq_to_before_gt<@T>(sep: option::t<token::token>,
613+
f: fn(parser) -> T,
614+
p: parser) -> [T] {
614615
let first = true;
615616
let v = [];
616617
while p.peek() != token::GT && p.peek() != token::BINOP(token::LSR) &&
@@ -625,15 +626,15 @@ fn parse_seq_to_before_gt<T>(sep: option::t<token::token>, f: fn(parser) -> T,
625626
ret v;
626627
}
627628

628-
fn parse_seq_to_gt<T>(sep: option::t<token::token>, f: fn(parser) -> T,
629+
fn parse_seq_to_gt<@T>(sep: option::t<token::token>, f: fn(parser) -> T,
629630
p: parser) -> [T] {
630631
let v = parse_seq_to_before_gt(sep, f, p);
631632
expect_gt(p);
632633

633634
ret v;
634635
}
635636

636-
fn parse_seq_lt_gt<T>(sep: option::t<token::token>, f: fn(parser) -> T,
637+
fn parse_seq_lt_gt<@T>(sep: option::t<token::token>, f: fn(parser) -> T,
637638
p: parser) -> spanned<[T]> {
638639
let lo = p.get_lo_pos();
639640
expect(p, token::LT);
@@ -643,15 +644,16 @@ fn parse_seq_lt_gt<T>(sep: option::t<token::token>, f: fn(parser) -> T,
643644
ret spanned(lo, hi, result);
644645
}
645646

646-
fn parse_seq_to_end<T>(ket: token::token, sep: option::t<token::token>,
647+
fn parse_seq_to_end<@T>(ket: token::token, sep: option::t<token::token>,
647648
f: fn(parser) -> T, p: parser) -> [T] {
648649
let val = parse_seq_to_before_end(ket, sep, f, p);
649650
p.bump();
650651
ret val;
651652
}
652653

653-
fn parse_seq_to_before_end<T>(ket: token::token, sep: option::t<token::token>,
654-
f: fn(parser) -> T, p: parser) -> [T] {
654+
fn parse_seq_to_before_end<@T>(ket: token::token,
655+
sep: option::t<token::token>,
656+
f: fn(parser) -> T, p: parser) -> [T] {
655657
let first: bool = true;
656658
let v: [T] = [];
657659
while p.peek() != ket {
@@ -665,7 +667,7 @@ fn parse_seq_to_before_end<T>(ket: token::token, sep: option::t<token::token>,
665667
}
666668

667669

668-
fn parse_seq<T>(bra: token::token, ket: token::token,
670+
fn parse_seq<@T>(bra: token::token, ket: token::token,
669671
sep: option::t<token::token>, f: fn(parser) -> T, p: parser)
670672
-> spanned<[T]> {
671673
let lo = p.get_lo_pos();

src/lib/either.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ fn either<T, U,
1010
alt value { left(l) { f_left(l) } right(r) { f_right(r) } }
1111
}
1212

13-
fn lefts<T, U>(eithers: [t<T, U>]) -> [T] {
13+
fn lefts<@T, U>(eithers: [t<T, U>]) -> [T] {
1414
let result: [T] = [];
1515
for elt: t<T, U> in eithers {
1616
alt elt { left(l) { result += [l]; } _ {/* fallthrough */ } }
1717
}
1818
ret result;
1919
}
2020

21-
fn rights<T, U>(eithers: [t<T, U>]) -> [U] {
21+
fn rights<T, @U>(eithers: [t<T, U>]) -> [U] {
2222
let result: [U] = [];
2323
for elt: t<T, U> in eithers {
2424
alt elt { right(r) { result += [r]; } _ {/* fallthrough */ } }
2525
}
2626
ret result;
2727
}
2828

29-
fn partition<T, U>(eithers: [t<T, U>]) -> {lefts: [T], rights: [U]} {
29+
fn partition<@T, @U>(eithers: [t<T, U>]) -> {lefts: [T], rights: [U]} {
3030
let lefts: [T] = [];
3131
let rights: [U] = [];
3232
for elt: t<T, U> in eithers {

src/lib/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ iter iter2<@T>(v: [T]) -> (uint, T) {
343343
mod unsafe {
344344
type vec_repr = {mutable fill: uint, mutable alloc: uint, data: u8};
345345

346-
fn from_buf<T>(ptr: *T, elts: uint) -> [T] {
346+
fn from_buf<@T>(ptr: *T, elts: uint) -> [T] {
347347
ret rustrt::vec_from_buf_shared(ptr, elts);
348348
}
349349

src/test/run-pass/alloca-from-derived-tydesc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ tag option<T> { some(T); none; }
22

33
type r<T> = {mutable v: [option<T>]};
44

5-
fn f<T>() -> [T] { ret []; }
5+
fn f<@T>() -> [T] { ret []; }
66

77
fn main() { let r: r<int> = {mutable v: []}; r.v = f(); }

src/test/run-pass/ivec-add.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fn double<T>(a: T) -> [T] { ret [a] + [a]; }
1+
fn double<@T>(a: T) -> [T] { ret [a] + [a]; }
22

33
fn double_int(a: int) -> [int] { ret [a] + [a]; }
44

src/test/run-pass/vec-push.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

22

3-
fn push<T>(&v: [mutable? T], t: T) { v += [t]; }
3+
fn push<@T>(&v: [mutable? T], t: T) { v += [t]; }
44

55
fn main() { let v = [1, 2, 3]; push(v, 1); }

0 commit comments

Comments
 (0)