Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Convert ret to return

  • Loading branch information...
commit b355936b4da0831f47afe8f251daee503c8caa32 1 parent dc499f1
@brson brson authored
Showing with 3,573 additions and 3,496 deletions.
  1. +25 −25 doc/rust.md
  2. +24 −26 doc/tutorial.md
  3. +75 −75 src/cargo/cargo.rs
  4. +3 −3 src/cargo/pgp.rs
  5. +3 −3 src/compiletest/compiletest.rs
  6. +3 −3 src/compiletest/errors.rs
  7. +8 −8 src/compiletest/header.rs
  8. +3 −3 src/compiletest/procsrv.rs
  9. +9 −9 src/compiletest/runtest.rs
  10. +5 −5 src/fuzzer/ast_match.rs
  11. +1 −1  src/fuzzer/cycles.rs
  12. +11 −11 src/fuzzer/fuzzer.rs
  13. +1 −1  src/fuzzer/ivec_fuzz.rs
  14. +1 −1  src/fuzzer/rand_util.rs
  15. +1 −1  src/libcore/arc.rs
  16. +1 −1  src/libcore/at_vec.rs
  17. +8 −8 src/libcore/char.rs
  18. +1 −1  src/libcore/comm.rs
  19. +4 −4 src/libcore/dvec.rs
  20. +3 −3 src/libcore/either.rs
  21. +30 −30 src/libcore/extfmt.rs
  22. +31 −31 src/libcore/f32.rs
  23. +31 −31 src/libcore/f64.rs
  24. +27 −27 src/libcore/float.rs
  25. +8 −8 src/libcore/hash.rs
  26. +15 −15 src/libcore/int-template.rs
  27. +4 −4 src/libcore/int-template/int.rs
  28. +18 −18 src/libcore/io.rs
  29. +2 −2 src/libcore/iter-trait.rs
  30. +14 −14 src/libcore/iter.rs
  31. +2 −2 src/libcore/option.rs
  32. +33 −33 src/libcore/os.rs
  33. +11 −11 src/libcore/path.rs
  34. +3 −3 src/libcore/pipes.rs
  35. +1 −1  src/libcore/ptr.rs
  36. +5 −5 src/libcore/rand.rs
  37. +9 −9 src/libcore/result.rs
  38. +2 −2 src/libcore/rt.rs
  39. +10 −10 src/libcore/run.rs
  40. +11 −11 src/libcore/send_map.rs
  41. +1 −1  src/libcore/stackwalk.rs
  42. +68 −68 src/libcore/str.rs
  43. +3 −3 src/libcore/task.rs
  44. +3 −3 src/libcore/tuple.rs
  45. +18 −18 src/libcore/uint-template.rs
  46. +1 −1  src/libcore/uint-template/u8.rs
  47. +9 −9 src/libcore/uint-template/uint.rs
  48. +32 −32 src/libcore/unicode.rs
  49. +1 −1  src/libcore/unsafe.rs
  50. +61 −61 src/libcore/vec.rs
  51. +4 −4 src/libstd/arena.rs
  52. +2 −2 src/libstd/base64.rs
  53. +11 −11 src/libstd/bitv.rs
  54. +6 −6 src/libstd/c_vec.rs
  55. +3 −3 src/libstd/cmp.rs
  56. +26 −20 src/libstd/deque.rs
  57. +29 −25 src/libstd/ebml.rs
  58. +30 −30 src/libstd/getopts.rs
  59. +26 −26 src/libstd/json.rs
  60. +12 −12 src/libstd/list.rs
  61. +21 −21 src/libstd/map.rs
  62. +1 −1  src/libstd/md4.rs
  63. +3 −3 src/libstd/net_ip.rs
  64. +2 −2 src/libstd/net_tcp.rs
  65. +13 −13 src/libstd/net_url.rs
  66. +89 −89 src/libstd/rope.rs
  67. +6 −6 src/libstd/sha1.rs
  68. +8 −8 src/libstd/smallintmap.rs
  69. +12 −12 src/libstd/sort.rs
  70. +2 −2 src/libstd/tempfile.rs
  71. +4 −4 src/libstd/term.rs
  72. +10 −10 src/libstd/test.rs
  73. +6 −6 src/libstd/time.rs
  74. +1 −1  src/libstd/treemap.rs
  75. +6 −6 src/libstd/unicode.rs
  76. +1 −1  src/libstd/uv_global_loop.rs
  77. +1 −1  src/libstd/uv_iotask.rs
  78. +58 −58 src/libstd/uv_ll.rs
  79. +2 −2 src/libsyntax/ast_map.rs
  80. +49 −49 src/libsyntax/ast_util.rs
  81. +21 −21 src/libsyntax/attr.rs
  82. +18 −18 src/libsyntax/codemap.rs
  83. +1 −1  src/libsyntax/diagnostic.rs
  84. +9 −9 src/libsyntax/ext/base.rs
  85. +7 −7 src/libsyntax/ext/build.rs
  86. +1 −1  src/libsyntax/ext/concat_idents.rs
  87. +2 −2 src/libsyntax/ext/env.rs
  88. +8 −8 src/libsyntax/ext/expand.rs
  89. +30 −24 src/libsyntax/ext/fmt.rs
  90. +1 −1  src/libsyntax/ext/ident_to_str.rs
  91. +1 −1  src/libsyntax/ext/log_syntax.rs
  92. +1 −1  src/libsyntax/ext/pipes/parse_proto.rs
  93. +1 −1  src/libsyntax/ext/pipes/proto.rs
  94. +4 −4 src/libsyntax/ext/qquote.rs
  95. +43 −41 src/libsyntax/ext/simplext.rs
  96. +10 −10 src/libsyntax/ext/source_util.rs
  97. +6 −6 src/libsyntax/ext/tt/earley_parser.rs
  98. +5 −2 src/libsyntax/ext/tt/macro_rules.rs
  99. +7 −7 src/libsyntax/ext/tt/transcribe.rs
  100. +54 −52 src/libsyntax/fold.rs
  101. +15 −15 src/libsyntax/parse.rs
  102. +15 −15 src/libsyntax/parse/attr.rs
  103. +3 −3 src/libsyntax/parse/classify.rs
  104. +13 −11 src/libsyntax/parse/comments.rs
  105. +14 −14 src/libsyntax/parse/common.rs
  106. +6 −6 src/libsyntax/parse/eval.rs
  107. +87 −85 src/libsyntax/parse/lexer.rs
  108. +137 −130 src/libsyntax/parse/parser.rs
  109. +1 −1  src/libsyntax/parse/token.rs
  110. +11 −11 src/libsyntax/print/pp.rs
  111. +36 −34 src/libsyntax/print/pprust.rs
  112. +4 −4 src/libsyntax/util/interner.rs
  113. +3 −3 src/libsyntax/visit.rs
  114. +4 −4 src/rustc/back/abi.rs
  115. +27 −27 src/rustc/back/link.rs
  116. +5 −5 src/rustc/back/rpath.rs
  117. +2 −2 src/rustc/back/upcall.rs
  118. +1 −1  src/rustc/back/x86.rs
  119. +1 −1  src/rustc/back/x86_64.rs
  120. +27 −25 src/rustc/driver/driver.rs
  121. +10 −7 src/rustc/driver/rustc.rs
  122. +1 −1  src/rustc/driver/session.rs
  123. +16 −12 src/rustc/front/config.rs
  124. +2 −2 src/rustc/front/core_inject.rs
  125. +1 −1  src/rustc/front/intrinsic_inject.rs
  126. +16 −16 src/rustc/front/test.rs
  127. +31 −31 src/rustc/lib/llvm.rs
  128. +4 −2 src/rustc/metadata/common.rs
  129. +6 −6 src/rustc/metadata/creader.rs
  130. +8 −8 src/rustc/metadata/csearch.rs
  131. +13 −13 src/rustc/metadata/cstore.rs
  132. +57 −57 src/rustc/metadata/decoder.rs
  133. +10 −10 src/rustc/metadata/encoder.rs
  134. +2 −2 src/rustc/metadata/filesearch.rs
  135. +13 −13 src/rustc/metadata/loader.rs
  136. +53 −53 src/rustc/metadata/tydecode.rs
  137. +5 −5 src/rustc/metadata/tyencode.rs
  138. +5 −5 src/rustc/middle/astencode.rs
  139. +3 −3 src/rustc/middle/borrowck.rs
  140. +11 −11 src/rustc/middle/borrowck/categorization.rs
  141. +22 −19 src/rustc/middle/borrowck/check_loans.rs
  142. +1 −1  src/rustc/middle/borrowck/gather_loans.rs
  143. +4 −4 src/rustc/middle/borrowck/preserve.rs
  144. +1 −1  src/rustc/middle/capture.rs
  145. +14 −14 src/rustc/middle/check_alt.rs
  146. +2 −2 src/rustc/middle/check_const.rs
  147. +4 −4 src/rustc/middle/freevars.rs
  148. +4 −4 src/rustc/middle/kind.rs
  149. +1 −1  src/rustc/middle/lang_items.rs
  150. +1 −1  src/rustc/middle/lint.rs
  151. +19 −19 src/rustc/middle/liveness.rs
  152. +2 −2 src/rustc/middle/pat_util.rs
  153. +11 −11 src/rustc/middle/region.rs
  154. +122 −122 src/rustc/middle/resolve3.rs
  155. +35 −33 src/rustc/middle/trans/alt.rs
  156. +247 −243 src/rustc/middle/trans/base.rs
  157. +176 −175 src/rustc/middle/trans/build.rs
  158. +15 −11 src/rustc/middle/trans/closure.rs
  159. +87 −85 src/rustc/middle/trans/common.rs
  160. +2 −2 src/rustc/middle/trans/consts.rs
  161. +37 −37 src/rustc/middle/trans/debuginfo.rs
  162. +36 −36 src/rustc/middle/trans/foreign.rs
  163. +3 −3 src/rustc/middle/trans/impl.rs
  164. +4 −4 src/rustc/middle/trans/reachable.rs
  165. +2 −2 src/rustc/middle/trans/reflect.rs
  166. +25 −25 src/rustc/middle/trans/shape.rs
  167. +13 −13 src/rustc/middle/trans/tvec.rs
  168. +5 −5 src/rustc/middle/trans/type_of.rs
  169. +2 −2 src/rustc/middle/trans/type_use.rs
  170. +2 −2 src/rustc/middle/trans/uniq.rs
  171. +29 −25 src/rustc/middle/tstate/ann.rs
  172. +88 −85 src/rustc/middle/tstate/auxiliary.rs
  173. +3 −3 src/rustc/middle/tstate/collect_locals.rs
  174. +4 −4 src/rustc/middle/tstate/pre_post_conditions.rs
  175. +49 −46 src/rustc/middle/tstate/states.rs
  176. +3 −3 src/rustc/middle/tstate/tritv.rs
  177. +115 −111 src/rustc/middle/ty.rs
  178. +5 −5 src/rustc/middle/typeck.rs
  179. +7 −7 src/rustc/middle/typeck/astconv.rs
  180. +36 −35 src/rustc/middle/typeck/check.rs
  181. +2 −2 src/rustc/middle/typeck/check/alt.rs
  182. +5 −5 src/rustc/middle/typeck/check/method.rs
  183. +8 −8 src/rustc/middle/typeck/check/regionck.rs
  184. +2 −2 src/rustc/middle/typeck/check/regionmanip.rs
  185. +4 −4 src/rustc/middle/typeck/check/vtable.rs
  186. +13 −13 src/rustc/middle/typeck/check/writeback.rs
  187. +10 −9 src/rustc/middle/typeck/coherence.rs
  188. +13 −13 src/rustc/middle/typeck/collect.rs
  189. +41 −41 src/rustc/middle/typeck/infer.rs
  190. +5 −5 src/rustc/util/common.rs
  191. +8 −8 src/rustc/util/ppaux.rs
  192. +1 −1  src/rustdoc/astsrv.rs
  193. +2 −2 src/rustdoc/config.rs
  194. +1 −1  src/rustdoc/desc_to_brief_pass.rs
  195. +2 −2 src/rustdoc/markdown_index_pass.rs
  196. +6 −6 src/rustdoc/markdown_pass.rs
  197. +1 −1  src/rustdoc/markdown_writer.rs
  198. +2 −2 src/rustdoc/page_pass.rs
  199. +3 −3 src/rustdoc/rustdoc.rs
  200. +1 −1  src/rustdoc/sectionalize_pass.rs
  201. +2 −2 src/test/auxiliary/cci_class_4.rs
  202. +2 −2 src/test/auxiliary/cci_class_cast.rs
  203. +3 −3 src/test/auxiliary/cci_nested_lib.rs
  204. +1 −1  src/test/auxiliary/test_comm.rs
  205. +1 −1  src/test/bench/core-std.rs
  206. +2 −2 src/test/bench/core-vec-append.rs
  207. +4 −4 src/test/bench/graph500-bfs.rs
  208. +3 −3 src/test/bench/shootout-ackermann.rs
  209. +4 −4 src/test/bench/shootout-binarytrees.rs
  210. +3 −3 src/test/bench/shootout-chameneos-redux.rs
  211. +3 −3 src/test/bench/shootout-fannkuchredux.rs
  212. +8 −8 src/test/bench/shootout-fasta.rs
  213. +2 −2 src/test/bench/shootout-fibo.rs
  214. +10 −10 src/test/bench/shootout-k-nucleotide-pipes.rs
  215. +11 −11 src/test/bench/shootout-k-nucleotide.rs
  216. +7 −7 src/test/bench/shootout-nbody.rs
  217. +2 −2 src/test/bench/shootout-pfib.rs
  218. +2 −2 src/test/bench/shootout-threadring.rs
  219. +3 −3 src/test/bench/sudoku.rs
  220. +6 −6 src/test/bench/task-perf-word-count-generic.rs
  221. +5 −5 src/test/bench/task-perf-word-count.rs
  222. +1 −1  src/test/compile-fail/bad-bang-ann-3.rs
  223. +2 −2 src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs
  224. +3 −3 src/test/compile-fail/block-coerce-no.rs
  225. +1 −1  src/test/compile-fail/block-copy.rs
  226. +1 −1  src/test/compile-fail/borrowck-move-from-unsafe-ptr.rs
  227. +1 −1  src/test/compile-fail/borrowck-mut-vec-as-imm-slice-bad.rs
  228. +1 −1  src/test/compile-fail/cap-clause-illegal-cap.rs
  229. +1 −1  src/test/compile-fail/capture1.rs
  230. +2 −2 src/test/compile-fail/class-cast-to-iface.rs
  231. +1 −1  src/test/compile-fail/constrained-type-missing-check.rs
  232. +1 −1  src/test/compile-fail/dead-code-ret.rs
  233. +1 −1  src/test/compile-fail/for-loop-decl.rs
  234. +1 −1  src/test/compile-fail/fully-qualified-type-name2.rs
  235. +1 −1  src/test/compile-fail/fully-qualified-type-name3.rs
  236. +1 −1  src/test/compile-fail/fully-qualified-type-name4.rs
  237. +1 −1  src/test/compile-fail/iface-cast.rs
  238. +2 −2 src/test/compile-fail/import-glob-circular.rs
  239. +2 −2 src/test/compile-fail/issue-1193.rs
  240. +1 −1  src/test/compile-fail/issue-1448-1.rs
  241. +1 −1  src/test/compile-fail/issue-2150.rs
  242. +2 −2 src/test/compile-fail/issue-3021-d.rs
  243. +1 −1  src/test/compile-fail/issue-897-2.rs
  244. +1 −1  src/test/compile-fail/issue-897.rs
  245. +1 −1  src/test/compile-fail/lambda-mutate-nested.rs
  246. +1 −1  src/test/compile-fail/lambda-mutate.rs
  247. +1 −1  src/test/compile-fail/liveness-break-uninit-2.rs
  248. +1 −1  src/test/compile-fail/liveness-break-uninit.rs
  249. +2 −2 src/test/compile-fail/liveness-forgot-ret.rs
  250. +1 −1  src/test/compile-fail/liveness-init-in-called-fn-expr.rs
  251. +1 −1  src/test/compile-fail/liveness-init-in-fn-expr.rs
  252. +1 −1  src/test/compile-fail/liveness-missing-ret2.rs
  253. +1 −1  src/test/compile-fail/liveness-return.rs
  254. +1 −1  src/test/compile-fail/liveness-while.rs
  255. +1 −1  src/test/compile-fail/loop-does-not-diverge.rs
  256. +1 −1  src/test/compile-fail/macro-2.rs
  257. +2 −2 src/test/compile-fail/nested-ty-params.rs
  258. +1 −1  src/test/compile-fail/pattern-tyvar-2.rs
  259. +1 −1  src/test/compile-fail/pure-loop-body.rs
  260. +4 −4 src/test/compile-fail/regions-bounds.rs
  261. +2 −2 src/test/compile-fail/regions-creating-enums.rs
  262. +1 −1  src/test/compile-fail/regions-iface-2.rs
  263. +2 −2 src/test/compile-fail/regions-iface-3.rs
  264. +2 −2 src/test/compile-fail/regions-infer-borrow-scope-too-big.rs
  265. +2 −2 src/test/compile-fail/regions-nested-fns-2.rs
  266. +3 −3 src/test/compile-fail/regions-nested-fns.rs
  267. +1 −1  src/test/compile-fail/regions-ret.rs
  268. +8 −8 src/test/compile-fail/regions-scoping.rs
  269. +3 −3 src/test/compile-fail/ret-non-nil.rs
  270. +2 −2 src/test/compile-fail/sendfn-is-not-a-lambda.rs
  271. +2 −2 src/test/compile-fail/tail-typeck.rs
  272. +1 −1  src/test/compile-fail/tps-invariant-iface.rs
  273. +1 −1  src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs
  274. +1 −1  src/test/compile-fail/unsafe-fn-autoderef.rs
  275. +1 −1  src/test/compile-fail/unsafe-fn-called-from-safe.rs
  276. +1 −1  src/test/compile-fail/unsafe-fn-deref-ptr.rs
  277. +1 −1  src/test/compile-fail/unsafe-fn-used-as-value.rs
  278. +1 −1  src/test/compile-fail/unused-imports-warn.rs
  279. +1 −1  src/test/compile-fail/vec-concat-bug.rs
  280. +1 −1  src/test/compile-fail/wrong-ret-type.rs
  281. +1 −1  src/test/pretty/blank-lines.rs
  282. +1 −1  src/test/pretty/block-arg-disambig.rs
  283. +2 −2 src/test/pretty/disamb-stmt-expr.rs
  284. +1 −1  src/test/run-fail/expr-alt-fail-fn.rs
  285. +1 −1  src/test/run-fail/expr-if-fail-fn.rs
  286. +2 −2 src/test/run-fail/if-check-fail.rs
  287. +2 −2 src/test/run-fail/unwind-misc-1.rs
  288. +2 −2 src/test/run-fail/zip-different-lengths.rs
  289. +1 −1  src/test/run-pass-fulldeps/issue-1926.rs
  290. +1 −1  src/test/run-pass/alias-uninit-value.rs
  291. +1 −1  src/test/run-pass/alloca-from-derived-tydesc.rs
  292. +1 −1  src/test/run-pass/alt-bot-2.rs
  293. +1 −1  src/test/run-pass/alt-join.rs
  294. +2 −2 src/test/run-pass/alt-pattern-lit.rs
  295. +1 −1  src/test/run-pass/alt-tag.rs
  296. +1 −1  src/test/run-pass/alt-with-ret-arm.rs
  297. +2 −2 src/test/run-pass/argument-passing.rs
  298. +1 −1  src/test/run-pass/artificial-block.rs
  299. +1 −1  src/test/run-pass/assignability-iface.rs
  300. +1 −1  src/test/run-pass/auto-instantiate.rs
Sorry, we could not display the entire diff because too many files (456) changed.
View
50 doc/rust.md
@@ -219,7 +219,7 @@ if impl import
let log loop
mod mut
pure
-ret
+return
true trait type
unchecked unsafe
while
@@ -841,17 +841,17 @@ value has the corresponding [*function type*](#function-types), and can be
used otherwise exactly as a function item (with a minor additional cost of
calling the function indirectly).
-Every control path in a function logically ends with a `ret` expression or a
+Every control path in a function logically ends with a `return` expression or a
diverging expression. If the outermost block of a function has a
value-producing expression in its final-expression position, that expression
-is interpreted as an implicit `ret` expression applied to the
+is interpreted as an implicit `return` expression applied to the
final-expression.
An example of a function:
~~~~
fn add(x: int, y: int) -> int {
- ret x + y;
+ return x + y;
}
~~~~
@@ -876,7 +876,7 @@ unifies with any type. Rust has no syntax for $\bot$.
It might be necessary to declare a diverging function because as mentioned
previously, the typechecker checks that every control path in a function ends
-with a [`ret`](#return-expressions) or diverging expression. So, if `my_err`
+with a [`return`](#return-expressions) or diverging expression. So, if `my_err`
were declared without the `!` annotation, the following code would not
typecheck:
@@ -885,7 +885,7 @@ typecheck:
fn f(i: int) -> int {
if i == 42 {
- ret 42;
+ return 42;
}
else {
my_err(~"Bad number!");
@@ -895,7 +895,7 @@ fn f(i: int) -> int {
The typechecker would complain that `f` doesn't return a value in the
`else` branch. Adding the `!` annotation on `my_err` would
-express that `f` requires no explicit `ret`, as if it returns
+express that `f` requires no explicit `return`, as if it returns
control to the caller, it returns a value (true because it never returns
control).
@@ -915,7 +915,7 @@ An example of a predicate:
~~~~
pure fn lt_42(x: int) -> bool {
- ret (x < 42);
+ return (x < 42);
}
~~~~
@@ -1845,7 +1845,7 @@ An example of an `as` expression:
fn avg(v: ~[float]) -> float {
let sum: float = sum(v);
let sz: float = len(v) as float;
- ret sum / sz;
+ return sum / sz;
}
~~~~
@@ -2079,21 +2079,21 @@ For a block `b`, the expression `loop b` is semantically equivalent to
typestate analysis pass takes into account that `loop`s are infinite.
For example, the following (contrived) function uses a `loop` with a
-`ret` expression:
+`return` expression:
~~~~
fn count() -> bool {
let mut i = 0;
loop {
i += 1;
- if i == 20 { ret true; }
+ if i == 20 { return true; }
}
}
~~~~
This function compiles, because typestate recognizes that the `loop`
-never terminates (except non-locally, with `ret`), thus there is no
-need to insert a spurious `fail` or `ret` after the `loop`. If `loop`
+never terminates (except non-locally, with `return`), thus there is no
+need to insert a spurious `fail` or `return` after the `loop`. If `loop`
were replaced with `while true`, the function would be rejected
because from the compiler's perspective, there would be a control path
along which `count` does not return a value (that is, if the loop
@@ -2200,7 +2200,7 @@ let x: list<int> = cons(10, @cons(11, @nil));
alt x {
cons(_, @nil) { fail ~"singleton list"; }
- cons(*) { ret; }
+ cons(*) { return; }
nil { fail ~"empty list"; }
}
~~~~
@@ -2235,7 +2235,7 @@ alt x {
process_ten();
}
nil {
- ret;
+ return;
}
_ {
fail;
@@ -2353,7 +2353,7 @@ fn read_file_lines(path: ~str) -> ~[~str] {
lines(f) |s| {
r += ~[s];
}
- ret r;
+ return r;
}
~~~~
@@ -2372,23 +2372,23 @@ expression.
### Return expressions
~~~~~~~~{.ebnf .gram}
-ret_expr : "ret" expr ? ;
+return_expr : "return" expr ? ;
~~~~~~~~
-Return expressions are denoted with the keyword `ret`. Evaluating a `ret`
-expression^[A `ret` expression is analogous to a `return` expression
+Return expressions are denoted with the keyword `return`. Evaluating a `return`
+expression^[A `return` expression is analogous to a `return` expression
in the C family.] moves its argument into the output slot of the current
function, destroys the current function activation frame, and transfers
control to the caller frame.
-An example of a `ret` expression:
+An example of a `return` expression:
~~~~
fn max(a: int, b: int) -> int {
if a > b {
- ret a;
+ return a;
}
- ret b;
+ return b;
}
~~~~
@@ -2738,7 +2738,7 @@ An example of a `fn` type:
~~~~~~~~
fn add(x: int, y: int) -> int {
- ret x + y;
+ return x + y;
}
let mut x = add(5,7);
@@ -2784,10 +2784,10 @@ Within the body of an item that has type parameter declarations, the names of it
~~~~~~~
fn map<A: copy, B: copy>(f: fn(A) -> B, xs: ~[A]) -> ~[B] {
- if xs.len() == 0 { ret ~[]; }
+ if xs.len() == 0 { return ~[]; }
let first: B = f(xs[0]);
let rest: ~[B] = map(f, xs.slice(1, xs.len()));
- ret ~[first] + rest;
+ return ~[first] + rest;
}
~~~~~~~
View
50 doc/tutorial.md
@@ -54,7 +54,7 @@ fn boring_old_factorial(n: int) -> int {
result *= i;
i += 1;
}
- ret result;
+ return result;
}
~~~~
@@ -62,9 +62,7 @@ Several differences from C stand out. Types do not come before, but
after variable names (preceded by a colon). For local variables
(introduced with `let`), types are optional, and will be inferred when
left off. Constructs like `while` and `if` do not require parentheses
-around the condition (though they allow them). Also, there's a
-tendency towards aggressive abbreviation in the keywords—`fn` for
-function, `ret` for return.
+around the condition (though they allow them).
You should, however, not conclude that Rust is simply an evolution of
C. As will become clear in the rest of this tutorial, it goes in quite
@@ -697,15 +695,15 @@ end of the block:
fn signum(x: int) -> int {
if x < 0 { -1 }
else if x > 0 { 1 }
- else { ret 0; }
+ else { return 0; }
}
~~~~
-The `ret` (return) and its semicolon could have been left out without
+The `return` and its semicolon could have been left out without
changing the meaning of this function, but it illustrates that you
will not get a type error in this case, although the last arm doesn't
have type `int`, because control doesn't reach the end of that arm
-(`ret` is jumping out of the function).
+(`return` is jumping out of the function).
## Pattern matching
@@ -913,11 +911,11 @@ colons and the return type follows the arrow.
~~~~
fn int_to_str(i: int) -> ~str {
- ret ~"tube sock";
+ return ~"tube sock";
}
~~~~
-The `ret` keyword immediately returns from the body of a function. It
+The `return` keyword immediately returns from the body of a function. It
is optionally followed by an expression to return. A function can
also return a value by having its top level block produce an
expression.
@@ -926,9 +924,9 @@ expression.
# const copernicus: int = 0;
fn int_to_str(i: int) -> ~str {
if i == copernicus {
- ret ~"tube sock";
+ return ~"tube sock";
} else {
- ret ~"violin";
+ return ~"violin";
}
}
~~~~
@@ -946,7 +944,7 @@ and both the return type and the return value may be omitted from
the definition. The following two functions are equivalent.
~~~~
-fn do_nothing_the_hard_way() -> () { ret (); }
+fn do_nothing_the_hard_way() -> () { return (); }
fn do_nothing_the_easy_way() { }
~~~~
@@ -1552,7 +1550,7 @@ their environment". For example you couldn't write the following:
let foo = 10;
fn bar() -> int {
- ret foo; // `bar` cannot refer to `foo`
+ return foo; // `bar` cannot refer to `foo`
}
~~~~
@@ -1617,7 +1615,7 @@ returns it from a function, and then calls it:
use std;
fn mk_appender(suffix: ~str) -> fn@(~str) -> ~str {
- ret fn@(s: ~str) -> ~str { s + suffix };
+ return fn@(s: ~str) -> ~str { s + suffix };
}
fn main() {
@@ -1635,7 +1633,7 @@ be written:
~~~~
fn mk_appender(suffix: ~str) -> fn@(~str) -> ~str {
- ret |s| s + suffix;
+ return |s| s + suffix;
}
~~~~
@@ -1742,7 +1740,7 @@ Empty argument lists can be omitted from `do` expressions.
Most iteration in Rust is done with `for` loops. Like `do`,
`for` is a nice syntax for doing control flow with closures.
-Additionally, within a `for` loop, `break`, `again`, and `ret`
+Additionally, within a `for` loop, `break`, `again`, and `retern`
work just as they do with `while` and `loop`.
Consider again our `each` function, this time improved to
@@ -1790,7 +1788,7 @@ for each(~[2, 4, 8, 5, 16]) |n| {
}
~~~~
-As an added bonus, you can use the `ret` keyword, which is not
+As an added bonus, you can use the `return` keyword, which is not
normally allowed in closures, in a block that appears as the body of a
`for` loop — this will cause a return to happen from the outer
function, not just the loop body.
@@ -1799,7 +1797,7 @@ function, not just the loop body.
# import each = vec::each;
fn contains(v: ~[int], elt: int) -> bool {
for each(v) |x| {
- if (x == elt) { ret true; }
+ if (x == elt) { return true; }
}
false
}
@@ -1960,7 +1958,7 @@ copy, that's a win.
~~~~
type person = {name: ~str, address: ~str};
fn make_person(+name: ~str, +address: ~str) -> person {
- ret {name: name, address: address};
+ return {name: name, address: address};
}
~~~~
@@ -1987,7 +1985,7 @@ fn map<T, U>(vector: ~[T], function: fn(T) -> U) -> ~[U] {
for vector.each |element| {
vec::push(accumulator, function(element));
}
- ret accumulator;
+ return accumulator;
}
~~~~
@@ -2473,7 +2471,7 @@ fn comma_sep<T: to_str>(elts: ~[T]) -> ~str {
else { result += ~", "; }
result += elt.to_str();
}
- ret result;
+ return result;
}
~~~~
@@ -2633,14 +2631,14 @@ extern mod crypto {
fn as_hex(data: ~[u8]) -> ~str {
let mut acc = ~"";
for data.each |byte| { acc += #fmt("%02x", byte as uint); }
- ret acc;
+ return acc;
}
fn sha1(data: ~str) -> ~str unsafe {
let bytes = str::bytes(data);
let hash = crypto::SHA1(vec::unsafe::to_ptr(bytes),
vec::len(bytes) as c_uint, ptr::null());
- ret as_hex(vec::unsafe::from_buf(hash, 20u));
+ return as_hex(vec::unsafe::from_buf(hash, 20u));
}
fn main(args: ~[~str]) {
@@ -2740,7 +2738,7 @@ fn sha1(data: ~str) -> ~str {
let bytes = str::bytes(data);
let hash = crypto::SHA1(vec::unsafe::to_ptr(bytes),
vec::len(bytes), ptr::null());
- ret as_hex(vec::unsafe::from_buf(hash, 20u));
+ return as_hex(vec::unsafe::from_buf(hash, 20u));
}
}
~~~~
@@ -2783,7 +2781,7 @@ Let's look at our `sha1` function again.
let bytes = str::bytes(data);
let hash = crypto::SHA1(vec::unsafe::to_ptr(bytes),
vec::len(bytes), ptr::null());
-ret as_hex(vec::unsafe::from_buf(hash, 20u));
+return as_hex(vec::unsafe::from_buf(hash, 20u));
# }
# }
~~~~
@@ -2830,7 +2828,7 @@ extern mod lib_c {
fn unix_time_in_microseconds() -> u64 unsafe {
let x = {mut tv_sec: 0 as c_ulonglong, mut tv_usec: 0 as c_ulonglong};
lib_c::gettimeofday(ptr::addr_of(x), ptr::null());
- ret (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64);
+ return (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64);
}
# fn main() { assert #fmt("%?", unix_time_in_microseconds()) != ~""; }
View
150 src/cargo/cargo.rs
@@ -125,7 +125,7 @@ fn is_uuid(id: ~str) -> bool {
}
if !part.all(is_hex_digit) {
- ret false;
+ return false;
}
alt i {
@@ -148,10 +148,10 @@ fn is_uuid(id: ~str) -> bool {
}
}
if correct >= 5u {
- ret true;
+ return true;
}
}
- ret false;
+ return false;
}
#[test]
@@ -207,10 +207,10 @@ fn is_git_url(url: ~str) -> bool {
fn assume_source_method(url: ~str) -> ~str {
if is_git_url(url) {
- ret ~"git";
+ return ~"git";
}
if str::starts_with(url, ~"file://") || os::path_exists(url) {
- ret ~"file";
+ return ~"file";
}
~"curl"
@@ -350,7 +350,7 @@ fn load_crate(filename: ~str) -> option<crate> {
crate_type: crate_type,
deps: deps })
}
- _ { ret none; }
+ _ { return none; }
}
}
@@ -367,7 +367,7 @@ fn rest(s: ~str, start: uint) -> ~str {
}
fn need_dir(s: ~str) {
- if os::path_is_dir(s) { ret; }
+ if os::path_is_dir(s) { return; }
if !os::make_dir(s, 493_i32 /* oct: 755 */) {
fail fmt!{"can't make_dir %s", s};
}
@@ -419,7 +419,7 @@ fn parse_source(name: ~str, j: json::json) -> source {
if method == ~"file" {
url = os::make_absolute(url);
}
- ret @{
+ return @{
name: name,
mut url: url,
mut method: method,
@@ -432,7 +432,7 @@ fn parse_source(name: ~str, j: json::json) -> source {
}
fn try_parse_sources(filename: ~str, sources: map::hashmap<~str, source>) {
- if !os::path_exists(filename) { ret; }
+ if !os::path_exists(filename) { return; }
let c = io::read_whole_file_str(filename);
alt json::from_str(result::get(c)) {
ok(json::dict(j)) {
@@ -454,13 +454,13 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) {
+ src.name + ~", '" + *n + ~"'"+
~" is an invalid name (alphanumeric, underscores and" +
~" dashes only)");
- ret;
+ return;
}
*n
}
_ {
warn(~"malformed source json: " + src.name + ~" (missing name)");
- ret;
+ return;
}
};
@@ -470,13 +470,13 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) {
warn(~"malformed source json: "
+ src.name + ~", '" + *n + ~"'"+
~" is an invalid uuid");
- ret;
+ return;
}
*n
}
_ {
warn(~"malformed source json: " + src.name + ~" (missing uuid)");
- ret;
+ return;
}
};
@@ -484,7 +484,7 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) {
some(json::string(n)) { *n }
_ {
warn(~"malformed source json: " + src.name + ~" (missing url)");
- ret;
+ return;
}
};
@@ -493,7 +493,7 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) {
_ {
warn(~"malformed source json: "
+ src.name + ~" (missing method)");
- ret;
+ return;
}
};
@@ -520,7 +520,7 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) {
_ {
warn(~"malformed source json: " + src.name
+ ~" (missing description)");
- ret;
+ return;
}
};
@@ -551,7 +551,7 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) {
fn load_source_info(c: cargo, src: source) {
let dir = path::connect(c.sourcedir, src.name);
let srcfile = path::connect(dir, ~"source.json");
- if !os::path_exists(srcfile) { ret; }
+ if !os::path_exists(srcfile) { return; }
let srcstr = io::read_whole_file_str(srcfile);
alt json::from_str(result::get(srcstr)) {
ok(json::dict(s)) {
@@ -573,7 +573,7 @@ fn load_source_packages(c: cargo, src: source) {
log(debug, ~"loading source: " + src.name);
let dir = path::connect(c.sourcedir, src.name);
let pkgfile = path::connect(dir, ~"packages.json");
- if !os::path_exists(pkgfile) { ret; }
+ if !os::path_exists(pkgfile) { return; }
let pkgstr = io::read_whole_file_str(pkgfile);
alt json::from_str(result::get(pkgstr)) {
ok(json::list(js)) {
@@ -718,7 +718,7 @@ fn run_in_buildpath(what: ~str, path: ~str, subdir: ~str, cf: ~str,
~[~"--out-dir", buildpath, cf] + extra_flags);
if p.status != 0 {
error(fmt!{"rustc failed: %d\n%s\n%s", p.status, p.err, p.out});
- ret none;
+ return none;
}
some(buildpath)
}
@@ -726,7 +726,7 @@ fn run_in_buildpath(what: ~str, path: ~str, subdir: ~str, cf: ~str,
fn test_one_crate(_c: cargo, path: ~str, cf: ~str) {
let buildpath = alt run_in_buildpath(~"testing", path, ~"/test", cf,
~[ ~"--test"]) {
- none { ret; }
+ none { return; }
some(bp) { bp }
};
run_programs(buildpath);
@@ -735,7 +735,7 @@ fn test_one_crate(_c: cargo, path: ~str, cf: ~str) {
fn install_one_crate(c: cargo, path: ~str, cf: ~str) {
let buildpath = alt run_in_buildpath(~"installing", path,
~"/build", cf, ~[]) {
- none { ret; }
+ none { return; }
some(bp) { bp }
};
let newv = os::list_dir_path(buildpath);
@@ -867,7 +867,7 @@ fn cargo_suggestion(c: cargo, fallback: fn())
if c.sources.size() == 0u {
error(~"no sources defined - you may wish to run " +
~"`cargo init`");
- ret;
+ return;
}
fallback();
}
@@ -882,12 +882,12 @@ fn install_uuid(c: cargo, wd: ~str, uuid: ~str) {
if vec::len(ps) == 1u {
let (sname, p) = copy ps[0];
install_package(c, sname, wd, p);
- ret;
+ return;
} else if vec::len(ps) == 0u {
cargo_suggestion(c, || {
error(~"can't find package: " + uuid);
});
- ret;
+ return;
}
error(~"found multiple packages:");
for ps.each |elt| {
@@ -906,12 +906,12 @@ fn install_named(c: cargo, wd: ~str, name: ~str) {
if vec::len(ps) == 1u {
let (sname, p) = copy ps[0];
install_package(c, sname, wd, p);
- ret;
+ return;
} else if vec::len(ps) == 0u {
cargo_suggestion(c, || {
error(~"can't find package: " + name);
});
- ret;
+ return;
}
error(~"found multiple packages:");
for ps.each |elt| {
@@ -929,7 +929,7 @@ fn install_uuid_specific(c: cargo, wd: ~str, src: ~str, uuid: ~str) {
install_package(c, src, wd, p);
true
} else { false }
- }) { ret; }
+ }) { return; }
}
_ { }
}
@@ -945,7 +945,7 @@ fn install_named_specific(c: cargo, wd: ~str, src: ~str, name: ~str) {
install_package(c, src, wd, p);
true
} else { false }
- }) { ret; }
+ }) { return; }
}
_ { }
}
@@ -955,7 +955,7 @@ fn install_named_specific(c: cargo, wd: ~str, src: ~str, name: ~str) {
fn cmd_uninstall(c: cargo) {
if vec::len(c.opts.free) < 3u {
cmd_usage();
- ret;
+ return;
}
let lib = c.libdir;
@@ -976,7 +976,7 @@ fn cmd_uninstall(c: cargo) {
} else {
error(~"could not uninstall: '" + full + ~"'");
}
- ret;
+ return;
}
none { again; }
}
@@ -994,7 +994,7 @@ fn cmd_uninstall(c: cargo) {
} else {
error(~"could not uninstall: '" + full + ~"'");
}
- ret;
+ return;
}
none { again; }
}
@@ -1008,7 +1008,7 @@ fn cmd_uninstall(c: cargo) {
} else {
error(~"could not uninstall: '" + full + ~"'");
}
- ret;
+ return;
}
none { again; }
}
@@ -1022,7 +1022,7 @@ fn install_query(c: cargo, wd: ~str, target: ~str) {
alt c.dep_cache.find(target) {
some(inst) {
if inst {
- ret;
+ return;
}
}
none {}
@@ -1032,7 +1032,7 @@ fn install_query(c: cargo, wd: ~str, target: ~str) {
if is_archive_path(target) {
install_file(c, wd, target);
- ret;
+ return;
} else if is_git_url(target) {
let reference = if c.opts.free.len() >= 4u {
some(c.opts.free[3u])
@@ -1042,7 +1042,7 @@ fn install_query(c: cargo, wd: ~str, target: ~str) {
install_git(c, wd, target, reference);
} else if !valid_pkg_name(target) && has_archive_extension(target) {
install_curl(c, wd, target);
- ret;
+ return;
} else {
let mut ps = copy target;
@@ -1094,7 +1094,7 @@ fn cmd_install(c: cargo) unsafe {
}
install_source(c, wd);
- ret;
+ return;
}
sync(c);
@@ -1127,7 +1127,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool {
if !os::copy_file(path::connect(url, ~"packages.json"), pkgfile) {
error(fmt!{"fetch for source %s (url %s) failed", name, url});
- ret false;
+ return false;
}
if os::copy_file(path::connect(url, ~"source.json"), srcfile) {
@@ -1143,7 +1143,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool {
~[~"-f", ~"-s", ~"-o", keyfile, u]);
if p.status != 0 {
error(fmt!{"fetch for source %s (key %s) failed", name, u});
- ret false;
+ return false;
}
pgp::add(c.root, keyfile);
}
@@ -1156,7 +1156,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool {
if !r {
error(fmt!{"signature verification failed for source %s",
name});
- ret false;
+ return false;
}
if has_src_file {
@@ -1165,7 +1165,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool {
if !e {
error(fmt!{"signature verification failed for source %s",
name});
- ret false;
+ return false;
}
}
}
@@ -1186,7 +1186,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool {
info(fmt!{"synced source: %s", name});
- ret true;
+ return true;
}
fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
@@ -1227,20 +1227,20 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
if p.status != 0 {
error(fmt!{"fetch for source %s (url %s) failed", name, url});
- ret false;
+ return false;
}
}
else {
if !os::change_dir(dir) {
error(fmt!{"fetch for source %s (url %s) failed", name, url});
- ret false;
+ return false;
}
let p = run::program_output(~"git", ~[~"pull"]);
if p.status != 0 {
error(fmt!{"fetch for source %s (url %s) failed", name, url});
- ret false;
+ return false;
}
}
@@ -1253,7 +1253,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
if p.status != 0 {
error(fmt!{"fetch for source %s (key %s) failed", name, u});
rollback(name, dir, false);
- ret false;
+ return false;
}
pgp::add(c.root, keyfile);
}
@@ -1267,7 +1267,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
error(fmt!{"signature verification failed for source %s",
name});
rollback(name, dir, false);
- ret false;
+ return false;
}
if has_src_file {
@@ -1277,7 +1277,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
error(fmt!{"signature verification failed for source %s",
name});
rollback(name, dir, false);
- ret false;
+ return false;
}
}
}
@@ -1288,7 +1288,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
info(fmt!{"synced source: %s", name});
- ret true;
+ return true;
}
fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
@@ -1313,7 +1313,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
if p.status != 0 {
error(fmt!{"fetch for source %s (url %s) failed", name, url});
- ret false;
+ return false;
}
if smart {
url = src.url + ~"/source.json";
@@ -1332,7 +1332,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
~[~"-f", ~"-s", ~"-o", keyfile, u]);
if p.status != 0 {
error(fmt!{"fetch for source %s (key %s) failed", name, u});
- ret false;
+ return false;
}
pgp::add(c.root, keyfile);
}
@@ -1351,7 +1351,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
sigfile, url]);
if p.status != 0 {
error(fmt!{"fetch for source %s (sig %s) failed", name, url});
- ret false;
+ return false;
}
let r = pgp::verify(c.root, pkgfile, sigfile, f);
@@ -1359,7 +1359,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
if !r {
error(fmt!{"signature verification failed for source %s",
name});
- ret false;
+ return false;
}
if smart && has_src_file {
@@ -1371,7 +1371,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
if p.status != 0 {
error(fmt!{"fetch for source %s (sig %s) failed",
name, url});
- ret false;
+ return false;
}
let e = pgp::verify(c.root, srcfile, srcsigfile, f);
@@ -1379,7 +1379,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
if !e {
error(~"signature verification failed for " +
~"source " + name);
- ret false;
+ return false;
}
}
}
@@ -1400,7 +1400,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
info(fmt!{"synced source: %s", name});
- ret true;
+ return true;
}
fn sync_one(c: cargo, src: source) {
@@ -1435,20 +1435,20 @@ fn cmd_init(c: cargo) {
run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", srcfile, srcurl]);
if p.status != 0 {
error(fmt!{"fetch of sources.json failed: %s", p.out});
- ret;
+ return;
}
let p =
run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", sigfile, sigurl]);
if p.status != 0 {
error(fmt!{"fetch of sources.json.sig failed: %s", p.out});
- ret;
+ return;
}
let r = pgp::verify(c.root, srcfile, sigfile, pgp::signing_key_fp());
if !r {
error(fmt!{"signature verification failed for '%s'", srcfile});
- ret;
+ return;
}
copy_warn(srcfile, destsrcfile);
@@ -1518,7 +1518,7 @@ fn cmd_list(c: cargo) {
fn cmd_search(c: cargo) {
if vec::len(c.opts.free) < 3u {
cmd_usage();
- ret;
+ return;
}
sync(c);
@@ -1559,7 +1559,7 @@ fn dump_cache(c: cargo) {
}
fn dump_sources(c: cargo) {
if c.sources.size() < 1u {
- ret;
+ return;
}
need_dir(c.root);
@@ -1618,7 +1618,7 @@ fn cmd_sources(c: cargo) {
info(fmt!{"%s (%s) via %s",
v.name, v.url, v.method});
}
- ret;
+ return;
}
let action = c.opts.free[2u];
@@ -1634,7 +1634,7 @@ fn cmd_sources(c: cargo) {
~"add" {
if vec::len(c.opts.free) < 5u {
cmd_usage();
- ret;
+ return;
}
let name = c.opts.free[3u];
@@ -1642,7 +1642,7 @@ fn cmd_sources(c: cargo) {
if !valid_pkg_name(name) {
error(fmt!{"'%s' is an invalid source name", name});
- ret;
+ return;
}
alt c.sources.find(name) {
@@ -1665,14 +1665,14 @@ fn cmd_sources(c: cargo) {
~"remove" {
if vec::len(c.opts.free) < 4u {
cmd_usage();
- ret;
+ return;
}
let name = c.opts.free[3u];
if !valid_pkg_name(name) {
error(fmt!{"'%s' is an invalid source name", name});
- ret;
+ return;
}
alt c.sources.find(name) {
@@ -1688,7 +1688,7 @@ fn cmd_sources(c: cargo) {
~"set-url" {
if vec::len(c.opts.free) < 5u {
cmd_usage();
- ret;
+ return;
}
let name = c.opts.free[3u];
@@ -1696,7 +1696,7 @@ fn cmd_sources(c: cargo) {
if !valid_pkg_name(name) {
error(fmt!{"'%s' is an invalid source name", name});
- ret;
+ return;
}
alt c.sources.find(name) {
@@ -1719,7 +1719,7 @@ fn cmd_sources(c: cargo) {
~"set-method" {
if vec::len(c.opts.free) < 5u {
cmd_usage();
- ret;
+ return;
}
let name = c.opts.free[3u];
@@ -1727,7 +1727,7 @@ fn cmd_sources(c: cargo) {
if !valid_pkg_name(name) {
error(fmt!{"'%s' is an invalid source name", name});
- ret;
+ return;
}
alt c.sources.find(name) {
@@ -1753,7 +1753,7 @@ fn cmd_sources(c: cargo) {
~"rename" {
if vec::len(c.opts.free) < 5u {
cmd_usage();
- ret;
+ return;
}
let name = c.opts.free[3u];
@@ -1761,11 +1761,11 @@ fn cmd_sources(c: cargo) {
if !valid_pkg_name(name) {
error(fmt!{"'%s' is an invalid source name", name});
- ret;
+ return;
}
if !valid_pkg_name(newn) {
error(fmt!{"'%s' is an invalid source name", newn});
- ret;
+ return;
}
alt c.sources.find(name) {
@@ -1879,7 +1879,7 @@ fn main(argv: ~[~str]) {
if vec::len(o.free) < 2u {
cmd_usage();
- ret;
+ return;
}
if o.help {
alt o.free[1] {
@@ -1891,11 +1891,11 @@ fn main(argv: ~[~str]) {
~"sources" { cmd_usage_sources(); }
_ { cmd_usage(); }
}
- ret;
+ return;
}
if o.free[1] == ~"usage" {
cmd_usage();
- ret;
+ return;
}
let mut c = configure(o);
View
6 src/cargo/pgp.rs
@@ -1,5 +1,5 @@
fn gpg(args: ~[~str]) -> { status: int, out: ~str, err: ~str } {
- ret run::program_output(~"gpg", args);
+ return run::program_output(~"gpg", args);
}
fn signing_key() -> ~str {
@@ -91,7 +91,7 @@ fn verify(root: ~str, data: ~str, sig: ~str, keyfp: ~str) -> bool {
data]);
let res = ~"Primary key fingerprint: " + keyfp;
for str::split_char(p.err, '\n').each |line| {
- if line == res { ret true; }
+ if line == res { return true; }
}
- ret false;
+ return false;
}
View
6 src/compiletest/compiletest.rs
@@ -47,7 +47,7 @@ fn parse_config(args: ~[~str]) -> config {
err(f) { fail getopts::fail_str(f) }
};
- ret {compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"),
+ return {compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"),
run_lib_path: getopts::opt_str(matches, ~"run-lib-path"),
rustc_path: getopts::opt_str(matches, ~"rustc-path"),
src_base: getopts::opt_str(matches, ~"src-base"),
@@ -143,7 +143,7 @@ fn make_tests(config: config) -> ~[test::test_desc] {
vec::push(tests, make_test(config, file))
}
}
- ret tests;
+ return tests;
}
fn is_test(config: config, testfile: ~str) -> bool {
@@ -163,7 +163,7 @@ fn is_test(config: config, testfile: ~str) -> bool {
if str::starts_with(name, pre) { valid = false; }
}
- ret valid;
+ return valid;
}
fn make_test(config: config, testfile: ~str) ->
View
6 src/compiletest/errors.rs
@@ -17,14 +17,14 @@ fn load_errors(testfile: ~str) -> ~[expected_error] {
error_patterns += parse_expected(line_num, ln);
line_num += 1u;
}
- ret error_patterns;
+ return error_patterns;
}
fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] unsafe {
let error_tag = ~"//~";
let mut idx;
alt str::find_str(line, error_tag) {
- option::none { ret ~[]; }
+ option::none { return ~[]; }
option::some(nn) { idx = (nn as uint) + str::len(error_tag); }
}
@@ -49,5 +49,5 @@ fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] unsafe {
debug!{"line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg};
- ret ~[{line: line_num - adjust_line, kind: kind, msg: msg}];
+ return ~[{line: line_num - adjust_line, kind: kind, msg: msg}];
}
View
16 src/compiletest/header.rs
@@ -51,7 +51,7 @@ fn load_props(testfile: ~str) -> test_props {
vec::push(exec_env, ee);
}
};
- ret {
+ return {
error_patterns: error_patterns,
compile_flags: compile_flags,
pp_exact: pp_exact,
@@ -63,12 +63,12 @@ fn load_props(testfile: ~str) -> test_props {
fn is_test_ignored(config: config, testfile: ~str) -> bool {
let mut found = false;
for iter_header(testfile) |ln| {
- if parse_name_directive(ln, ~"xfail-test") { ret true; }
- if parse_name_directive(ln, xfail_target()) { ret true; }
+ if parse_name_directive(ln, ~"xfail-test") { return true; }
+ if parse_name_directive(ln, xfail_target()) { return true; }
if config.mode == common::mode_pretty &&
- parse_name_directive(ln, ~"xfail-pretty") { ret true; }
+ parse_name_directive(ln, ~"xfail-pretty") { return true; }
};
- ret found;
+ return found;
fn xfail_target() -> ~str {
~"xfail-" + os::sysname()
@@ -85,10 +85,10 @@ fn iter_header(testfile: ~str, it: fn(~str) -> bool) -> bool {
// with a warm page cache. Maybe with a cold one.
if str::starts_with(ln, ~"fn")
|| str::starts_with(ln, ~"mod") {
- ret false;
- } else { if !(it(ln)) { ret false; } }
+ return false;
+ } else { if !(it(ln)) { return false; } }
}
- ret true;
+ return true;
}
fn parse_error_pattern(line: ~str) -> option<~str> {
View
6 src/compiletest/procsrv.rs
@@ -21,7 +21,7 @@ fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] {
if str::ends_with(prog, ~"rustc.exe") {
vec::push(env, (~"RUST_THREADS", ~"1"));
}
- ret env;
+ return env;
}
#[cfg(target_os = "linux")]
@@ -84,7 +84,7 @@ fn run(lib_path: ~str,
};
count -= 1;
};
- ret {status: status, out: outs, err: errs};
+ return {status: status, out: outs, err: errs};
}
fn writeclose(fd: c_int, s: option<~str>) {
@@ -106,5 +106,5 @@ fn readclose(fd: c_int) -> ~str {
buf += str::from_bytes(bytes);
}
os::fclose(file);
- ret buf;
+ return buf;
}
View
18 src/compiletest/runtest.rs
@@ -134,7 +134,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: ~str) {
fatal_procres(~"pretty-printed source does not typecheck", procres);
}
- ret;
+ return;
fn print_source(config: config, testfile: ~str, src: ~str) -> procres {
compose_and_run(config, testfile, make_pp_args(config, testfile),
@@ -144,7 +144,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: ~str) {
fn make_pp_args(config: config, _testfile: ~str) -> procargs {
let prog = config.rustc_path;
let args = ~[~"-", ~"--pretty", ~"normal"];
- ret {prog: prog, args: args};
+ return {prog: prog, args: args};
}
fn compare_source(expected: ~str, actual: ~str) {
@@ -181,7 +181,7 @@ actual:\n\
~"--no-trans", ~"--lib", ~"-L", config.build_base,
~"-L", aux_output_dir_name(config, testfile)];
args += split_maybe_args(config.rustcflags);
- ret {prog: prog, args: args};
+ return {prog: prog, args: args};
}
}
@@ -211,7 +211,7 @@ fn check_error_patterns(props: test_props,
next_err_pat = props.error_patterns[next_err_idx];
}
}
- if done { ret; }
+ if done { return; }
let missing_patterns =
vec::slice(props.error_patterns, next_err_idx,
@@ -340,7 +340,7 @@ fn compose_and_run_compiler(
}
fn ensure_dir(path: path) {
- if os::path_is_dir(path) { ret; }
+ if os::path_is_dir(path) { return; }
if !os::make_dir(path, 0x1c0i32) {
fail fmt!{"can't make dir %s", path};
}
@@ -351,7 +351,7 @@ fn compose_and_run(config: config, testfile: ~str,
procenv: ~[(~str, ~str)],
lib_path: ~str,
input: option<~str>) -> procres {
- ret program_output(config, testfile, lib_path,
+ return program_output(config, testfile, lib_path,
procargs.prog, procargs.args, procenv, input);
}
@@ -363,7 +363,7 @@ fn make_compile_args(config: config, props: test_props, extras: ~[~str],
~"-L", config.build_base] + extras;
args += split_maybe_args(config.rustcflags);
args += split_maybe_args(props.compile_flags);
- ret {prog: prog, args: args};
+ return {prog: prog, args: args};
}
fn make_lib_name(config: config, auxfile: ~str, testfile: ~str) -> ~str {
@@ -391,7 +391,7 @@ fn make_run_args(config: config, _props: test_props, testfile: ~str) ->
};
let args = toolargs + ~[make_exe_name(config, testfile)];
- ret {prog: args[0], args: vec::slice(args, 1u, vec::len(args))};
+ return {prog: args[0], args: vec::slice(args, 1u, vec::len(args))};
}
fn split_maybe_args(argstr: option<~str>) -> ~[~str] {
@@ -419,7 +419,7 @@ fn program_output(config: config, testfile: ~str, lib_path: ~str, prog: ~str,
};
let res = procsrv::run(lib_path, prog, args, env, input);
dump_output(config, testfile, res.out, res.err);
- ret {status: res.status,
+ return {status: res.status,
stdout: res.out,
stderr: res.err,
cmdline: cmdline};
View
10 src/fuzzer/ast_match.rs
@@ -5,17 +5,17 @@ fn vec_equal<T>(v: ~[T], u: ~[T],
element_equality_test: fn@(&&T, &&T) -> bool) ->
bool {
let Lv = vec::len(v);
- if Lv != vec::len(u) { ret false; }
+ if Lv != vec::len(u) { return false; }
let i = 0u;
while i < Lv {
- if !element_equality_test(v[i], u[i]) { ret false; }
+ if !element_equality_test(v[i], u[i]) { return false; }
i += 1u;
}
- ret true;
+ return true;
}
-pure fn builtin_equal<T>(&&a: T, &&b: T) -> bool { ret a == b; }
-pure fn builtin_equal_int(&&a: int, &&b: int) -> bool { ret a == b; }
+pure fn builtin_equal<T>(&&a: T, &&b: T) -> bool { return a == b; }
+pure fn builtin_equal_int(&&a: int, &&b: int) -> bool { return a == b; }
fn main() {
assert (builtin_equal(5, 5));
View
2  src/fuzzer/cycles.rs
@@ -39,7 +39,7 @@ type pointy = {
// To add: objects; traits; anything type-parameterized?
fn empty_pointy() -> @pointy {
- ret @{
+ return @{
mut a : none,
mut b : ~none,
mut c : @none,
View
22 src/fuzzer/fuzzer.rs
@@ -450,7 +450,7 @@ fn has_raw_pointers(c: ast::crate) -> bool {
visit::mk_simple_visitor(@{visit_ty: |a| visit_ty(has_rp, a)
with *visit::default_simple_visitor()});
visit::visit_crate(c, (), v);
- ret *has_rp;
+ return *has_rp;
}
fn content_is_dangerous_to_run(code: ~str) -> bool {
@@ -461,16 +461,16 @@ fn content_is_dangerous_to_run(code: ~str) -> bool {
~"unsafe",
~"log"]; // python --> rust pipe deadlock?
- for dangerous_patterns.each |p| { if contains(code, p) { ret true; } }
- ret false;
+ for dangerous_patterns.each |p| { if contains(code, p) { return true; } }
+ return false;
}
fn content_is_dangerous_to_compile(code: ~str) -> bool {
let dangerous_patterns =
~[~"xfail-test"];
- for dangerous_patterns.each |p| { if contains(code, p) { ret true; } }
- ret false;
+ for dangerous_patterns.each |p| { if contains(code, p) { return true; } }
+ return false;
}
fn content_might_not_converge(code: ~str) -> bool {
@@ -485,8 +485,8 @@ fn content_might_not_converge(code: ~str) -> bool {
~"\n\n\n\n\n" // https://github.com/mozilla/rust/issues/850
];
- for confusing_patterns.each |p| { if contains(code, p) { ret true; } }
- ret false;
+ for confusing_patterns.each |p| { if contains(code, p) { return true; } }
+ return false;
}
fn file_might_not_converge(filename: ~str) -> bool {
@@ -499,9 +499,9 @@ fn file_might_not_converge(filename: ~str) -> bool {
];
- for confusing_files.each |f| { if contains(filename, f) { ret true; } }
+ for confusing_files.each |f| { if contains(filename, f) { return true; } }
- ret false;
+ return false;
}
fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
@@ -512,7 +512,7 @@ fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
while i < maxIters {
oldv = newv;
- if content_might_not_converge(*oldv) { ret; }
+ if content_might_not_converge(*oldv) { return; }
newv = @parse_and_print(oldv);
if oldv == newv { break; }
i += 1u;
@@ -592,7 +592,7 @@ fn check_variants(files: ~[~str], cx: context) {
fn main(args: ~[~str]) {
if vec::len(args) != 2u {
error!{"usage: %s <testdir>", args[0]};
- ret;
+ return;
}
let mut files = ~[];
let root = args[1];
View
2  src/fuzzer/ivec_fuzz.rs
@@ -91,7 +91,7 @@ fn vec_to_str(v: ~[int]) -> str {
if i + 1u < len(v) { s += ", "; }
i += 1u;
}
- ret s + "]";
+ return s + "]";
}
fn show_edits(a: ~[int], xs: ~[int]) {
View
2  src/fuzzer/rand_util.rs
@@ -51,7 +51,7 @@ fn weighted_choice<T: copy>(r : rand::rng, v : ~[weighted<T>]) -> T {
for {weight: weight, item: item} in v {
so_far += weight;
if so_far > chosen {
- ret item;
+ return item;
}
}
core::unreachable();
View
2  src/libcore/arc.rs
@@ -61,7 +61,7 @@ fn get<T: const send>(rc: &arc<T>) -> &T {
// Cast us back into the correct region
let r = unsafe::reinterpret_cast(&ptr.data);
unsafe::forget(ptr);
- ret r;
+ return r;
}
}
View
2  src/libcore/at_vec.rs
@@ -60,7 +60,7 @@ pure fn build_sized<A>(size: uint, builder: fn(push: pure fn(+A))) -> @[A] {
<fn(push: pure fn(+A)), fn(push: fn(+A))>
(builder)(|+x| unsafe::push(vec, x));
}
- ret vec;
+ return vec;
}
/**
View
16 src/libcore/char.rs
@@ -51,7 +51,7 @@ import is_XID_continue = unicode::derived_property::XID_Continue;
* in terms of the Unicode General Category 'Ll'
*/
pure fn is_lowercase(c: char) -> bool {
- ret unicode::general_category::Ll(c);
+ return unicode::general_category::Ll(c);
}
/**
@@ -59,7 +59,7 @@ pure fn is_lowercase(c: char) -> bool {
* in terms of the Unicode General Category 'Lu'.
*/
pure fn is_uppercase(c: char) -> bool {
- ret unicode::general_category::Lu(c);
+ return unicode::general_category::Lu(c);
}
/**
@@ -68,7 +68,7 @@ pure fn is_uppercase(c: char) -> bool {
* additional 'Cc'-category control codes in the range [0x09, 0x0d]
*/
pure fn is_whitespace(c: char) -> bool {
- ret ('\x09' <= c && c <= '\x0d')
+ return ('\x09' <= c && c <= '\x0d')
|| unicode::general_category::Zs(c)
|| unicode::general_category::Zl(c)
|| unicode::general_category::Zp(c);
@@ -80,7 +80,7 @@ pure fn is_whitespace(c: char) -> bool {
* 'Nl', 'No' and the Derived Core Property 'Alphabetic'.
*/
pure fn is_alphanumeric(c: char) -> bool {
- ret unicode::derived_property::Alphabetic(c) ||
+ return unicode::derived_property::Alphabetic(c) ||
unicode::general_category::Nd(c) ||
unicode::general_category::Nl(c) ||
unicode::general_category::No(c);
@@ -93,7 +93,7 @@ pure fn is_ascii(c: char) -> bool {
/// Indicates whether the character is numeric (Nd, Nl, or No)
pure fn is_digit(c: char) -> bool {
- ret unicode::general_category::Nd(c) ||
+ return unicode::general_category::Nd(c) ||
unicode::general_category::Nl(c) ||
unicode::general_category::No(c);
}
@@ -117,7 +117,7 @@ pure fn to_digit(c: char, radix: uint) -> option<uint> {
'0' to '9' { c as uint - ('0' as uint) }
'a' to 'z' { c as uint + 10u - ('a' as uint) }
'A' to 'Z' { c as uint + 10u - ('A' as uint) }
- _ { ret none; }
+ _ { return none; }
};
if val < radix { some(val) }
else { none }
@@ -142,7 +142,7 @@ fn escape_unicode(c: char) -> ~str {
str::push_str(out, str::from_char(c));
for uint::range(str::len(s), pad) |_i| { str::push_str(out, ~"0"); }
str::push_str(out, s);
- ret out;
+ return out;
}
/**
@@ -178,7 +178,7 @@ fn escape_default(c: char) -> ~str {
* -1 if a < b, 0 if a == b, +1 if a > b
*/
pure fn cmp(a: char, b: char) -> int {
- ret if b > a { -1 }
+ return if b > a { -1 }
else if b < a { 1 }
else { 0 }
}
View
2  src/libcore/comm.rs
@@ -207,7 +207,7 @@ fn recv_<T: send>(p: *rust_port) -> T {
// this is a good place to yield
task::yield();
}
- ret res;
+ return res;
}
fn peek_(p: *rust_port) -> bool {
View
8 src/libcore/dvec.rs
@@ -72,7 +72,7 @@ fn from_vec<A>(+v: ~[mut A]) -> dvec<A> {
/// Consumes the vector and returns its contents
fn unwrap<A>(-d: dvec<A>) -> ~[mut A] {
let dvec_({data: v}) <- d;