Permalink
Browse files

Reformat

This changes the indexing syntax from .() to [], the vector syntax from ~[] to
[] and the extension syntax from #fmt() to #fmt[]
  • Loading branch information...
1 parent 4aa1655 commit 518dc52f85c2efb67aaa1208c02e9a7e0bdaca49 @brson brson committed Aug 19, 2011
Showing with 5,126 additions and 5,409 deletions.
  1. +15 −17 src/comp/back/link.rs
  2. +35 −39 src/comp/back/upcall.rs
  3. +94 −98 src/comp/driver/rustc.rs
  4. +3 −4 src/comp/driver/session.rs
  5. +13 −14 src/comp/front/attr.rs
  6. +1 −1 src/comp/front/config.rs
  7. +42 −49 src/comp/front/test.rs
  8. +45 −40 src/comp/lib/llvm.rs
  9. +29 −30 src/comp/metadata/creader.rs
  10. +6 −6 src/comp/metadata/cstore.rs
  11. +46 −47 src/comp/metadata/decoder.rs
  12. +50 −49 src/comp/metadata/encoder.rs
  13. +48 −46 src/comp/metadata/tydecode.rs
  14. +6 −7 src/comp/metadata/tyencode.rs
  15. +137 −124 src/comp/middle/alias.rs
  16. +27 −28 src/comp/middle/ast_map.rs
  17. +7 −14 src/comp/middle/check_alt.rs
  18. +66 −61 src/comp/middle/freevars.rs
  19. +84 −82 src/comp/middle/gc.rs
  20. +23 −28 src/comp/middle/kind.rs
  21. +88 −96 src/comp/middle/resolve.rs
  22. +206 −193 src/comp/middle/shape.rs
  23. +814 −867 src/comp/middle/trans.rs
  24. +94 −96 src/comp/middle/trans_alt.rs
  25. +161 −163 src/comp/middle/trans_common.rs
  26. +127 −151 src/comp/middle/trans_objects.rs
  27. +7 −7 src/comp/middle/tstate/annotate.rs
  28. +94 −103 src/comp/middle/tstate/auxiliary.rs
  29. +11 −11 src/comp/middle/tstate/bitvectors.rs
  30. +9 −8 src/comp/middle/tstate/ck.rs
  31. +20 −18 src/comp/middle/tstate/collect_locals.rs
  32. +70 −74 src/comp/middle/tstate/pre_post_conditions.rs
  33. +89 −98 src/comp/middle/tstate/states.rs
  34. +21 −14 src/comp/middle/tstate/tritv.rs
  35. +252 −261 src/comp/middle/ty.rs
  36. +423 −406 src/comp/middle/typeck.rs
  37. +32 −35 src/comp/syntax/ast.rs
  38. +27 −28 src/comp/syntax/codemap.rs
  39. +15 −18 src/comp/syntax/ext/base.rs
  40. +10 −7 src/comp/syntax/ext/concat_idents.rs
  41. +8 −5 src/comp/syntax/ext/env.rs
  42. +4 −5 src/comp/syntax/ext/expand.rs
  43. +30 −27 src/comp/syntax/ext/fmt.rs
  44. +8 −5 src/comp/syntax/ext/ident_to_str.rs
  45. +1 −1 src/comp/syntax/ext/log_syntax.rs
  46. +70 −67 src/comp/syntax/ext/simplext.rs
  47. +77 −81 src/comp/syntax/fold.rs
  48. +7 −8 src/comp/syntax/parse/eval.rs
  49. +44 −48 src/comp/syntax/parse/lexer.rs
  50. +298 −320 src/comp/syntax/parse/parser.rs
  51. +3 −0 src/comp/syntax/parse/token.rs
  52. +49 −52 src/comp/syntax/print/pp.rs
  53. +133 −167 src/comp/syntax/print/pprust.rs
  54. +4 −4 src/comp/syntax/util/interner.rs
  55. +37 −44 src/comp/syntax/visit.rs
  56. +3 −4 src/comp/util/common.rs
  57. +55 −56 src/comp/util/ppaux.rs
  58. +6 −6 src/fuzzer/ast_match.rs
  59. +103 −82 src/fuzzer/fuzzer.rs
  60. +23 −23 src/fuzzer/ivec_fuzz.rs
  61. +23 −35 src/lib/aio.rs
  62. +12 −15 src/lib/bitv.rs
  63. +52 −28 src/lib/char.rs
  64. +15 −27 src/lib/comm.rs
  65. +17 −16 src/lib/deque.rs
  66. +19 −19 src/lib/ebml.rs
  67. +10 −9 src/lib/either.rs
  68. +26 −26 src/lib/extfmt.rs
  69. +4 −4 src/lib/fs.rs
  70. +1 −1 src/lib/generic_os.rs
  71. +33 −33 src/lib/getopts.rs
  72. +1 −1 src/lib/int.rs
  73. +60 −73 src/lib/io.rs
  74. +6 −15 src/lib/list.rs
  75. +37 −36 src/lib/map.rs
  76. +7 −16 src/lib/net.rs
  77. +1 −4 src/lib/option.rs
  78. +6 −7 src/lib/rand.rs
  79. +16 −22 src/lib/run_program.rs
  80. +47 −49 src/lib/sha1.rs
  81. +11 −31 src/lib/sio.rs
  82. +2 −2 src/lib/smallintmap.rs
  83. +16 −16 src/lib/sort.rs
  84. +35 −42 src/lib/str.rs
  85. +64 −82 src/lib/task.rs
  86. +5 −5 src/lib/term.rs
  87. +44 −58 src/lib/test.rs
  88. +1 −1 src/lib/time.rs
  89. +1 −1 src/lib/u64.rs
  90. +5 −7 src/lib/ufind.rs
  91. +3 −5 src/lib/uint.rs
  92. +51 −58 src/lib/vec.rs
  93. +1 −3 src/lib/win32_fs.rs
  94. +8 −7 src/lib/win32_os.rs
  95. +1 −1 src/test/bench/99bob-iter.rs
  96. +1 −1 src/test/bench/99bob-pattern.rs
  97. +2 −2 src/test/bench/99bob-simple.rs
  98. +1 −1 src/test/bench/99bob-tail.rs
  99. +1 −1 src/test/bench/shootout-ackermann.rs
  100. +7 −7 src/test/bench/shootout-binarytrees.rs
  101. +13 −13 src/test/bench/shootout-fannkuchredux.rs
  102. +13 −15 src/test/bench/shootout-fasta.rs
  103. +1 −1 src/test/bench/shootout-fibo.rs
  104. +16 −17 src/test/bench/shootout-nbody.rs
  105. +6 −6 src/test/bench/shootout-pfib.rs
  106. +7 −15 src/test/bench/task-perf-spawnalot.rs
  107. +10 −18 src/test/bench/task-perf-word-count.rs
  108. +2 −2 src/test/compile-fail/alias-mismatch.rs
  109. +1 −1 src/test/compile-fail/aliasness-mismatch.rs
  110. +3 −6 src/test/compile-fail/alt-join.rs
  111. +1 −1 src/test/compile-fail/and-init.rs
  112. +1 −1 src/test/compile-fail/arg-count-mismatch.rs
  113. +1 −1 src/test/compile-fail/arg-type-mismatch.rs
  114. +1 −1 src/test/compile-fail/assign-alias.rs
  115. +1 −1 src/test/compile-fail/auto-deref-bind.rs
  116. +1 −1 src/test/compile-fail/bad-bang-ann-2.rs
  117. +1 −1 src/test/compile-fail/bad-bang-ann-3.rs
  118. +1 −1 src/test/compile-fail/bad-bang-ann.rs
  119. +1 −1 src/test/compile-fail/bad-env-capture.rs
  120. +1 −1 src/test/compile-fail/bad-env-capture2.rs
  121. +1 −1 src/test/compile-fail/bad-env-capture3.rs
  122. +1 −1 src/test/compile-fail/bad-main.rs
  123. +1 −1 src/test/compile-fail/bad-module.rs
  124. +1 −1 src/test/compile-fail/bad-record-pat-2.rs
  125. +1 −1 src/test/compile-fail/bad-record-pat.rs
  126. +1 −1 src/test/compile-fail/bang-tailexpr.rs
  127. +1 −1 src/test/compile-fail/binop-add-tup-assign.rs
  128. +1 −1 src/test/compile-fail/binop-add-tup.rs
  129. +1 −1 src/test/compile-fail/binop-bitxor-str.rs
  130. +1 −1 src/test/compile-fail/binop-logic-float.rs
  131. +1 −1 src/test/compile-fail/binop-logic-int.rs
  132. +1 −1 src/test/compile-fail/binop-mul-bool.rs
  133. +1 −1 src/test/compile-fail/binop-sub-obj.rs
  134. +1 −1 src/test/compile-fail/binop-typeck.rs
  135. +4 −4 src/test/compile-fail/block-coerce-no.rs
  136. +2 −2 src/test/compile-fail/block-copy.rs
  137. +2 −2 src/test/compile-fail/block-uninit.rs
  138. +1 −1 src/test/compile-fail/break-outside-loop.rs
  139. +1 −1 src/test/compile-fail/break-uninit.rs
  140. +1 −1 src/test/compile-fail/break-uninit2.rs
  141. +1 −1 src/test/compile-fail/capture1.rs
  142. +2 −2 src/test/compile-fail/constructor-as-cast.rs
  143. +1 −1 src/test/compile-fail/copy-a-resource.rs
  144. +1 −1 src/test/compile-fail/cross-crate-glob-collision.rs
  145. +1 −1 src/test/compile-fail/direct-obj-fn-call.rs
  146. +1 −1 src/test/compile-fail/do-while-constraints.rs
  147. +8 −18 src/test/compile-fail/do-while-pred-constraints.rs
  148. +1 −1 src/test/compile-fail/dup-link-name.rs
  149. +1 −1 src/test/compile-fail/export-fully-qualified.rs
  150. +1 −1 src/test/compile-fail/export-import.rs
  151. +1 −1 src/test/compile-fail/export-no-tag-variants.rs
  152. +1 −1 src/test/compile-fail/export-tag-variant.rs
  153. +1 −1 src/test/compile-fail/export.rs
  154. +1 −1 src/test/compile-fail/export2.rs
  155. +1 −1 src/test/compile-fail/ext-nonexistent.rs
  156. +1 −1 src/test/compile-fail/extend-non-object.rs
  157. +1 −3 src/test/compile-fail/extenv-no-args.rs
  158. +1 −1 src/test/compile-fail/extenv-not-string-literal.rs
  159. +1 −1 src/test/compile-fail/extenv-too-many-args.rs
  160. +1 −1 src/test/compile-fail/extfmt-missing-type.rs
  161. +1 −3 src/test/compile-fail/extfmt-no-args.rs
  162. +2 −2 src/test/compile-fail/extfmt-non-literal.rs
  163. +2 −2 src/test/compile-fail/extfmt-non-literal2.rs
  164. +1 −1 src/test/compile-fail/extfmt-not-enough-args.rs
  165. +1 −1 src/test/compile-fail/extfmt-too-many-args.rs
  166. +1 −1 src/test/compile-fail/extfmt-unknown-type.rs
  167. +2 −2 src/test/compile-fail/extfmt-unsigned-plus.rs
  168. +2 −2 src/test/compile-fail/extfmt-unsigned-space.rs
  169. +1 −1 src/test/compile-fail/extfmt-unterminated-conv.rs
  170. +1 −1 src/test/compile-fail/fail-expr.rs
  171. +1 −1 src/test/compile-fail/fail-type-err.rs
  172. +1 −1 src/test/compile-fail/fn-bad-block-type.rs
  173. +1 −1 src/test/compile-fail/fn-compare-mismatch.rs
  174. +1 −1 src/test/compile-fail/fn-constraint.rs
  175. +1 −1 src/test/compile-fail/fn-expr-type-state.rs
  176. +1 −1 src/test/compile-fail/fn-expr-typestate-2.rs
  177. +1 −1 src/test/compile-fail/for-each-over-bs.rs
  178. +1 −1 src/test/compile-fail/forgot-ret.rs
  179. +1 −1 src/test/compile-fail/fru-extra-field.rs
  180. +1 −1 src/test/compile-fail/fru-typestate.rs
  181. +1 −1 src/test/compile-fail/if-branch-types.rs
  182. +2 −2 src/test/compile-fail/if-check-precond-fail.rs
  183. +1 −1 src/test/compile-fail/if-typeck.rs
Sorry, we could not display the entire diff because too many files (642) changed.
View
32 src/comp/back/link.rs
@@ -137,10 +137,9 @@ mod write {
False);
if threshold != 0u {
- llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(MPMB,
- threshold);
+ llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(
+ MPMB, threshold);
}
-
llvm::LLVMPassManagerBuilderPopulateModulePassManager(MPMB,
pm.llpm);
@@ -293,21 +292,21 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str,
provided_metas {
let name: option::t<str> = none;
let vers: option::t<str> = none;
- let cmh_items: [@ast::meta_item] = ~[];
+ let cmh_items: [@ast::meta_item] = [];
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
attr::require_unique_names(sess, linkage_metas);
for meta: @ast::meta_item in linkage_metas {
if attr::get_meta_item_name(meta) == "name" {
alt attr::get_meta_item_value_str(meta) {
some(v) { name = some(v); }
- none. { cmh_items += ~[meta]; }
+ none. { cmh_items += [meta]; }
}
- } else if (attr::get_meta_item_name(meta) == "vers") {
+ } else if attr::get_meta_item_name(meta) == "vers" {
alt attr::get_meta_item_value_str(meta) {
some(v) { vers = some(v); }
- none. { cmh_items += ~[meta]; }
+ none. { cmh_items += [meta]; }
}
- } else { cmh_items += ~[meta]; }
+ } else { cmh_items += [meta]; }
}
ret {name: name, vers: vers, cmh_items: cmh_items};
}
@@ -316,7 +315,7 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str,
fn crate_meta_extras_hash(sha: sha1, _crate: &ast::crate,
metas: &provided_metas) -> str {
fn len_and_str(s: &str) -> str {
- ret #fmt("%u_%s", str::byte_len(s), s);
+ ret #fmt["%u_%s", str::byte_len(s), s];
}
fn len_and_str_lit(l: &ast::lit) -> str {
@@ -345,8 +344,8 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str,
fn warn_missing(sess: &session::session, name: str, default: str) {
if !sess.get_opts().library { ret; }
- sess.warn(#fmt("missing crate link meta '%s', using '%s' as default",
- name, default));
+ sess.warn(#fmt["missing crate link meta '%s', using '%s' as default",
+ name, default]);
}
fn crate_meta_name(sess: &session::session, _crate: &ast::crate,
@@ -356,8 +355,7 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str,
none. {
let name =
{
- let os =
- str::split(fs::basename(output), '.' as u8);
+ let os = str::split(fs::basename(output), '.' as u8);
assert (vec::len(os) >= 2u);
vec::pop(os);
str::connect(os, ".")
@@ -429,7 +427,7 @@ fn mangle(ss: &[str]) -> str {
let n = "_ZN"; // Begin name-sequence.
- for s: str in ss { n += #fmt("%u%s", str::byte_len(s), s); }
+ for s: str in ss { n += #fmt["%u%s", str::byte_len(s), s]; }
n += "E"; // End name-sequence.
ret n;
@@ -438,7 +436,7 @@ fn mangle(ss: &[str]) -> str {
fn exported_name(path: &[str], hash: &str, _vers: &str) -> str {
// FIXME: versioning isn't working yet
- ret mangle(path + ~[hash]); // + "@" + vers;
+ ret mangle(path + [hash]); // + "@" + vers;
}
@@ -451,12 +449,12 @@ fn mangle_internal_name_by_type_only(ccx: &@crate_ctxt, t: &ty::t, name: &str)
-> str {
let s = util::ppaux::ty_to_short_str(ccx.tcx, t);
let hash = get_symbol_hash(ccx, t);
- ret mangle(~[name, s, hash]);
+ ret mangle([name, s, hash]);
}
fn mangle_internal_name_by_path_and_seq(ccx: &@crate_ctxt, path: &[str],
flav: &str) -> str {
- ret mangle(path + ~[ccx.names.next(flav)]);
+ ret mangle(path + [ccx.names.next(flav)]);
}
fn mangle_internal_name_by_path(_ccx: &@crate_ctxt, path: &[str]) -> str {
View
74 src/comp/back/upcall.rs
@@ -51,72 +51,68 @@ type upcalls =
fn declare_upcalls(_tn: type_names, tydesc_type: TypeRef,
taskptr_type: TypeRef, llmod: ModuleRef) -> @upcalls {
- fn decl(llmod: ModuleRef, name: str, tys: [TypeRef],
- rv: TypeRef) -> ValueRef {
- let arg_tys: [TypeRef] = ~[];
- for t: TypeRef in tys { arg_tys += ~[t]; }
+ fn decl(llmod: ModuleRef, name: str, tys: [TypeRef], rv: TypeRef) ->
+ ValueRef {
+ let arg_tys: [TypeRef] = [];
+ for t: TypeRef in tys { arg_tys += [t]; }
let fn_ty = T_fn(arg_tys, rv);
ret trans::decl_cdecl_fn(llmod, "upcall_" + name, fn_ty);
}
- fn decl_with_taskptr(taskptr_type: TypeRef,
- llmod: ModuleRef, name: str, tys: [TypeRef],
- rv: TypeRef) -> ValueRef {
- ret decl(llmod, name, ~[taskptr_type] + tys, rv);
+ fn decl_with_taskptr(taskptr_type: TypeRef, llmod: ModuleRef, name: str,
+ tys: [TypeRef], rv: TypeRef) -> ValueRef {
+ ret decl(llmod, name, [taskptr_type] + tys, rv);
}
let dv = bind decl_with_taskptr(taskptr_type, llmod, _, _, T_void());
let d = bind decl_with_taskptr(taskptr_type, llmod, _, _, _);
let dr = bind decl(llmod, _, _, _);
- let empty_vec: [TypeRef] = ~[];
- ret @{grow_task: dv("grow_task", ~[T_size_t()]),
+ let empty_vec: [TypeRef] = [];
+ ret @{grow_task: dv("grow_task", [T_size_t()]),
_yield: dv("yield", empty_vec),
- sleep: dv("sleep", ~[T_size_t()]),
- _fail: dv("fail", ~[T_ptr(T_i8()), T_ptr(T_i8()), T_size_t()]),
- kill: dv("kill", ~[taskptr_type]),
+ sleep: dv("sleep", [T_size_t()]),
+ _fail: dv("fail", [T_ptr(T_i8()), T_ptr(T_i8()), T_size_t()]),
+ kill: dv("kill", [taskptr_type]),
exit: dv("exit", empty_vec),
malloc:
- d("malloc", ~[T_size_t(), T_ptr(tydesc_type)], T_ptr(T_i8())),
- free: dv("free", ~[T_ptr(T_i8()), T_int()]),
+ d("malloc", [T_size_t(), T_ptr(tydesc_type)], T_ptr(T_i8())),
+ free: dv("free", [T_ptr(T_i8()), T_int()]),
shared_malloc:
- d("shared_malloc", ~[T_size_t(), T_ptr(tydesc_type)],
+ d("shared_malloc", [T_size_t(), T_ptr(tydesc_type)],
T_ptr(T_i8())),
- shared_free: dv("shared_free", ~[T_ptr(T_i8())]),
- mark: d("mark", ~[T_ptr(T_i8())], T_int()),
- new_str: d("new_str", ~[T_ptr(T_i8()), T_size_t()], T_ptr(T_str())),
+ shared_free: dv("shared_free", [T_ptr(T_i8())]),
+ mark: d("mark", [T_ptr(T_i8())], T_int()),
+ new_str: d("new_str", [T_ptr(T_i8()), T_size_t()], T_ptr(T_str())),
evec_append:
d("evec_append",
- ~[T_ptr(tydesc_type), T_ptr(tydesc_type),
- T_ptr(T_opaque_vec_ptr()), T_opaque_vec_ptr(), T_bool()],
+ [T_ptr(tydesc_type), T_ptr(tydesc_type),
+ T_ptr(T_opaque_vec_ptr()), T_opaque_vec_ptr(), T_bool()],
T_void()),
get_type_desc:
d("get_type_desc",
- ~[T_ptr(T_nil()), T_size_t(), T_size_t(), T_size_t(),
- T_ptr(T_ptr(tydesc_type))], T_ptr(tydesc_type)),
+ [T_ptr(T_nil()), T_size_t(), T_size_t(), T_size_t(),
+ T_ptr(T_ptr(tydesc_type))], T_ptr(tydesc_type)),
ivec_resize:
- d("ivec_resize", ~[T_ptr(T_opaque_ivec()), T_int()], T_void()),
+ d("ivec_resize", [T_ptr(T_opaque_ivec()), T_int()], T_void()),
ivec_spill:
- d("ivec_spill", ~[T_ptr(T_opaque_ivec()), T_int()], T_void()),
+ d("ivec_spill", [T_ptr(T_opaque_ivec()), T_int()], T_void()),
ivec_resize_shared:
- d("ivec_resize_shared", ~[T_ptr(T_opaque_ivec()), T_int()],
+ d("ivec_resize_shared", [T_ptr(T_opaque_ivec()), T_int()],
T_void()),
ivec_spill_shared:
- d("ivec_spill_shared", ~[T_ptr(T_opaque_ivec()), T_int()],
+ d("ivec_spill_shared", [T_ptr(T_opaque_ivec()), T_int()],
T_void()),
cmp_type:
- dr("cmp_type", ~[T_ptr(T_i1()), taskptr_type,
- T_ptr(tydesc_type), T_ptr(T_ptr(tydesc_type)),
- T_ptr(T_i8()), T_ptr(T_i8()), T_i8()],
- T_void()),
+ dr("cmp_type",
+ [T_ptr(T_i1()), taskptr_type, T_ptr(tydesc_type),
+ T_ptr(T_ptr(tydesc_type)), T_ptr(T_i8()), T_ptr(T_i8()),
+ T_i8()], T_void()),
log_type:
- dr("log_type", ~[taskptr_type, T_ptr(tydesc_type),
- T_ptr(T_i8()), T_i32()],
+ dr("log_type",
+ [taskptr_type, T_ptr(tydesc_type), T_ptr(T_i8()), T_i32()],
T_void()),
- dynastack_mark:
- d("dynastack_mark", ~[], T_ptr(T_i8())),
- dynastack_alloc:
- d("dynastack_alloc", ~[T_size_t()], T_ptr(T_i8())),
- dynastack_free:
- d("dynastack_free", ~[T_ptr(T_i8())], T_void())};
+ dynastack_mark: d("dynastack_mark", [], T_ptr(T_i8())),
+ dynastack_alloc: d("dynastack_alloc", [T_size_t()], T_ptr(T_i8())),
+ dynastack_free: d("dynastack_free", [T_ptr(T_i8())], T_void())};
}
//
// Local Variables:
View
192 src/comp/driver/rustc.rs
@@ -53,11 +53,11 @@ fn default_configuration(sess: session::session, argv0: str, input: str) ->
let mk = attr::mk_name_value_item_str;
- ret ~[ // Target bindings.
- mk("target_os", std::os::target_os()), mk("target_arch", "x86"),
- mk("target_libc", libc),
- // Build bindings.
- mk("build_compiler", argv0), mk("build_input", input)];
+ ret [ // Target bindings.
+ mk("target_os", std::os::target_os()), mk("target_arch", "x86"),
+ mk("target_libc", libc),
+ // Build bindings.
+ mk("build_compiler", argv0), mk("build_input", input)];
}
fn build_configuration(sess: session::session, argv0: str, input: str) ->
@@ -71,8 +71,8 @@ fn build_configuration(sess: session::session, argv0: str, input: str) ->
{
if sess.get_opts().test && !attr::contains_name(user_cfg, "test")
{
- ~[attr::mk_word_item("test")]
- } else { ~[] }
+ [attr::mk_word_item("test")]
+ } else { [] }
};
ret user_cfg + gen_cfg + default_cfg;
}
@@ -81,8 +81,8 @@ fn build_configuration(sess: session::session, argv0: str, input: str) ->
fn parse_cfgspecs(cfgspecs: &[str]) -> ast::crate_cfg {
// FIXME: It would be nice to use the parser to parse all varieties of
// meta_item here. At the moment we just support the meta_word variant.
- let words = ~[];
- for s: str in cfgspecs { words += ~[attr::mk_word_item(s)]; }
+ let words = [];
+ for s: str in cfgspecs { words += [attr::mk_word_item(s)]; }
ret words;
}
@@ -92,31 +92,29 @@ fn parse_input(sess: session::session, cfg: &ast::crate_cfg, input: str) ->
@ast::crate {
if !input_is_stdin(input) {
parser::parse_crate_from_file(input, cfg, sess.get_parse_sess())
- } else {
- parse_input_src(sess, cfg, input).crate
- }
+ } else { parse_input_src(sess, cfg, input).crate }
}
-fn parse_input_src(sess: session::session, cfg: &ast::crate_cfg,
- infile: str) -> {crate: @ast::crate, src: str} {
- let srcbytes = if infile != "-" {
- io::file_reader(infile)
- } else {
- io::stdin()
- }.read_whole_stream();
+fn parse_input_src(sess: session::session, cfg: &ast::crate_cfg, infile: str)
+ -> {crate: @ast::crate, src: str} {
+ let srcbytes =
+ if infile != "-" {
+ io::file_reader(infile)
+ } else { io::stdin() }.read_whole_stream();
let src = str::unsafe_from_bytes(srcbytes);
- let crate = parser::parse_crate_from_source_str(infile, src, cfg,
- sess.get_parse_sess());
+ let crate =
+ parser::parse_crate_from_source_str(infile, src, cfg,
+ sess.get_parse_sess());
ret {crate: crate, src: src};
}
-fn time<T>(do_it: bool, what: str, thunk: fn() -> T ) -> T {
+fn time<T>(do_it: bool, what: str, thunk: fn() -> T) -> T {
if !do_it { ret thunk(); }
let start = std::time::precise_time_s();
let rv = thunk();
let end = std::time::precise_time_s();
- log_err #fmt("time: %s took %s s", what,
- common::float_to_str(end - start, 3u));
+ log_err #fmt["time: %s took %s s", what,
+ common::float_to_str(end - start, 3u)];
ret rv;
}
@@ -143,33 +141,33 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
bind middle::ast_map::map_crate(*crate));
time(time_passes, "external crate/lib resolution",
bind creader::read_crates(sess, *crate));
- let {def_map, ext_map} =
+ let {def_map: def_map, ext_map: ext_map} =
time(time_passes, "resolution",
bind resolve::resolve_crate(sess, ast_map, crate));
let freevars =
time(time_passes, "freevar finding",
bind freevars::annotate_freevars(sess, def_map, crate));
let ty_cx = ty::mk_ctxt(sess, def_map, ext_map, ast_map, freevars);
time::<()>(time_passes, "typechecking",
- bind typeck::check_crate(ty_cx, crate));
+ bind typeck::check_crate(ty_cx, crate));
time::<()>(time_passes, "alt checking",
- bind middle::check_alt::check_crate(ty_cx, crate));
+ bind middle::check_alt::check_crate(ty_cx, crate));
if sess.get_opts().run_typestate {
time(time_passes, "typestate checking",
bind middle::tstate::ck::check_crate(ty_cx, crate));
}
time(time_passes, "alias checking",
bind middle::alias::check_crate(ty_cx, crate));
time::<()>(time_passes, "kind checking",
- bind kind::check_crate(ty_cx, crate));
+ bind kind::check_crate(ty_cx, crate));
if sess.get_opts().no_trans { ret; }
let llmod =
time::<llvm::llvm::ModuleRef>(time_passes, "translation",
- bind trans::trans_crate(sess, crate,
- ty_cx, output,
- ast_map));
+ bind trans::trans_crate(sess, crate,
+ ty_cx, output,
+ ast_map));
time::<()>(time_passes, "LLVM passes",
- bind link::write::run_passes(sess, llmod, output));
+ bind link::write::run_passes(sess, llmod, output));
}
fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str,
@@ -222,7 +220,8 @@ fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str,
alt ppm {
ppm_typed. {
let amap = middle::ast_map::map_crate(*crate);
- let {def_map, ext_map} = resolve::resolve_crate(sess, amap, crate);
+ let {def_map: def_map, ext_map: ext_map} =
+ resolve::resolve_crate(sess, amap, crate);
let freevars = freevars::annotate_freevars(sess, def_map, crate);
let ty_cx = ty::mk_ctxt(sess, def_map, ext_map, amap, freevars);
typeck::check_crate(ty_cx, crate);
@@ -239,14 +238,14 @@ fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str,
fn version(argv0: str) {
let vers = "unknown version";
- let env_vers = #env("CFG_VERSION");
+ let env_vers = #env["CFG_VERSION"];
if str::byte_len(env_vers) != 0u { vers = env_vers; }
- io::stdout().write_str(#fmt("%s %s\n", argv0, vers));
+ io::stdout().write_str(#fmt["%s %s\n", argv0, vers]);
}
fn usage(argv0: str) {
- io::stdout().write_str(#fmt("usage: %s [options] <input>\n", argv0) +
- "
+ io::stdout().write_str(#fmt["usage: %s [options] <input>\n", argv0] +
+ "
options:
-h --help display this message
@@ -287,9 +286,9 @@ fn get_os(triple: str) -> session::os {
ret if str::find(triple, "win32") >= 0 ||
str::find(triple, "mingw32") >= 0 {
session::os_win32
- } else if (str::find(triple, "darwin") >= 0) {
+ } else if str::find(triple, "darwin") >= 0 {
session::os_macos
- } else if (str::find(triple, "linux") >= 0) {
+ } else if str::find(triple, "linux") >= 0 {
session::os_linux
} else { log_err "Unknown operating system!"; fail };
}
@@ -300,10 +299,10 @@ fn get_arch(triple: str) -> session::arch {
str::find(triple, "i686") >= 0 ||
str::find(triple, "i786") >= 0 {
session::arch_x86
- } else if (str::find(triple, "x86_64") >= 0) {
+ } else if str::find(triple, "x86_64") >= 0 {
session::arch_x64
- } else if (str::find(triple, "arm") >= 0 ||
- str::find(triple, "xscale") >= 0) {
+ } else if str::find(triple, "arm") >= 0 ||
+ str::find(triple, "xscale") >= 0 {
session::arch_arm
} else { log_err "Unknown architecture! " + triple; fail };
}
@@ -331,21 +330,21 @@ fn build_session_options(binary: str, match: getopts::match, binary_dir: str)
let library = opt_present(match, "lib");
let static = opt_present(match, "static");
- let library_search_paths = ~[binary_dir + "/lib"];
+ let library_search_paths = [binary_dir + "/lib"];
let lsp_vec = getopts::opt_strs(match, "L");
- for lsp: str in lsp_vec { library_search_paths += ~[lsp]; }
+ for lsp: str in lsp_vec { library_search_paths += [lsp]; }
let parse_only = opt_present(match, "parse-only");
let no_trans = opt_present(match, "no-trans");
let output_type =
if parse_only || no_trans {
link::output_type_none
- } else if (opt_present(match, "S")) {
+ } else if opt_present(match, "S") {
link::output_type_assembly
- } else if (opt_present(match, "c")) {
+ } else if opt_present(match, "c") {
link::output_type_object
- } else if (opt_present(match, "emit-llvm")) {
+ } else if opt_present(match, "emit-llvm") {
link::output_type_bitcode
} else { link::output_type_exe };
let verify = !opt_present(match, "noverify");
@@ -363,7 +362,7 @@ fn build_session_options(binary: str, match: getopts::match, binary_dir: str)
fail;
}
2u
- } else if (opt_present(match, "OptLevel")) {
+ } else if opt_present(match, "OptLevel") {
alt getopts::opt_str(match, "OptLevel") {
"0" { 0u }
"1" { 1u }
@@ -417,24 +416,23 @@ fn build_session(sopts: @session::options) -> session::session {
fn parse_pretty(sess: session::session, name: &str) -> pp_mode {
if str::eq(name, "normal") {
ret ppm_normal;
- } else if (str::eq(name, "typed")) {
+ } else if str::eq(name, "typed") {
ret ppm_typed;
- } else if (str::eq(name, "identified")) { ret ppm_identified; }
+ } else if str::eq(name, "identified") { ret ppm_identified; }
sess.fatal("argument to `pretty` or `expand` must be one of `normal`, " +
"`typed`, or `identified`");
}
fn opts() -> [getopts::opt] {
- ret ~[optflag("h"), optflag("help"), optflag("v"), optflag("version"),
- optflag("glue"), optflag("emit-llvm"), optflagopt("pretty"),
- optflagopt("expand"), optflag("ls"), optflag("parse-only"),
- optflag("no-trans"),
- optflag("O"), optopt("OptLevel"), optmulti("L"), optflag("S"),
- optflag("c"), optopt("o"), optflag("g"), optflag("save-temps"),
- optopt("sysroot"), optflag("stats"), optflag("time-passes"),
- optflag("time-llvm-passes"), optflag("no-typestate"),
- optflag("noverify"), optmulti("cfg"), optflag("test"),
- optflag("lib"), optflag("static"), optflag("gc")];
+ ret [optflag("h"), optflag("help"), optflag("v"), optflag("version"),
+ optflag("glue"), optflag("emit-llvm"), optflagopt("pretty"),
+ optflagopt("expand"), optflag("ls"), optflag("parse-only"),
+ optflag("no-trans"), optflag("O"), optopt("OptLevel"), optmulti("L"),
+ optflag("S"), optflag("c"), optopt("o"), optflag("g"),
+ optflag("save-temps"), optopt("sysroot"), optflag("stats"),
+ optflag("time-passes"), optflag("time-llvm-passes"),
+ optflag("no-typestate"), optflag("noverify"), optmulti("cfg"),
+ optflag("test"), optflag("lib"), optflag("static"), optflag("gc")];
}
fn main(args: [str]) {
@@ -444,7 +442,7 @@ fn main(args: [str]) {
alt getopts::getopts(args, opts()) {
getopts::success(m) { m }
getopts::failure(f) {
- log_err #fmt("error: %s", getopts::fail_str(f));
+ log_err #fmt["error: %s", getopts::fail_str(f)];
fail
}
};
@@ -471,10 +469,10 @@ fn main(args: [str]) {
}
if n_inputs == 0u {
sess.fatal("No input filename given.");
- } else if (n_inputs > 1u) {
+ } else if n_inputs > 1u {
sess.fatal("Multiple input filenames provided.");
}
- let ifile = match.free.(0);
+ let ifile = match.free[0];
let saved_out_filename: str = "";
let cfg = build_configuration(sess, binary, ifile);
let expand =
@@ -502,10 +500,7 @@ fn main(args: [str]) {
none::<pp_mode>. {/* continue */ }
}
let ls = opt_present(match, "ls");
- if ls {
- metadata::creader::list_file_metadata(ifile, io::stdout());
- ret;
- }
+ if ls { metadata::creader::list_file_metadata(ifile, io::stdout()); ret; }
let stop_after_codegen =
sopts.output_type != link::output_type_exe ||
@@ -516,29 +511,31 @@ fn main(args: [str]) {
// "-" as input file will cause the parser to read from stdin so we
// have to make up a name
// We want to toss everything after the final '.'
- let parts = if !input_is_stdin(ifile) {
- str::split(ifile, '.' as u8)
- } else {
- ~["default", "rs"]
- };
+ let parts =
+ if !input_is_stdin(ifile) {
+ str::split(ifile, '.' as u8)
+ } else { ["default", "rs"] };
vec::pop(parts);
saved_out_filename = str::connect(parts, ".");
- let suffix = alt sopts.output_type {
- link::output_type_none. { "none" }
- link::output_type_bitcode. { "bc" }
- link::output_type_assembly. { "s" }
- // Object and exe output both use the '.o' extension here
- link::output_type_object. | link::output_type_exe. { "o" }
- };
+ let suffix =
+ alt sopts.output_type {
+ link::output_type_none. { "none" }
+ link::output_type_bitcode. { "bc" }
+ link::output_type_assembly. { "s" }
+
+ // Object and exe output both use the '.o' extension here
+ link::output_type_object. | link::output_type_exe. {
+ "o"
+ }
+ };
let ofile = saved_out_filename + "." + suffix;
compile_input(sess, cfg, ifile, ofile);
}
some(ofile) {
// FIXME: what about windows? This will create a foo.exe.o.
saved_out_filename = ofile;
- let temp_filename = if !stop_after_codegen {
- ofile + ".o"
- } else { ofile };
+ let temp_filename =
+ if !stop_after_codegen { ofile + ".o" } else { ofile };
compile_input(sess, cfg, ifile, temp_filename);
}
}
@@ -556,8 +553,8 @@ fn main(args: [str]) {
// The invocations of gcc share some flags across platforms
let gcc_args =
- ~[stage, "-Lrt", "-lrustrt", glu, "-m32", "-o", saved_out_filename,
- saved_out_filename + ".o"];
+ [stage, "-Lrt", "-lrustrt", glu, "-m32", "-o", saved_out_filename,
+ saved_out_filename + ".o"];
let lib_cmd;
let os = sess.get_targ_cfg().os;
@@ -591,46 +588,45 @@ fn main(args: [str]) {
let cstore = sess.get_cstore();
for cratepath: str in cstore::get_used_crate_files(cstore) {
if str::ends_with(cratepath, ".rlib") {
- gcc_args += ~[cratepath];
+ gcc_args += [cratepath];
cont;
}
let dir = fs::dirname(cratepath);
- if dir != "" { gcc_args += ~["-L" + dir]; }
+ if dir != "" { gcc_args += ["-L" + dir]; }
let libarg = unlib(sess.get_targ_cfg(), fs::basename(cratepath));
- gcc_args += ~["-l" + libarg];
+ gcc_args += ["-l" + libarg];
}
let ula = cstore::get_used_link_args(cstore);
- for arg: str in ula { gcc_args += ~[arg]; }
+ for arg: str in ula { gcc_args += [arg]; }
let used_libs = cstore::get_used_libraries(cstore);
- for l: str in used_libs { gcc_args += ~["-l" + l]; }
+ for l: str in used_libs { gcc_args += ["-l" + l]; }
if sopts.library {
- gcc_args += ~[lib_cmd];
+ gcc_args += [lib_cmd];
} else {
// FIXME: why do we hardcode -lm?
- gcc_args += ~["-lm", main];
+ gcc_args += ["-lm", main];
}
// We run 'gcc' here
let err_code = run::run_program(prog, gcc_args);
if 0 != err_code {
- sess.err(#fmt("linking with gcc failed with code %d", err_code));
- sess.note(#fmt("gcc arguments: %s",
- str::connect(gcc_args, " ")));
+ sess.err(#fmt["linking with gcc failed with code %d", err_code]);
+ sess.note(#fmt["gcc arguments: %s", str::connect(gcc_args, " ")]);
sess.abort_if_errors();
}
// Clean up on Darwin
if sess.get_targ_cfg().os == session::os_macos {
- run::run_program("dsymutil", ~[saved_out_filename]);
+ run::run_program("dsymutil", [saved_out_filename]);
}
// Remove the temporary object file if we aren't saving temps
if !sopts.save_temps {
- run::run_program("rm", ~[saved_out_filename + ".o"]);
+ run::run_program("rm", [saved_out_filename + ".o"]);
}
}
@@ -641,7 +637,7 @@ mod test {
#[test]
fn test_switch_implies_cfg_test() {
let match =
- alt getopts::getopts(~["--test"], opts()) {
+ alt getopts::getopts(["--test"], opts()) {
getopts::success(m) { m }
};
let sessopts = build_session_options("whatever", match, "whatever");
@@ -655,7 +651,7 @@ mod test {
#[test]
fn test_switch_implies_cfg_test_unless_cfg_test() {
let match =
- alt getopts::getopts(~["--test", "--cfg=test"], opts()) {
+ alt getopts::getopts(["--test", "--cfg=test"], opts()) {
getopts::success(m) { m }
};
let sessopts = build_session_options("whatever", match, "whatever");
View
7 src/comp/driver/session.rs
@@ -43,8 +43,7 @@ type options =
test: bool,
parse_only: bool,
no_trans: bool,
- do_gc: bool
- };
+ do_gc: bool};
type crate_metadata = {name: str, data: [u8]};
@@ -90,10 +89,10 @@ obj session(targ_cfg: @config,
}
fn note(msg: str) { codemap::emit_note(none, msg, parse_sess.cm); }
fn span_bug(sp: span, msg: str) -> ! {
- self.span_fatal(sp, #fmt("internal compiler error %s", msg));
+ self.span_fatal(sp, #fmt["internal compiler error %s", msg]);
}
fn bug(msg: str) -> ! {
- self.fatal(#fmt("internal compiler error %s", msg));
+ self.fatal(#fmt["internal compiler error %s", msg]);
}
fn span_unimpl(sp: span, msg: str) -> ! {
self.span_bug(sp, "unimplemented " + msg);
View
27 src/comp/front/attr.rs
@@ -30,7 +30,7 @@ export mk_attr;
// From a list of crate attributes get only the meta_items that impact crate
// linkage
fn find_linkage_metas(attrs: &[ast::attribute]) -> [@ast::meta_item] {
- let metas: [@ast::meta_item] = ~[];
+ let metas: [@ast::meta_item] = [];
for attr: ast::attribute in find_attrs_by_name(attrs, "link") {
alt attr.node.value.node {
ast::meta_list(_, items) { metas += items; }
@@ -95,8 +95,8 @@ fn attr_meta(attr: &ast::attribute) -> @ast::meta_item { @attr.node.value }
// Get the meta_items from inside a vector of attributes
fn attr_metas(attrs: &[ast::attribute]) -> [@ast::meta_item] {
- let mitems = ~[];
- for a: ast::attribute in attrs { mitems += ~[attr_meta(a)]; }
+ let mitems = [];
+ for a: ast::attribute in attrs { mitems += [attr_meta(a)]; }
ret mitems;
}
@@ -122,11 +122,11 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool {
}
fn contains(haystack: &[@ast::meta_item], needle: @ast::meta_item) -> bool {
- log #fmt("looking for %s",
- syntax::print::pprust::meta_item_to_str(*needle));
+ log #fmt["looking for %s",
+ syntax::print::pprust::meta_item_to_str(*needle)];
for item: @ast::meta_item in haystack {
- log #fmt("looking in %s",
- syntax::print::pprust::meta_item_to_str(*item));
+ log #fmt["looking in %s",
+ syntax::print::pprust::meta_item_to_str(*item)];
if eq(item, needle) { log "found it!"; ret true; }
}
log "found it not :(";
@@ -152,13 +152,13 @@ fn sort_meta_items(items: &[@ast::meta_item]) -> [@ast::meta_item] {
}
// This is sort of stupid here, converting to a vec of mutables and back
- let v: [mutable @ast::meta_item] = ~[mutable];
- for mi: @ast::meta_item in items { v += ~[mutable mi]; }
+ let v: [mutable @ast::meta_item] = [mutable];
+ for mi: @ast::meta_item in items { v += [mutable mi]; }
std::sort::quick_sort(lteq, v);
- let v2: [@ast::meta_item] = ~[];
- for mi: @ast::meta_item in v { v2 += ~[mi]; }
+ let v2: [@ast::meta_item] = [];
+ for mi: @ast::meta_item in v { v2 += [mi]; }
ret v2;
}
@@ -176,14 +176,13 @@ fn remove_meta_items_by_name(items: &[@ast::meta_item], name: str) ->
ret vec::filter_map(filter, items);
}
-fn require_unique_names(sess: &session::session,
- metas: &[@ast::meta_item]) {
+fn require_unique_names(sess: &session::session, metas: &[@ast::meta_item]) {
let map = map::mk_hashmap::<str, ()>(str::hash, str::eq);
for meta: @ast::meta_item in metas {
let name = get_meta_item_name(meta);
if map.contains_key(name) {
sess.span_fatal(meta.span,
- #fmt("duplicate meta item `%s`", name));
+ #fmt["duplicate meta item `%s`", name]);
}
map.insert(name, ());
}
View
2 src/comp/front/config.rs
@@ -115,7 +115,7 @@ fn in_cfg(cfg: &ast::crate_cfg, attrs: &[ast::attribute]) -> bool {
}
}
let cfg_metas = attr::attr_metas(item_cfg_attrs);
- vec::foldl(extract_metas, ~[], cfg_metas)
+ vec::foldl(extract_metas, [], cfg_metas)
};
for cfg_mi: @ast::meta_item in item_cfg_metas {
View
91 src/comp/front/test.rs
@@ -9,7 +9,7 @@ import front::attr;
export modify_for_testing;
-type node_id_gen = @fn() -> ast::node_id ;
+type node_id_gen = @fn() -> ast::node_id;
type test = {path: [ast::ident], ignore: bool};
@@ -36,8 +36,8 @@ fn modify_for_testing(crate: @ast::crate) -> @ast::crate {
let cx: test_ctxt =
@{next_node_id: next_node_id_fn,
- mutable path: ~[],
- mutable testfns: ~[]};
+ mutable path: [],
+ mutable testfns: []};
let precursor =
{fold_crate: bind fold_crate(cx, _, _),
@@ -51,8 +51,8 @@ fn modify_for_testing(crate: @ast::crate) -> @ast::crate {
ret res;
}
-fn fold_mod(_cx: &test_ctxt, m: &ast::_mod, fld: fold::ast_fold)
- -> ast::_mod {
+fn fold_mod(_cx: &test_ctxt, m: &ast::_mod, fld: fold::ast_fold) ->
+ ast::_mod {
// Remove any defined main function from the AST so it doesn't clash with
// the one we're going to add. FIXME: This is sloppy. Instead we should
@@ -87,14 +87,14 @@ fn fold_crate(cx: &test_ctxt, c: &ast::crate_, fld: fold::ast_fold) ->
fn fold_item(cx: &test_ctxt, i: &@ast::item, fld: fold::ast_fold) ->
@ast::item {
- cx.path += ~[i.ident];
- log #fmt("current path: %s", ast::path_name_i(cx.path));
+ cx.path += [i.ident];
+ log #fmt["current path: %s", ast::path_name_i(cx.path)];
if is_test_fn(i) {
log "this is a test function";
let test = {path: cx.path, ignore: is_ignored(i)};
- cx.testfns += ~[test];
- log #fmt("have %u test functions", vec::len(cx.testfns));
+ cx.testfns += [test];
+ log #fmt["have %u test functions", vec::len(cx.testfns)];
}
let res = fold::noop_fold_item(i, fld);
@@ -127,7 +127,7 @@ fn is_ignored(i: &@ast::item) -> bool {
fn add_test_module(cx: &test_ctxt, m: &ast::_mod) -> ast::_mod {
let testmod = mk_test_module(cx);
- ret {items: m.items + ~[testmod] with m};
+ ret {items: m.items + [testmod] with m};
}
/*
@@ -154,16 +154,16 @@ fn mk_test_module(cx: &test_ctxt) -> @ast::item {
// The synthesized main function which will call the console test runner
// with our list of tests
let mainfn = mk_main(cx);
- let testmod: ast::_mod = {view_items: ~[], items: ~[mainfn, testsfn]};
+ let testmod: ast::_mod = {view_items: [], items: [mainfn, testsfn]};
let item_ = ast::item_mod(testmod);
let item: ast::item =
{ident: "__test",
- attrs: ~[],
+ attrs: [],
id: cx.next_node_id(),
node: item_,
span: ast::dummy_sp()};
- log #fmt("Synthetic test module:\n%s\n", pprust::item_to_str(@item));
+ log #fmt["Synthetic test module:\n%s\n", pprust::item_to_str(@item)];
ret @item;
}
@@ -176,27 +176,27 @@ fn mk_tests(cx: &test_ctxt) -> @ast::item {
let ret_ty = mk_test_desc_vec_ty(cx);
let decl: ast::fn_decl =
- {inputs: ~[],
+ {inputs: [],
output: ret_ty,
purity: ast::impure_fn,
il: ast::il_normal,
cf: ast::return,
- constraints: ~[]};
+ constraints: []};
let proto = ast::proto_fn;
// The vector of test_descs for this crate
let test_descs = mk_test_desc_vec(cx);
let body_: ast::blk_ =
- {stmts: ~[], expr: option::some(test_descs), id: cx.next_node_id()};
+ {stmts: [], expr: option::some(test_descs), id: cx.next_node_id()};
let body = nospan(body_);
let fn_ = {decl: decl, proto: proto, body: body};
- let item_ = ast::item_fn(fn_, ~[]);
+ let item_ = ast::item_fn(fn_, []);
let item: ast::item =
{ident: "tests",
- attrs: ~[],
+ attrs: [],
id: cx.next_node_id(),
node: item_,
span: ast::dummy_sp()};
@@ -205,19 +205,19 @@ fn mk_tests(cx: &test_ctxt) -> @ast::item {
fn empty_fn_ty() -> ast::ty {
let proto = ast::proto_fn;
- let input_ty = ~[];
+ let input_ty = [];
let ret_ty = @nospan(ast::ty_nil);
let cf = ast::return;
- let constrs = ~[];
+ let constrs = [];
ret nospan(ast::ty_fn(proto, input_ty, ret_ty, cf, constrs));
}
// The ast::ty of [std::test::test_desc]
fn mk_test_desc_vec_ty(cx: &test_ctxt) -> @ast::ty {
let test_desc_ty_path: ast::path =
nospan({global: false,
- idents: ~["std", "test", "test_desc"],
- types: ~[]});
+ idents: ["std", "test", "test_desc"],
+ types: []});
let test_desc_ty: ast::ty =
nospan(ast::ty_path(test_desc_ty_path, cx.next_node_id()));
@@ -228,11 +228,11 @@ fn mk_test_desc_vec_ty(cx: &test_ctxt) -> @ast::ty {
}
fn mk_test_desc_vec(cx: &test_ctxt) -> @ast::expr {
- log #fmt("building test vector from %u tests", vec::len(cx.testfns));
- let descs = ~[];
+ log #fmt["building test vector from %u tests", vec::len(cx.testfns)];
+ let descs = [];
for test: test in cx.testfns {
let test_ = test; // Satisfy alias analysis
- descs += ~[mk_test_desc_rec(cx, test_)];
+ descs += [mk_test_desc_rec(cx, test_)];
}
ret @{id: cx.next_node_id(),
@@ -243,7 +243,7 @@ fn mk_test_desc_vec(cx: &test_ctxt) -> @ast::expr {
fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr {
let path = test.path;
- log #fmt("encoding %s", ast::path_name_i(path));
+ log #fmt["encoding %s", ast::path_name_i(path)];
let name_lit: ast::lit =
nospan(ast::lit_str(ast::path_name_i(path), ast::sk_rc));
@@ -255,8 +255,7 @@ fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr {
let name_field: ast::field =
nospan({mut: ast::imm, ident: "name", expr: @name_expr});
- let fn_path: ast::path =
- nospan({global: false, idents: path, types: ~[]});
+ let fn_path: ast::path = nospan({global: false, idents: path, types: []});
let fn_expr: ast::expr =
{id: cx.next_node_id(),
@@ -277,7 +276,7 @@ fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr {
nospan({mut: ast::imm, ident: "ignore", expr: @ignore_expr});
let desc_rec_: ast::expr_ =
- ast::expr_rec(~[name_field, fn_field, ignore_field], option::none);
+ ast::expr_rec([name_field, fn_field, ignore_field], option::none);
let desc_rec: ast::expr =
{id: cx.next_node_id(), node: desc_rec_, span: ast::dummy_sp()};
ret @desc_rec;
@@ -294,28 +293,28 @@ fn mk_main(cx: &test_ctxt) -> @ast::item {
let ret_ty = nospan(ast::ty_nil);
let decl: ast::fn_decl =
- {inputs: ~[args_arg],
+ {inputs: [args_arg],
output: @ret_ty,
purity: ast::impure_fn,
il: ast::il_normal,
cf: ast::return,
- constraints: ~[]};
+ constraints: []};
let proto = ast::proto_fn;
let test_main_call_expr = mk_test_main_call(cx);
let body_: ast::blk_ =
- {stmts: ~[],
+ {stmts: [],
expr: option::some(test_main_call_expr),
id: cx.next_node_id()};
let body = {node: body_, span: ast::dummy_sp()};
let fn_ = {decl: decl, proto: proto, body: body};
- let item_ = ast::item_fn(fn_, ~[]);
+ let item_ = ast::item_fn(fn_, []);
let item: ast::item =
{ident: "main",
- attrs: ~[],
+ attrs: [],
id: cx.next_node_id(),
node: item_,
span: ast::dummy_sp()};
@@ -326,38 +325,32 @@ fn mk_test_main_call(cx: &test_ctxt) -> @ast::expr {
// Get the args passed to main so we can pass the to test_main
let args_path: ast::path =
- nospan({global: false, idents: ~["args"], types: ~[]});
+ nospan({global: false, idents: ["args"], types: []});
let args_path_expr_: ast::expr_ = ast::expr_path(args_path);
let args_path_expr: ast::expr =
- {id: cx.next_node_id(),
- node: args_path_expr_,
- span: ast::dummy_sp()};
+ {id: cx.next_node_id(), node: args_path_expr_, span: ast::dummy_sp()};
// Call __test::test to generate the vector of test_descs
let test_path: ast::path =
- nospan({global: false, idents: ~["tests"], types: ~[]});
+ nospan({global: false, idents: ["tests"], types: []});
let test_path_expr_: ast::expr_ = ast::expr_path(test_path);
let test_path_expr: ast::expr =
- {id: cx.next_node_id(),
- node: test_path_expr_,
- span: ast::dummy_sp()};
+ {id: cx.next_node_id(), node: test_path_expr_, span: ast::dummy_sp()};
- let test_call_expr_: ast::expr_ = ast::expr_call(@test_path_expr, ~[]);
+ let test_call_expr_: ast::expr_ = ast::expr_call(@test_path_expr, []);
let test_call_expr: ast::expr =
- {id: cx.next_node_id(),
- node: test_call_expr_,
- span: ast::dummy_sp()};
+ {id: cx.next_node_id(), node: test_call_expr_, span: ast::dummy_sp()};
// Call std::test::test_main
let test_main_path: ast::path =
nospan({global: false,
- idents: ~["std", "test", "test_main"],
- types: ~[]});
+ idents: ["std", "test", "test_main"],
+ types: []});
let test_main_path_expr_: ast::expr_ = ast::expr_path(test_main_path);
@@ -368,7 +361,7 @@ fn mk_test_main_call(cx: &test_ctxt) -> @ast::expr {
let test_main_call_expr_: ast::expr_ =
ast::expr_call(@test_main_path_expr,
- ~[@args_path_expr, @test_call_expr]);
+ [@args_path_expr, @test_call_expr]);
let test_main_call_expr: ast::expr =
{id: cx.next_node_id(),
View
85 src/comp/lib/llvm.rs
@@ -81,20 +81,20 @@ const LLVMOptimizeForSizeAttribute: uint = 8192u;
const LLVMStackProtectAttribute: uint = 16384u;
const LLVMStackProtectReqAttribute: uint = 32768u;
const LLVMAlignmentAttribute: uint = 2031616u;
- // 31 << 16
+// 31 << 16
const LLVMNoCaptureAttribute: uint = 2097152u;
const LLVMNoRedZoneAttribute: uint = 4194304u;
const LLVMNoImplicitFloatAttribute: uint = 8388608u;
const LLVMNakedAttribute: uint = 16777216u;
const LLVMInlineHintAttribute: uint = 33554432u;
const LLVMStackAttribute: uint = 469762048u;
- // 7 << 26
+// 7 << 26
const LLVMUWTableAttribute: uint = 1073741824u;
- // 1 << 30
+// 1 << 30
- // Consts for the LLVM IntPredicate type, pre-cast to uint.
- // FIXME: as above.
+// Consts for the LLVM IntPredicate type, pre-cast to uint.
+// FIXME: as above.
const LLVMIntEQ: uint = 32u;
@@ -276,9 +276,9 @@ native "cdecl" mod llvm = "rustllvm" {
/* Operations on constants of any type */
fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
- /* all zeroes */
+ /* all zeroes */
fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
- /* only for int/vector */
+ /* only for int/vector */
fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
fn LLVMIsConstant(Val: ValueRef) -> Bool;
fn LLVMIsNull(Val: ValueRef) -> Bool;
@@ -809,19 +809,19 @@ native "cdecl" mod llvm = "rustllvm" {
Value: Bool);
fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: PassManagerBuilderRef,
Value: Bool);
- fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(PMB:
- PassManagerBuilderRef,
- Value: Bool);
- fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB:
- PassManagerBuilderRef,
- threshold: uint);
- fn LLVMPassManagerBuilderPopulateModulePassManager(PMB:
- PassManagerBuilderRef,
- PM: PassManagerRef);
-
- fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB:
- PassManagerBuilderRef,
- PM: PassManagerRef);
+ fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
+ PMB: PassManagerBuilderRef,
+ Value: Bool);
+ fn LLVMPassManagerBuilderUseInlinerWithThreshold(
+ PMB: PassManagerBuilderRef,
+ threshold: uint);
+ fn LLVMPassManagerBuilderPopulateModulePassManager(
+ PMB: PassManagerBuilderRef,
+ PM: PassManagerRef);
+
+ fn LLVMPassManagerBuilderPopulateFunctionPassManager(
+ PMB: PassManagerBuilderRef,
+ PM: PassManagerRef);
/** Destroys a memory buffer. */
fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
@@ -905,68 +905,68 @@ native "cdecl" mod llvm = "rustllvm" {
* it's attached to.
*/
-resource BuilderRef_res(B: BuilderRef) {
- llvm::LLVMDisposeBuilder(B);
-}
+resource BuilderRef_res(B: BuilderRef) { llvm::LLVMDisposeBuilder(B); }
+
+obj builder(B: BuilderRef,
+ terminated: @mutable bool,
-obj builder(B: BuilderRef, terminated: @mutable bool,
// Stored twice so that we don't have to constantly deref
res: @BuilderRef_res) {
/* Terminators */
fn RetVoid() -> ValueRef {
- assert (!*terminated);
+ assert (!*terminated);;
*terminated = true;
ret llvm::LLVMBuildRetVoid(B);
}
fn Ret(V: ValueRef) -> ValueRef {
- assert (!*terminated);
+ assert (!*terminated);;
*terminated = true;
ret llvm::LLVMBuildRet(B, V);
}
fn AggregateRet(RetVals: &[ValueRef]) -> ValueRef {
- assert (!*terminated);
+ assert (!*terminated);;
*terminated = true;
ret llvm::LLVMBuildAggregateRet(B, vec::to_ptr(RetVals),
vec::len(RetVals));
}
fn Br(Dest: BasicBlockRef) -> ValueRef {
- assert (!*terminated);
+ assert (!*terminated);;
*terminated = true;
ret llvm::LLVMBuildBr(B, Dest);
}
fn CondBr(If: ValueRef, Then: BasicBlockRef, Else: BasicBlockRef) ->
ValueRef {
- assert (!*terminated);
+ assert (!*terminated);;
*terminated = true;
ret llvm::LLVMBuildCondBr(B, If, Then, Else);
}
fn Switch(V: ValueRef, Else: BasicBlockRef, NumCases: uint) -> ValueRef {
- assert (!*terminated);
+ assert (!*terminated);;
*terminated = true;
ret llvm::LLVMBuildSwitch(B, V, Else, NumCases);
}
fn IndirectBr(Addr: ValueRef, NumDests: uint) -> ValueRef {
- assert (!*terminated);
+ assert (!*terminated);;
*terminated = true;
ret llvm::LLVMBuildIndirectBr(B, Addr, NumDests);
}
fn Invoke(Fn: ValueRef, Args: &[ValueRef], Then: BasicBlockRef,
Catch: BasicBlockRef) -> ValueRef {
- assert (!*terminated);
+ assert (!*terminated);;
*terminated = true;
ret llvm::LLVMBuildInvoke(B, Fn, vec::to_ptr(Args), vec::len(Args),
Then, Catch, str::buf(""));
}
fn Unreachable() -> ValueRef {
- assert (!*terminated);
+ assert (!*terminated);;
*terminated = true;
ret llvm::LLVMBuildUnreachable(B);
}
@@ -1402,14 +1402,12 @@ obj builder(B: BuilderRef, terminated: @mutable bool,
let T: ValueRef =
llvm::LLVMGetNamedFunction(M, str::buf("llvm.trap"));
assert (T as int != 0);
- let Args: [ValueRef] = ~[];
+ let Args: [ValueRef] = [];
ret llvm::LLVMBuildCall(B, T, vec::to_ptr(Args), vec::len(Args),
str::buf(""));
}
- fn is_terminated() -> bool {
- ret *terminated;
- }
+ fn is_terminated() -> bool { ret *terminated; }
}
fn new_builder(llbb: BasicBlockRef) -> builder {
@@ -1454,15 +1452,15 @@ fn mk_type_names() -> type_names {
}
fn type_to_str(names: type_names, ty: TypeRef) -> str {
- ret type_to_str_inner(names, ~[], ty);
+ ret type_to_str_inner(names, [], ty);
}
fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
str {
if names.type_has_name(ty) { ret names.get_name(ty); }
- let outer = outer0 + ~[ty];
+ let outer = outer0 + [ty];
let kind: int = llvm::LLVMGetTypeKind(ty);
@@ -1480,6 +1478,7 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
alt kind {
+
// FIXME: more enum-as-int constants determined from Core::h;
// horrible, horrible. Complete as needed.
@@ -1494,11 +1493,13 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
6 { ret "Label"; }
+
7 {
ret "i" + std::int::str(llvm::LLVMGetIntTypeWidth(ty) as int);
}
+
8 {
let s = "fn(";
let out_ty: TypeRef = llvm::LLVMGetReturnType(ty);
@@ -1512,6 +1513,7 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
}
+
9 {
let s: str = "{";
let n_elts: uint = llvm::LLVMCountStructElementTypes(ty);
@@ -1523,12 +1525,14 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
}
+
10 {
let el_ty = llvm::LLVMGetElementType(ty);
ret "[" + type_to_str_inner(names, outer, el_ty) + "]";
}
+
11 {
let i: uint = 0u;
for tout: TypeRef in outer0 {
@@ -1543,12 +1547,13 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
}
+
12 {
ret "Opaque";
}
13 { ret "Vector"; }
14 { ret "Metadata"; }
- _ { log_err #fmt("unknown TypeKind %d", kind as int); fail; }
+ _ { log_err #fmt["unknown TypeKind %d", kind as int]; fail; }
}
}
View
59 src/comp/metadata/creader.rs
@@ -67,7 +67,7 @@ fn visit_item(e: env, i: &@ast::item) {
}
let cstore = e.sess.get_cstore();
if !cstore::add_used_library(cstore, m.native_name) { ret; }
- for a: ast::attribute in
+ for a: ast::attribute in
attr::find_attrs_by_name(i.attrs, "link_args") {
alt attr::get_meta_item_value_str(attr::attr_meta(a)) {
some(linkarg) { cstore::add_used_link_args(cstore, linkarg); }
@@ -93,12 +93,12 @@ fn metadata_matches(crate_data: &@[u8], metas: &[@ast::meta_item]) -> bool {
let attrs = decoder::get_crate_attributes(crate_data);
let linkage_metas = attr::find_linkage_metas(attrs);
- log #fmt("matching %u metadata requirements against %u items",
- vec::len(metas), vec::len(linkage_metas));
+ log #fmt["matching %u metadata requirements against %u items",
+ vec::len(metas), vec::len(linkage_metas)];
for needed: @ast::meta_item in metas {
if !attr::contains(linkage_metas, needed) {
- log #fmt("missing %s", pprust::meta_item_to_str(*needed));
+ log #fmt["missing %s", pprust::meta_item_to_str(*needed)];
ret false;
}
}
@@ -116,26 +116,26 @@ fn default_native_lib_naming(sess: session::session, static: bool) ->
}
fn find_library_crate(sess: &session::session, ident: &ast::ident,
- metas: &[@ast::meta_item],
- library_search_paths: &[str]) ->
- option::t<{ident: str, data: @[u8]}> {
+ metas: &[@ast::meta_item], library_search_paths: &[str])
+ -> option::t<{ident: str, data: @[u8]}> {
attr::require_unique_names(sess, metas);
// FIXME: Probably want a warning here since the user
// is using the wrong type of meta item
- let crate_name = {
- let name_items = attr::find_meta_items_by_name(metas, "name");
- alt vec::last(name_items) {
- some(i) {
- alt attr::get_meta_item_value_str(i) {
- some(n) { n }
- _ { ident }
+ let crate_name =
+ {
+ let name_items = attr::find_meta_items_by_name(metas, "name");
+ alt vec::last(name_items) {
+ some(i) {
+ alt attr::get_meta_item_value_str(i) {
+ some(n) { n }
+ _ { ident }
+ }
+ }
+ none. { ident }
}
- }
- none. { ident }
- }
- };
+ };
let nn = default_native_lib_naming(sess, sess.get_opts().static);
let x =
@@ -157,23 +157,23 @@ fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str,
// manually filtering fs::list_dir here.
for library_search_path: str in library_search_paths {
- log #fmt("searching %s", library_search_path);
+ log #fmt["searching %s", library_search_path];
for path: str in fs::list_dir(library_search_path) {
- log #fmt("searching %s", path);
+ log #fmt["searching %s", path];
let f: str = fs::basename(path);
if !(str::starts_with(f, prefix) && str::ends_with(f, nn.suffix))
{
- log #fmt("skipping %s, doesn't look like %s*%s", path, prefix,
- nn.suffix);
+ log #fmt["skipping %s, doesn't look like %s*%s", path, prefix,
+ nn.suffix];
cont;
}
alt get_metadata_section(path) {
option::some(cvec) {
if !metadata_matches(cvec, metas) {
- log #fmt("skipping %s, metadata doesn't match", path);
+ log #fmt["skipping %s, metadata doesn't match", path];
cont;
}
- log #fmt("found %s with matching metadata", path);
+ log #fmt["found %s with matching metadata", path];
ret some({ident: path, data: cvec});
}
_ { }
@@ -204,15 +204,14 @@ fn get_metadata_section(filename: str) -> option::t<@[u8]> {
}
fn load_library_crate(sess: &session::session, span: span, ident: &ast::ident,
- metas: &[@ast::meta_item],
- library_search_paths: &[str]) ->
- {ident: str, data: @[u8]} {
+ metas: &[@ast::meta_item], library_search_paths: &[str])
+ -> {ident: str, data: @[u8]} {
alt find_library_crate(sess, ident, metas, library_search_paths) {
some(t) { ret t; }
none. {
- sess.span_fatal(span, #fmt("can't find crate for '%s'", ident));
+ sess.span_fatal(span, #fmt["can't find crate for '%s'", ident]);
}
}
}
@@ -253,7 +252,7 @@ fn resolve_crate_deps(e: env, cdata: &@[u8]) -> cstore::cnum_map {
for dep: decoder::crate_dep in decoder::get_crate_deps(cdata) {
let extrn_cnum = dep.cnum;
let cname = dep.ident;
- log #fmt("resolving dep %s", cname);
+ log #fmt["resolving dep %s", cname];
if e.crate_cache.contains_key(cname) {
log "already have it";
// We've already seen this crate
@@ -264,7 +263,7 @@ fn resolve_crate_deps(e: env, cdata: &@[u8]) -> cstore::cnum_map {
// This is a new one so we've got to load it
// FIXME: Need better error reporting than just a bogus span
let fake_span = ast::dummy_sp();
- let local_cnum = resolve_crate(e, cname, ~[], fake_span);
+ let local_cnum = resolve_crate(e, cname, [], fake_span);
cnum_map.insert(extrn_cnum, local_cnum);
}
}
View
12 src/comp/metadata/cstore.rs
@@ -56,9 +56,9 @@ fn mk_cstore() -> cstore {
let crate_map = map::new_int_hash::<ast::crate_num>();
ret private(@{metas: meta_cache,
use_crate_map: crate_map,
- mutable used_crate_files: ~[],
- mutable used_libraries: ~[],
- mutable used_link_args: ~[]});
+ mutable used_crate_files: [],
+ mutable used_libraries: [],
+ mutable used_link_args: []});
}
fn get_crate_data(cstore: &cstore, cnum: ast::crate_num) -> crate_metadata {
@@ -76,15 +76,15 @@ fn have_crate_data(cstore: &cstore, cnum: ast::crate_num) -> bool {
iter iter_crate_data(cstore: &cstore) ->
@{key: ast::crate_num, val: crate_metadata} {
- for each kv: @{key: ast::crate_num, val: crate_metadata} in
+ for each kv: @{key: ast::crate_num, val: crate_metadata} in
p(cstore).metas.items() {
put kv;
}
}
fn add_used_crate_file(cstore: &cstore, lib: &str) {
if !vec::member(lib, p(cstore).used_crate_files) {
- p(cstore).used_crate_files += ~[lib];
+ p(cstore).used_crate_files += [lib];
}
}
@@ -97,7 +97,7 @@ fn add_used_library(cstore: &cstore, lib: &str) -> bool {
if vec::member(lib, p(cstore).used_libraries) { ret false; }
- p(cstore).used_libraries += ~[lib];
+ p(cstore).used_libraries += [lib];
ret true;
}
View
93 src/comp/metadata/decoder.rs
@@ -33,9 +33,9 @@ export external_resolver;
// def_id for an item defined in another crate, somebody needs to figure out
// what crate that's in and give us a def_id that makes sense for the current
// build.
-type external_resolver = fn(&ast::def_id) -> ast::def_id ;
+type external_resolver = fn(&ast::def_id) -> ast::def_id;
-fn lookup_hash(d: &ebml::doc, eq_fn: fn(&[u8]) -> bool , hash: uint) ->
+fn lookup_hash(d: &ebml::doc, eq_fn: fn(&[u8]) -> bool, hash: uint) ->
[ebml::doc] {
let index = ebml::get_doc(d, tag_index);
let table = ebml::get_doc(index, tag_index_table);
@@ -44,27 +44,26 @@ fn lookup_hash(d: &ebml::doc, eq_fn: fn(&[u8]) -> bool , hash: uint) ->
let bucket = ebml::doc_at(d.data, pos);
// Awkward logic because we can't ret from foreach yet
- let result: [ebml::doc] = ~[];
+ let result: [ebml::doc] = [];
let belt = tag_index_buckets_bucket_elt;
for each elt: ebml::doc in ebml::tagged_docs(bucket, belt) {
let pos = ebml::be_uint_from_bytes(elt.data, elt.start, 4u);
if eq_fn(vec::slice::<u8>(*elt.data, elt.start + 4u, elt.end)) {
- result += ~[ebml::doc_at(d.data, pos)];
+ result += [ebml::doc_at(d.data, pos)];
}
}
ret result;
}
-fn maybe_find_item(item_id: int, items: &ebml::doc) ->
- option::t<ebml::doc> {
+fn maybe_find_item(item_id: int, items: &ebml::doc) -> option::t<ebml::doc> {
fn eq_item(bytes: &[u8], item_id: int) -> bool {
ret ebml::be_uint_from_bytes(@bytes, 0u, 4u) as int == item_id;
}
let eqer = bind eq_item(_, item_id);
let found = lookup_hash(items, eqer, hash_node_id(item_id));
if vec::len(found) == 0u {
ret option::none::<ebml::doc>;
- } else { ret option::some::<ebml::doc>(found.(0)); }
+ } else { ret option::some::<ebml::doc>(found[0]); }
}
fn find_item(item_id: int, items: &ebml::doc) -> ebml::doc {
@@ -115,19 +114,20 @@ fn item_type(item: &ebml::doc, this_cnum: ast::crate_num, tcx: ty::ctxt,
}
fn item_ty_param_kinds(item: &ebml::doc) -> [ast::kind] {
- let ks: [ast::kind] = ~[];
+ let ks: [ast::kind] = [];