Permalink
Browse files

Eliminate usages of old sugared call syntax

  • Loading branch information...
1 parent 8b24911 commit a3382b6f26e582210a3b649c9a71badaef0530bf @brson brson committed Jun 26, 2012
Showing with 1,561 additions and 1,572 deletions.
  1. +2 −2 doc/rust.md
  2. +21 −33 doc/tutorial.md
  3. +4 −4 src/cargo/cargo.rs
  4. +3 −3 src/compiletest/header.rs
  5. +5 −5 src/compiletest/procsrv.rs
  6. +1 −1 src/compiletest/runtest.rs
  7. +7 −7 src/fuzzer/fuzzer.rs
  8. +7 −7 src/libcore/arc.rs
  9. +2 −2 src/libcore/bool.rs
  10. +21 −21 src/libcore/comm.rs
  11. +8 −8 src/libcore/dvec.rs
  12. +7 −7 src/libcore/future.rs
  13. +2 −2 src/libcore/int-template.rs
  14. +26 −26 src/libcore/io.rs
  15. +1 −1 src/libcore/iter-trait/dvec.rs
  16. +5 −5 src/libcore/iter.rs
  17. +2 −2 src/libcore/newcomm.rs
  18. +2 −2 src/libcore/option.rs
  19. +41 −42 src/libcore/os.rs
  20. +17 −17 src/libcore/priv.rs
  21. +8 −8 src/libcore/ptr.rs
  22. +1 −1 src/libcore/rand.rs
  23. +8 −8 src/libcore/result.rs
  24. +11 −11 src/libcore/run.rs
  25. +1 −1 src/libcore/stackwalk.rs
  26. +30 −30 src/libcore/str.rs
  27. +3 −3 src/libcore/sys.rs
  28. +53 −53 src/libcore/task.rs
  29. +3 −3 src/libcore/uint-template.rs
  30. +25 −25 src/libcore/vec.rs
  31. +16 −16 src/libstd/ebml.rs
  32. +4 −4 src/libstd/json.rs
  33. +2 −2 src/libstd/list.rs
  34. +4 −4 src/libstd/map.rs
  35. +1 −1 src/libstd/md4.rs
  36. +24 −24 src/libstd/net_tcp.rs
  37. +19 −19 src/libstd/par.rs
  38. +1 −1 src/libstd/rope.rs
  39. +14 −14 src/libstd/serialization.rs
  40. +1 −1 src/libstd/smallintmap.rs
  41. +2 −2 src/libstd/test.rs
  42. +38 −38 src/libstd/time.rs
  43. +10 −10 src/libstd/timer.rs
  44. +9 −9 src/libstd/uv_global_loop.rs
  45. +8 −8 src/libstd/uv_iotask.rs
  46. +2 −2 src/libstd/uv_ll.rs
  47. +4 −4 src/libsyntax/ast_map.rs
  48. +9 −9 src/libsyntax/ast_util.rs
  49. +2 −2 src/libsyntax/attr.rs
  50. +1 −1 src/libsyntax/diagnostic.rs
  51. +22 −20 src/libsyntax/ext/auto_serialize.rs
  52. +2 −2 src/libsyntax/ext/expand.rs
  53. +5 −5 src/libsyntax/ext/qquote.rs
  54. +1 −1 src/libsyntax/ext/simplext.rs
  55. +2 −2 src/libsyntax/ext/source_util.rs
  56. +6 −6 src/libsyntax/fold.rs
  57. +5 −5 src/libsyntax/parse/parser.rs
  58. +4 −4 src/libsyntax/print/pprust.rs
  59. +4 −4 src/libsyntax/visit.rs
  60. +1 −1 src/rustc/back/link.rs
  61. +2 −2 src/rustc/driver/driver.rs
  62. +2 −2 src/rustc/driver/rustc.rs
  63. +1 −1 src/rustc/front/config.rs
  64. +1 −1 src/rustc/front/test.rs
  65. +2 −2 src/rustc/metadata/creader.rs
  66. +1 −1 src/rustc/metadata/csearch.rs
  67. +1 −1 src/rustc/metadata/cstore.rs
  68. +24 −24 src/rustc/metadata/decoder.rs
  69. +19 −19 src/rustc/metadata/encoder.rs
  70. +3 −3 src/rustc/metadata/filesearch.rs
  71. +2 −2 src/rustc/metadata/tydecode.rs
  72. +2 −2 src/rustc/metadata/tyencode.rs
  73. +84 −84 src/rustc/middle/astencode.rs
  74. +9 −9 src/rustc/middle/borrowck/categorization.rs
  75. +5 −5 src/rustc/middle/borrowck/check_loans.rs
  76. +2 −2 src/rustc/middle/borrowck/gather_loans.rs
  77. +1 −1 src/rustc/middle/capture.rs
  78. +1 −1 src/rustc/middle/check_alt.rs
  79. +1 −1 src/rustc/middle/check_const.rs
  80. +6 −6 src/rustc/middle/kind.rs
  81. +3 −3 src/rustc/middle/lint.rs
  82. +30 −30 src/rustc/middle/liveness.rs
  83. +3 −3 src/rustc/middle/pat_util.rs
  84. +28 −28 src/rustc/middle/resolve.rs
  85. +12 −12 src/rustc/middle/trans/alt.rs
  86. +32 −31 src/rustc/middle/trans/base.rs
  87. +1 −1 src/rustc/middle/trans/build.rs
  88. +7 −7 src/rustc/middle/trans/closure.rs
  89. +11 −11 src/rustc/middle/trans/common.rs
  90. +8 −8 src/rustc/middle/trans/foreign.rs
  91. +2 −2 src/rustc/middle/trans/impl.rs
  92. +2 −2 src/rustc/middle/trans/reachable.rs
  93. +2 −2 src/rustc/middle/trans/reflect.rs
  94. +8 −8 src/rustc/middle/trans/shape.rs
  95. +1 −1 src/rustc/middle/trans/tvec.rs
  96. +2 −2 src/rustc/middle/trans/type_of.rs
  97. +10 −10 src/rustc/middle/trans/type_use.rs
  98. +1 −1 src/rustc/middle/trans/uniq.rs
  99. +7 −7 src/rustc/middle/tstate/auxiliary.rs
  100. +1 −1 src/rustc/middle/tstate/bitvectors.rs
  101. +4 −4 src/rustc/middle/tstate/pre_post_conditions.rs
  102. +36 −40 src/rustc/middle/ty.rs
  103. +9 −9 src/rustc/middle/typeck/astconv.rs
  104. +29 −29 src/rustc/middle/typeck/check.rs
  105. +3 −3 src/rustc/middle/typeck/check/alt.rs
  106. +10 −10 src/rustc/middle/typeck/check/regionmanip.rs
  107. +1 −1 src/rustc/middle/typeck/check/writeback.rs
  108. +15 −15 src/rustc/middle/typeck/collect.rs
  109. +133 −132 src/rustc/middle/typeck/infer.rs
  110. +2 −2 src/rustc/middle/typeck/rscope.rs
  111. +2 −2 src/rustc/util/common.rs
  112. +14 −14 src/rustdoc/astsrv.rs
  113. +14 −14 src/rustdoc/attr_pass.rs
  114. +12 −10 src/rustdoc/config.rs
  115. +7 −7 src/rustdoc/desc_to_brief_pass.rs
  116. +18 −18 src/rustdoc/doc.rs
  117. +6 −6 src/rustdoc/extract.rs
  118. +13 −13 src/rustdoc/fold.rs
  119. +5 −5 src/rustdoc/markdown_index_pass.rs
  120. +6 −6 src/rustdoc/markdown_pass.rs
  121. +8 −8 src/rustdoc/markdown_writer.rs
  122. +3 −3 src/rustdoc/page_pass.rs
  123. +4 −4 src/rustdoc/par.rs
  124. +4 −4 src/rustdoc/path_pass.rs
  125. +4 −4 src/rustdoc/prune_hidden_pass.rs
  126. +6 −6 src/rustdoc/prune_unexported_pass.rs
  127. +10 −10 src/rustdoc/reexport_pass.rs
  128. +8 −8 src/rustdoc/rustdoc.rs
  129. +3 −3 src/rustdoc/sectionalize_pass.rs
  130. +3 −3 src/rustdoc/sort_item_name_pass.rs
  131. +2 −2 src/rustdoc/sort_item_type_pass.rs
  132. +2 −2 src/rustdoc/sort_pass.rs
  133. +6 −6 src/rustdoc/text_pass.rs
  134. +1 −1 src/rustdoc/trim_pass.rs
  135. +16 −16 src/rustdoc/tystr_pass.rs
  136. +3 −3 src/rustdoc/unindent_pass.rs
  137. +1 −1 src/test/auxiliary/cci_capture_clause.rs
  138. +1 −1 src/test/auxiliary/test_comm.rs
  139. +21 −21 src/test/bench/graph500-bfs.rs
  140. +1 −1 src/test/bench/msgsend-ring-new.rs
  141. +1 −1 src/test/bench/msgsend-ring.rs
  142. +3 −3 src/test/bench/msgsend.rs
  143. +1 −1 src/test/bench/shootout-k-nucleotide.rs
  144. +2 −2 src/test/bench/shootout-mandelbrot.rs
  145. +4 −4 src/test/bench/shootout-pfib.rs
  146. +1 −1 src/test/bench/shootout-threadring.rs
  147. +2 −2 src/test/bench/task-perf-alloc-unwind.rs
  148. +6 −6 src/test/bench/task-perf-one-million.rs
  149. +2 −2 src/test/bench/task-perf-spawnalot.rs
  150. +3 −3 src/test/bench/task-perf-word-count-generic.rs
  151. +2 −2 src/test/bench/task-perf-word-count.rs
  152. +1 −1 src/test/compile-fail/block-arg-as-stmt-with-value.rs
  153. +1 −1 src/test/compile-fail/borrowck-assign-comp-idx.rs
  154. +1 −1 src/test/compile-fail/borrowck-lend-flow.rs
  155. +1 −1 src/test/compile-fail/borrowck-loan-blocks-move-cc.rs
  156. +1 −1 src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs
  157. +1 −1 src/test/compile-fail/borrowck-loan-rcvr.rs
  158. +3 −3 src/test/compile-fail/borrowck-loan-vec-content.rs
  159. +3 −3 src/test/compile-fail/cap-clause-with-stack-closure.rs
  160. +1 −1 src/test/compile-fail/do1.rs
  161. +1 −1 src/test/compile-fail/issue-2149.rs
  162. +1 −1 src/test/compile-fail/issue-2151.rs
  163. +1 −1 src/test/compile-fail/issue-2487-b.rs
  164. +3 −3 src/test/compile-fail/kindck-implicit-close-over-mut-var.rs
  165. +1 −1 src/test/compile-fail/liveness-issue-2163.rs
  166. +1 −1 src/test/compile-fail/no-capture-arc.rs
  167. +1 −1 src/test/compile-fail/no-reuse-move-arc.rs
  168. +1 −1 src/test/compile-fail/no-send-res-ports.rs
  169. +1 −1 src/test/compile-fail/private-method.rs
  170. +2 −2 src/test/compile-fail/pure-higher-order.rs
  171. +1 −1 src/test/compile-fail/regions-addr-of-upvar-self.rs
  172. +1 −1 src/test/compile-fail/regions-escape-loop-via-vec.rs
  173. +9 −9 src/test/compile-fail/regions-scoping.rs
  174. +2 −2 src/test/compile-fail/vec-concat-bug.rs
  175. +1 −1 src/test/pretty/block-arg-disambig.rs
  176. +1 −1 src/test/pretty/disamb-stmt-expr.rs
  177. +1 −1 src/test/run-fail/bug-2470-bounds-check-overflow.rs
  178. +2 −2 src/test/run-fail/crust-fail.rs
  179. +1 −1 src/test/run-fail/for-each-loop-fail.rs
  180. +1 −1 src/test/run-fail/issue-2156.rs
  181. +1 −1 src/test/run-fail/linked-failure.rs
  182. +1 −1 src/test/run-fail/linked-failure2.rs
  183. +2 −2 src/test/run-fail/linked-failure3.rs
  184. +3 −3 src/test/run-fail/linked-failure4.rs
  185. +1 −1 src/test/run-fail/morestack2.rs
  186. +1 −1 src/test/run-fail/morestack3.rs
  187. +1 −1 src/test/run-fail/morestack4.rs
  188. +1 −1 src/test/run-fail/rt-set-exit-status-fail2.rs
  189. +1 −1 src/test/run-fail/small-negative-indexing.rs
  190. +1 −1 src/test/run-fail/spawnfail.rs
  191. +1 −1 src/test/run-fail/task-comm-recv-block.rs
  192. +1 −1 src/test/run-fail/unwind-iter.rs
  193. +1 −1 src/test/run-fail/unwind-iter2.rs
  194. +2 −2 src/test/run-pass-fulldeps/qquote.rs
  195. +1 −1 src/test/run-pass/alt-phi.rs
  196. +1 −1 src/test/run-pass/auto_serialize.rs
  197. +2 −2 src/test/run-pass/basic-1.rs
  198. +2 −2 src/test/run-pass/basic-2.rs
  199. +2 −2 src/test/run-pass/basic.rs
  200. +1 −1 src/test/run-pass/block-arg-can-be-followed-by-binop.rs
  201. +1 −1 src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs
  202. +1 −1 src/test/run-pass/block-arg-can-be-followed-by-call.rs
  203. +4 −4 src/test/run-pass/block-arg-in-parentheses.rs
  204. +1 −1 src/test/run-pass/block-arg-used-as-any.rs
  205. +12 −12 src/test/run-pass/block-arg.rs
  206. +1 −1 src/test/run-pass/borrowck-borrow-from-expr-block.rs
  207. +1 −1 src/test/run-pass/borrowck-preserve-box-in-field.rs
  208. +1 −1 src/test/run-pass/borrowck-preserve-box-in-uniq.rs
  209. +1 −1 src/test/run-pass/borrowck-preserve-box.rs
  210. +1 −1 src/test/run-pass/borrowck-preserve-expl-deref.rs
  211. +1 −1 src/test/run-pass/cci_impl_exe.rs
  212. +1 −1 src/test/run-pass/cci_iter_exe.rs
  213. +1 −1 src/test/run-pass/cci_no_inline_exe.rs
  214. +1 −1 src/test/run-pass/chan-leak.rs
  215. +1 −1 src/test/run-pass/child-outlives-parent.rs
  216. +1 −1 src/test/run-pass/class-iface-bounded-param.rs
  217. +2 −2 src/test/run-pass/class-implements-multiple-ifaces.rs
  218. +2 −2 src/test/run-pass/cleanup-copy-mode.rs
  219. +1 −1 src/test/run-pass/comm.rs
  220. +1 −1 src/test/run-pass/crust-call-deep2.rs
  221. +1 −1 src/test/run-pass/crust-call-scrub.rs
  222. +2 −2 src/test/run-pass/crust-stress.rs
  223. +2 −2 src/test/run-pass/crust-yield.rs
  224. +3 −3 src/test/run-pass/foreach-nested.rs
  225. +1 −1 src/test/run-pass/foreach-put-structured.rs
  226. +1 −1 src/test/run-pass/foreach-simple-outer-slot.rs
  227. +1 −1 src/test/run-pass/hashmap-memory.rs
  228. +1 −1 src/test/run-pass/intrinsic-frame-address.rs
  229. +4 −4 src/test/run-pass/issue-2185.rs
  230. +1 −1 src/test/run-pass/issue-2487-a.rs
  231. +2 −2 src/test/run-pass/issue-507.rs
  232. +2 −2 src/test/run-pass/issue-687.rs
  233. +3 −3 src/test/run-pass/issue-783.rs
  234. +1 −1 src/test/run-pass/iter-range.rs
  235. +1 −1 src/test/run-pass/ivec-tag.rs
  236. +1 −1 src/test/run-pass/last-use-in-block.rs
  237. +1 −1 src/test/run-pass/last-use-is-capture.rs
  238. +2 −2 src/test/run-pass/lazychan.rs
  239. +2 −2 src/test/run-pass/lots-a-fail.rs
  240. +2 −2 src/test/run-pass/many.rs
  241. +2 −2 src/test/run-pass/monad.rs
  242. +1 −1 src/test/run-pass/morestack5.rs
  243. +1 −1 src/test/run-pass/morestack6.rs
  244. +2 −2 src/test/run-pass/osmain.rs
  245. +2 −2 src/test/run-pass/regions-params.rs
  246. +2 −2 src/test/run-pass/send-iloop.rs
  247. +1 −1 src/test/run-pass/send-resource.rs
  248. +1 −1 src/test/run-pass/sendfn-generic-fn.rs
  249. +3 −3 src/test/run-pass/spawn-fn.rs
  250. +1 −1 src/test/run-pass/spawn-types.rs
  251. +1 −1 src/test/run-pass/spawn.rs
  252. +1 −1 src/test/run-pass/spawn2.rs
  253. +1 −1 src/test/run-pass/static-impl.rs
  254. +1 −1 src/test/run-pass/task-comm-0.rs
  255. +1 −1 src/test/run-pass/task-comm-1.rs
  256. +1 −1 src/test/run-pass/task-comm-10.rs
  257. +1 −1 src/test/run-pass/task-comm-11.rs
  258. +1 −1 src/test/run-pass/task-comm-12.rs
  259. +1 −1 src/test/run-pass/task-comm-13.rs
  260. +1 −1 src/test/run-pass/task-comm-14.rs
  261. +1 −1 src/test/run-pass/task-comm-15.rs
  262. +1 −1 src/test/run-pass/task-comm-17.rs
  263. +1 −1 src/test/run-pass/task-comm-3.rs
  264. +4 −4 src/test/run-pass/task-comm-7.rs
  265. +1 −1 src/test/run-pass/task-comm-9.rs
  266. +2 −2 src/test/run-pass/task-comm-chan-cleanup4.rs
  267. +4 −4 src/test/run-pass/task-comm.rs
  268. +2 −2 src/test/run-pass/task-killjoin.rs
  269. +1 −1 src/test/run-pass/task-life-0.rs
  270. +2 −2 src/test/run-pass/terminate-in-initializer.rs
  271. +1 −1 src/test/run-pass/threads.rs
  272. +1 −1 src/test/run-pass/too-much-recursion.rs
  273. +1 −1 src/test/run-pass/type-params-in-for-each.rs
  274. +1 −1 src/test/run-pass/unique-send-2.rs
  275. +1 −1 src/test/run-pass/unwind-box.rs
  276. +1 −1 src/test/run-pass/unwind-resource.rs
  277. +1 −1 src/test/run-pass/unwind-resource2.rs
  278. +1 −1 src/test/run-pass/unwind-unique.rs
  279. +1 −1 src/test/run-pass/yield.rs
  280. +1 −1 src/test/run-pass/yield1.rs
View
@@ -1638,7 +1638,7 @@ task in a _failing state_.
~~~~
# let buildr = task::builder();
# task::unsupervise(buildr);
-# task::run(buildr) {||
+# do task::run(buildr) {||
(~[1, 2, 3, 4])[0];
(~[mut 'x', 'y'])[1] = 'z';
@@ -3365,7 +3365,7 @@ An example of a `spawn` call:
let po = comm::port();
let ch = comm::chan(po);
-task::spawn {||
+do task::spawn {||
// let task run, do other things
// ...
comm::send(ch, true);
View
@@ -924,7 +924,7 @@ processes. They copy the values they close over, much like boxed
closures, but they also 'own' them—meaning no other code can access
them. Unique closures mostly exist for spawning new [tasks](#tasks).
-### Shorthand syntax
+### Do syntax
The compact syntax used for stack closures (`{|arg1, arg2| body}`) can
also be used to express boxed and unique closures in situations where
@@ -934,25 +934,10 @@ the long-hand syntax for the function you're passing, since the
compiler can look at the argument type to find out what the parameter
types are.
-As a further simplification, if the final parameter to a function is a
-closure, the closure need not be placed within parentheses. You could,
-for example, write...
-
-~~~~
-let doubled = vec::map(~[1, 2, 3]) {|x| x*2};
-~~~~
-
-`vec::map` is a function in the core library that applies its last
-argument to every element of a vector, producing a new vector.
-
-Even when a closure takes no parameters, you must still write the bars
-for the parameter list, as in `{|| ...}`.
-
-## Iteration
-
-Functions taking closures provide a good way to define non-trivial
-iteration constructs. For example, this one iterates over a vector
-of integers backwards:
+Because closures in Rust are so versatile, they are used often, and in
+particular, functions taking closures are used as control structures
+in much the same way as `if` or `loop`. For example, this one iterates
+over a vector of integers backwards:
~~~~
fn for_rev(v: ~[int], act: fn(int)) {
@@ -971,19 +956,22 @@ To run such an iteration, you could do this:
for_rev(~[1, 2, 3], {|n| log(error, n); });
~~~~
-Making use of the shorthand where a final closure argument can be
-moved outside of the parentheses permits the following, which
-looks quite like a normal loop:
+Because this is such a common pattern Rust has a special form
+of function call that can be written more like a built-in control
+structure:
~~~~
-# fn for_rev(v: ~[int], act: fn(int)) {}
-for_rev(~[1, 2, 3]) {|n|
+# fn for_rev(v: [int], act: fn(int)) {}
+do for_rev(~[1, 2, 3]) {|n|
log(error, n);
}
~~~~
-Note that, because `for_rev()` returns unit type, no semicolon is
-needed when the final closure is pulled outside of the parentheses.
+Notice that the call is prefixed with the keyword `do` and, instead of
+writing the final closure inside the argument list it is moved outside
+of the parenthesis where it looks visually more like a typical block
+of code. The `do` expression is purely syntactic sugar for a call
+that takes a final closure argument.
# For loops
@@ -992,12 +980,12 @@ To allow breaking out of loops, many iteration functions, such as
`false` to break off iteration.
~~~~
-vec::each(~[2, 4, 8, 5, 16]) {|n|
+vec::each(~[2, 4, 8, 5, 16], {|n|
if n % 2 != 0 {
io::println("found odd number!");
false
} else { true }
-}
+});
~~~~
You can see how that gets noisy. As a syntactic convenience, if the
@@ -2350,7 +2338,7 @@ module `task`. Let's begin with the simplest one, `task::spawn()`:
~~~~
let some_value = 22;
-task::spawn {||
+do task::spawn {||
io::println("This executes in the child task.");
io::println(#fmt("%d", some_value));
}
@@ -2376,7 +2364,7 @@ in parallel. We might write something like:
# fn some_other_expensive_computation() {}
let port = comm::port::<int>();
let chan = comm::chan::<int>(port);
-task::spawn {||
+do task::spawn {||
let result = some_expensive_computation();
comm::send(chan, result);
}
@@ -2407,7 +2395,7 @@ The next statement actually spawns the child:
# fn some_expensive_computation() -> int { 42 }
# let port = comm::port::<int>();
# let chan = comm::chan::<int>(port);
-task::spawn {||
+do task::spawn {||
let result = some_expensive_computation();
comm::send(chan, result);
}
@@ -2470,7 +2458,7 @@ Here is the code for the parent task:
fn main() {
let from_child = comm::port();
let to_parent = comm::chan(from_child);
- let to_child = task::spawn_listener {|from_parent|
+ let to_child = do task::spawn_listener {|from_parent|
stringifier(from_parent, to_parent);
};
comm::send(to_child, 22u);
View
@@ -1469,10 +1469,10 @@ fn print_source(s: source) {
}, copy s.packages);
let l = vec::len(pks);
- print(io::with_str_writer() { |writer|
+ print(io::with_str_writer({ |writer|
let mut list = " >> ";
- vec::iteri(pks) { |i, pk|
+ do vec::iteri(pks) { |i, pk|
if str::len(list) > 78u {
writer.write_line(list);
list = " >> ";
@@ -1481,14 +1481,14 @@ fn print_source(s: source) {
}
writer.write_line(list);
- });
+ }));
}
fn cmd_list(c: cargo) {
sync(c);
if vec::len(c.opts.free) >= 3u {
- vec::iter_between(c.opts.free, 2u, vec::len(c.opts.free)) { |name|
+ do vec::iter_between(c.opts.free, 2u, vec::len(c.opts.free)) { |name|
if !valid_pkg_name(name) {
error(#fmt("'%s' is an invalid source name", name));
} else {
@@ -43,11 +43,11 @@ fn load_props(testfile: str) -> test_props {
pp_exact = parse_pp_exact(ln, testfile);
}
- option::iter(parse_aux_build(ln)) {|ab|
+ do option::iter(parse_aux_build(ln)) {|ab|
vec::push(aux_builds, ab);
}
- option::iter(parse_exec_env(ln)) {|ee|
+ do option::iter(parse_exec_env(ln)) {|ee|
vec::push(exec_env, ee);
}
};
@@ -104,7 +104,7 @@ fn parse_compile_flags(line: str) -> option<str> {
}
fn parse_exec_env(line: str) -> option<(str, str)> {
- parse_name_value_directive(line, "exec-env").map {|nv|
+ do parse_name_value_directive(line, "exec-env").map {|nv|
// nv is either FOO or FOO=BAR
let strs = str::splitn_char(nv, '=', 1u);
alt strs.len() {
View
@@ -13,7 +13,7 @@ fn target_env(lib_path: str, prog: str) -> ~[(str,str)] {
assert prog.ends_with(".exe");
let aux_path = prog.slice(0u, prog.len() - 4u) + ".libaux";
- env = vec::map(env) {|pair|
+ env = do vec::map(env) {|pair|
let (k,v) = pair;
if k == "PATH" { ("PATH", v + ";" + lib_path + ";" + aux_path) }
else { (k,v) }
@@ -60,14 +60,14 @@ fn run(lib_path: str,
writeclose(pipe_in.out, input);
let p = comm::port();
let ch = comm::chan(p);
- task::spawn_sched(task::single_threaded) {||
+ do task::spawn_sched(task::single_threaded) {||
let errput = readclose(pipe_err.in);
comm::send(ch, (2, errput));
- };
- task::spawn_sched(task::single_threaded) {||
+ }
+ do task::spawn_sched(task::single_threaded) {||
let output = readclose(pipe_out.in);
comm::send(ch, (1, output));
- };
+ }
let status = run::waitpid(pid);
let mut errs = "";
let mut outs = "";
@@ -321,7 +321,7 @@ fn compose_and_run_compiler(
let extra_link_args = ~["-L", aux_output_dir_name(config, testfile)];
- vec::iter(props.aux_builds) {|rel_ab|
+ do vec::iter(props.aux_builds) {|rel_ab|
let abs_ab = path::connect(config.aux_base, rel_ab);
let aux_args =
make_compile_args(config, props, ~["--lib"] + extra_link_args,
View
@@ -259,9 +259,9 @@ fn check_variants_T<T: copy>(
let L = vec::len(things);
if L < 100u {
- under(uint::min(L, 20u)) {|i|
+ do under(uint::min(L, 20u)) {|i|
log(error, "Replacing... #" + uint::str(i));
- under(uint::min(L, 30u)) {|j|
+ do under(uint::min(L, 30u)) {|j|
log(error, "With... " + stringifier(@things[j]));
let crate2 = @replacer(crate, i, things[j], cx.mode);
// It would be best to test the *crate* for stability, but
@@ -421,15 +421,15 @@ fn parse_and_print(code: @str) -> str {
write_file(filename, *code);
let crate = parse::parse_crate_from_source_str(
filename, code, ~[], sess);
- io::with_str_reader(*code) { |rdr|
+ io::with_str_reader(*code, { |rdr|
as_str({|a|pprust::print_crate(sess.cm,
sess.span_diagnostic,
crate,
filename,
rdr, a,
pprust::no_ann(),
false)})
- }
+ })
}
fn has_raw_pointers(c: ast::crate) -> bool {
@@ -565,16 +565,16 @@ fn check_variants(files: ~[str], cx: context) {
parse::parse_crate_from_source_str(
file,
s, ~[], sess);
- io::with_str_reader(*s) { |rdr|
+ io::with_str_reader(*s, { |rdr|
#error("%s",
as_str({|a|pprust::print_crate(sess.cm,
sess.span_diagnostic,
crate,
file,
rdr, a,
pprust::no_ann(),
- false)}));
- }
+ false)}))
+ });
check_variants_of_ast(*crate, sess.cm, file, cx);
}
}
View
@@ -109,9 +109,9 @@ impl methods<T: send> for exclusive<T> {
unsafe::reinterpret_cast(self.data);
let r = {
let rec: &ex_data<T> = &(*ptr).data;
- rec.lock.lock_cond() {|c|
+ rec.lock.lock_cond({|c|
f(c, &rec.data)
- }
+ })
};
unsafe::forget(ptr);
r
@@ -135,7 +135,7 @@ fn shared_arc<T: send const>(-data: T) -> shared_arc<T> {
let a = arc::arc(data);
let p = port();
let c = chan(p);
- task::spawn() {|move a|
+ do task::spawn() {|move a|
let mut live = true;
let terminate = port();
let get = port();
@@ -174,7 +174,7 @@ mod tests {
let p = port();
let c = chan(p);
- task::spawn() {||
+ do task::spawn() {||
let p = port();
c.send(chan(p));
@@ -200,7 +200,7 @@ mod tests {
let p = port();
let c = chan(p);
- task::spawn() {||
+ do task::spawn() {||
let arc_v = get_arc(arc_c);
let v = *get(&arc_v);
assert v[2] == 3;
@@ -225,7 +225,7 @@ mod tests {
let total = total.clone();
futures += ~[future::spawn({||
for uint::range(0u, count) {|_i|
- total.with {|_cond, count|
+ do total.with {|_cond, count|
**count += 1u;
}
}
@@ -234,7 +234,7 @@ mod tests {
for futures.each {|f| f.get() };
- total.with {|_cond, total|
+ do total.with {|_cond, total|
assert **total == num_tasks * count
};
}
View
@@ -65,7 +65,7 @@ pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
#[test]
fn test_bool_from_str() {
- all_values { |v|
+ do all_values { |v|
assert some(v) == from_str(bool::to_str(v))
}
}
@@ -78,7 +78,7 @@ fn test_bool_to_str() {
#[test]
fn test_bool_to_bit() {
- all_values { |v|
+ do all_values { |v|
assert to_bit(v) == if is_true(v) { 1u8 } else { 0u8 };
}
}
Oops, something went wrong.

0 comments on commit a3382b6

Please sign in to comment.