Permalink
Browse files

demode the each() method on vec and other iterables.

  • Loading branch information...
1 parent 1c39f19 commit cfed923600e2f7ad34241501200d595abccdeb54 @nikomatsakis nikomatsakis committed Sep 19, 2012
Showing with 483 additions and 456 deletions.
  1. +21 −21 src/cargo/cargo.rs
  2. +1 −1 src/cargo/pgp.rs
  3. +3 −3 src/compiletest/compiletest.rs
  4. +9 −9 src/compiletest/runtest.rs
  5. +16 −14 src/fuzzer/fuzzer.rs
  6. +1 −1 src/libcore/dlist.rs
  7. +1 −1 src/libcore/dvec.rs
  8. +1 −1 src/libcore/iter-trait.rs
  9. +2 −2 src/libcore/iter-trait/dlist.rs
  10. +1 −1 src/libcore/iter-trait/dvec.rs
  11. +2 −2 src/libcore/iter-trait/option.rs
  12. +16 −16 src/libcore/iter.rs
  13. +1 −1 src/libcore/os.rs
  14. +10 −6 src/libcore/path.rs
  15. +2 −2 src/libcore/vec.rs
  16. +3 −3 src/libstd/json.rs
  17. +3 −3 src/libstd/net_url.rs
  18. +1 −1 src/libstd/smallintmap.rs
  19. +1 −1 src/libstd/timer.rs
  20. +7 −7 src/libsyntax/ast_map.rs
  21. +18 −10 src/libsyntax/ast_util.rs
  22. +3 −3 src/libsyntax/attr.rs
  23. +1 −1 src/libsyntax/codemap.rs
  24. +2 −2 src/libsyntax/diagnostic.rs
  25. +1 −1 src/libsyntax/ext/concat_idents.rs
  26. +4 −4 src/libsyntax/ext/fmt.rs
  27. +3 −3 src/libsyntax/ext/pipes/pipec.rs
  28. +1 −1 src/libsyntax/ext/pipes/proto.rs
  29. +2 −2 src/libsyntax/ext/simplext.rs
  30. +2 −2 src/libsyntax/ext/tt/macro_parser.rs
  31. +1 −1 src/libsyntax/parse/eval.rs
  32. +4 −4 src/libsyntax/parse/parser.rs
  33. +3 −3 src/libsyntax/parse/token.rs
  34. +32 −28 src/libsyntax/print/pprust.rs
  35. +1 −1 src/libsyntax/util/interner.rs
  36. +28 −22 src/libsyntax/visit.rs
  37. +12 −13 src/rustc/back/link.rs
  38. +1 −1 src/rustc/back/rpath.rs
  39. +1 −1 src/rustc/back/upcall.rs
  40. +9 −7 src/rustc/driver/driver.rs
  41. +2 −2 src/rustc/driver/rustc.rs
  42. +1 −1 src/rustc/front/config.rs
  43. +1 −1 src/rustc/front/test.rs
  44. +2 −2 src/rustc/lib/llvm.rs
  45. +1 −1 src/rustc/metadata/creader.rs
  46. +3 −3 src/rustc/metadata/decoder.rs
  47. +18 −18 src/rustc/metadata/encoder.rs
  48. +2 −2 src/rustc/metadata/filesearch.rs
  49. +2 −2 src/rustc/metadata/loader.rs
  50. +3 −3 src/rustc/metadata/tyencode.rs
  51. +8 −8 src/rustc/middle/borrowck/check_loans.rs
  52. +2 −2 src/rustc/middle/borrowck/gather_loans.rs
  53. +3 −3 src/rustc/middle/capture.rs
  54. +5 −13 src/rustc/middle/check_alt.rs
  55. +2 −2 src/rustc/middle/kind.rs
  56. +2 −2 src/rustc/middle/lang_items.rs
  57. +5 −5 src/rustc/middle/lint.rs
  58. +5 −5 src/rustc/middle/liveness.rs
  59. +4 −4 src/rustc/middle/mem_categorization.rs
  60. +3 −3 src/rustc/middle/region.rs
  61. +30 −30 src/rustc/middle/resolve.rs
  62. +4 −4 src/rustc/middle/trans/alt.rs
  63. +2 −2 src/rustc/middle/trans/common.rs
  64. +1 −1 src/rustc/middle/trans/debuginfo.rs
  65. +5 −3 src/rustc/middle/trans/expr.rs
  66. +1 −1 src/rustc/middle/trans/meth.rs
  67. +2 −2 src/rustc/middle/trans/monomorphize.rs
  68. +3 −1 src/rustc/middle/trans/reachable.rs
  69. +9 −11 src/rustc/middle/trans/shape.rs
  70. +1 −1 src/rustc/middle/trans/tvec.rs
  71. +1 −1 src/rustc/middle/tstate/annotate.rs
  72. +15 −15 src/rustc/middle/ty.rs
  73. +11 −10 src/rustc/middle/typeck/check.rs
  74. +4 −4 src/rustc/middle/typeck/check/alt.rs
  75. +5 −5 src/rustc/middle/typeck/check/method.rs
  76. +1 −1 src/rustc/middle/typeck/check/regionck.rs
  77. +1 −1 src/rustc/middle/typeck/check/regionmanip.rs
  78. +1 −1 src/rustc/middle/typeck/check/vtable.rs
  79. +2 −2 src/rustc/middle/typeck/check/writeback.rs
  80. +9 −8 src/rustc/middle/typeck/coherence.rs
  81. +4 −4 src/rustc/middle/typeck/collect.rs
  82. +5 −4 src/rustc/util/ppaux.rs
  83. +4 −4 src/rustdoc/markdown_pass.rs
  84. +4 −4 src/rustdoc/sectionalize_pass.rs
  85. +7 −7 src/test/bench/graph500-bfs.rs
  86. +1 −1 src/test/bench/msgsend-ring-mutex-arcs.rs
  87. +1 −1 src/test/bench/msgsend-ring-pipes.rs
  88. +1 −1 src/test/bench/msgsend-ring-rw-arcs.rs
  89. +7 −6 src/test/bench/shootout-k-nucleotide-pipes.rs
  90. +7 −6 src/test/bench/shootout-k-nucleotide.rs
  91. +1 −1 src/test/bench/shootout-pfib.rs
  92. +3 −2 src/test/bench/task-perf-word-count-generic.rs
  93. +1 −1 src/test/compile-fail/issue-2149.rs
  94. +1 −1 src/test/run-pass/argv.rs
  95. +1 −1 src/test/run-pass/block-iter-1.rs
  96. +1 −1 src/test/run-pass/block-iter-2.rs
  97. +1 −1 src/test/run-pass/borrowck-borrow-from-at-vec.rs
  98. +3 −3 src/test/run-pass/explicit-self-closures.rs
  99. +2 −1 src/test/run-pass/hashmap-memory.rs
  100. +1 −1 src/test/run-pass/linear-for-loop.rs
  101. +1 −1 src/test/run-pass/loop-scope.rs
  102. +1 −1 src/test/run-pass/main-ivec.rs
  103. +1 −1 src/test/run-pass/monad.rs
  104. +2 −1 src/test/run-pass/morestack6.rs
  105. +1 −1 src/test/run-pass/reflect-visit-data.rs
  106. +2 −2 src/test/run-pass/static-impl.rs
  107. +1 −1 src/test/run-pass/static-method-test.rs
  108. +2 −2 src/test/run-pass/task-comm-3.rs
  109. +2 −2 src/test/run-pass/task-comm.rs
  110. +1 −1 src/test/run-pass/trait-generic.rs
View
42 src/cargo/cargo.rs
@@ -325,9 +325,9 @@ fn load_crate(filename: &Path) -> Option<crate> {
let mut attr_from = ~"";
for m.each |item| {
- match attr::get_meta_item_value_str(item) {
+ match attr::get_meta_item_value_str(*item) {
Some(value) => {
- let name = attr::get_meta_item_name(item);
+ let name = attr::get_meta_item_name(*item);
match name {
~"vers" => attr_vers = value,
@@ -530,7 +530,7 @@ fn load_one_source_package(src: source, p: map::HashMap<~str, json::Json>) {
match p.find(~"tags") {
Some(json::List(js)) => {
for (*js).each |j| {
- match j {
+ match *j {
json::String(j) => vec::grow(tags, 1u, *j),
_ => ()
}
@@ -602,7 +602,7 @@ fn load_source_packages(c: &cargo, src: source) {
match json::from_str(result::get(pkgstr)) {
Ok(json::List(js)) => {
for (*js).each |j| {
- match j {
+ match *j {
json::Dict(p) => {
load_one_source_package(src, p);
}
@@ -715,7 +715,7 @@ fn configure(opts: options) -> cargo {
fn for_each_package(c: &cargo, b: fn(source, package)) {
for c.sources.each_value |v| {
for v.packages.each |p| {
- b(v, p);
+ b(v, *p);
}
}
}
@@ -773,15 +773,15 @@ fn install_one_crate(c: &cargo, path: &Path, cf: &Path) {
!str::starts_with(option::get(ct.filename()),
~"lib")) {
debug!(" bin: %s", ct.to_str());
- install_to_dir(ct, &c.bindir);
+ install_to_dir(*ct, &c.bindir);
if c.opts.mode == system_mode {
// FIXME (#2662): Put this file in PATH / symlink it so it can
// be used as a generic executable
// `cargo install -G rustray` and `rustray file.obj`
}
} else {
debug!(" lib: %s", ct.to_str());
- install_to_dir(ct, &c.libdir);
+ install_to_dir(*ct, &c.libdir);
}
}
}
@@ -814,7 +814,7 @@ fn install_source(c: &cargo, path: &Path) {
}
for cratefiles.each |cf| {
- match load_crate(&cf) {
+ match load_crate(cf) {
None => loop,
Some(crate) => {
for crate.deps.each |query| {
@@ -823,15 +823,15 @@ fn install_source(c: &cargo, path: &Path) {
// condition")
let wd = get_temp_workdir(c);
- install_query(c, &wd, query);
+ install_query(c, &wd, *query);
}
os::change_dir(path);
if c.opts.test {
- test_one_crate(c, path, &cf);
+ test_one_crate(c, path, cf);
}
- install_one_crate(c, path, &cf);
+ install_one_crate(c, path, cf);
}
}
}
@@ -915,7 +915,7 @@ fn install_uuid(c: &cargo, wd: &Path, uuid: ~str) {
}
error(~"found multiple packages:");
for ps.each |elt| {
- let (sname,p) = copy elt;
+ let (sname,p) = copy *elt;
info(~" " + sname + ~"/" + p.uuid + ~" (" + p.name + ~")");
}
}
@@ -939,7 +939,7 @@ fn install_named(c: &cargo, wd: &Path, name: ~str) {
}
error(~"found multiple packages:");
for ps.each |elt| {
- let (sname,p) = copy elt;
+ let (sname,p) = copy *elt;
info(~" " + sname + ~"/" + p.uuid + ~" (" + p.name + ~")");
}
}
@@ -949,7 +949,7 @@ fn install_uuid_specific(c: &cargo, wd: &Path, src: ~str, uuid: ~str) {
Some(s) => {
for s.packages.each |p| {
if p.uuid == uuid {
- install_package(c, src, wd, p);
+ install_package(c, src, wd, *p);
return;
}
}
@@ -964,7 +964,7 @@ fn install_named_specific(c: &cargo, wd: &Path, src: ~str, name: ~str) {
Some(s) => {
for s.packages.each |p| {
if p.name == name {
- install_package(c, src, wd, p);
+ install_package(c, src, wd, *p);
return;
}
}
@@ -1002,22 +1002,22 @@ fn cmd_uninstall(c: &cargo) {
if is_uuid(target) {
for os::list_dir(lib).each |file| {
- match str::find_str(file, ~"-" + target + ~"-") {
- Some(_) => if !try_uninstall(&lib.push(file)) { return },
+ match str::find_str(*file, ~"-" + target + ~"-") {
+ Some(_) => if !try_uninstall(&lib.push(*file)) { return },
None => ()
}
}
error(~"can't find package with uuid: " + target);
} else {
for os::list_dir(lib).each |file| {
- match str::find_str(file, ~"lib" + target + ~"-") {
- Some(_) => if !try_uninstall(&lib.push(file)) { return },
+ match str::find_str(*file, ~"lib" + target + ~"-") {
+ Some(_) => if !try_uninstall(&lib.push(*file)) { return },
None => ()
}
}
for os::list_dir(bin).each |file| {
- match str::find_str(file, target) {
- Some(_) => if !try_uninstall(&lib.push(file)) { return },
+ match str::find_str(*file, target) {
+ Some(_) => if !try_uninstall(&lib.push(*file)) { return },
None => ()
}
}
View
2 src/cargo/pgp.rs
@@ -95,7 +95,7 @@ fn verify(root: &Path, data: &Path, sig: &Path, keyfp: ~str) -> bool {
~"--verify", sig.to_str(),
data.to_str()]);
let res = ~"Primary key fingerprint: " + keyfp;
- for str::split_char(p.err, '\n').each |line| {
+ for str::split_char_each(p.err, '\n') |line| {
if line == res { return true; }
}
return false;
View
6 src/compiletest/compiletest.rs
@@ -138,7 +138,7 @@ fn make_tests(config: config) -> ~[test::TestDesc] {
config.src_base.to_str());
let mut tests = ~[];
for os::list_dir_path(&config.src_base).each |file| {
- let file = copy file;
+ let file = copy *file;
debug!("inspecting file %s", file.to_str());
if is_test(config, file) {
vec::push(tests, make_test(config, file))
@@ -160,11 +160,11 @@ fn is_test(config: config, testfile: &Path) -> bool {
let mut valid = false;
for valid_extensions.each |ext| {
- if str::ends_with(name, ext) { valid = true; }
+ if str::ends_with(name, *ext) { valid = true; }
}
for invalid_prefixes.each |pre| {
- if str::starts_with(name, pre) { valid = false; }
+ if str::starts_with(name, *pre) { valid = false; }
}
return valid;
View
18 src/compiletest/runtest.rs
@@ -219,7 +219,7 @@ fn check_error_patterns(props: test_props,
let mut next_err_pat = props.error_patterns[next_err_idx];
let mut done = false;
for str::split_char(procres.stderr, '\n').each |line| {
- if str::contains(line, next_err_pat) {
+ if str::contains(*line, next_err_pat) {
debug!("found error pattern %s", next_err_pat);
next_err_idx += 1u;
if next_err_idx == vec::len(props.error_patterns) {
@@ -240,7 +240,7 @@ fn check_error_patterns(props: test_props,
missing_patterns[0]), procres);
} else {
for missing_patterns.each |pattern| {
- error(fmt!("error pattern '%s' not found!", pattern));
+ error(fmt!("error pattern '%s' not found!", *pattern));
}
fatal_procres(~"multiple error patterns not found", procres);
}
@@ -273,10 +273,10 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error],
for vec::eachi(expected_errors) |i, ee| {
if !found_flags[i] {
debug!("prefix=%s ee.kind=%s ee.msg=%s line=%s",
- prefixes[i], ee.kind, ee.msg, line);
- if (str::starts_with(line, prefixes[i]) &&
- str::contains(line, ee.kind) &&
- str::contains(line, ee.msg)) {
+ prefixes[i], ee.kind, ee.msg, *line);
+ if (str::starts_with(*line, prefixes[i]) &&
+ str::contains(*line, ee.kind) &&
+ str::contains(*line, ee.msg)) {
found_flags[i] = true;
was_expected = true;
break;
@@ -285,13 +285,13 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error],
}
// ignore this msg which gets printed at the end
- if str::contains(line, ~"aborting due to") {
+ if str::contains(*line, ~"aborting due to") {
was_expected = true;
}
- if !was_expected && is_compiler_error_or_warning(line) {
+ if !was_expected && is_compiler_error_or_warning(*line) {
fatal_procres(fmt!("unexpected compiler error or warning: '%s'",
- line),
+ *line),
procres);
}
}
View
30 src/fuzzer/fuzzer.rs
@@ -33,7 +33,7 @@ fn find_rust_files(files: &mut ~[Path], path: &Path) {
&& !contains(path.to_str(), ~"compile-fail")
&& !contains(path.to_str(), ~"build") {
for os::list_dir_path(path).each |p| {
- find_rust_files(files, p);
+ find_rust_files(files, *p);
}
}
}
@@ -463,15 +463,15 @@ fn content_is_dangerous_to_run(code: ~str) -> bool {
~"unsafe",
~"log"]; // python --> rust pipe deadlock?
- for dangerous_patterns.each |p| { if contains(code, p) { return true; } }
+ 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) { return true; } }
+ for dangerous_patterns.each |p| { if contains(code, *p) { return true; } }
return false;
}
@@ -487,7 +487,7 @@ 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) { return true; } }
+ for confusing_patterns.each |p| { if contains(code, *p) { return true; } }
return false;
}
@@ -502,7 +502,7 @@ fn file_might_not_converge(filename: &Path) -> bool {
for confusing_files.each |f| {
- if contains(filename.to_str(), f) {
+ if contains(filename.to_str(), *f) {
return true;
}
}
@@ -540,8 +540,8 @@ fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
fn check_convergence(files: &[Path]) {
error!("pp convergence tests: %u files", vec::len(files));
for files.each |file| {
- if !file_might_not_converge(&file) {
- let s = @result::get(io::read_whole_file_str(&file));
+ if !file_might_not_converge(file) {
+ let s = @result::get(io::read_whole_file_str(file));
if !content_might_not_converge(*s) {
error!("pp converge: %s", file.to_str());
// Change from 7u to 2u once
@@ -555,13 +555,13 @@ fn check_convergence(files: &[Path]) {
fn check_variants(files: &[Path], cx: context) {
for files.each |file| {
if cx.mode == tm_converge &&
- file_might_not_converge(&file) {
+ file_might_not_converge(file) {
error!("Skipping convergence test based on\
file_might_not_converge");
loop;
}
- let s = @result::get(io::read_whole_file_str(&file));
+ let s = @result::get(io::read_whole_file_str(file));
if contains(*s, ~"#") {
loop; // Macros are confusing
}
@@ -572,11 +572,13 @@ fn check_variants(files: &[Path], cx: context) {
loop;
}
- log(error, ~"check_variants: " + file.to_str());
+ let file_str = file.to_str();
+
+ log(error, ~"check_variants: " + file_str);
let sess = parse::new_parse_sess(option::None);
let crate =
parse::parse_crate_from_source_str(
- file.to_str(),
+ file_str,
s, ~[], sess);
io::with_str_reader(*s, |rdr| {
error!("%s",
@@ -586,12 +588,12 @@ fn check_variants(files: &[Path], cx: context) {
syntax::parse::token::mk_fake_ident_interner(),
sess.span_diagnostic,
crate,
- file.to_str(),
+ file_str,
rdr, a,
pprust::no_ann(),
- false) ))
+ false)))
});
- check_variants_of_ast(*crate, sess.cm, &file, cx);
+ check_variants_of_ast(*crate, sess.cm, file, cx);
}
}
View
2 src/libcore/dlist.rs
@@ -678,7 +678,7 @@ mod tests {
let mut x = 0;
for l.each |i| {
x += 1;
- if (i == 3) { break; }
+ if (*i == 3) { break; }
}
assert x == 3;
}
View
2 src/libcore/dvec.rs
@@ -272,7 +272,7 @@ impl<A: Copy> DVec<A> {
}
};
- for ts.each |t| { vec::push(v, t) };
+ for ts.each |t| { vec::push(v, *t) };
v
}
}
View
2 src/libcore/iter-trait.rs
@@ -7,7 +7,7 @@ use inst::{IMPL_T, EACH, SIZE_HINT};
export extensions;
impl<A> IMPL_T<A>: iter::BaseIter<A> {
- pure fn each(blk: fn(A) -> bool) { EACH(self, blk) }
+ pure fn each(blk: fn(v: &A) -> bool) { EACH(self, blk) }
pure fn size_hint() -> Option<uint> { SIZE_HINT(self) }
}
View
4 src/libcore/iter-trait/dlist.rs
@@ -8,12 +8,12 @@ type IMPL_T<A> = dlist::DList<A>;
* e.g. breadth-first search with in-place enqueues), but removing the current
* node is forbidden.
*/
-pure fn EACH<A>(self: IMPL_T<A>, f: fn(A) -> bool) {
+pure fn EACH<A>(self: IMPL_T<A>, f: fn(v: &A) -> bool) {
let mut link = self.peek_n();
while option::is_some(link) {
let nobe = option::get(link);
assert nobe.linked;
- if !f(nobe.data) { break; }
+ if !f(&nobe.data) { break; }
// Check (weakly) that the user didn't do a remove.
if self.size == 0 {
fail ~"The dlist became empty during iteration??"
View
2 src/libcore/iter-trait/dvec.rs
@@ -6,7 +6,7 @@ type IMPL_T<A> = dvec::DVec<A>;
*
* Attempts to access this dvec during iteration will fail.
*/
-pure fn EACH<A>(self: IMPL_T<A>, f: fn(A) -> bool) {
+pure fn EACH<A>(self: IMPL_T<A>, f: fn(v: &A) -> bool) {
unsafe {
do self.swap |v| {
v.each(f);
View
4 src/libcore/iter-trait/option.rs
@@ -1,10 +1,10 @@
#[allow(non_camel_case_types)]
type IMPL_T<A> = Option<A>;
-pure fn EACH<A>(self: IMPL_T<A>, f: fn(A) -> bool) {
+pure fn EACH<A>(self: IMPL_T<A>, f: fn(v: &A) -> bool) {
match self {
None => (),
- Some(a) => { f(a); }
+ Some(ref a) => { f(a); }
}
}
View
32 src/libcore/iter.rs
@@ -10,7 +10,7 @@ use cmp::{Eq, Ord};
type InitOp<T> = fn(uint) -> T;
trait BaseIter<A> {
- pure fn each(blk: fn(A) -> bool);
+ pure fn each(blk: fn(v: &A) -> bool);
pure fn size_hint() -> Option<uint>;
}
@@ -69,21 +69,21 @@ trait Buildable<A> {
pure fn eachi<A,IA:BaseIter<A>>(self: IA, blk: fn(uint, A) -> bool) {
let mut i = 0u;
for self.each |a| {
- if !blk(i, a) { break; }
+ if !blk(i, *a) { break; }
i += 1u;
}
}
pure fn all<A,IA:BaseIter<A>>(self: IA, blk: fn(A) -> bool) -> bool {
for self.each |a| {
- if !blk(a) { return false; }
+ if !blk(*a) { return false; }
}
return true;
}
pure fn any<A,IA:BaseIter<A>>(self: IA, blk: fn(A) -> bool) -> bool {
for self.each |a| {
- if blk(a) { return true; }
+ if blk(*a) { return true; }
}
return false;
}
@@ -92,7 +92,7 @@ pure fn filter_to_vec<A:Copy,IA:BaseIter<A>>(self: IA,
prd: fn(A) -> bool) -> ~[A] {
do vec::build_sized_opt(self.size_hint()) |push| {
for self.each |a| {
- if prd(a) { push(a); }
+ if prd(*a) { push(*a); }
}
}
}
@@ -101,7 +101,7 @@ pure fn map_to_vec<A:Copy,B,IA:BaseIter<A>>(self: IA, op: fn(A) -> B)
-> ~[B] {
do vec::build_sized_opt(self.size_hint()) |push| {
for self.each |a| {
- push(op(a));
+ push(op(*a));
}
}
}
@@ -111,8 +111,8 @@ pure fn flat_map_to_vec<A:Copy,B:Copy,IA:BaseIter<A>,IB:BaseIter<B>>(
do vec::build |push| {
for self.each |a| {
- for op(a).each |b| {
- push(b);
+ for op(*a).each |b| {
+ push(*b);
}
}
}
@@ -121,7 +121,7 @@ pure fn flat_map_to_vec<A:Copy,B:Copy,IA:BaseIter<A>,IB:BaseIter<B>>(
pure fn foldl<A,B,IA:BaseIter<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B {
let mut b <- b0;
for self.each |a| {
- b = blk(b, a);
+ b = blk(b, *a);
}
move b
}
@@ -132,7 +132,7 @@ pure fn to_vec<A:Copy,IA:BaseIter<A>>(self: IA) -> ~[A] {
pure fn contains<A:Eq,IA:BaseIter<A>>(self: IA, x: A) -> bool {
for self.each |a| {
- if a == x { return true; }
+ if *a == x { return true; }
}
return false;
}
@@ -152,7 +152,7 @@ pure fn position<A,IA:BaseIter<A>>(self: IA, f: fn(A) -> bool)
{
let mut i = 0;
for self.each |a| {
- if f(a) { return Some(i); }
+ if f(*a) { return Some(i); }
i += 1;
}
return None;
@@ -205,7 +205,7 @@ pure fn max<A:Copy Ord,IA:BaseIter<A>>(self: IA) -> A {
pure fn find<A: Copy,IA:BaseIter<A>>(self: IA,
p: fn(A) -> bool) -> Option<A> {
for self.each |i| {
- if p(i) { return Some(i) }
+ if p(*i) { return Some(*i) }
}
return None;
}
@@ -254,7 +254,7 @@ pure fn build_sized_opt<A,B: Buildable<A>>(
fn map<T,IT: BaseIter<T>,U,BU: Buildable<U>>(v: IT, f: fn(T) -> U) -> BU {
do build_sized_opt(v.size_hint()) |push| {
for v.each() |elem| {
- push(f(elem));
+ push(f(*elem));
}
}
}
@@ -292,8 +292,8 @@ pure fn append<T: Copy,IT: BaseIter<T>,BT: Buildable<T>>(
let size_opt = lhs.size_hint().chain(
|sz1| rhs.size_hint().map(|sz2| sz1+sz2));
do build_sized_opt(size_opt) |push| {
- for lhs.each |x| { push(x); }
- for rhs.each |x| { push(x); }
+ for lhs.each |x| { push(*x); }
+ for rhs.each |x| { push(*x); }
}
}
@@ -303,6 +303,6 @@ pure fn append<T: Copy,IT: BaseIter<T>,BT: Buildable<T>>(
pure fn copy_seq<T: Copy,IT: BaseIter<T>,BT: Buildable<T>>(
v: IT) -> BT {
do build_sized_opt(v.size_hint()) |push| {
- for v.each |x| { push(x); }
+ for v.each |x| { push(*x); }
}
}
View
2 src/libcore/os.rs
@@ -529,7 +529,7 @@ fn walk_dir(p: &Path, f: fn((&Path)) -> bool) {
fn walk_dir_(p: &Path, f: fn((&Path)) -> bool) -> bool {
let mut keepgoing = true;
do list_dir(p).each |q| {
- let path = &p.push(q);
+ let path = &p.push(*q);
if !f(path) {
keepgoing = false;
false
View
16 src/libcore/path.rs
@@ -203,7 +203,9 @@ impl PosixPath : GenericPath {
pure fn push_many(cs: &[~str]) -> PosixPath {
let mut v = copy self.components;
for cs.each |e| {
- let mut ss = str::split_nonempty(e, |c| windows::is_sep(c as u8));
+ let mut ss = str::split_nonempty(
+ *e,
+ |c| windows::is_sep(c as u8));
unsafe { vec::push_all_move(v, move ss); }
}
PosixPath { components: move v, ..self }
@@ -395,7 +397,9 @@ impl WindowsPath : GenericPath {
pure fn push_many(cs: &[~str]) -> WindowsPath {
let mut v = copy self.components;
for cs.each |e| {
- let mut ss = str::split_nonempty(e, |c| windows::is_sep(c as u8));
+ let mut ss = str::split_nonempty(
+ *e,
+ |c| windows::is_sep(c as u8));
unsafe { vec::push_all_move(v, move ss); }
}
return WindowsPath { components: move v, ..self }
@@ -430,13 +434,13 @@ pure fn normalize(components: &[~str]) -> ~[~str] {
unsafe {
for components.each |c| {
unsafe {
- if c == ~"." && components.len() > 1 { loop; }
- if c == ~"" { loop; }
- if c == ~".." && cs.len() != 0 {
+ if *c == ~"." && components.len() > 1 { loop; }
+ if *c == ~"" { loop; }
+ if *c == ~".." && cs.len() != 0 {
vec::pop(cs);
loop;
}
- vec::push(cs, copy c);
+ vec::push(cs, copy *c);
}
}
}
View
4 src/libcore/vec.rs
@@ -1874,9 +1874,9 @@ mod bytes {
// required in the slice.
impl<A> &[A]: iter::BaseIter<A> {
- pure fn each(blk: fn(A) -> bool) {
+ pure fn each(blk: fn(v: &A) -> bool) {
for each(self) |e| {
- if (!blk(*e)) {
+ if (!blk(e)) {
return;
}
}
View
6 src/libstd/json.rs
@@ -61,7 +61,7 @@ fn to_writer(wr: io::Writer, j: Json) {
wr.write_str(~", ");
}
first = false;
- to_writer(wr, item);
+ to_writer(wr, *item);
};
wr.write_char(']');
}
@@ -122,7 +122,7 @@ fn to_writer_pretty(wr: io::Writer, j: Json, indent: uint) {
wr.write_str(spaces(inner_indent));
}
first = false;
- to_writer_pretty(wr, item, inner_indent);
+ to_writer_pretty(wr, *item, inner_indent);
};
// ]
@@ -156,7 +156,7 @@ fn to_writer_pretty(wr: io::Writer, j: Json, indent: uint) {
// k: v }
let mut first = true;
for sorted_pairs.each |kv| {
- let (key, value) = kv;
+ let (key, value) = *kv;
if !first {
wr.write_str(~",\n");
wr.write_str(spaces(inner_indent));
View
6 src/libstd/net_url.rs
@@ -199,7 +199,7 @@ fn encode_form_urlencoded(m: HashMap<~str, @DVec<@~str>>) -> ~str {
first = false;
}
- out += #fmt("%s=%s", key, encode_plus(*value));
+ out += #fmt("%s=%s", key, encode_plus(**value));
}
}
@@ -328,7 +328,7 @@ fn query_from_str(rawquery: &str) -> Query {
let mut query: Query = ~[];
if str::len(rawquery) != 0 {
for str::split_char(rawquery, '&').each |p| {
- let (k, v) = split_char_first(p, '=');
+ let (k, v) = split_char_first(*p, '=');
vec::push(query, (decode_component(k), decode_component(v)));
};
}
@@ -338,7 +338,7 @@ fn query_from_str(rawquery: &str) -> Query {
fn query_to_str(+query: Query) -> ~str {
let mut strvec = ~[];
for query.each |kv| {
- let (k, v) = copy kv;
+ let (k, v) = copy *kv;
strvec += ~[#fmt("%s=%s", encode_component(k), encode_component(v))];
};
return str::connect(strvec, ~"&");
View
2 src/libstd/smallintmap.rs
@@ -70,7 +70,7 @@ impl<V: Copy> SmallIntMap<V>: map::Map<uint, V> {
pure fn size() -> uint {
let mut sz = 0u;
for self.v.each |item| {
- match item {
+ match *item {
Some(_) => sz += 1u,
_ => ()
}
View
2 src/libstd/timer.rs
@@ -179,7 +179,7 @@ mod test {
for iter::repeat(repeat) {
for spec.each |spec| {
- let (times, maxms) = spec;
+ let (times, maxms) = *spec;
do task::spawn {
use rand::*;
let rng = Rng();
View
14 src/libsyntax/ast_map.rs
@@ -151,7 +151,7 @@ fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
for decl.inputs.each |a| {
cx.map.insert(a.id,
node_arg(/* FIXME (#2543) */
- copy a, cx.local_id));
+ copy *a, cx.local_id));
cx.local_id += 1u;
}
match fk {
@@ -220,14 +220,14 @@ fn map_item(i: @item, cx: ctx, v: vt) {
item_impl(_, _, _, ms) => {
let impl_did = ast_util::local_def(i.id);
for ms.each |m| {
- map_method(impl_did, extend(cx, i.ident), m,
+ map_method(impl_did, extend(cx, i.ident), *m,
cx);
}
}
item_enum(enum_definition, _) => {
for enum_definition.variants.each |v| {
cx.map.insert(v.node.id, node_variant(
- /* FIXME (#2543) */ copy v, i,
+ /* FIXME (#2543) */ copy *v, i,
extend(cx, i.ident)));
}
}
@@ -238,7 +238,7 @@ fn map_item(i: @item, cx: ctx, v: vt) {
};
for nm.items.each |nitem| {
cx.map.insert(nitem.id,
- node_foreign_item(nitem, abi,
+ node_foreign_item(*nitem, abi,
/* FIXME (#2543) */
if nm.sort == ast::named {
extend(cx, i.ident)
@@ -264,9 +264,9 @@ fn map_item(i: @item, cx: ctx, v: vt) {
cx.map.insert(p.impl_id, node_item(i, item_path));
}
for methods.each |tm| {
- let id = ast_util::trait_method_to_ty_method(tm).id;
+ let id = ast_util::trait_method_to_ty_method(*tm).id;
let d_id = ast_util::local_def(i.id);
- cx.map.insert(id, node_trait_method(@tm, d_id, item_path));
+ cx.map.insert(id, node_trait_method(@*tm, d_id, item_path));
}
}
_ => ()
@@ -310,7 +310,7 @@ fn map_view_item(vi: @view_item, cx: ctx, _v: vt) {
(id, path_to_ident(pth))
}
};
- cx.map.insert(id, node_export(vp, extend(cx, name)));
+ cx.map.insert(id, node_export(*vp, extend(cx, name)));
},
_ => ()
}
View
28 src/libsyntax/ast_util.rs
@@ -312,7 +312,7 @@ fn split_trait_methods(trait_methods: ~[trait_method])
-> (~[ty_method], ~[@method]) {
let mut reqd = ~[], provd = ~[];
for trait_methods.each |trt_method| {
- match trt_method {
+ match *trt_method {
required(tm) => vec::push(reqd, tm),
provided(m) => vec::push(provd, m)
}
@@ -575,15 +575,23 @@ pure fn is_item_impl(item: @ast::item) -> bool {
fn walk_pat(pat: @pat, it: fn(@pat)) {
it(pat);
match pat.node {
- pat_ident(_, _, Some(p)) => walk_pat(p, it),
- pat_rec(fields, _) | pat_struct(_, fields, _) =>
- for fields.each |f| { walk_pat(f.pat, it) },
- pat_enum(_, Some(s)) | pat_tup(s) => for s.each |p| {
- walk_pat(p, it)
- },
- pat_box(s) | pat_uniq(s) | pat_region(s) => walk_pat(s, it),
- pat_wild | pat_lit(_) | pat_range(_, _) | pat_ident(_, _, _)
- | pat_enum(_, _) => ()
+ pat_ident(_, _, Some(p)) => walk_pat(p, it),
+ pat_rec(fields, _) | pat_struct(_, fields, _) => {
+ for fields.each |f| {
+ walk_pat(f.pat, it)
+ }
+ }
+ pat_enum(_, Some(s)) | pat_tup(s) => {
+ for s.each |p| {
+ walk_pat(*p, it)
+ }
+ }
+ pat_box(s) | pat_uniq(s) | pat_region(s) => {
+ walk_pat(s, it)
+ }
+ pat_wild | pat_lit(_) | pat_range(_, _) | pat_ident(_, _, _) |
+ pat_enum(_, _) => {
+ }
}
}
View
6 src/libsyntax/attr.rs
@@ -91,7 +91,7 @@ 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 mut mitems = ~[];
- for attrs.each |a| { vec::push(mitems, attr_meta(a)); }
+ for attrs.each |a| { vec::push(mitems, attr_meta(*a)); }
return mitems;
}
@@ -189,7 +189,7 @@ fn find_meta_items_by_name(metas: ~[@ast::meta_item], name: ~str) ->
*/
fn contains(haystack: ~[@ast::meta_item], needle: @ast::meta_item) -> bool {
for haystack.each |item| {
- if eq(item, needle) { return true; }
+ if eq(*item, needle) { return true; }
}
return false;
}
@@ -370,7 +370,7 @@ fn require_unique_names(diagnostic: span_handler,
metas: ~[@ast::meta_item]) {
let map = map::HashMap();
for metas.each |meta| {
- let name = get_meta_item_name(meta);
+ let name = get_meta_item_name(*meta);
// FIXME: How do I silence the warnings? --pcw (#2619)
if map.contains_key(name) {
View
2 src/libsyntax/codemap.rs
@@ -242,7 +242,7 @@ fn get_snippet(cm: codemap::codemap, fidx: uint, lo: uint, hi: uint) -> ~str
}
fn get_filemap(cm: codemap, filename: ~str) -> filemap {
- for cm.files.each |fm| { if fm.name == filename { return fm; } }
+ for cm.files.each |fm| { if fm.name == filename { return *fm; } }
//XXjdm the following triggers a mismatched type bug
// (or expected function, found _|_)
fail; // ("asking for " + filename + " which we don't know about");
View
4 src/libsyntax/diagnostic.rs
@@ -219,8 +219,8 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
}
// Print the offending lines
for display_lines.each |line| {
- io::stderr().write_str(fmt!("%s:%u ", fm.name, line + 1u));
- let s = codemap::get_line(fm, line as int) + ~"\n";
+ io::stderr().write_str(fmt!("%s:%u ", fm.name, *line + 1u));
+ let s = codemap::get_line(fm, *line as int) + ~"\n";
io::stderr().write_str(s);
}
if elided {
View
2 src/libsyntax/ext/concat_idents.rs
@@ -6,7 +6,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
let mut res_str = ~"";
for args.each |e| {
res_str += *cx.parse_sess().interner.get(
- expr_to_ident(cx, e, ~"expected an ident"));
+ expr_to_ident(cx, *e, ~"expected an ident"));
}
let res = cx.parse_sess().interner.intern(@res_str);
View
8 src/libsyntax/ext/fmt.rs
@@ -53,7 +53,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
fn make_flags(cx: ext_ctxt, sp: span, flags: ~[Flag]) -> @ast::expr {
let mut tmp_expr = make_rt_path_expr(cx, sp, @~"flag_none");
for flags.each |f| {
- let fstr = match f {
+ let fstr = match *f {
FlagLeftJustify => ~"flag_left_justify",
FlagLeftZeroPad => ~"flag_left_zero_pad",
FlagSpaceForSign => ~"flag_space_for_sign",
@@ -139,7 +139,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
_ => cx.span_unimpl(sp, unsupported)
}
for cnv.flags.each |f| {
- match f {
+ match *f {
FlagLeftJustify => (),
FlagSignAlways => {
if !is_signed_type(cnv) {
@@ -196,7 +196,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
_ => debug!("param: none")
}
for c.flags.each |f| {
- match f {
+ match *f {
FlagLeftJustify => debug!("flag: left justify"),
FlagLeftZeroPad => debug!("flag: left zero pad"),
FlagSpaceForSign => debug!("flag: left space pad"),
@@ -243,7 +243,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
let mut piece_exprs = ~[];
let nargs = args.len();
for pieces.each |pc| {
- match pc {
+ match *pc {
PieceString(s) => {
vec::push(piece_exprs, mk_uniq_str(cx, fmt_sp, s))
}
View
6 src/libsyntax/ext/pipes/pipec.rs
@@ -202,7 +202,7 @@ impl state: to_type_decls {
let mut items_msg = ~[];
for self.messages.each |m| {
- let message(name, span, tys, this, next) = m;
+ let message(name, span, tys, this, next) = *m;
let tys = match next {
Some({state: next, tys: next_tys}) => {
@@ -366,7 +366,7 @@ impl protocol: gen_init {
for (copy self.states).each |s| {
for s.ty_params.each |tp| {
match params.find(|tpp| tp.ident == tpp.ident) {
- None => vec::push(params, tp),
+ None => vec::push(params, *tp),
_ => ()
}
}
@@ -382,7 +382,7 @@ impl protocol: gen_init {
let fields = do (copy self.states).map_to_vec |s| {
for s.ty_params.each |tp| {
match params.find(|tpp| tp.ident == tpp.ident) {
- None => vec::push(params, tp),
+ None => vec::push(params, *tp),
_ => ()
}
}
View
2 src/libsyntax/ext/pipes/proto.rs
@@ -102,7 +102,7 @@ impl state {
/// from this state.
fn reachable(f: fn(state) -> bool) {
for self.messages.each |m| {
- match m {
+ match *m {
message(_, _, _, _, Some({state: id, _})) => {
let state = self.proto.get_state(id);
if !f(state) { break }
View
4 src/libsyntax/ext/simplext.rs
@@ -92,7 +92,7 @@ fn option_flatten_map<T: Copy, U: Copy>(f: fn@(T) -> Option<U>, v: ~[T]) ->
Option<~[U]> {
let mut res = ~[];
for v.each |elem| {
- match f(elem) {
+ match f(*elem) {
None => return None,
Some(fv) => vec::push(res, fv)
}
@@ -156,7 +156,7 @@ fn use_selectors_to_bind(b: binders, e: @expr) -> Option<bindings> {
let res = HashMap();
//need to do this first, to check vec lengths.
for b.literal_ast_matchers.each |sel| {
- match sel(match_expr(e)) { None => return None, _ => () }
+ match (*sel)(match_expr(e)) { None => return None, _ => () }
}
let mut never_mind: bool = false;
for b.real_binders.each |key, val| {
View
4 src/libsyntax/ext/tt/macro_parser.rs
@@ -174,7 +174,7 @@ fn nameize(p_s: parse_sess, ms: ~[matcher], res: ~[@named_match])
match m {
{node: match_tok(_), span: _} => (),
{node: match_seq(more_ms, _, _, _, _), span: _} => {
- for more_ms.each() |next_m| { n_rec(p_s, next_m, res, ret_val) };
+ for more_ms.each() |next_m| { n_rec(p_s, *next_m, res, ret_val) };
}
{node: match_nonterminal(bind_name, _, idx), span: sp} => {
if ret_val.contains_key(bind_name) {
@@ -186,7 +186,7 @@ fn nameize(p_s: parse_sess, ms: ~[matcher], res: ~[@named_match])
}
}
let ret_val = HashMap::<uint,@named_match>();
- for ms.each() |m| { n_rec(p_s, m, res, ret_val) }
+ for ms.each() |m| { n_rec(p_s, *m, res, ret_val) }
return ret_val;
}
View
2 src/libsyntax/parse/eval.rs
@@ -13,7 +13,7 @@ fn eval_crate_directives(cx: ctx,
&view_items: ~[@ast::view_item],
&items: ~[@ast::item]) {
for cdirs.each |sub_cdir| {
- eval_crate_directive(cx, sub_cdir, prefix, view_items, items);
+ eval_crate_directive(cx, *sub_cdir, prefix, view_items, items);
}
}
View
8 src/libsyntax/parse/parser.rs
@@ -2244,7 +2244,7 @@ impl parser {
IMPORTS_AND_ITEMS_ALLOWED);
for items.each |item| {
- let decl = @spanned(item.span.lo, item.span.hi, decl_item(item));
+ let decl = @spanned(item.span.lo, item.span.hi, decl_item(*item));
push(stmts, @spanned(item.span.lo, item.span.hi,
stmt_decl(decl, self.get_id())));
}
@@ -2699,7 +2699,7 @@ impl parser {
}
members(mms) => {
for mms.each |mm| {
- match mm {
+ match *mm {
@field_member(struct_field) =>
vec::push(fields, struct_field),
@method_member(the_method_member) =>
@@ -3090,7 +3090,7 @@ impl parser {
}
members(mms) => {
for mms.each |mm| {
- match mm {
+ match *mm {
@field_member(struct_field) =>
vec::push(fields, struct_field),
@method_member(the_method_member) =>
@@ -3163,7 +3163,7 @@ impl parser {
seq_sep_trailing_disallowed(token::COMMA),
|p| p.parse_ty(false));
for arg_tys.each |ty| {
- vec::push(args, {ty: ty, id: self.get_id()});
+ vec::push(args, {ty: *ty, id: self.get_id()});
}
kind = tuple_variant_kind(args);
} else if self.eat(token::EQ) {
View
6 src/libsyntax/parse/token.rs
@@ -389,7 +389,7 @@ fn temporary_keyword_table() -> HashMap<~str, ()> {
~"self", ~"static",
];
for keys.each |word| {
- words.insert(word, ());
+ words.insert(*word, ());
}
words
}
@@ -415,7 +415,7 @@ fn strict_keyword_table() -> HashMap<~str, ()> {
~"while"
];
for keys.each |word| {
- words.insert(word, ());
+ words.insert(*word, ());
}
words
}
@@ -426,7 +426,7 @@ fn reserved_keyword_table() -> HashMap<~str, ()> {
~"be"
];
for keys.each |word| {
- words.insert(word, ());
+ words.insert(*word, ());
}
words
}
View
60 src/libsyntax/print/pprust.rs
@@ -281,7 +281,7 @@ fn commasep<IN>(s: ps, b: breaks, elts: ~[IN], op: fn(ps, IN)) {
let mut first = true;
for elts.each |elt| {
if first { first = false; } else { word_space(s, ~","); }
- op(s, elt);
+ op(s, *elt);
}
end(s);
}
@@ -293,12 +293,12 @@ fn commasep_cmnt<IN>(s: ps, b: breaks, elts: ~[IN], op: fn(ps, IN),
let len = vec::len::<IN>(elts);
let mut i = 0u;
for elts.each |elt| {
- maybe_print_comment(s, get_span(elt).hi);
- op(s, elt);
+ maybe_print_comment(s, get_span(*elt).hi);
+ op(s, *elt);
i += 1u;
if i < len {
word(s.s, ~",");
- maybe_print_trailing_comment(s, get_span(elt),
+ maybe_print_trailing_comment(s, get_span(*elt),
Some(get_span(elts[i]).hi));
space_if_not_bol(s);
}
@@ -314,18 +314,18 @@ fn commasep_exprs(s: ps, b: breaks, exprs: ~[@ast::expr]) {
fn print_mod(s: ps, _mod: ast::_mod, attrs: ~[ast::attribute]) {
print_inner_attributes(s, attrs);
for _mod.view_items.each |vitem| {
- print_view_item(s, vitem);
+ print_view_item(s, *vitem);
}
- for _mod.items.each |item| { print_item(s, item); }
+ for _mod.items.each |item| { print_item(s, *item); }
}
fn print_foreign_mod(s: ps, nmod: ast::foreign_mod,
attrs: ~[ast::attribute]) {
print_inner_attributes(s, attrs);
for nmod.view_items.each |vitem| {
- print_view_item(s, vitem);
+ print_view_item(s, *vitem);
}
- for nmod.items.each |item| { print_foreign_item(s, item); }
+ for nmod.items.each |item| { print_foreign_item(s, *item); }
}
fn print_region(s: ps, region: @ast::region, sep: ~str) {
@@ -525,7 +525,7 @@ fn print_item(s: ps, &&item: @ast::item) {
bopen(s);
for methods.each |meth| {
- print_method(s, meth);
+ print_method(s, *meth);
}
bclose(s, item.span);
}
@@ -540,7 +540,9 @@ fn print_item(s: ps, &&item: @ast::item) {
}
word(s.s, ~" ");
bopen(s);
- for methods.each |meth| { print_trait_method(s, meth); }
+ for methods.each |meth| {
+ print_trait_method(s, *meth);
+ }
bclose(s, item.span);
}
ast::item_mac({node: ast::mac_invoc_tt(pth, tts), _}) => {
@@ -549,7 +551,9 @@ fn print_item(s: ps, &&item: @ast::item) {
print_ident(s, item.ident);
cbox(s, indent_unit);
popen(s);
- for tts.each |tt| { print_tt(s, tt); }
+ for tts.each |tt| {
+ print_tt(s, *tt);
+ }
pclose(s);
end(s);
}
@@ -602,7 +606,7 @@ fn print_variants(s: ps, variants: ~[ast::variant], span: ast::span) {
maybe_print_comment(s, v.span.lo);
print_outer_attributes(s, v.node.attrs);
ibox(s, indent_unit);
- print_variant(s, v);
+ print_variant(s, *v);
word(s.s, ~",");
end(s);
maybe_print_trailing_comment(s, v.span, None::<uint>);
@@ -661,7 +665,7 @@ fn print_struct(s: ps, struct_def: @ast::struct_def, tps: ~[ast::ty_param],
}
}
for struct_def.methods.each |method| {
- print_method(s, method);
+ print_method(s, *method);
}
bclose(s, span);
}
@@ -675,7 +679,7 @@ fn print_struct(s: ps, struct_def: @ast::struct_def, tps: ~[ast::ty_param],
/// expression arguments as expressions). It can be done! I think.
fn print_tt(s: ps, tt: ast::token_tree) {
match tt {
- ast::tt_delim(tts) => for tts.each() |tt_elt| { print_tt(s, tt_elt); },
+ ast::tt_delim(tts) => for tts.each() |tt_elt| { print_tt(s, *tt_elt); },
ast::tt_tok(_, tk) => {
match tk {
parse::token::IDENT(*) => { // don't let idents run together
@@ -688,7 +692,7 @@ fn print_tt(s: ps, tt: ast::token_tree) {
}
ast::tt_seq(_, tts, sep, zerok) => {
word(s.s, ~"$(");
- for tts.each() |tt_elt| { print_tt(s, tt_elt); }
+ for tts.each() |tt_elt| { print_tt(s, *tt_elt); }
word(s.s, ~")");
match sep {
Some(tk) => word(s.s, parse::token::to_str(s.intr, tk)),
@@ -767,7 +771,7 @@ fn print_outer_attributes(s: ps, attrs: ~[ast::attribute]) {
let mut count = 0;
for attrs.each |attr| {
match attr.node.style {
- ast::attr_outer => { print_attribute(s, attr); count += 1; }
+ ast::attr_outer => { print_attribute(s, *attr); count += 1; }
_ => {/* fallthrough */ }
}
}
@@ -779,7 +783,7 @@ fn print_inner_attributes(s: ps, attrs: ~[ast::attribute]) {
for attrs.each |attr| {
match attr.node.style {
ast::attr_inner => {
- print_attribute(s, attr);
+ print_attribute(s, *attr);
if !attr.node.is_sugared_doc {
word(s.s, ~";");
}
@@ -870,9 +874,9 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type,
print_inner_attributes(s, attrs);
- for blk.node.view_items.each |vi| { print_view_item(s, vi); }
+ for blk.node.view_items.each |vi| { print_view_item(s, *vi); }
for blk.node.stmts.each |st| {
- print_stmt(s, *st);
+ print_stmt(s, **st);
}
match blk.node.expr {
Some(expr) => {
@@ -956,7 +960,7 @@ fn print_mac(s: ps, m: ast::mac) {
print_path(s, pth, false);
word(s.s, ~"!");
popen(s);
- for tts.each() |tt| { print_tt(s, tt); }
+ for tts.each() |tt| { print_tt(s, *tt); }
pclose(s);
}
ast::mac_ellipsis => word(s.s, ~"..."),
@@ -1167,7 +1171,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
if first {
first = false;
} else { space(s.s); word_space(s, ~"|"); }
- print_pat(s, p);
+ print_pat(s, *p);
}
space(s.s);
match arm.guard {
@@ -1445,7 +1449,7 @@ fn print_path(s: ps, &&path: @ast::path, colons_before_params: bool) {
let mut first = true;
for path.idents.each |id| {
if first { first = false; } else { word(s.s, ~"::"); }
- print_ident(s, id);
+ print_ident(s, *id);
}
if path.rp.is_some() || !path.types.is_empty() {
if colons_before_params { word(s.s, ~"::"); }
@@ -1599,12 +1603,12 @@ fn print_fn_args(s: ps, decl: ast::fn_decl,
box(s, 0u, inconsistent);
let mut first = true;
for opt_self_ty.each |self_ty| {
- first = !print_self_ty(s, self_ty);
+ first = !print_self_ty(s, *self_ty);
}
for decl.inputs.each |arg| {
if first { first = false; } else { word_space(s, ~","); }
- print_arg(s, arg);
+ print_arg(s, *arg);
}
for cap_items.each |cap_item| {
@@ -1836,11 +1840,11 @@ fn print_ty_fn(s: ps, opt_proto: Option<ast::proto>, purity: ast::purity,
box(s, 0u, inconsistent);
let mut first = true;
for opt_self_ty.each |self_ty| {
- first = !print_self_ty(s, self_ty);
+ first = !print_self_ty(s, *self_ty);
}
for decl.inputs.each |arg| {
if first { first = false; } else { word_space(s, ~","); }
- print_arg(s, arg);
+ print_arg(s, *arg);
}
end(s);
pclose(s);
@@ -1988,7 +1992,7 @@ fn print_comment(s: ps, cmnt: comments::cmnt) {
for cmnt.lines.each |line| {
// Don't print empty lines because they will end up as trailing
// whitespace
- if str::is_not_empty(line) { word(s.s, line); }
+ if str::is_not_empty(*line) { word(s.s, *line); }
hardbreak(s.s);
}
}
@@ -2000,7 +2004,7 @@ fn print_comment(s: ps, cmnt: comments::cmnt) {
} else {
ibox(s, 0u);
for cmnt.lines.each |line| {
- if str::is_not_empty(line) { word(s.s, line); }
+ if str::is_not_empty(*line) { word(s.s, *line); }
hardbreak(s.s);
}
end(s);
View
2 src/libsyntax/util/interner.rs
@@ -21,7 +21,7 @@ fn mk<T:Eq IterBytes Hash Const Copy>() -> interner<T> {
fn mk_prefill<T:Eq IterBytes Hash Const Copy>(init: ~[T]) -> interner<T> {
let rv = mk();
- for init.each() |v| { rv.intern(v); }
+ for init.each() |v| { rv.intern(*v); }
return rv;
}
View
50 src/libsyntax/visit.rs
@@ -98,16 +98,16 @@ fn visit_crate_directive<E>(cd: @crate_directive, e: E, v: vt<E>) {
match cd.node {
cdir_src_mod(_, _) => (),
cdir_dir_mod(_, cdirs, _) => for cdirs.each |cdir| {
- visit_crate_directive(cdir, e, v);
+ visit_crate_directive(*cdir, e, v);
},
cdir_view_item(vi) => v.visit_view_item(vi, e, v),
cdir_syntax(_) => ()
}
}
fn visit_mod<E>(m: _mod, _sp: span, _id: node_id, e: E, v: vt<E>) {
- for m.view_items.each |vi| { v.visit_view_item(vi, e, v); }
- for m.items.each |i| { v.visit_item(i, e, v); }
+ for m.view_items.each |vi| { v.visit_view_item(*vi, e, v); }
+ for m.items.each |i| { v.visit_item(*i, e, v); }
}
fn visit_view_item<E>(_vi: @view_item, _e: E, _v: vt<E>) { }
@@ -132,8 +132,8 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
}
item_mod(m) => v.visit_mod(m, i.span, i.id, e, v),
item_foreign_mod(nm) => {
- for nm.view_items.each |vi| { v.visit_view_item(vi, e, v); }
- for nm.items.each |ni| { v.visit_foreign_item(ni, e, v); }
+ for nm.view_items.each |vi| { v.visit_view_item(*vi, e, v); }
+ for nm.items.each |ni| { v.visit_foreign_item(*ni, e, v); }
}
item_ty(t, tps) => {
v.visit_ty(t, e, v);
@@ -150,7 +150,7 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
}
v.visit_ty(ty, e, v);
for methods.each |m| {
- visit_method_helper(m, e, v)
+ visit_method_helper(*m, e, v)
}
}
item_class(struct_def, tps) => {
@@ -161,7 +161,7 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
v.visit_ty_params(tps, e, v);
for traits.each |p| { visit_path(p.path, e, v); }
for methods.each |m| {
- v.visit_trait_method(m, e, v);
+ v.visit_trait_method(*m, e, v);
}
}
item_mac(m) => visit_mac(m, e, v)
@@ -198,7 +198,7 @@ fn visit_ty<E>(t: @ty, e: E, v: vt<E>) {
v.visit_ty(f.node.mt.ty, e, v);
},
ty_tup(ts) => for ts.each |tt| {
- v.visit_ty(tt, e, v);
+ v.visit_ty(*tt, e, v);
},
ty_fn(_, _, bounds, decl) => {
for decl.inputs.each |a| { v.visit_ty(a.ty, e, v); }
@@ -215,15 +215,15 @@ fn visit_ty<E>(t: @ty, e: E, v: vt<E>) {
}
fn visit_path<E>(p: @path, e: E, v: vt<E>) {
- for p.types.each |tp| { v.visit_ty(tp, e, v); }
+ for p.types.each |tp| { v.visit_ty(*tp, e, v); }
}
fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
match p.node {
pat_enum(path, children) => {
visit_path(path, e, v);
do option::iter(children) |children| {
- for children.each |child| { v.visit_pat(child, e, v); }}
+ for children.each |child| { v.visit_pat(*child, e, v); }}
}
pat_rec(fields, _) => for fields.each |f| {
v.visit_pat(f.pat, e, v)
@@ -235,7 +235,7 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
}
}
pat_tup(elts) => for elts.each |elt| {
- v.visit_pat(elt, e, v)
+ v.visit_pat(*elt, e, v)
},
pat_box(inner) | pat_uniq(inner) | pat_region(inner) =>
v.visit_pat(inner, e, v),
@@ -333,12 +333,14 @@ fn visit_trait_method<E>(m: trait_method, e: E, v: vt<E>) {
fn visit_struct_def<E>(sd: @struct_def, nm: ast::ident, tps: ~[ty_param],
id: node_id, e: E, v: vt<E>) {
for sd.fields.each |f| {
- v.visit_struct_field(f, e, v);
+ v.visit_struct_field(*f, e, v);
}
for sd.methods.each |m| {
- v.visit_struct_method(m, e, v);
+ v.visit_struct_method(*m, e, v);
+ }
+ for sd.traits.each |p| {
+ visit_path(p.path, e, v);
}
- for sd.traits.each |p| { visit_path(p.path, e, v); }
do option::iter(sd.ctor) |ctor| {
visit_class_ctor_helper(ctor, nm, tps, ast_util::local_def(id), e, v);
};
@@ -356,8 +358,12 @@ fn visit_struct_method<E>(m: @method, e: E, v: vt<E>) {
}
fn visit_block<E>(b: ast::blk, e: E, v: vt<E>) {
- for b.node.view_items.each |vi| { v.visit_view_item(vi, e, v); }
- for b.node.stmts.each |s| { v.visit_stmt(s, e, v); }
+ for b.node.view_items.each |vi| {
+ v.visit_view_item(*vi, e, v);
+ }
+ for b.node.stmts.each |s| {
+ v.visit_stmt(*s, e, v);
+ }
visit_expr_opt(b.node.expr, e, v);
}
@@ -372,7 +378,7 @@ fn visit_stmt<E>(s: @stmt, e: E, v: vt<E>) {
fn visit_decl<E>(d: @decl, e: E, v: vt<E>) {
match d.node {
decl_local(locs) => for locs.each |loc| {
- v.visit_local(loc, e, v)
+ v.visit_local(*loc, e, v)
},
decl_item(it) => v.visit_item(it, e, v)
}
@@ -383,7 +389,7 @@ fn visit_expr_opt<E>(eo: Option<@expr>, e: E, v: vt<E>) {
}
fn visit_exprs<E>(exprs: ~[@expr], e: E, v: vt<E>) {
- for exprs.each |ex| { v.visit_expr(ex, e, v); }
+ for exprs.each |ex| { v.visit_expr(*ex, e, v); }
}
fn visit_mac<E>(m: mac, e: E, v: vt<E>) {
@@ -414,7 +420,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
for flds.each |f| { v.visit_expr(f.node.expr, e, v); }
visit_expr_opt(base, e, v);
}
- expr_tup(elts) => for elts.each |el| { v.visit_expr(el, e, v); },
+ expr_tup(elts) => for elts.each |el| { v.visit_expr(*el, e, v); },
expr_call(callee, args, _) => {
visit_exprs(args, e, v);
v.visit_expr(callee, e, v);
@@ -436,7 +442,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
expr_loop(b, _) => v.visit_block(b, e, v),
expr_match(x, arms) => {
v.visit_expr(x, e, v);
- for arms.each |a| { v.visit_arm(a, e, v); }
+ for arms.each |a| { v.visit_arm(*a, e, v); }
}
expr_fn(proto, decl, body, cap_clause) => {
v.visit_fn(fk_anon(proto, cap_clause), decl, body,
@@ -458,7 +464,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
}
expr_field(x, _, tys) => {
v.visit_expr(x, e, v);
- for tys.each |tp| { v.visit_ty(tp, e, v); }
+ for tys.each |tp| { v.visit_ty(*tp, e, v); }
}
expr_index(a, b) => { v.visit_expr(a, e, v); v.visit_expr(b, e, v); }
expr_path(p) => visit_path(p, e, v),
@@ -476,7 +482,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
}
fn visit_arm<E>(a: arm, e: E, v: vt<E>) {
- for a.pats.each |p| { v.visit_pat(p, e, v); }
+ for a.pats.each |p| { v.visit_pat(*p, e, v); }
visit_expr_opt(a.guard, e, v);
v.visit_block(a.body, e, v);
}
View
25 src/rustc/back/link.rs
@@ -400,17 +400,17 @@ fn build_link_meta(sess: session, c: ast::crate, output: &Path,
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
attr::require_unique_names(sess.diagnostic(), linkage_metas);
for linkage_metas.each |meta| {
- if attr::get_meta_item_name(meta) == ~"name" {
- match attr::get_meta_item_value_str(meta) {
+ if attr::get_meta_item_name(*meta) == ~"name" {
+ match attr::get_meta_item_value_str(*meta) {
Some(v) => { name = Some(v); }
- None => vec::push(cmh_items, meta)
+ None => vec::push(cmh_items, *meta)
}
- } else if attr::get_meta_item_name(meta) == ~"vers" {
- match attr::get_meta_item_value_str(meta) {
+ } else if attr::get_meta_item_name(*meta) == ~"vers" {
+ match attr::get_meta_item_value_str(*meta) {
Some(v) => { vers = Some(v); }
- None => vec::push(cmh_items, meta)
+ None => vec::push(cmh_items, *meta)