about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-10-10 13:54:03 +0200
committerMarijn Haverbeke <marijnh@gmail.com>2011-10-10 16:01:51 +0200
commit33167f7decfdc70c9dca6c41f80883f12c13cfbc (patch)
tree6a7b610fe6af5bd7e1ff81c54e63a580505f32d2 /src
parentb4bae8fea5943a0b95a1a9be13a8155ee45418b7 (diff)
downloadrust-33167f7decfdc70c9dca6c41f80883f12c13cfbc.tar.gz
rust-33167f7decfdc70c9dca6c41f80883f12c13cfbc.zip
Adjust function signatures to allow for vecs being immediate
Some code was relying on vectors being implicitly by-reference (as
non-immediate value). This adds the necessary &&-sigils.

Closes #1021
Diffstat (limited to 'src')
-rw-r--r--src/comp/back/rpath.rs4
-rw-r--r--src/comp/driver/rustc.rs2
-rw-r--r--src/comp/front/config.rs2
-rw-r--r--src/comp/metadata/common.rs2
-rw-r--r--src/comp/metadata/encoder.rs2
-rw-r--r--src/comp/middle/resolve.rs2
-rw-r--r--src/comp/middle/trans.rs24
-rw-r--r--src/comp/syntax/ext/simplext.rs4
-rw-r--r--src/comp/syntax/fold.rs10
-rw-r--r--src/comp/syntax/print/pprust.rs2
-rw-r--r--src/compiletest/runtest.rs2
-rw-r--r--src/lib/str.rs6
-rw-r--r--src/test/bench/task-perf-word-count-generic.rs4
-rw-r--r--src/test/run-fail/unwind-misc-1.rs4
-rw-r--r--src/test/run-pass/bind-parameterized-args-2.rs2
15 files changed, 34 insertions, 38 deletions
diff --git a/src/comp/back/rpath.rs b/src/comp/back/rpath.rs
index a1bcb8f8bd3..fcf76e6e423 100644
--- a/src/comp/back/rpath.rs
+++ b/src/comp/back/rpath.rs
@@ -101,7 +101,7 @@ fn get_rpaths_relative_to_output(os: session::os,
 fn get_rpath_relative_to_output(os: session::os,
                                 cwd: fs::path,
                                 output: fs::path,
-                                lib: fs::path) -> str {
+                                &&lib: fs::path) -> str {
     // Mac doesn't appear to support $ORIGIN
     let prefix = alt os {
         session::os_linux. { "$ORIGIN" + fs::path_sep() }
@@ -154,7 +154,7 @@ fn get_absolute_rpaths(cwd: fs::path, libs: [fs::path]) -> [str] {
     vec::map(bind get_absolute_rpath(cwd, _), libs)
 }
 
-fn get_absolute_rpath(cwd: fs::path, lib: fs::path) -> str {
+fn get_absolute_rpath(cwd: fs::path, &&lib: fs::path) -> str {
     fs::dirname(get_absolute(cwd, lib))
 }
 
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs
index 46865d10fa2..c7084138c98 100644
--- a/src/comp/driver/rustc.rs
+++ b/src/comp/driver/rustc.rs
@@ -409,7 +409,7 @@ fn build_session(sopts: @session::options) -> session::session {
                          none, 0u, filesearch);
 }
 
-fn parse_pretty(sess: session::session, name: str) -> pp_mode {
+fn parse_pretty(sess: session::session, &&name: str) -> pp_mode {
     if str::eq(name, "normal") {
         ret ppm_normal;
     } else if str::eq(name, "expanded") {
diff --git a/src/comp/front/config.rs b/src/comp/front/config.rs
index 7d1c6eea7ae..676f77c95b3 100644
--- a/src/comp/front/config.rs
+++ b/src/comp/front/config.rs
@@ -98,7 +98,7 @@ fn in_cfg(cfg: ast::crate_cfg, attrs: [ast::attribute]) -> bool {
     // so we can match against them. This is the list of configurations for
     // which the item is valid
     let item_cfg_metas = {
-        fn extract_metas(inner_items: [@ast::meta_item],
+        fn extract_metas(&&inner_items: [@ast::meta_item],
                          &&cfg_item: @ast::meta_item) -> [@ast::meta_item] {
             alt cfg_item.node {
               ast::meta_list(name, items) {
diff --git a/src/comp/metadata/common.rs b/src/comp/metadata/common.rs
index 134e43d6280..fdb2d72da6f 100644
--- a/src/comp/metadata/common.rs
+++ b/src/comp/metadata/common.rs
@@ -67,7 +67,7 @@ const tag_items_data_item_inlineness: uint = 0x27u;
 // djb's cdb hashes.
 fn hash_node_id(&&node_id: int) -> uint { ret 177573u ^ (node_id as uint); }
 
-fn hash_path(s: str) -> uint {
+fn hash_path(&&s: str) -> uint {
     let h = 5381u;
     for ch: u8 in str::bytes(s) { h = (h << 5u) + h ^ (ch as uint); }
     ret h;
diff --git a/src/comp/metadata/encoder.rs b/src/comp/metadata/encoder.rs
index f8145c306c8..7850b4139a1 100644
--- a/src/comp/metadata/encoder.rs
+++ b/src/comp/metadata/encoder.rs
@@ -425,7 +425,7 @@ fn encode_index<T>(ebml_w: ebml::writer, buckets: [@[entry<T>]],
     ebml::end_tag(ebml_w);
 }
 
-fn write_str(writer: io::writer, s: str) { writer.write_str(s); }
+fn write_str(writer: io::writer, &&s: str) { writer.write_str(s); }
 
 fn write_int(writer: io::writer, &&n: int) {
     writer.write_be_uint(n as uint, 4u);
diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs
index fe95ecc0b85..f2995f58b6c 100644
--- a/src/comp/middle/resolve.rs
+++ b/src/comp/middle/resolve.rs
@@ -1400,7 +1400,7 @@ fn add_name(ch: checker, sp: span, name: ident) {
     ch.seen += [name];
 }
 
-fn ident_id(i: ident) -> ident { ret i; }
+fn ident_id(&&i: ident) -> ident { ret i; }
 
 fn ensure_unique<T>(e: env, sp: span, elts: [T], id: fn(T) -> ident,
                     kind: str) {
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 4e20543bc0b..8e2fa8fedf0 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -5633,7 +5633,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
                    takes_argv: bool) -> ValueRef {
         let unit_ty = ty::mk_str(ccx.tcx);
         let vecarg_ty: ty::arg =
-            {mode: ast::by_ref,
+            {mode: ast::by_val,
              ty: ty::mk_vec(ccx.tcx, {ty: unit_ty, mut: ast::imm})};
         // FIXME: mk_nil should have a postcondition
         let nt = ty::mk_nil(ccx.tcx);
@@ -5653,14 +5653,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
         let lltaskarg = llvm::LLVMGetParam(llfdecl, 1u);
         let llenvarg = llvm::LLVMGetParam(llfdecl, 2u);
         let args = [lloutputarg, lltaskarg, llenvarg];
-        if takes_argv {
-            let llargvarg = llvm::LLVMGetParam(llfdecl, 3u);
-            // The runtime still passes the arg vector by value, this kludge
-            // makes sure it becomes a pointer (to a pointer to a vec).
-            let minus_ptr = llvm::LLVMGetElementType(val_ty(llargvarg));
-            llargvarg = PointerCast(bcx, llargvarg, minus_ptr);
-            args += [do_spill_noroot(bcx, llargvarg)];
-        }
+        if takes_argv { args += [llvm::LLVMGetParam(llfdecl, 3u)]; }
         Call(bcx, main_llfn, args);
         build_return(bcx);
 
@@ -5944,7 +5937,7 @@ fn register_native_fn(ccx: @crate_ctxt, sp: span, path: [str], name: str,
 
 fn item_path(item: @ast::item) -> [str] { ret [item.ident]; }
 
-fn collect_native_item(ccx: @crate_ctxt, i: @ast::native_item, pt: [str],
+fn collect_native_item(ccx: @crate_ctxt, i: @ast::native_item, &&pt: [str],
                        _v: vt<[str]>) {
     alt i.node {
       ast::native_item_fn(_, _, _) {
@@ -5956,7 +5949,8 @@ fn collect_native_item(ccx: @crate_ctxt, i: @ast::native_item, pt: [str],
     }
 }
 
-fn collect_item_1(ccx: @crate_ctxt, i: @ast::item, pt: [str], v: vt<[str]>) {
+fn collect_item_1(ccx: @crate_ctxt, i: @ast::item, &&pt: [str],
+                  v: vt<[str]>) {
     visit::visit_item(i, pt + item_path(i), v);
     alt i.node {
       ast::item_const(_, _) {
@@ -5977,7 +5971,8 @@ fn collect_item_1(ccx: @crate_ctxt, i: @ast::item, pt: [str], v: vt<[str]>) {
     }
 }
 
-fn collect_item_2(ccx: @crate_ctxt, i: @ast::item, pt: [str], v: vt<[str]>) {
+fn collect_item_2(ccx: @crate_ctxt, i: @ast::item, &&pt: [str],
+                  v: vt<[str]>) {
     let new_pt = pt + item_path(i);
     visit::visit_item(i, new_pt, v);
     alt i.node {
@@ -6018,7 +6013,7 @@ fn collect_items(ccx: @crate_ctxt, crate: @ast::crate) {
     visit::visit_crate(*crate, [], visit::mk_vt(visitor2));
 }
 
-fn collect_tag_ctor(ccx: @crate_ctxt, i: @ast::item, pt: [str],
+fn collect_tag_ctor(ccx: @crate_ctxt, i: @ast::item, &&pt: [str],
                     v: vt<[str]>) {
     let new_pt = pt + item_path(i);
     visit::visit_item(i, new_pt, v);
@@ -6044,7 +6039,8 @@ fn collect_tag_ctors(ccx: @crate_ctxt, crate: @ast::crate) {
 
 
 // The constant translation pass.
-fn trans_constant(ccx: @crate_ctxt, it: @ast::item, pt: [str], v: vt<[str]>) {
+fn trans_constant(ccx: @crate_ctxt, it: @ast::item, &&pt: [str],
+                  v: vt<[str]>) {
     let new_pt = pt + item_path(it);
     visit::visit_item(it, new_pt, v);
     alt it.node {
diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs
index 966d1f95c00..656ee3663af 100644
--- a/src/comp/syntax/ext/simplext.rs
+++ b/src/comp/syntax/ext/simplext.rs
@@ -245,7 +245,7 @@ fn follow_for_trans(cx: ext_ctxt, mmaybe: option::t<arb_depth<matchable>>,
 /* helper for transcribe_exprs: what vars from `b` occur in `e`? */
 iter free_vars(b: bindings, e: @expr) -> ident {
     let idents: hashmap<ident, ()> = new_str_hash::<()>();
-    fn mark_ident(i: ident, _fld: ast_fold, b: bindings,
+    fn mark_ident(&&i: ident, _fld: ast_fold, b: bindings,
                   idents: hashmap<ident, ()>) -> ident {
         if b.contains_key(i) { idents.insert(i, ()); }
         ret i;
@@ -325,7 +325,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
 
 // substitute, in a position that's required to be an ident
 fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
-                    i: ident, _fld: ast_fold) -> ident {
+                    &&i: ident, _fld: ast_fold) -> ident {
     ret alt follow_for_trans(cx, b.find(i), idx_path) {
           some(match_ident(a_id)) { a_id.node }
           some(m) { match_error(cx, m, "an identifier") }
diff --git a/src/comp/syntax/fold.rs b/src/comp/syntax/fold.rs
index 2249cf66147..4a81ca1da0e 100644
--- a/src/comp/syntax/fold.rs
+++ b/src/comp/syntax/fold.rs
@@ -39,7 +39,7 @@ type ast_fold_precursor =
      fold_mod: fn(_mod, ast_fold) -> _mod,
      fold_native_mod: fn(native_mod, ast_fold) -> native_mod,
      fold_variant: fn(variant_, ast_fold) -> variant_,
-     fold_ident: fn(ident, ast_fold) -> ident,
+     fold_ident: fn(&&ident, ast_fold) -> ident,
      fold_path: fn(path_, ast_fold) -> path_,
      fold_local: fn(local_, ast_fold) -> local_,
      map_exprs: fn(fn(&&@expr) -> @expr, [@expr]) -> [@expr],
@@ -66,7 +66,7 @@ type a_f =
      fold_mod: fn(_mod) -> _mod,
      fold_native_mod: fn(native_mod) -> native_mod,
      fold_variant: fn(variant) -> variant,
-     fold_ident: fn(ident) -> ident,
+     fold_ident: fn(&&ident) -> ident,
      fold_path: fn(path) -> path,
      fold_local: fn(&&@local) -> @local,
      map_exprs: fn(fn(&&@expr) -> @expr, [@expr]) -> [@expr],
@@ -96,7 +96,7 @@ fn nf_fn_dummy(_f: _fn) -> _fn { fail; }
 fn nf_mod_dummy(_m: _mod) -> _mod { fail; }
 fn nf_native_mod_dummy(_n: native_mod) -> native_mod { fail; }
 fn nf_variant_dummy(_v: variant) -> variant { fail; }
-fn nf_ident_dummy(_i: ident) -> ident { fail; }
+fn nf_ident_dummy(&&_i: ident) -> ident { fail; }
 fn nf_path_dummy(_p: path) -> path { fail; }
 fn nf_obj_field_dummy(_o: obj_field) -> obj_field { fail; }
 fn nf_local_dummy(&&_o: @local) -> @local { fail; }
@@ -471,7 +471,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
     ret {name: v.name, args: vec::map(fold_variant_arg, v.args), id: v.id};
 }
 
-fn noop_fold_ident(i: ident, _fld: ast_fold) -> ident { ret i; }
+fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident { ret i; }
 
 fn noop_fold_path(p: path_, fld: ast_fold) -> path_ {
     ret {global: p.global,
@@ -667,7 +667,7 @@ fn make_fold(afp: ast_fold_precursor) -> @foldres {
        variant {
         ret {node: afp.fold_variant(x.node, f), span: afp.new_span(x.span)};
     }
-    fn f_ident(afp: ast_fold_precursor, f: ast_fold, x: ident) -> ident {
+    fn f_ident(afp: ast_fold_precursor, f: ast_fold, &&x: ident) -> ident {
         ret afp.fold_ident(x, f);
     }
     fn f_path(afp: ast_fold_precursor, f: ast_fold, x: path) -> path {
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index a24b4c9b984..f20dc407ec8 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -1277,7 +1277,7 @@ fn print_view_item(s: ps, item: @ast::view_item) {
       ast::view_item_export(ids, _) {
         head(s, "export");
         commasep(s, inconsistent, ids,
-                 fn (s: ps, w: ast::ident) { word(s.s, w) });
+                 fn (s: ps, &&w: ast::ident) { word(s.s, w) });
       }
     }
     word(s.s, ";");
diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs
index ebedb4f0685..06a327c507f 100644
--- a/src/compiletest/runtest.rs
+++ b/src/compiletest/runtest.rs
@@ -276,7 +276,7 @@ fn make_run_args(config: config, _props: test_props, testfile: str) ->
 
 fn split_maybe_args(argstr: option::t<str>) -> [str] {
     fn rm_whitespace(v: [str]) -> [str] {
-        fn flt(s: str) -> option::t<str> {
+        fn flt(&&s: str) -> option::t<str> {
             if !is_whitespace(s) { option::some(s) } else { option::none }
         }
 
diff --git a/src/lib/str.rs b/src/lib/str.rs
index 9efb24b6e51..a3c8a548692 100644
--- a/src/lib/str.rs
+++ b/src/lib/str.rs
@@ -11,11 +11,11 @@ native "rust" mod rustrt {
     fn rust_str_push(&s: str, ch: u8);
 }
 
-fn eq(a: str, b: str) -> bool { a == b }
+fn eq(&&a: str, &&b: str) -> bool { a == b }
 
-fn lteq(a: str, b: str) -> bool { a <= b }
+fn lteq(&&a: str, &&b: str) -> bool { a <= b }
 
-fn hash(s: str) -> uint {
+fn hash(&&s: str) -> uint {
     // djb hash.
     // FIXME: replace with murmur.
 
diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs
index 436d6d1400d..1edfff5828d 100644
--- a/src/test/bench/task-perf-word-count-generic.rs
+++ b/src/test/bench/task-perf-word-count-generic.rs
@@ -29,7 +29,7 @@ import std::comm::port;
 import std::comm::recv;
 import std::comm::send;
 
-fn map(filename: [u8], emit: map_reduce::putter<[u8], int>) {
+fn map(&&filename: [u8], emit: map_reduce::putter<[u8], int>) {
     let f = io::file_reader(str::unsafe_from_bytes(filename));
 
     while true {
@@ -40,7 +40,7 @@ fn map(filename: [u8], emit: map_reduce::putter<[u8], int>) {
     }
 }
 
-fn reduce(_word: [u8], get: map_reduce::getter<int>) {
+fn reduce(&&_word: [u8], get: map_reduce::getter<int>) {
     let count = 0;
 
     while true { alt get() { some(_) { count += 1; } none. { break; } } }
diff --git a/src/test/run-fail/unwind-misc-1.rs b/src/test/run-fail/unwind-misc-1.rs
index 15d433ae363..822d1fc4b30 100644
--- a/src/test/run-fail/unwind-misc-1.rs
+++ b/src/test/run-fail/unwind-misc-1.rs
@@ -6,7 +6,7 @@ import std::uint;
 
 fn main() {
     let count = @mutable 0u;
-    let hash = bind fn (_s: [@str], count: @mutable uint) -> uint {
+    let hash = bind fn (&&_s: [@str], count: @mutable uint) -> uint {
         *count += 1u;
         if *count == 10u {
             fail;
@@ -15,7 +15,7 @@ fn main() {
         }
     } (_, count);
 
-    fn eq(s: [@str], t: [@str]) -> bool {
+    fn eq(&&s: [@str], &&t: [@str]) -> bool {
         ret s == t;
     }
 
diff --git a/src/test/run-pass/bind-parameterized-args-2.rs b/src/test/run-pass/bind-parameterized-args-2.rs
index 266ad2ddbed..c4d3b51cc28 100644
--- a/src/test/run-pass/bind-parameterized-args-2.rs
+++ b/src/test/run-pass/bind-parameterized-args-2.rs
@@ -3,5 +3,5 @@ fn main() {
 
     let y = bind echo(42, _);
 
-    y(fn (i: str) { });
+    y(fn(&&i: str) { });
 }