about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-09-23 18:50:00 -0700
committerBrian Anderson <banderson@mozilla.com>2011-09-24 12:36:51 -0700
commit856acbf66d21a20bd115f11c55c7abecd1f4c92e (patch)
treea72941a31d110bf53eb9d99d86a56c636576ceca /src
parente5d5682065eac04322bb1cc21c1cd672393c6c33 (diff)
downloadrust-856acbf66d21a20bd115f11c55c7abecd1f4c92e.tar.gz
rust-856acbf66d21a20bd115f11c55c7abecd1f4c92e.zip
Vectors containing pinned kinds become pinned
Otherwise they could be copied
Diffstat (limited to 'src')
-rw-r--r--src/comp/metadata/encoder.rs2
-rw-r--r--src/comp/middle/ty.rs11
-rw-r--r--src/comp/syntax/ext/simplext.rs2
-rw-r--r--src/comp/syntax/parse/parser.rs18
-rw-r--r--src/lib/either.rs6
-rw-r--r--src/lib/vec.rs2
-rw-r--r--src/test/run-pass/alloca-from-derived-tydesc.rs2
-rw-r--r--src/test/run-pass/ivec-add.rs2
-rw-r--r--src/test/run-pass/vec-push.rs2
9 files changed, 23 insertions, 24 deletions
diff --git a/src/comp/metadata/encoder.rs b/src/comp/metadata/encoder.rs
index 154f623eacb..bf43b158be7 100644
--- a/src/comp/metadata/encoder.rs
+++ b/src/comp/metadata/encoder.rs
@@ -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 []]; }
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 190b974f72a..a013359f3b0 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -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);
       }
diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs
index c6b6056bbc4..528b2cdc756 100644
--- a/src/comp/syntax/ext/simplext.rs
+++ b/src/comp/syntax/ext/simplext.rs
@@ -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 {
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index a3918986175..ba01d4e4a1e 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -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();
diff --git a/src/lib/either.rs b/src/lib/either.rs
index 143f0cabe92..d20b124a968 100644
--- a/src/lib/either.rs
+++ b/src/lib/either.rs
@@ -10,7 +10,7 @@ fn either<T, U,
     alt value { left(l) { f_left(l) } right(r) { f_right(r) } }
 }
 
-fn lefts<T, U>(eithers: [t<T, U>]) -> [T] {
+fn lefts<@T, U>(eithers: [t<T, U>]) -> [T] {
     let result: [T] = [];
     for elt: t<T, U> in eithers {
         alt elt { left(l) { result += [l]; } _ {/* fallthrough */ } }
@@ -18,7 +18,7 @@ fn lefts<T, U>(eithers: [t<T, U>]) -> [T] {
     ret result;
 }
 
-fn rights<T, U>(eithers: [t<T, U>]) -> [U] {
+fn rights<T, @U>(eithers: [t<T, U>]) -> [U] {
     let result: [U] = [];
     for elt: t<T, U> in eithers {
         alt elt { right(r) { result += [r]; } _ {/* fallthrough */ } }
@@ -26,7 +26,7 @@ fn rights<T, U>(eithers: [t<T, U>]) -> [U] {
     ret result;
 }
 
-fn partition<T, U>(eithers: [t<T, U>]) -> {lefts: [T], rights: [U]} {
+fn partition<@T, @U>(eithers: [t<T, U>]) -> {lefts: [T], rights: [U]} {
     let lefts: [T] = [];
     let rights: [U] = [];
     for elt: t<T, U> in eithers {
diff --git a/src/lib/vec.rs b/src/lib/vec.rs
index fef91259b50..84bd02e3689 100644
--- a/src/lib/vec.rs
+++ b/src/lib/vec.rs
@@ -343,7 +343,7 @@ iter iter2<@T>(v: [T]) -> (uint, T) {
 mod unsafe {
     type vec_repr = {mutable fill: uint, mutable alloc: uint, data: u8};
 
-    fn from_buf<T>(ptr: *T, elts: uint) -> [T] {
+    fn from_buf<@T>(ptr: *T, elts: uint) -> [T] {
         ret rustrt::vec_from_buf_shared(ptr, elts);
     }
 
diff --git a/src/test/run-pass/alloca-from-derived-tydesc.rs b/src/test/run-pass/alloca-from-derived-tydesc.rs
index 6077bbf6723..57e31935738 100644
--- a/src/test/run-pass/alloca-from-derived-tydesc.rs
+++ b/src/test/run-pass/alloca-from-derived-tydesc.rs
@@ -2,6 +2,6 @@ tag option<T> { some(T); none; }
 
 type r<T> = {mutable v: [option<T>]};
 
-fn f<T>() -> [T] { ret []; }
+fn f<@T>() -> [T] { ret []; }
 
 fn main() { let r: r<int> = {mutable v: []}; r.v = f(); }
diff --git a/src/test/run-pass/ivec-add.rs b/src/test/run-pass/ivec-add.rs
index f9378b21317..e13b2557b09 100644
--- a/src/test/run-pass/ivec-add.rs
+++ b/src/test/run-pass/ivec-add.rs
@@ -1,4 +1,4 @@
-fn double<T>(a: T) -> [T] { ret [a] + [a]; }
+fn double<@T>(a: T) -> [T] { ret [a] + [a]; }
 
 fn double_int(a: int) -> [int] { ret [a] + [a]; }
 
diff --git a/src/test/run-pass/vec-push.rs b/src/test/run-pass/vec-push.rs
index 0e0d828bf63..bb7b6805f14 100644
--- a/src/test/run-pass/vec-push.rs
+++ b/src/test/run-pass/vec-push.rs
@@ -1,5 +1,5 @@
 
 
-fn push<T>(&v: [mutable? T], t: T) { v += [t]; }
+fn push<@T>(&v: [mutable? T], t: T) { v += [t]; }
 
 fn main() { let v = [1, 2, 3]; push(v, 1); }