From edc11a9f09060b355010b8cc71da45c4f35eadf0 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Wed, 17 Apr 2013 19:36:59 -0700 Subject: rustc: Suppress derived pattern-match-checking errors typeck::check::_match wasn't suppressing derived errors properly. Fixed it. --- src/test/compile-fail/issue-5100.rs | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/test/compile-fail/issue-5100.rs (limited to 'src/test') diff --git a/src/test/compile-fail/issue-5100.rs b/src/test/compile-fail/issue-5100.rs new file mode 100644 index 00000000000..dbfdb38f721 --- /dev/null +++ b/src/test/compile-fail/issue-5100.rs @@ -0,0 +1,44 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum A { B, C } + +fn main() { + match (true, false) { + B => (), //~ ERROR expected `(bool,bool)` but found an enum or structure pattern + _ => () + } + + match (true, false) { + (true, false, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found `(bool,bool,bool)` (expected a tuple with 2 elements but found one with 3 elements) + } + + match (true, false) { + @(true, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found an @-box pattern + } + + match (true, false) { + ~(true, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found a ~-box pattern + } + + match (true, false) { + &(true, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found an &-pointer pattern + } + + + let v = [('a', 'b') //~ ERROR expected function but found `(char,char)` + ('c', 'd'), + ('e', 'f')]; + + for v.each |&(x,y)| {} // should be OK + + // Make sure none of the errors above were fatal + let x: char = true; //~ ERROR expected `char` but found `bool` +} -- cgit 1.4.1-3-g733a5 From 9ddcf1cdd3f90366858c7e2746aedd726b477ea3 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 29 Apr 2013 17:11:20 -0700 Subject: test: Remove run-pass/too-much-recursion.rs I don't understand how this is still passing on the bots. This condition should trigger an abort now. --- src/test/run-pass/too-much-recursion.rs | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 src/test/run-pass/too-much-recursion.rs (limited to 'src/test') diff --git a/src/test/run-pass/too-much-recursion.rs b/src/test/run-pass/too-much-recursion.rs deleted file mode 100644 index adccc786926..00000000000 --- a/src/test/run-pass/too-much-recursion.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// xfail-win32 -// error-pattern:ran out of stack - -// Test that the task fails after hitting the recursion limit, but -// that it doesn't bring down the whole proc - -pub fn main() { - do task::spawn_unlinked { - fn f() { f() }; - f(); - }; -} -- cgit 1.4.1-3-g733a5 From 849f8142a244ae08c06ed190c234aa809a68f6c0 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 29 Apr 2013 20:46:54 -0700 Subject: rustc / test: Fix error message --- src/librustc/middle/typeck/check/_match.rs | 8 ++++---- src/test/compile-fail/alt-vec-mismatch-2.rs | 2 +- src/test/compile-fail/alt-vec-mismatch.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/test') diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index e73cf440d40..5ff71057121 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -625,10 +625,10 @@ pub fn check_pointer_pat(pcx: &pat_ctxt, fcx.infcx().type_error_message_str(span, |actual| { fmt!("mismatched types: expected `%s` but found %s", resolved_expected, actual)}, - fmt!("an %s pattern", match pointer_kind { - Managed => "@-box", - Owned => "~-box", - Borrowed => "&-pointer" + fmt!("%s pattern", match pointer_kind { + Managed => "an @-box", + Owned => "a ~-box", + Borrowed => "an &-pointer" }), None); fcx.write_error(pat_id); diff --git a/src/test/compile-fail/alt-vec-mismatch-2.rs b/src/test/compile-fail/alt-vec-mismatch-2.rs index 9e8fb84951d..bef18cc666a 100644 --- a/src/test/compile-fail/alt-vec-mismatch-2.rs +++ b/src/test/compile-fail/alt-vec-mismatch-2.rs @@ -1,5 +1,5 @@ fn main() { match () { - [()] => { } //~ ERROR mismatched type: expected `()` but found vector + [()] => { } //~ ERROR mismatched type: expected `()` but found a vector pattern } } diff --git a/src/test/compile-fail/alt-vec-mismatch.rs b/src/test/compile-fail/alt-vec-mismatch.rs index ef4d92ea491..1f6822cfd2c 100644 --- a/src/test/compile-fail/alt-vec-mismatch.rs +++ b/src/test/compile-fail/alt-vec-mismatch.rs @@ -1,6 +1,6 @@ fn main() { match ~"foo" { - ['f', 'o', .._] => { } //~ ERROR mismatched type: expected `~str` but found vector + ['f', 'o', .._] => { } //~ ERROR mismatched type: expected `~str` but found a vector pattern _ => { } } } -- cgit 1.4.1-3-g733a5 From 229ebf0bca23f5619940ecf2cf4541e0bb7416de Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 11:40:44 -0700 Subject: deleted two tests intended to test RUST_CC_ZEAL, an apparently defunct flag for the cycle collector --- src/test/run-pass/issue-1466.rs | 17 ----------------- src/test/run-pass/issue-1989.rs | 33 --------------------------------- 2 files changed, 50 deletions(-) delete mode 100644 src/test/run-pass/issue-1466.rs delete mode 100644 src/test/run-pass/issue-1989.rs (limited to 'src/test') diff --git a/src/test/run-pass/issue-1466.rs b/src/test/run-pass/issue-1466.rs deleted file mode 100644 index 1915f1b3a41..00000000000 --- a/src/test/run-pass/issue-1466.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// exec-env:RUST_CC_ZEAL=1 -// xfail-test - -pub fn main() { - error!("%?", os::getenv(~"RUST_CC_ZEAL")); - let _x = @{a: @10, b: ~true}; -} diff --git a/src/test/run-pass/issue-1989.rs b/src/test/run-pass/issue-1989.rs deleted file mode 100644 index e3327283a81..00000000000 --- a/src/test/run-pass/issue-1989.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// exec-env:RUST_CC_ZEAL=1 - -enum maybe_pointy { - none, - p(@mut Pointy) -} - -struct Pointy { - a : maybe_pointy, - f : @fn()->(), -} - -fn empty_pointy() -> @mut Pointy { - return @mut Pointy{ - a : none, - f : || {}, - } -} - -pub fn main() { - let v = ~[empty_pointy(), empty_pointy()]; - v[0].a = p(v[0]); -} -- cgit 1.4.1-3-g733a5 From 5d8db6fd373f73e989439a4a95c6039ddc3fe1ed Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 12:25:44 -0700 Subject: remove (non-parsing) test related to impl d for d feature --- src/test/auxiliary/issue-2196-a.rs | 13 ------------- src/test/auxiliary/issue-2196-b.rs | 18 ------------------ src/test/auxiliary/issue-2196-c.rc | 16 ---------------- src/test/auxiliary/issue-2196-c.rs | 14 -------------- src/test/auxiliary/issue-2196-d.rs | 0 src/test/run-pass/issue-2196.rs | 19 ------------------- 6 files changed, 80 deletions(-) delete mode 100644 src/test/auxiliary/issue-2196-a.rs delete mode 100644 src/test/auxiliary/issue-2196-b.rs delete mode 100644 src/test/auxiliary/issue-2196-c.rc delete mode 100644 src/test/auxiliary/issue-2196-c.rs delete mode 100644 src/test/auxiliary/issue-2196-d.rs delete mode 100644 src/test/run-pass/issue-2196.rs (limited to 'src/test') diff --git a/src/test/auxiliary/issue-2196-a.rs b/src/test/auxiliary/issue-2196-a.rs deleted file mode 100644 index 959164d85dd..00000000000 --- a/src/test/auxiliary/issue-2196-a.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[link(name = "issue2196a", vers = "0.1")]; -#[crate_type = "lib"]; - diff --git a/src/test/auxiliary/issue-2196-b.rs b/src/test/auxiliary/issue-2196-b.rs deleted file mode 100644 index 1ef9334b7cd..00000000000 --- a/src/test/auxiliary/issue-2196-b.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[link(name = "issue2196b", vers = "0.1")]; -#[crate_type = "lib"]; - -use a(name = "issue2196a"); - -type d = str; -impl d for d { } - diff --git a/src/test/auxiliary/issue-2196-c.rc b/src/test/auxiliary/issue-2196-c.rc deleted file mode 100644 index 59c1e8108c0..00000000000 --- a/src/test/auxiliary/issue-2196-c.rc +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[link(name = "issue2196c", vers = "0.1")]; -#[crate_type = "lib"]; - -use b(name = "issue2196b"); -#[path = "issue-2196-d.rs"] -mod d; diff --git a/src/test/auxiliary/issue-2196-c.rs b/src/test/auxiliary/issue-2196-c.rs deleted file mode 100644 index 290267cbf32..00000000000 --- a/src/test/auxiliary/issue-2196-c.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use b::d; - -type t = uint; - diff --git a/src/test/auxiliary/issue-2196-d.rs b/src/test/auxiliary/issue-2196-d.rs deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/test/run-pass/issue-2196.rs b/src/test/run-pass/issue-2196.rs deleted file mode 100644 index 3fce821561a..00000000000 --- a/src/test/run-pass/issue-2196.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// xfail-test -// aux-build:issue-2196-a.rs -// aux-build:issue-2196-b.rs -// aux-build:issue-2196-c.rc - -use c(name = "issue2196c"); -use c::t; - -pub fn main() { } -- cgit 1.4.1-3-g733a5 From 78942a2d16a9cb57f518ee6220b252e1e96e5881 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 13:22:59 -0700 Subject: this issue is a dup of another one that has a correct test case this test case has rotted wrt modern syntax. fortunately, this issue was a dup of another one, and that one still ICEs. --- src/test/run-pass/issue-2869.rs | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 src/test/run-pass/issue-2869.rs (limited to 'src/test') diff --git a/src/test/run-pass/issue-2869.rs b/src/test/run-pass/issue-2869.rs deleted file mode 100644 index 619f4b4d7db..00000000000 --- a/src/test/run-pass/issue-2869.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// xfail-test -enum pat { pat_ident(Option) } - -fn f(pat: pat) -> bool { true } - -fn num_bindings(pat: pat) -> uint { - match pat { - pat_ident(_) if f(pat) { 0 } - pat_ident(None) { 1 } - pat_ident(Some(sub)) { sub } - } -} - -pub fn main() {} -- cgit 1.4.1-3-g733a5 From 77da0553455c5b236ea80056f743b26c7c0edbd3 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 13:44:49 -0700 Subject: This test case is obsolete for two reasons First, it refers to a feature (trait bounds on type parameters) that's apparently no longer in the language. Second, if I understand the issue correctly, it should never have been a "run-pass" test because it was supposed to fail. --- src/test/run-pass/issue-3480.rs | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 src/test/run-pass/issue-3480.rs (limited to 'src/test') diff --git a/src/test/run-pass/issue-3480.rs b/src/test/run-pass/issue-3480.rs deleted file mode 100644 index aaff822398d..00000000000 --- a/src/test/run-pass/issue-3480.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// xfail-test -type IMap = ~[(K, V)]; - -trait ImmutableMap -{ - fn contains_key(key: K) -> bool; -} - -impl IMap : ImmutableMap -{ - fn contains_key(key: K) -> bool { - vec::find(self, |e| {e.first() == key}).is_some() - } -} - -pub fn main() {} -- cgit 1.4.1-3-g733a5 From 9455eaf77bef8f225e146e61107d26010f137b51 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 13:58:15 -0700 Subject: changed to impl trait for type stx --- src/test/run-pass/issue-3979-generics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/run-pass/issue-3979-generics.rs b/src/test/run-pass/issue-3979-generics.rs index d26e9f1ba7b..57962911538 100644 --- a/src/test/run-pass/issue-3979-generics.rs +++ b/src/test/run-pass/issue-3979-generics.rs @@ -32,7 +32,7 @@ impl Positioned for Point { } } -impl Point: Movable; +impl Movable for Point; pub fn main() { let p = Point{ x: 1, y: 2}; -- cgit 1.4.1-3-g733a5 From 8408012ca4ed6e8e0aa2aa85e24eb53b4b17308d Mon Sep 17 00:00:00 2001 From: Jed Davis Date: Tue, 30 Apr 2013 11:36:22 -0700 Subject: The null case of a nullable-poiner enum might not be nullary. Cases like `Either<@int,()>` have a null case with at most one value but a nonzero number of fields; if we misreport this, then bad things can happen inside of, for example, pattern matching. Closes #6117. --- src/librustc/middle/trans/adt.rs | 4 ++-- src/test/run-pass/issue-6117.rs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/test/run-pass/issue-6117.rs (limited to 'src/test') diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index b3e24fcc939..0ee2a2c4cb1 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -409,8 +409,8 @@ pub fn num_args(r: &Repr, discr: int) -> uint { st.fields.len() - (if dtor { 1 } else { 0 }) } General(ref cases) => cases[discr as uint].fields.len() - 1, - NullablePointer{ nonnull: ref nonnull, nndiscr, _ } => { - if discr == nndiscr { nonnull.fields.len() } else { 0 } + NullablePointer{ nonnull: ref nonnull, nndiscr, nullfields: ref nullfields, _ } => { + if discr == nndiscr { nonnull.fields.len() } else { nullfields.len() } } } } diff --git a/src/test/run-pass/issue-6117.rs b/src/test/run-pass/issue-6117.rs new file mode 100644 index 00000000000..73e9391f016 --- /dev/null +++ b/src/test/run-pass/issue-6117.rs @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() { + match Left(@17) { + Right(()) => {} + _ => {} + } +} -- cgit 1.4.1-3-g733a5 From 41d06dbd28a9c26ecf114c020c6d855252fe323c Mon Sep 17 00:00:00 2001 From: Jed Davis Date: Tue, 30 Apr 2013 12:05:06 -0700 Subject: Reverse accidental src/llvm reversion in 876483dcf, and add test. The test is reduced from a doc test, but making it separate ensures that (1) unrelated changes to the docs won't leave this case uncovered, and (2) the nature of any future failures will be more obvious to whoever sees the tree on fire as a result. --- src/llvm | 2 +- .../run-pass/enum-nullable-simplifycfg-misopt.rs | 24 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/test/run-pass/enum-nullable-simplifycfg-misopt.rs (limited to 'src/test') diff --git a/src/llvm b/src/llvm index 56dd407f4f9..2e9f0d21fe3 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit 56dd407f4f97a01b8df6554c569170d2fc276fcb +Subproject commit 2e9f0d21fe321849a4759a01fc28eae82ef196d6 diff --git a/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs b/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs new file mode 100644 index 00000000000..b5cf15f3b38 --- /dev/null +++ b/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs @@ -0,0 +1,24 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +/*! + * This is a regression test for a bug in LLVM, fixed in upstream r179587, + * where the switch instructions generated for destructuring enums + * represented with nullable pointers could be misoptimized in some cases. + */ + +enum List { Nil, Cons(X, @List) } +pub fn main() { + match Cons(10, @Nil) { + Cons(10, _) => {} + Nil => {} + _ => fail!() + } +} -- cgit 1.4.1-3-g733a5 From 4493cf49cdaeb7aea974b9155a678fb8c9e3e390 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 30 Apr 2013 16:17:19 -0700 Subject: Fix error messages harder --- src/test/compile-fail/alt-vec-mismatch-2.rs | 2 +- src/test/compile-fail/alt-vec-mismatch.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/compile-fail/alt-vec-mismatch-2.rs b/src/test/compile-fail/alt-vec-mismatch-2.rs index bef18cc666a..6ea0300cf1e 100644 --- a/src/test/compile-fail/alt-vec-mismatch-2.rs +++ b/src/test/compile-fail/alt-vec-mismatch-2.rs @@ -1,5 +1,5 @@ fn main() { match () { - [()] => { } //~ ERROR mismatched type: expected `()` but found a vector pattern + [()] => { } //~ ERROR mismatched types: expected `()` but found a vector pattern } } diff --git a/src/test/compile-fail/alt-vec-mismatch.rs b/src/test/compile-fail/alt-vec-mismatch.rs index 1f6822cfd2c..85ed8761ee9 100644 --- a/src/test/compile-fail/alt-vec-mismatch.rs +++ b/src/test/compile-fail/alt-vec-mismatch.rs @@ -1,6 +1,6 @@ fn main() { match ~"foo" { - ['f', 'o', .._] => { } //~ ERROR mismatched type: expected `~str` but found a vector pattern + ['f', 'o', .._] => { } //~ ERROR mismatched types: expected `~str` but found a vector pattern _ => { } } } -- cgit 1.4.1-3-g733a5 From dd310d6c3b635628f584f3266b3ab31888fd0e95 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 14:48:59 -0700 Subject: Got test cases to pass, after some major surgery --- src/test/auxiliary/issue2378a.rs | 11 +++++++---- src/test/auxiliary/issue2378b.rs | 14 ++++++++------ src/test/run-pass/issue2378c.rs | 12 ++++++------ 3 files changed, 21 insertions(+), 16 deletions(-) (limited to 'src/test') diff --git a/src/test/auxiliary/issue2378a.rs b/src/test/auxiliary/issue2378a.rs index ead338c4bc8..1873aca5909 100644 --- a/src/test/auxiliary/issue2378a.rs +++ b/src/test/auxiliary/issue2378a.rs @@ -8,13 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[link (name = "issue2378a")]; +#[crate_type = "lib"]; + enum maybe { just(T), nothing } -impl copy> for maybe for methods T { +impl Index for maybe { + fn index(&self, idx: &uint) -> T { match self { - just(t) { t } - nothing { fail!(); } + &just(ref t) => copy *t, + ¬hing => { fail!(); } } } } diff --git a/src/test/auxiliary/issue2378b.rs b/src/test/auxiliary/issue2378b.rs index 9037417ef62..20f07a5cb54 100644 --- a/src/test/auxiliary/issue2378b.rs +++ b/src/test/auxiliary/issue2378b.rs @@ -8,15 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use issue2378a; +#[link (name = "issue2378b")]; +#[crate_type = "lib"]; + +extern mod issue2378a; use issue2378a::maybe; -use issue2378a::methods; -type two_maybes = {a: maybe, b: maybe}; +struct two_maybes {a: maybe, b: maybe} -impl copy> for two_maybes for methods (T, T) { - (self.a[idx], self.b[idx]) +impl Index for two_maybes { + fn index(&self, idx: &uint) -> (T, T) { + (self.a[*idx], self.b[*idx]) } } diff --git a/src/test/run-pass/issue2378c.rs b/src/test/run-pass/issue2378c.rs index ea8c47a3eb9..98e60c56476 100644 --- a/src/test/run-pass/issue2378c.rs +++ b/src/test/run-pass/issue2378c.rs @@ -8,17 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test -- #2378 unfixed // aux-build:issue2378a.rs // aux-build:issue2378b.rs +// xfail-fast - check-fast doesn't understand aux-build -use issue2378a; -use issue2378b; +extern mod issue2378a; +extern mod issue2378b; -use issue2378a::{just, methods}; -use issue2378b::{methods}; +use issue2378a::{just}; +use issue2378b::{two_maybes}; pub fn main() { - let x = {a: just(3), b: just(5)}; + let x = two_maybes{a: just(3), b: just(5)}; assert!(x[0u] == (3, 5)); } -- cgit 1.4.1-3-g733a5 From 325263fe221647b7d6ef6c3cc1efd0d1e7cf3a21 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 15:05:39 -0700 Subject: this test still doesn't pass, but at least it parses... --- src/test/run-pass/mlist-cycle.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/test') diff --git a/src/test/run-pass/mlist-cycle.rs b/src/test/run-pass/mlist-cycle.rs index e886c941a4b..a67f1574f64 100644 --- a/src/test/run-pass/mlist-cycle.rs +++ b/src/test/run-pass/mlist-cycle.rs @@ -10,16 +10,18 @@ // xfail-test // -*- rust -*- -extern mod std; +extern mod core; +use core::gc; +use core::gc::rustrt; -type cell = {c: @list}; +struct cell {c: @list} enum list { link(@mut cell), nil, } pub fn main() { - let first: @cell = @mut {c: @nil()}; - let second: @cell = @mut {c: @link(first)}; + let first: @cell = @mut cell{c: @nil()}; + let second: @cell = @mut cell{c: @link(first)}; first._0 = @link(second); - sys.rustrt.gc(); - let third: @cell = @mut {c: @nil()}; + rustrt::gc(); + let third: @cell = @mut cell{c: @nil()}; } -- cgit 1.4.1-3-g733a5 From 7e89a514a5ce9aa427ca350a4ba62e63f3c89f95 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 15:13:24 -0700 Subject: This test case now parses I've done a slapdash job of fixing up the syntax; it didn't pass before, and it doesn't pass now, but at least it parses... --- src/test/run-pass/preempt.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/test') diff --git a/src/test/run-pass/preempt.rs b/src/test/run-pass/preempt.rs index e0434c14048..3d3e178f064 100644 --- a/src/test/run-pass/preempt.rs +++ b/src/test/run-pass/preempt.rs @@ -13,7 +13,7 @@ fn starve_main(alive: chan) { debug!("signalling main"); - alive <| 1; + alive.recv(1); debug!("starving main"); let i: int = 0; loop { i += 1; } @@ -22,10 +22,12 @@ fn starve_main(alive: chan) { pub fn main() { let alive: port = port(); debug!("main started"); - let s: task = spawn starve_main(chan(alive)); + let s: task = do task::spawn { + starve_main(chan(alive)); + }; let i: int; debug!("main waiting for alive signal"); - alive |> i; + alive.send(i); debug!("main got alive signal"); while i < 50 { debug!("main iterated"); i += 1; } debug!("main completed"); -- cgit 1.4.1-3-g733a5 From add60bb081b9c23c8606a22b078f0885d5ab169c Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 15:20:36 -0700 Subject: Test now passes --- src/test/run-pass/regions-fn-subtyping-2.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/test') diff --git a/src/test/run-pass/regions-fn-subtyping-2.rs b/src/test/run-pass/regions-fn-subtyping-2.rs index a995b3d9693..a660b9c9ee2 100644 --- a/src/test/run-pass/regions-fn-subtyping-2.rs +++ b/src/test/run-pass/regions-fn-subtyping-2.rs @@ -8,20 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test - // Issue #2263. // Here, `f` is a function that takes a pointer `x` and a function // `g`, where `g` requires its argument `y` to be in the same region // that `x` is in. -fn has_same_region(f: &fn(x: &a.int, g: &fn(y: &a.int))) { +fn has_same_region(f: &fn<'a>(x: &'a int, g: &fn(y: &'a int))) { // `f` should be the type that `wants_same_region` wants, but // right now the compiler complains that it isn't. wants_same_region(f); } -fn wants_same_region(_f: &fn(x: &b.int, g: &fn(y: &b.int))) { +fn wants_same_region(_f: &fn<'b>(x: &'b int, g: &fn(y: &'b int))) { } pub fn main() { -- cgit 1.4.1-3-g733a5 From cc4e0186ac005768ebede5b6b858b223c33e4de3 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 15:49:28 -0700 Subject: added test case for issue 5927 --- src/test/run-fail/issue-5927.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/test/run-fail/issue-5927.rs (limited to 'src/test') diff --git a/src/test/run-fail/issue-5927.rs b/src/test/run-fail/issue-5927.rs new file mode 100644 index 00000000000..f302d706c15 --- /dev/null +++ b/src/test/run-fail/issue-5927.rs @@ -0,0 +1,20 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + + +// error-pattern:cant-use-x-as-pattern-mumble + +fn main() { + let z = match 3 { + x() => x + }; + assert_eq!(z,3); +} -- cgit 1.4.1-3-g733a5 From d6bb587c12da816b2872db1c1f9154a58fc91006 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 16:44:36 -0700 Subject: with syntax fixes, this test case now appears to pass --- src/test/run-pass/tag-align-dyn-u64.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/test') diff --git a/src/test/run-pass/tag-align-dyn-u64.rs b/src/test/run-pass/tag-align-dyn-u64.rs index a9c59de49ee..0fdf4e019a7 100644 --- a/src/test/run-pass/tag-align-dyn-u64.rs +++ b/src/test/run-pass/tag-align-dyn-u64.rs @@ -8,27 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test - -tag a_tag { - a_tag(A); +enum a_tag { + a_tag(A) } -type t_rec = { +struct t_rec { c8: u8, t: a_tag -}; +} fn mk_rec() -> t_rec { - return { c8:0u8, t:a_tag(0u64) }; + return t_rec { c8:0u8, t:a_tag(0u64) }; } -fn is_8_byte_aligned(&&u: a_tag) -> bool { +fn is_8_byte_aligned(u: &a_tag) -> bool { let p = ptr::to_unsafe_ptr(u) as uint; return (p & 7u) == 0u; } pub fn main() { let x = mk_rec(); - assert!(is_8_byte_aligned(x.t)); + assert!(is_8_byte_aligned(&x.t)); } -- cgit 1.4.1-3-g733a5 From 178305ffecf4e183a425028ba53b39a4f4dd1121 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 16:48:33 -0700 Subject: fixed up issue-2185, but now it has a trait failure --- src/test/run-pass/issue-2185.rs | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'src/test') diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index ac680d3d12e..350dea4415d 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -8,22 +8,45 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test FIXME #2263 +// does the second one subsume the first? +// xfail-test // xfail-fast + +// notes on this test case: +// On Thu, Apr 18, 2013 at 6:30 PM, John Clements wrote: +// the "issue-2185.rs" test was xfailed with a ref to #2263. Issue #2263 is now fixed, so I tried it again, and after adding some &self parameters, I got this error: +// +// Running /usr/local/bin/rustc: +// issue-2185.rs:24:0: 26:1 error: conflicting implementations for a trait +// issue-2185.rs:24 impl iterable for @fn(&fn(uint)) { +// issue-2185.rs:25 fn iter(&self, blk: &fn(v: uint)) { self( |i| blk(i) ) } +// issue-2185.rs:26 } +// issue-2185.rs:20:0: 22:1 note: note conflicting implementation here +// issue-2185.rs:20 impl iterable for @fn(&fn(A)) { +// issue-2185.rs:21 fn iter(&self, blk: &fn(A)) { self(blk); } +// issue-2185.rs:22 } +// +// … so it looks like it's just not possible to implement both the generic iterable and iterable for the type iterable. Is it okay if I just remove this test? +// +// but Niko responded: +// think it's fine to remove this test, just because it's old and cruft and not hard to reproduce. *However* it should eventually be possible to implement the same interface for the same type multiple times with different type parameters, it's just that our current trait implementation has accidental limitations. + +// so I'm leaving it in. + // This test had to do with an outdated version of the iterable trait. // However, the condition it was testing seemed complex enough to // warrant still having a test, so I inlined the old definitions. trait iterable { - fn iter(blk: &fn(A)); + fn iter(&self, blk: &fn(A)); } impl iterable for @fn(&fn(A)) { - fn iter(blk: &fn(A)) { self(blk); } + fn iter(&self, blk: &fn(A)) { self(blk); } } impl iterable for @fn(&fn(uint)) { - fn iter(blk: &fn(&&v: uint)) { self( |i| blk(i) ) } + fn iter(&self, blk: &fn(v: uint)) { self( |i| blk(i) ) } } fn filter>(self: IA, prd: @fn(A) -> bool, blk: &fn(A)) { -- cgit 1.4.1-3-g733a5 From 3a5361aec990ff2b07cabf9d9fbfac67f056d97f Mon Sep 17 00:00:00 2001 From: John Clements Date: Tue, 30 Apr 2013 10:39:20 -0700 Subject: more commits on issue 2185 --- src/test/run-pass/issue-2185.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/test') diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index 350dea4415d..8a553784c5e 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -32,6 +32,7 @@ // think it's fine to remove this test, just because it's old and cruft and not hard to reproduce. *However* it should eventually be possible to implement the same interface for the same type multiple times with different type parameters, it's just that our current trait implementation has accidental limitations. // so I'm leaving it in. +// actually, it looks like this is related to bug #3429. I'll rename this bug. // This test had to do with an outdated version of the iterable trait. // However, the condition it was testing seemed complex enough to -- cgit 1.4.1-3-g733a5 From 527f7716b76cf77f57915c663d88f72037e11af4 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 16:55:48 -0700 Subject: after syntax fixes, these tests appear to pass --- src/test/run-pass/tag-align-dyn-variants.rs | 64 ++++++++++++++--------------- 1 file changed, 31 insertions(+), 33 deletions(-) (limited to 'src/test') diff --git a/src/test/run-pass/tag-align-dyn-variants.rs b/src/test/run-pass/tag-align-dyn-variants.rs index 4fc6410f8f3..96921f2a065 100644 --- a/src/test/run-pass/tag-align-dyn-variants.rs +++ b/src/test/run-pass/tag-align-dyn-variants.rs @@ -8,64 +8,62 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test - -tag a_tag { - varA(A); - varB(B); +enum a_tag { + varA(A), + varB(B) } -type t_rec = { +struct t_rec { chA: u8, tA: a_tag, chB: u8, tB: a_tag -}; +} -fn mk_rec(a: A, b: B) -> t_rec { - return { chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) }; +fn mk_rec(a: A, b: B) -> t_rec { + return t_rec{ chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) }; } -fn is_aligned(amnt: uint, &&u: A) -> bool { +fn is_aligned(amnt: uint, u: &A) -> bool { let p = ptr::to_unsafe_ptr(u) as uint; return (p & (amnt-1u)) == 0u; } -fn variant_data_is_aligned(amnt: uint, &&u: a_tag) -> bool { +fn variant_data_is_aligned(amnt: uint, u: &a_tag) -> bool { match u { - varA(a) { is_aligned(amnt, a) } - varB(b) { is_aligned(amnt, b) } + &varA(ref a) => is_aligned(amnt, a), + &varB(ref b) => is_aligned(amnt, b) } } pub fn main() { let x = mk_rec(22u64, 23u64); - assert!(is_aligned(8u, x.tA)); - assert!(variant_data_is_aligned(8u, x.tA)); - assert!(is_aligned(8u, x.tB)); - assert!(variant_data_is_aligned(8u, x.tB)); + assert!(is_aligned(8u, &x.tA)); + assert!(variant_data_is_aligned(8u, &x.tA)); + assert!(is_aligned(8u, &x.tB)); + assert!(variant_data_is_aligned(8u, &x.tB)); let x = mk_rec(22u64, 23u32); - assert!(is_aligned(8u, x.tA)); - assert!(variant_data_is_aligned(8u, x.tA)); - assert!(is_aligned(8u, x.tB)); - assert!(variant_data_is_aligned(4u, x.tB)); + assert!(is_aligned(8u, &x.tA)); + assert!(variant_data_is_aligned(8u, &x.tA)); + assert!(is_aligned(8u, &x.tB)); + assert!(variant_data_is_aligned(4u, &x.tB)); let x = mk_rec(22u32, 23u64); - assert!(is_aligned(8u, x.tA)); - assert!(variant_data_is_aligned(4u, x.tA)); - assert!(is_aligned(8u, x.tB)); - assert!(variant_data_is_aligned(8u, x.tB)); + assert!(is_aligned(8u, &x.tA)); + assert!(variant_data_is_aligned(4u, &x.tA)); + assert!(is_aligned(8u, &x.tB)); + assert!(variant_data_is_aligned(8u, &x.tB)); let x = mk_rec(22u32, 23u32); - assert!(is_aligned(4u, x.tA)); - assert!(variant_data_is_aligned(4u, x.tA)); - assert!(is_aligned(4u, x.tB)); - assert!(variant_data_is_aligned(4u, x.tB)); + assert!(is_aligned(4u, &x.tA)); + assert!(variant_data_is_aligned(4u, &x.tA)); + assert!(is_aligned(4u, &x.tB)); + assert!(variant_data_is_aligned(4u, &x.tB)); let x = mk_rec(22f64, 23f64); - assert!(is_aligned(8u, x.tA)); - assert!(variant_data_is_aligned(8u, x.tA)); - assert!(is_aligned(8u, x.tB)); - assert!(variant_data_is_aligned(8u, x.tB)); + assert!(is_aligned(8u, &x.tA)); + assert!(variant_data_is_aligned(8u, &x.tA)); + assert!(is_aligned(8u, &x.tB)); + assert!(variant_data_is_aligned(8u, &x.tB)); } -- cgit 1.4.1-3-g733a5 From 3931ce448e0329672583d3210df714cca5176f02 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 17:08:23 -0700 Subject: fixed the test case, hope it's still testing something --- src/test/run-pass/tag-align-shape.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/test') diff --git a/src/test/run-pass/tag-align-shape.rs b/src/test/run-pass/tag-align-shape.rs index 052bacad7ce..43a793a34c8 100644 --- a/src/test/run-pass/tag-align-shape.rs +++ b/src/test/run-pass/tag-align-shape.rs @@ -8,22 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test -// -// See issue #1535 - -tag a_tag { - a_tag(u64); +enum a_tag { + a_tag(u64) } -type t_rec = { +struct t_rec { c8: u8, t: a_tag -}; +} pub fn main() { - let x = {c8: 22u8, t: a_tag(44u64)}; + let x = t_rec {c8: 22u8, t: a_tag(44u64)}; let y = fmt!("%?", x); debug!("y = %s", y); - assert!(y == "(22, a_tag(44))"); + assert_eq!(y, ~"{c8: 22, t: a_tag(44)}"); } -- cgit 1.4.1-3-g733a5 From d1921fb3caa131c83673020a377e1d0cd245b1ea Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 17:10:26 -0700 Subject: fixed this test case too --- src/test/run-pass/tag-align-u64.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/test') diff --git a/src/test/run-pass/tag-align-u64.rs b/src/test/run-pass/tag-align-u64.rs index fd96d7d0242..56d384e5fdb 100644 --- a/src/test/run-pass/tag-align-u64.rs +++ b/src/test/run-pass/tag-align-u64.rs @@ -8,27 +8,26 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test -tag a_tag { - a_tag(u64); +enum a_tag { + a_tag(u64) } -type t_rec = { +struct t_rec { c8: u8, t: a_tag -}; +} fn mk_rec() -> t_rec { - return { c8:0u8, t:a_tag(0u64) }; + return t_rec { c8:0u8, t:a_tag(0u64) }; } -fn is_8_byte_aligned(&&u: a_tag) -> bool { +fn is_8_byte_aligned(u: &a_tag) -> bool { let p = ptr::to_unsafe_ptr(u) as u64; return (p & 7u64) == 0u64; } pub fn main() { let x = mk_rec(); - assert!(is_8_byte_aligned(x.t)); + assert!(is_8_byte_aligned(&x.t)); } -- cgit 1.4.1-3-g733a5 From 89bb02adf9f3ec55340b775a3b1f75c25478ce73 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 17:20:28 -0700 Subject: typestate is not planned for upcoming versions of rust.... --- src/test/run-pass/tstate-loop-break.rs | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 src/test/run-pass/tstate-loop-break.rs (limited to 'src/test') diff --git a/src/test/run-pass/tstate-loop-break.rs b/src/test/run-pass/tstate-loop-break.rs deleted file mode 100644 index 4228f72b7ca..00000000000 --- a/src/test/run-pass/tstate-loop-break.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// xfail-test - -fn is_even(i: int) -> bool { (i%2) == 0 } -fn even(i: int) : is_even(i) -> int { i } - -fn test() { - let v = 4; - loop { - check is_even(v); - break; - } - even(v); -} - -pub fn main() { - test(); -} -- cgit 1.4.1-3-g733a5 From c75b7630bcc45bf9f2c7f6831e46c84b0c8f024f Mon Sep 17 00:00:00 2001 From: John Clements Date: Tue, 30 Apr 2013 10:40:08 -0700 Subject: renamed issue-2185 to issue-3429 --- src/test/run-pass/issue-1895.rs | 16 ---------------- src/test/run-pass/issue-3429.rs | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 src/test/run-pass/issue-1895.rs create mode 100644 src/test/run-pass/issue-3429.rs (limited to 'src/test') diff --git a/src/test/run-pass/issue-1895.rs b/src/test/run-pass/issue-1895.rs deleted file mode 100644 index 67877795cc0..00000000000 --- a/src/test/run-pass/issue-1895.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn main() { - let x = 1; - let y: @fn() -> int = || x; - let z = y(); -} - diff --git a/src/test/run-pass/issue-3429.rs b/src/test/run-pass/issue-3429.rs new file mode 100644 index 00000000000..67877795cc0 --- /dev/null +++ b/src/test/run-pass/issue-3429.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() { + let x = 1; + let y: @fn() -> int = || x; + let z = y(); +} + -- cgit 1.4.1-3-g733a5 From fc661079a479f0aff6add4478c3afb8c2226b333 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 18 Apr 2013 17:28:22 -0700 Subject: fixed up syntax --- src/test/run-pass/type-sizes.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/test') diff --git a/src/test/run-pass/type-sizes.rs b/src/test/run-pass/type-sizes.rs index bc2ca20d642..134f1e4098f 100644 --- a/src/test/run-pass/type-sizes.rs +++ b/src/test/run-pass/type-sizes.rs @@ -8,9 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test -use sys::rustrt::size_of; -extern mod std; +extern mod core; +use core::sys::size_of; + +struct t {a: u8, b: i8} +struct u {a: u8, b: i8, c: u8} +struct v {a: u8, b: i8, c: v2, d: u32} +struct v2 {u: char, v: u8} +struct w {a: int, b: ()} +struct x {a: int, b: (), c: ()} +struct y {x: int} pub fn main() { assert!((size_of::() == 1 as uint)); @@ -18,14 +25,14 @@ pub fn main() { assert!((size_of::() == 4 as uint)); assert!((size_of::() == 1 as uint)); assert!((size_of::() == 4 as uint)); - assert!((size_of::<{a: u8, b: i8}>() == 2 as uint)); - assert!((size_of::<{a: u8, b: i8, c: u8}>() == 3 as uint)); + assert!((size_of::() == 2 as uint)); + assert!((size_of::() == 3 as uint)); // Alignment causes padding before the char and the u32. - assert!(size_of::<{a: u8, b: i8, c: {u: char, v: u8}, d: u32}>() == + assert!(size_of::() == 16 as uint); assert!((size_of::() == size_of::())); - assert!((size_of::<{a: int, b: ()}>() == size_of::())); - assert!((size_of::<{a: int, b: (), c: ()}>() == size_of::())); - assert!((size_of::() == size_of::<{x: int}>())); + assert!((size_of::() == size_of::())); + assert!((size_of::() == size_of::())); + assert!((size_of::() == size_of::())); } -- cgit 1.4.1-3-g733a5 From ab1d8ead91ac23e07f4ba9a186e0ae7ddbcd2515 Mon Sep 17 00:00:00 2001 From: John Clements Date: Tue, 30 Apr 2013 11:58:55 -0700 Subject: fixed pattern, moved test to compile-fail --- src/test/compile-fail/issue-5927.rs | 20 ++++++++++++++++++++ src/test/run-fail/issue-5927.rs | 20 -------------------- 2 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 src/test/compile-fail/issue-5927.rs delete mode 100644 src/test/run-fail/issue-5927.rs (limited to 'src/test') diff --git a/src/test/compile-fail/issue-5927.rs b/src/test/compile-fail/issue-5927.rs new file mode 100644 index 00000000000..a1b4ee7aa34 --- /dev/null +++ b/src/test/compile-fail/issue-5927.rs @@ -0,0 +1,20 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + + +// error-pattern:unresolved enum variant + +fn main() { + let z = match 3 { + x() => x + }; + assert_eq!(z,3); +} diff --git a/src/test/run-fail/issue-5927.rs b/src/test/run-fail/issue-5927.rs deleted file mode 100644 index f302d706c15..00000000000 --- a/src/test/run-fail/issue-5927.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - - -// error-pattern:cant-use-x-as-pattern-mumble - -fn main() { - let z = match 3 { - x() => x - }; - assert_eq!(z,3); -} -- cgit 1.4.1-3-g733a5 From ee26c7c433dbb8d41a2b65dbc89eb84acfc2d311 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Wed, 1 May 2013 15:40:05 +1000 Subject: Revert rename of Div to Quot --- doc/rust.md | 6 +- src/libcore/core.rc | 2 +- src/libcore/num/f32.rs | 9 +-- src/libcore/num/f64.rs | 9 +-- src/libcore/num/float.rs | 10 +-- src/libcore/num/int-template.rs | 123 +++++++++++++++++------------------- src/libcore/num/num.rs | 29 ++++----- src/libcore/num/strconv.rs | 16 ++--- src/libcore/num/uint-template.rs | 29 ++++----- src/libcore/ops.rs | 6 -- src/libcore/prelude.rs | 2 +- src/librustc/middle/const_eval.rs | 10 +-- src/librustc/middle/lang_items.rs | 10 +-- src/librustc/middle/resolve.rs | 6 +- src/librustc/middle/trans/base.rs | 6 +- src/librustc/middle/trans/consts.rs | 2 +- src/librustc/middle/trans/expr.rs | 2 +- src/librustc/middle/ty.rs | 2 +- src/libstd/num/bigint.rs | 123 ++++++++++++++++++------------------ src/libstd/num/complex.rs | 6 +- src/libstd/num/rational.rs | 8 +-- src/libsyntax/ast.rs | 2 +- src/libsyntax/ast_util.rs | 6 +- src/libsyntax/parse/parser.rs | 4 +- src/libsyntax/parse/token.rs | 2 +- src/test/compile-fail/eval-enum.rs | 2 +- src/test/run-fail/divide-by-zero.rs | 2 +- 27 files changed, 199 insertions(+), 235 deletions(-) (limited to 'src/test') diff --git a/doc/rust.md b/doc/rust.md index 9f81b38009f..e23613e149c 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -1467,8 +1467,8 @@ A complete list of the built-in language items follows: : Elements can be subtracted. `mul` : Elements can be multiplied. -`quot` - : Elements have a quotient operation. +`div` + : Elements have a division operation. `rem` : Elements have a remainder operation. `neg` @@ -1857,7 +1857,7 @@ The default meaning of the operators on standard types is given here. Calls the `mul` method on the `core::ops::Mul` trait. `/` : Quotient. - Calls the `quot` method on the `core::ops::Quot` trait. + Calls the `div` method on the `core::ops::Div` trait. `%` : Remainder. Calls the `rem` method on the `core::ops::Rem` trait. diff --git a/src/libcore/core.rc b/src/libcore/core.rc index f9a56f613d5..26398f3fe52 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -78,7 +78,7 @@ pub use ops::{Drop}; #[cfg(stage0)] pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not}; #[cfg(not(stage0))] -pub use ops::{Add, Sub, Mul, Quot, Rem, Neg, Not}; +pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not}; pub use ops::{BitAnd, BitOr, BitXor}; pub use ops::{Shl, Shr, Index}; diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index e687f482fa9..04ddd63a177 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -123,7 +123,7 @@ pub fn sub(x: f32, y: f32) -> f32 { return x - y; } pub fn mul(x: f32, y: f32) -> f32 { return x * y; } #[inline(always)] -pub fn quot(x: f32, y: f32) -> f32 { return x / y; } +pub fn div(x: f32, y: f32) -> f32 { return x / y; } #[inline(always)] pub fn rem(x: f32, y: f32) -> f32 { return x % y; } @@ -279,16 +279,11 @@ impl Mul for f32 { fn mul(&self, other: &f32) -> f32 { *self * *other } } -#[cfg(stage0,notest)] +#[cfg(notest)] impl Div for f32 { #[inline(always)] fn div(&self, other: &f32) -> f32 { *self / *other } } -#[cfg(not(stage0),notest)] -impl Quot for f32 { - #[inline(always)] - fn quot(&self, other: &f32) -> f32 { *self / *other } -} #[cfg(stage0,notest)] impl Modulo for f32 { diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index d00e6ae2c0d..9f1944e3fad 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -149,7 +149,7 @@ pub fn sub(x: f64, y: f64) -> f64 { return x - y; } pub fn mul(x: f64, y: f64) -> f64 { return x * y; } #[inline(always)] -pub fn quot(x: f64, y: f64) -> f64 { return x / y; } +pub fn div(x: f64, y: f64) -> f64 { return x / y; } #[inline(always)] pub fn rem(x: f64, y: f64) -> f64 { return x % y; } @@ -296,15 +296,10 @@ impl Sub for f64 { impl Mul for f64 { fn mul(&self, other: &f64) -> f64 { *self * *other } } -#[cfg(stage0,notest)] +#[cfg(notest)] impl Div for f64 { fn div(&self, other: &f64) -> f64 { *self / *other } } -#[cfg(not(stage0),notest)] -impl Quot for f64 { - #[inline(always)] - fn quot(&self, other: &f64) -> f64 { *self / *other } -} #[cfg(stage0,notest)] impl Modulo for f64 { fn modulo(&self, other: &f64) -> f64 { *self % *other } diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index 3aa8848cdbe..f163d67a69c 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -25,7 +25,7 @@ use libc::c_int; use num::{Zero, One, strconv}; use prelude::*; -pub use f64::{add, sub, mul, quot, rem, lt, le, eq, ne, ge, gt}; +pub use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt}; pub use f64::logarithm; pub use f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor}; pub use f64::{erf, erfc, exp, expm1, exp2, abs_sub}; @@ -692,16 +692,12 @@ impl Mul for float { fn mul(&self, other: &float) -> float { *self * *other } } -#[cfg(stage0,notest)] +#[cfg(notest)] impl Div for float { #[inline(always)] fn div(&self, other: &float) -> float { *self / *other } } -#[cfg(not(stage0),notest)] -impl Quot for float { - #[inline(always)] - fn quot(&self, other: &float) -> float { *self / *other } -} + #[cfg(stage0,notest)] impl Modulo for float { #[inline(always)] diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index ec38a32c039..fadba84a0fe 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -30,7 +30,7 @@ pub fn sub(x: T, y: T) -> T { x - y } #[inline(always)] pub fn mul(x: T, y: T) -> T { x * y } #[inline(always)] -pub fn quot(x: T, y: T) -> T { x / y } +pub fn div(x: T, y: T) -> T { x / y } /// /// Returns the remainder of y / x. @@ -201,16 +201,11 @@ impl Mul for T { fn mul(&self, other: &T) -> T { *self * *other } } -#[cfg(stage0,notest)] +#[cfg(notest)] impl Div for T { - #[inline(always)] - fn div(&self, other: &T) -> T { *self / *other } -} -#[cfg(not(stage0),notest)] -impl Quot for T { /// - /// Returns the integer quotient, truncated towards 0. As this behaviour reflects - /// the underlying machine implementation it is more efficient than `Natural::div`. + /// Integer division, truncated towards 0. As this behaviour reflects the underlying + /// machine implementation it is more efficient than `Integer::div_floor`. /// /// # Examples /// @@ -227,7 +222,7 @@ impl Quot for T { /// ~~~ /// #[inline(always)] - fn quot(&self, other: &T) -> T { *self / *other } + fn div(&self, other: &T) -> T { *self / *other } } #[cfg(stage0,notest)] @@ -307,25 +302,25 @@ impl Integer for T { /// # Examples /// /// ~~~ - /// assert!(( 8).div( 3) == 2); - /// assert!(( 8).div(-3) == -3); - /// assert!((-8).div( 3) == -3); - /// assert!((-8).div(-3) == 2); + /// assert!(( 8).div_floor( 3) == 2); + /// assert!(( 8).div_floor(-3) == -3); + /// assert!((-8).div_floor( 3) == -3); + /// assert!((-8).div_floor(-3) == 2); /// - /// assert!(( 1).div( 2) == 0); - /// assert!(( 1).div(-2) == -1); - /// assert!((-1).div( 2) == -1); - /// assert!((-1).div(-2) == 0); + /// assert!(( 1).div_floor( 2) == 0); + /// assert!(( 1).div_floor(-2) == -1); + /// assert!((-1).div_floor( 2) == -1); + /// assert!((-1).div_floor(-2) == 0); /// ~~~ /// #[inline(always)] - fn div(&self, other: &T) -> T { + fn div_floor(&self, other: &T) -> T { // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_, // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf) - match self.quot_rem(other) { - (q, r) if (r > 0 && *other < 0) - || (r < 0 && *other > 0) => q - 1, - (q, _) => q, + match self.div_rem(other) { + (d, r) if (r > 0 && *other < 0) + || (r < 0 && *other > 0) => d - 1, + (d, _) => d, } } @@ -333,25 +328,25 @@ impl Integer for T { /// Integer modulo, satisfying: /// /// ~~~ - /// assert!(n.div(d) * d + n.modulo(d) == n) + /// assert!(n.div_floor(d) * d + n.mod_floor(d) == n) /// ~~~ /// /// # Examples /// /// ~~~ - /// assert!(( 8).modulo( 3) == 2); - /// assert!(( 8).modulo(-3) == -1); - /// assert!((-8).modulo( 3) == 1); - /// assert!((-8).modulo(-3) == -2); + /// assert!(( 8).mod_floor( 3) == 2); + /// assert!(( 8).mod_floor(-3) == -1); + /// assert!((-8).mod_floor( 3) == 1); + /// assert!((-8).mod_floor(-3) == -2); /// - /// assert!(( 1).modulo( 2) == 1); - /// assert!(( 1).modulo(-2) == -1); - /// assert!((-1).modulo( 2) == 1); - /// assert!((-1).modulo(-2) == -1); + /// assert!(( 1).mod_floor( 2) == 1); + /// assert!(( 1).mod_floor(-2) == -1); + /// assert!((-1).mod_floor( 2) == 1); + /// assert!((-1).mod_floor(-2) == -1); /// ~~~ /// #[inline(always)] - fn modulo(&self, other: &T) -> T { + fn mod_floor(&self, other: &T) -> T { // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_, // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf) match *self % *other { @@ -361,21 +356,21 @@ impl Integer for T { } } - /// Calculates `div` and `modulo` simultaneously + /// Calculates `div_floor` and `mod_floor` simultaneously #[inline(always)] - fn div_mod(&self, other: &T) -> (T,T) { + fn div_mod_floor(&self, other: &T) -> (T,T) { // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_, // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf) - match self.quot_rem(other) { - (q, r) if (r > 0 && *other < 0) - || (r < 0 && *other > 0) => (q - 1, r + *other), - (q, r) => (q, r), + match self.div_rem(other) { + (d, r) if (r > 0 && *other < 0) + || (r < 0 && *other > 0) => (d - 1, r + *other), + (d, r) => (d, r), } } - /// Calculates `quot` (`\`) and `rem` (`%`) simultaneously + /// Calculates `div` (`\`) and `rem` (`%`) simultaneously #[inline(always)] - fn quot_rem(&self, other: &T) -> (T,T) { + fn div_rem(&self, other: &T) -> (T,T) { (*self / *other, *self % *other) } @@ -599,42 +594,42 @@ mod tests { } #[test] - fn test_quot_rem() { - fn test_nd_qr(nd: (T,T), qr: (T,T)) { + fn test_div_rem() { + fn test_nd_dr(nd: (T,T), qr: (T,T)) { let (n,d) = nd; - let separate_quot_rem = (n / d, n % d); - let combined_quot_rem = n.quot_rem(&d); + let separate_div_rem = (n / d, n % d); + let combined_div_rem = n.div_rem(&d); - assert_eq!(separate_quot_rem, qr); - assert_eq!(combined_quot_rem, qr); + assert_eq!(separate_div_rem, qr); + assert_eq!(combined_div_rem, qr); - test_division_rule(nd, separate_quot_rem); - test_division_rule(nd, combined_quot_rem); + test_division_rule(nd, separate_div_rem); + test_division_rule(nd, combined_div_rem); } - test_nd_qr(( 8, 3), ( 2, 2)); - test_nd_qr(( 8, -3), (-2, 2)); - test_nd_qr((-8, 3), (-2, -2)); - test_nd_qr((-8, -3), ( 2, -2)); + test_nd_dr(( 8, 3), ( 2, 2)); + test_nd_dr(( 8, -3), (-2, 2)); + test_nd_dr((-8, 3), (-2, -2)); + test_nd_dr((-8, -3), ( 2, -2)); - test_nd_qr(( 1, 2), ( 0, 1)); - test_nd_qr(( 1, -2), ( 0, 1)); - test_nd_qr((-1, 2), ( 0, -1)); - test_nd_qr((-1, -2), ( 0, -1)); + test_nd_dr(( 1, 2), ( 0, 1)); + test_nd_dr(( 1, -2), ( 0, 1)); + test_nd_dr((-1, 2), ( 0, -1)); + test_nd_dr((-1, -2), ( 0, -1)); } #[test] - fn test_div_mod() { + fn test_div_mod_floor() { fn test_nd_dm(nd: (T,T), dm: (T,T)) { let (n,d) = nd; - let separate_div_mod = (n.div(&d), n.modulo(&d)); - let combined_div_mod = n.div_mod(&d); + let separate_div_mod_floor = (n.div_floor(&d), n.mod_floor(&d)); + let combined_div_mod_floor = n.div_mod_floor(&d); - assert_eq!(separate_div_mod, dm); - assert_eq!(combined_div_mod, dm); + assert_eq!(separate_div_mod_floor, dm); + assert_eq!(combined_div_mod_floor, dm); - test_division_rule(nd, separate_div_mod); - test_division_rule(nd, combined_div_mod); + test_division_rule(nd, separate_div_mod_floor); + test_division_rule(nd, combined_div_mod_floor); } test_nd_dm(( 8, 3), ( 2, 2)); diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index 3e43ebfef12..b8f47db7d12 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -11,13 +11,11 @@ //! An interface for numeric types use cmp::{Eq, Ord}; #[cfg(stage0)] -use ops::{Add, Sub, Mul, Neg}; -#[cfg(stage0)] -use Quot = ops::Div; +use ops::{Add, Sub, Mul, Div, Neg}; #[cfg(stage0)] use Rem = ops::Modulo; #[cfg(not(stage0))] -use ops::{Add, Sub, Mul, Quot, Rem, Neg}; +use ops::{Add, Sub, Mul, Div, Rem, Neg}; use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr}; use option::Option; use kinds::Copy; @@ -32,7 +30,7 @@ pub trait Num: Eq + Zero + One + Add + Sub + Mul - + Quot + + Div + Rem {} pub trait IntConvertible { @@ -76,12 +74,13 @@ pub fn abs>(v: T) -> T { pub trait Integer: Num + Orderable - + Quot + + Div + Rem { - fn div(&self, other: &Self) -> Self; - fn modulo(&self, other: &Self) -> Self; - fn div_mod(&self, other: &Self) -> (Self,Self); - fn quot_rem(&self, other: &Self) -> (Self,Self); + fn div_rem(&self, other: &Self) -> (Self,Self); + + fn div_floor(&self, other: &Self) -> Self; + fn mod_floor(&self, other: &Self) -> Self; + fn div_mod_floor(&self, other: &Self) -> (Self,Self); fn gcd(&self, other: &Self) -> Self; fn lcm(&self, other: &Self) -> Self; @@ -102,7 +101,7 @@ pub trait Round { pub trait Fractional: Num + Orderable + Round - + Quot { + + Div { fn recip(&self) -> Self; } @@ -226,7 +225,7 @@ pub trait Primitive: Num + Add + Sub + Mul - + Quot + + Div + Rem { // FIXME (#5527): These should be associated constants fn bits() -> uint; @@ -371,7 +370,7 @@ pub trait FromStrRadix { /// - If code written to use this function doesn't care about it, it's /// probably assuming that `x^0` always equals `1`. /// -pub fn pow_with_uint+Mul>( +pub fn pow_with_uint+Mul>( radix: uint, pow: uint) -> T { let _0: T = Zero::zero(); let _1: T = One::one(); @@ -413,13 +412,13 @@ pub fn test_num(ten: T, two: T) { assert_eq!(ten.add(&two), cast(12)); assert_eq!(ten.sub(&two), cast(8)); assert_eq!(ten.mul(&two), cast(20)); - assert_eq!(ten.quot(&two), cast(5)); + assert_eq!(ten.div(&two), cast(5)); assert_eq!(ten.rem(&two), cast(0)); assert_eq!(ten.add(&two), ten + two); assert_eq!(ten.sub(&two), ten - two); assert_eq!(ten.mul(&two), ten * two); - assert_eq!(ten.quot(&two), ten / two); + assert_eq!(ten.div(&two), ten / two); assert_eq!(ten.rem(&two), ten % two); } diff --git a/src/libcore/num/strconv.rs b/src/libcore/num/strconv.rs index 2f3cd92dac0..68e3b407a8b 100644 --- a/src/libcore/num/strconv.rs +++ b/src/libcore/num/strconv.rs @@ -10,15 +10,13 @@ use core::cmp::{Ord, Eq}; #[cfg(stage0)] -use ops::{Add, Sub, Mul, Neg}; -#[cfg(stage0)] -use Quot = ops::Div; +use ops::{Add, Sub, Mul, Div, Neg}; #[cfg(stage0)] use Rem = ops::Modulo; #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] -use ops::{Add, Sub, Mul, Quot, Rem, Neg}; +use ops::{Add, Sub, Mul, Div, Rem, Neg}; use option::{None, Option, Some}; use char; use str; @@ -67,7 +65,7 @@ fn is_neg_inf(num: &T) -> bool { } #[inline(always)] -fn is_neg_zero>(num: &T) -> bool { +fn is_neg_zero>(num: &T) -> bool { let _0: T = Zero::zero(); let _1: T = One::one(); @@ -180,7 +178,7 @@ static nan_buf: [u8, ..3] = ['N' as u8, 'a' as u8, 'N' as u8]; * - Fails if `radix` < 2 or `radix` > 36. */ pub fn to_str_bytes_common+Neg+Rem+Mul>( + Div+Neg+Rem+Mul>( num: &T, radix: uint, negative_zero: bool, sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) { if (radix as int) < 2 { @@ -388,7 +386,7 @@ pub fn to_str_bytes_common+Neg+Rem+Mul>( + Div+Neg+Rem+Mul>( num: &T, radix: uint, negative_zero: bool, sign: SignFormat, digits: SignificantDigits) -> (~str, bool) { let (bytes, special) = to_str_bytes_common(num, radix, @@ -441,7 +439,7 @@ priv static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u; * - Fails if `radix` > 18 and `special == true` due to conflict * between digit and lowest first character in `inf` and `NaN`, the `'i'`. */ -pub fn from_str_bytes_common+ +pub fn from_str_bytes_common+ Mul+Sub+Neg+Add+ NumStrConv>( buf: &[u8], radix: uint, negative: bool, fractional: bool, @@ -638,7 +636,7 @@ pub fn from_str_bytes_common+ * `from_str_bytes_common()`, for details see there. */ #[inline(always)] -pub fn from_str_common+Mul+ +pub fn from_str_common+Mul+ Sub+Neg+Add+NumStrConv>( buf: &str, radix: uint, negative: bool, fractional: bool, special: bool, exponent: ExponentFormat, empty_zero: bool, diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index 3dfdd22c42d..f6b98989545 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -31,7 +31,7 @@ pub fn sub(x: T, y: T) -> T { x - y } #[inline(always)] pub fn mul(x: T, y: T) -> T { x * y } #[inline(always)] -pub fn quot(x: T, y: T) -> T { x / y } +pub fn div(x: T, y: T) -> T { x / y } #[inline(always)] pub fn rem(x: T, y: T) -> T { x % y } @@ -166,16 +166,11 @@ impl Mul for T { fn mul(&self, other: &T) -> T { *self * *other } } -#[cfg(stage0,notest)] +#[cfg(notest)] impl Div for T { #[inline(always)] fn div(&self, other: &T) -> T { *self / *other } } -#[cfg(not(stage0),notest)] -impl Quot for T { - #[inline(always)] - fn quot(&self, other: &T) -> T { *self / *other } -} #[cfg(stage0,notest)] impl Modulo for T { @@ -197,23 +192,23 @@ impl Neg for T { impl Unsigned for T {} impl Integer for T { - /// Unsigned integer division. Returns the same result as `quot` (`/`). + /// Calculates `div` (`\`) and `rem` (`%`) simultaneously #[inline(always)] - fn div(&self, other: &T) -> T { *self / *other } + fn div_rem(&self, other: &T) -> (T,T) { + (*self / *other, *self % *other) + } - /// Unsigned integer modulo operation. Returns the same result as `rem` (`%`). + /// Unsigned integer division. Returns the same result as `div` (`/`). #[inline(always)] - fn modulo(&self, other: &T) -> T { *self / *other } + fn div_floor(&self, other: &T) -> T { *self / *other } - /// Calculates `div` and `modulo` simultaneously + /// Unsigned integer modulo operation. Returns the same result as `rem` (`%`). #[inline(always)] - fn div_mod(&self, other: &T) -> (T,T) { - (*self / *other, *self % *other) - } + fn mod_floor(&self, other: &T) -> T { *self / *other } - /// Calculates `quot` (`\`) and `rem` (`%`) simultaneously + /// Calculates `div_floor` and `modulo_floor` simultaneously #[inline(always)] - fn quot_rem(&self, other: &T) -> (T,T) { + fn div_mod_floor(&self, other: &T) -> (T,T) { (*self / *other, *self % *other) } diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 1aa7aada05c..5ba860c89c9 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -31,15 +31,9 @@ pub trait Mul { } #[lang="div"] -#[cfg(stage0)] pub trait Div { fn div(&self, rhs: &RHS) -> Result; } -#[lang="quot"] -#[cfg(not(stage0))] -pub trait Quot { - fn quot(&self, rhs: &RHS) -> Result; -} #[lang="modulo"] #[cfg(stage0)] diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index 9a2e480ce6e..4527fcf2923 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -17,7 +17,7 @@ pub use kinds::{Const, Copy, Owned, Durable}; #[cfg(stage0)] pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not}; #[cfg(not(stage0))] -pub use ops::{Add, Sub, Mul, Quot, Rem, Neg, Not}; +pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not}; pub use ops::{BitAnd, BitOr, BitXor}; pub use ops::{Drop}; pub use ops::{Shl, Shr, Index}; diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index bba4d35b560..86b7379bb69 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -279,7 +279,7 @@ pub fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: @expr) add => Ok(const_float(a + b)), subtract => Ok(const_float(a - b)), mul => Ok(const_float(a * b)), - quot => Ok(const_float(a / b)), + div => Ok(const_float(a / b)), rem => Ok(const_float(a % b)), eq => fromb(a == b), lt => fromb(a < b), @@ -295,8 +295,8 @@ pub fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: @expr) add => Ok(const_int(a + b)), subtract => Ok(const_int(a - b)), mul => Ok(const_int(a * b)), - quot if b == 0 => Err(~"attempted quotient with a divisor of zero"), - quot => Ok(const_int(a / b)), + div if b == 0 => Err(~"attempted to divide by zero"), + div => Ok(const_int(a / b)), rem if b == 0 => Err(~"attempted remainder with a divisor of zero"), rem => Ok(const_int(a % b)), and | bitand => Ok(const_int(a & b)), @@ -317,8 +317,8 @@ pub fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: @expr) add => Ok(const_uint(a + b)), subtract => Ok(const_uint(a - b)), mul => Ok(const_uint(a * b)), - quot if b == 0 => Err(~"attempted quotient with a divisor of zero"), - quot => Ok(const_uint(a / b)), + div if b == 0 => Err(~"attempted to divide by zero"), + div => Ok(const_uint(a / b)), rem if b == 0 => Err(~"attempted remainder with a divisor of zero"), rem => Ok(const_uint(a % b)), and | bitand => Ok(const_uint(a & b)), diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 2de12b9eb97..7298064e1c0 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -42,7 +42,7 @@ pub enum LangItem { AddTraitLangItem, // 5 SubTraitLangItem, // 6 MulTraitLangItem, // 7 - QuotTraitLangItem, // 8 + DivTraitLangItem, // 8 RemTraitLangItem, // 9 NegTraitLangItem, // 10 NotTraitLangItem, // 11 @@ -105,7 +105,7 @@ pub impl LanguageItems { 5 => "add", 6 => "sub", 7 => "mul", - 8 => "quot", + 8 => "div", 9 => "rem", 10 => "neg", 11 => "not", @@ -167,8 +167,8 @@ pub impl LanguageItems { pub fn mul_trait(&const self) -> def_id { self.items[MulTraitLangItem as uint].get() } - pub fn quot_trait(&const self) -> def_id { - self.items[QuotTraitLangItem as uint].get() + pub fn div_trait(&const self) -> def_id { + self.items[DivTraitLangItem as uint].get() } pub fn rem_trait(&const self) -> def_id { self.items[RemTraitLangItem as uint].get() @@ -268,7 +268,7 @@ fn LanguageItemCollector<'r>(crate: @crate, item_refs.insert(@~"add", AddTraitLangItem as uint); item_refs.insert(@~"sub", SubTraitLangItem as uint); item_refs.insert(@~"mul", MulTraitLangItem as uint); - item_refs.insert(@~"quot", QuotTraitLangItem as uint); + item_refs.insert(@~"div", DivTraitLangItem as uint); item_refs.insert(@~"rem", RemTraitLangItem as uint); item_refs.insert(@~"neg", NegTraitLangItem as uint); item_refs.insert(@~"not", NotTraitLangItem as uint); diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 294a21fac2c..d8ad53212e2 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -33,7 +33,7 @@ use syntax::ast::{def_upvar, def_use, def_variant, expr, expr_assign_op}; use syntax::ast::{expr_binary, expr_break, expr_field}; use syntax::ast::{expr_fn_block, expr_index, expr_method_call, expr_path}; use syntax::ast::{def_prim_ty, def_region, def_self, def_ty, def_ty_param}; -use syntax::ast::{def_upvar, def_use, def_variant, quot, eq}; +use syntax::ast::{def_upvar, def_use, def_variant, div, eq}; use syntax::ast::{expr, expr_again, expr_assign_op}; use syntax::ast::{expr_index, expr_loop}; use syntax::ast::{expr_path, expr_struct, expr_unary, fn_decl}; @@ -4901,9 +4901,9 @@ pub impl Resolver { self.add_fixed_trait_for_expr(expr.id, self.lang_items.mul_trait()); } - expr_binary(quot, _, _) | expr_assign_op(quot, _, _) => { + expr_binary(div, _, _) | expr_assign_op(div, _, _) => { self.add_fixed_trait_for_expr(expr.id, - self.lang_items.quot_trait()); + self.lang_items.div_trait()); } expr_binary(rem, _, _) | expr_assign_op(rem, _, _) => { self.add_fixed_trait_for_expr(expr.id, diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index efa10dfc2aa..262196ffffd 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -777,10 +777,10 @@ pub fn cast_shift_rhs(op: ast::binop, } } -pub fn fail_if_zero(cx: block, span: span, quotrem: ast::binop, +pub fn fail_if_zero(cx: block, span: span, divrem: ast::binop, rhs: ValueRef, rhs_t: ty::t) -> block { - let text = if quotrem == ast::quot { - @~"attempted quotient with a divisor of zero" + let text = if divrem == ast::div { + @~"attempted to divide by zero" } else { @~"attempted remainder with a divisor of zero" }; diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 25f34b8eaa9..c6c5561854c 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -270,7 +270,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { if is_float { llvm::LLVMConstFMul(te1, te2) } else { llvm::LLVMConstMul(te1, te2) } } - ast::quot => { + ast::div => { if is_float { llvm::LLVMConstFDiv(te1, te2) } else if signed { llvm::LLVMConstSDiv(te1, te2) } else { llvm::LLVMConstUDiv(te1, te2) } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index f83562add31..ae510ae6d11 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -1435,7 +1435,7 @@ fn trans_eager_binop(bcx: block, if is_float { FMul(bcx, lhs, rhs) } else { Mul(bcx, lhs, rhs) } } - ast::quot => { + ast::div => { if is_float { FDiv(bcx, lhs, rhs) } else { diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index c7fb1e94adf..4280cd4000d 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -4134,7 +4134,7 @@ pub fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool { ast::add => opcat_add, ast::subtract => opcat_sub, ast::mul => opcat_mult, - ast::quot => opcat_mult, + ast::div => opcat_mult, ast::rem => opcat_mult, ast::and => opcat_logic, ast::or => opcat_logic, diff --git a/src/libstd/num/bigint.rs b/src/libstd/num/bigint.rs index e010340b94d..fa9d6318cc9 100644 --- a/src/libstd/num/bigint.rs +++ b/src/libstd/num/bigint.rs @@ -293,10 +293,10 @@ impl Mul for BigUint { } } -impl Quot for BigUint { +impl Div for BigUint { #[inline(always)] - fn quot(&self, other: &BigUint) -> BigUint { - let (q, _) = self.quot_rem(other); + fn div(&self, other: &BigUint) -> BigUint { + let (q, _) = self.div_rem(other); return q; } } @@ -304,7 +304,7 @@ impl Quot for BigUint { impl Rem for BigUint { #[inline(always)] fn rem(&self, other: &BigUint) -> BigUint { - let (_, r) = self.quot_rem(other); + let (_, r) = self.div_rem(other); return r; } } @@ -316,19 +316,24 @@ impl Neg for BigUint { impl Integer for BigUint { #[inline(always)] - fn div(&self, other: &BigUint) -> BigUint { - let (d, _) = self.div_mod(other); + fn div_rem(&self, other: &BigUint) -> (BigUint, BigUint) { + self.div_mod_floor(other) + } + + #[inline(always)] + fn div_floor(&self, other: &BigUint) -> BigUint { + let (d, _) = self.div_mod_floor(other); return d; } #[inline(always)] - fn modulo(&self, other: &BigUint) -> BigUint { - let (_, m) = self.div_mod(other); + fn mod_floor(&self, other: &BigUint) -> BigUint { + let (_, m) = self.div_mod_floor(other); return m; } #[inline(always)] - fn div_mod(&self, other: &BigUint) -> (BigUint, BigUint) { + fn div_mod_floor(&self, other: &BigUint) -> (BigUint, BigUint) { if other.is_zero() { fail!() } if self.is_zero() { return (Zero::zero(), Zero::zero()); } if *other == One::one() { return (copy *self, Zero::zero()); } @@ -346,11 +351,11 @@ impl Integer for BigUint { shift += 1; } assert!(shift < BigDigit::bits); - let (d, m) = div_mod_inner(self << shift, other << shift); + let (d, m) = div_mod_floor_inner(self << shift, other << shift); return (d, m >> shift); #[inline(always)] - fn div_mod_inner(a: BigUint, b: BigUint) -> (BigUint, BigUint) { + fn div_mod_floor_inner(a: BigUint, b: BigUint) -> (BigUint, BigUint) { let mut m = a; let mut d = Zero::zero::(); let mut n = 1; @@ -409,11 +414,6 @@ impl Integer for BigUint { } } - #[inline(always)] - fn quot_rem(&self, other: &BigUint) -> (BigUint, BigUint) { - self.div_mod(other) - } - /** * Calculates the Greatest Common Divisor (GCD) of the number and `other` * @@ -485,7 +485,7 @@ impl ToStrRadix for BigUint { let mut result = ~[]; let mut m = n; while m > divider { - let (d, m0) = m.div_mod(÷r); + let (d, m0) = m.div_mod_floor(÷r); result += [m0.to_uint() as BigDigit]; m = d; } @@ -894,10 +894,10 @@ impl Mul for BigInt { } } -impl Quot for BigInt { +impl Div for BigInt { #[inline(always)] - fn quot(&self, other: &BigInt) -> BigInt { - let (q, _) = self.quot_rem(other); + fn div(&self, other: &BigInt) -> BigInt { + let (q, _) = self.div_rem(other); return q; } } @@ -905,7 +905,7 @@ impl Quot for BigInt { impl Rem for BigInt { #[inline(always)] fn rem(&self, other: &BigInt) -> BigInt { - let (_, r) = self.quot_rem(other); + let (_, r) = self.div_rem(other); return r; } } @@ -919,21 +919,36 @@ impl Neg for BigInt { impl Integer for BigInt { #[inline(always)] - fn div(&self, other: &BigInt) -> BigInt { - let (d, _) = self.div_mod(other); + fn div_rem(&self, other: &BigInt) -> (BigInt, BigInt) { + // r.sign == self.sign + let (d_ui, r_ui) = self.data.div_mod_floor(&other.data); + let d = BigInt::from_biguint(Plus, d_ui); + let r = BigInt::from_biguint(Plus, r_ui); + match (self.sign, other.sign) { + (_, Zero) => fail!(), + (Plus, Plus) | (Zero, Plus) => ( d, r), + (Plus, Minus) | (Zero, Minus) => (-d, r), + (Minus, Plus) => (-d, -r), + (Minus, Minus) => ( d, -r) + } + } + + #[inline(always)] + fn div_floor(&self, other: &BigInt) -> BigInt { + let (d, _) = self.div_mod_floor(other); return d; } #[inline(always)] - fn modulo(&self, other: &BigInt) -> BigInt { - let (_, m) = self.div_mod(other); + fn mod_floor(&self, other: &BigInt) -> BigInt { + let (_, m) = self.div_mod_floor(other); return m; } #[inline(always)] - fn div_mod(&self, other: &BigInt) -> (BigInt, BigInt) { + fn div_mod_floor(&self, other: &BigInt) -> (BigInt, BigInt) { // m.sign == other.sign - let (d_ui, m_ui) = self.data.quot_rem(&other.data); + let (d_ui, m_ui) = self.data.div_rem(&other.data); let d = BigInt::from_biguint(Plus, d_ui), m = BigInt::from_biguint(Plus, m_ui); match (self.sign, other.sign) { @@ -953,21 +968,6 @@ impl Integer for BigInt { } } - #[inline(always)] - fn quot_rem(&self, other: &BigInt) -> (BigInt, BigInt) { - // r.sign == self.sign - let (q_ui, r_ui) = self.data.div_mod(&other.data); - let q = BigInt::from_biguint(Plus, q_ui); - let r = BigInt::from_biguint(Plus, r_ui); - match (self.sign, other.sign) { - (_, Zero) => fail!(), - (Plus, Plus) | (Zero, Plus) => ( q, r), - (Plus, Minus) | (Zero, Minus) => (-q, r), - (Minus, Plus) => (-q, -r), - (Minus, Minus) => ( q, -r) - } - } - /** * Calculates the Greatest Common Divisor (GCD) of the number and `other` * @@ -1100,8 +1100,6 @@ pub impl BigInt { #[cfg(test)] mod biguint_tests { - - use core::*; use core::num::{IntConvertible, Zero, One, FromStrRadix}; use core::cmp::{Less, Equal, Greater}; use super::{BigUint, BigDigit}; @@ -1347,7 +1345,7 @@ mod biguint_tests { (&[ 0, 0, 1], &[ 0, 0, 0, 1], &[0, 0, 0, 0, 0, 1]) ]; - static quot_rem_quadruples: &'static [(&'static [BigDigit], + static div_rem_quadruples: &'static [(&'static [BigDigit], &'static [BigDigit], &'static [BigDigit], &'static [BigDigit])] @@ -1371,7 +1369,7 @@ mod biguint_tests { assert!(b * a == c); } - for quot_rem_quadruples.each |elm| { + for div_rem_quadruples.each |elm| { let (aVec, bVec, cVec, dVec) = *elm; let a = BigUint::from_slice(aVec); let b = BigUint::from_slice(bVec); @@ -1384,7 +1382,7 @@ mod biguint_tests { } #[test] - fn test_quot_rem() { + fn test_div_rem() { for mul_triples.each |elm| { let (aVec, bVec, cVec) = *elm; let a = BigUint::from_slice(aVec); @@ -1392,21 +1390,21 @@ mod biguint_tests { let c = BigUint::from_slice(cVec); if !a.is_zero() { - assert!(c.quot_rem(&a) == (copy b, Zero::zero())); + assert!(c.div_rem(&a) == (copy b, Zero::zero())); } if !b.is_zero() { - assert!(c.quot_rem(&b) == (copy a, Zero::zero())); + assert!(c.div_rem(&b) == (copy a, Zero::zero())); } } - for quot_rem_quadruples.each |elm| { + for div_rem_quadruples.each |elm| { let (aVec, bVec, cVec, dVec) = *elm; let a = BigUint::from_slice(aVec); let b = BigUint::from_slice(bVec); let c = BigUint::from_slice(cVec); let d = BigUint::from_slice(dVec); - if !b.is_zero() { assert!(a.quot_rem(&b) == (c, d)); } + if !b.is_zero() { assert!(a.div_rem(&b) == (c, d)); } } } @@ -1558,7 +1556,6 @@ mod biguint_tests { #[cfg(test)] mod bigint_tests { use super::{BigInt, BigUint, BigDigit, Sign, Minus, Zero, Plus}; - use core::*; use core::cmp::{Less, Equal, Greater}; use core::num::{IntConvertible, Zero, One, FromStrRadix}; @@ -1750,10 +1747,10 @@ mod bigint_tests { (&[ 0, 0, 1], &[ 0, 0, 0, 1], &[0, 0, 0, 0, 0, 1]) ]; - static quot_rem_quadruples: &'static [(&'static [BigDigit], - &'static [BigDigit], - &'static [BigDigit], - &'static [BigDigit])] + static div_rem_quadruples: &'static [(&'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit])] = &[ (&[ 1], &[ 2], &[], &[1]), (&[ 1, 1], &[ 2], &[-1/2+1], &[1]), @@ -1777,7 +1774,7 @@ mod bigint_tests { assert!((-b) * a == -c); } - for quot_rem_quadruples.each |elm| { + for div_rem_quadruples.each |elm| { let (aVec, bVec, cVec, dVec) = *elm; let a = BigInt::from_slice(Plus, aVec); let b = BigInt::from_slice(Plus, bVec); @@ -1790,9 +1787,9 @@ mod bigint_tests { } #[test] - fn test_div_mod() { + fn test_div_mod_floor() { fn check_sub(a: &BigInt, b: &BigInt, ans_d: &BigInt, ans_m: &BigInt) { - let (d, m) = a.div_mod(b); + let (d, m) = a.div_mod_floor(b); if !m.is_zero() { assert!(m.sign == b.sign); } @@ -1826,7 +1823,7 @@ mod bigint_tests { if !b.is_zero() { check(&c, &b, &a, &Zero::zero()); } } - for quot_rem_quadruples.each |elm| { + for div_rem_quadruples.each |elm| { let (aVec, bVec, cVec, dVec) = *elm; let a = BigInt::from_slice(Plus, aVec); let b = BigInt::from_slice(Plus, bVec); @@ -1841,9 +1838,9 @@ mod bigint_tests { #[test] - fn test_quot_rem() { + fn test_div_rem() { fn check_sub(a: &BigInt, b: &BigInt, ans_q: &BigInt, ans_r: &BigInt) { - let (q, r) = a.quot_rem(b); + let (q, r) = a.div_rem(b); if !r.is_zero() { assert!(r.sign == a.sign); } @@ -1869,7 +1866,7 @@ mod bigint_tests { if !b.is_zero() { check(&c, &b, &a, &Zero::zero()); } } - for quot_rem_quadruples.each |elm| { + for div_rem_quadruples.each |elm| { let (aVec, bVec, cVec, dVec) = *elm; let a = BigInt::from_slice(Plus, aVec); let b = BigInt::from_slice(Plus, bVec); diff --git a/src/libstd/num/complex.rs b/src/libstd/num/complex.rs index 02393b15cca..41d2b4a101c 100644 --- a/src/libstd/num/complex.rs +++ b/src/libstd/num/complex.rs @@ -102,9 +102,9 @@ impl Mul, Cmplx> for Cmplx { // (a + i b) / (c + i d) == [(a + i b) * (c - i d)] / (c*c + d*d) // == [(a*c + b*d) / (c*c + d*d)] + i [(b*c - a*d) / (c*c + d*d)] -impl Quot, Cmplx> for Cmplx { +impl Div, Cmplx> for Cmplx { #[inline] - fn quot(&self, other: &Cmplx) -> Cmplx { + fn div(&self, other: &Cmplx) -> Cmplx { let norm_sqr = other.norm_sqr(); Cmplx::new((self.re*other.re + self.im*other.im) / norm_sqr, (self.im*other.re - self.re*other.im) / norm_sqr) @@ -275,7 +275,7 @@ mod test { } } #[test] - fn test_quot() { + fn test_div() { assert_eq!(_neg1_1i / _0_1i, _1_1i); for all_consts.each |&c| { if c != Zero::zero() { diff --git a/src/libstd/num/rational.rs b/src/libstd/num/rational.rs index a7c170c1cd6..9b92b7241b9 100644 --- a/src/libstd/num/rational.rs +++ b/src/libstd/num/rational.rs @@ -143,9 +143,9 @@ impl // (a/b) / (c/d) = (a*d)/(b*c) impl - Quot,Ratio> for Ratio { + Div,Ratio> for Ratio { #[inline] - fn quot(&self, rhs: &Ratio) -> Ratio { + fn div(&self, rhs: &Ratio) -> Ratio { Ratio::new(self.numer * rhs.denom, self.denom * rhs.numer) } } @@ -395,7 +395,7 @@ mod test { } #[test] - fn test_quot() { + fn test_div() { assert_eq!(_1 / _1_2, _2); assert_eq!(_3_2 / _1_2, _1 + _2); assert_eq!(_1 / _neg1_2, _neg1_2 + _neg1_2 + _neg1_2 + _neg1_2); @@ -424,7 +424,7 @@ mod test { } #[test] #[should_fail] - fn test_quot_0() { + fn test_div_0() { let _a = _1 / _0; } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index ba6fe1cda4f..5690502c811 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -389,7 +389,7 @@ pub enum binop { add, subtract, mul, - quot, + div, rem, and, or, diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 148b713a4f5..0ffeb684dc0 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -73,7 +73,7 @@ pub fn binop_to_str(op: binop) -> ~str { add => return ~"+", subtract => return ~"-", mul => return ~"*", - quot => return ~"/", + div => return ~"/", rem => return ~"%", and => return ~"&&", or => return ~"||", @@ -96,7 +96,7 @@ pub fn binop_to_method_name(op: binop) -> Option<~str> { add => return Some(~"add"), subtract => return Some(~"sub"), mul => return Some(~"mul"), - quot => return Some(~"quot"), + div => return Some(~"div"), rem => return Some(~"rem"), bitxor => return Some(~"bitxor"), bitand => return Some(~"bitand"), @@ -341,7 +341,7 @@ pub fn is_self(d: ast::def) -> bool { /// Maps a binary operator to its precedence pub fn operator_prec(op: ast::binop) -> uint { match op { - mul | quot | rem => 12u, + mul | div | rem => 12u, // 'as' sits between here with 11 add | subtract => 10u, shl | shr => 9u, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 50bdfb2f557..42c6fad6463 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -19,7 +19,7 @@ use ast::{_mod, add, arg, arm, attribute, bind_by_ref, bind_infer}; use ast::{bind_by_copy, bitand, bitor, bitxor, blk}; use ast::{blk_check_mode, box}; use ast::{crate, crate_cfg, decl, decl_item}; -use ast::{decl_local, default_blk, deref, quot, enum_def}; +use ast::{decl_local, default_blk, deref, div, enum_def}; use ast::{expr, expr_, expr_addr_of, expr_match, expr_again}; use ast::{expr_assign, expr_assign_op, expr_binary, expr_block}; use ast::{expr_break, expr_call, expr_cast, expr_copy, expr_do_body}; @@ -1836,7 +1836,7 @@ pub impl Parser { token::PLUS => aop = add, token::MINUS => aop = subtract, token::STAR => aop = mul, - token::SLASH => aop = quot, + token::SLASH => aop = div, token::PERCENT => aop = rem, token::CARET => aop = bitxor, token::AND => aop = bitand, diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 0327a3b80da..9426e9abab3 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -371,7 +371,7 @@ impl<'self> to_bytes::IterBytes for StringRef<'self> { pub fn token_to_binop(tok: Token) -> Option { match tok { BINOP(STAR) => Some(ast::mul), - BINOP(SLASH) => Some(ast::quot), + BINOP(SLASH) => Some(ast::div), BINOP(PERCENT) => Some(ast::rem), BINOP(PLUS) => Some(ast::add), BINOP(MINUS) => Some(ast::subtract), diff --git a/src/test/compile-fail/eval-enum.rs b/src/test/compile-fail/eval-enum.rs index 01233419579..f92dad961d1 100644 --- a/src/test/compile-fail/eval-enum.rs +++ b/src/test/compile-fail/eval-enum.rs @@ -1,5 +1,5 @@ enum test { - quot_zero = 1/0, //~ERROR expected constant: attempted quotient with a divisor of zero + div_zero = 1/0, //~ERROR expected constant: attempted to divide by zero rem_zero = 1%0 //~ERROR expected constant: attempted remainder with a divisor of zero } diff --git a/src/test/run-fail/divide-by-zero.rs b/src/test/run-fail/divide-by-zero.rs index d4f3828ea71..9c996807ad8 100644 --- a/src/test/run-fail/divide-by-zero.rs +++ b/src/test/run-fail/divide-by-zero.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:attempted quotient with a divisor of zero +// error-pattern:attempted to divide by zero fn main() { let y = 0; let z = 1 / y; -- cgit 1.4.1-3-g733a5 From e596128bd87b978fb163235bcf5eb0ef7d446218 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Wed, 1 May 2013 20:52:09 +1000 Subject: Remove 'Local Variable' comments --- src/compiletest/compiletest.rc | 7 ------- src/libcore/core.rc | 9 --------- src/libcore/either.rs | 10 ---------- src/libcore/io.rs | 10 ---------- src/libcore/libc.rs | 9 --------- src/libcore/num/cmath.rs | 11 ----------- src/libcore/num/f32.rs | 10 ---------- src/libcore/num/f64.rs | 10 ---------- src/libcore/num/float.rs | 10 ---------- src/libcore/option.rs | 8 -------- src/libcore/rand.rs | 9 --------- src/libcore/run.rs | 8 -------- src/libcore/sys.rs | 8 -------- src/libcore/unstable/extfmt.rs | 8 -------- src/libcore/unstable/lang.rs | 8 -------- src/libfuzzer/fuzzer.rc | 7 ------- src/librustc/back/abi.rs | 9 --------- src/librustc/back/arm.rs | 11 ----------- src/librustc/back/link.rs | 10 ---------- src/librustc/back/mips.rs | 11 ----------- src/librustc/back/upcall.rs | 9 --------- src/librustc/back/x86.rs | 10 ---------- src/librustc/back/x86_64.rs | 10 ---------- src/librustc/driver/driver.rs | 8 -------- src/librustc/driver/session.rs | 7 ------- src/librustc/front/config.rs | 8 -------- src/librustc/front/test.rs | 8 -------- src/librustc/lib/llvm.rs | 10 ---------- src/librustc/metadata/creader.rs | 8 -------- src/librustc/metadata/csearch.rs | 8 -------- src/librustc/metadata/cstore.rs | 8 -------- src/librustc/metadata/decoder.rs | 8 -------- src/librustc/metadata/encoder.rs | 9 --------- src/librustc/metadata/tydecode.rs | 10 ---------- src/librustc/metadata/tyencode.rs | 10 ---------- src/librustc/middle/check_const.rs | 8 -------- src/librustc/middle/check_match.rs | 8 -------- src/librustc/middle/const_eval.rs | 9 --------- src/librustc/middle/freevars.rs | 8 -------- src/librustc/middle/kind.rs | 10 ---------- src/librustc/middle/lint.rs | 10 ---------- src/librustc/middle/trans/_match.rs | 8 -------- src/librustc/middle/trans/base.rs | 9 --------- src/librustc/middle/trans/build.rs | 10 ---------- src/librustc/middle/trans/common.rs | 10 ---------- src/librustc/middle/trans/tvec.rs | 10 ---------- src/librustc/middle/ty.rs | 8 -------- src/librustc/middle/typeck/mod.rs | 9 --------- src/librustc/rustc.rc | 8 -------- src/librustc/util/common.rs | 10 ---------- src/librustc/util/ppaux.rs | 8 -------- src/libstd/bitv.rs | 10 ---------- src/libstd/dbg.rs | 8 -------- src/libstd/getopts.rs | 8 -------- src/libstd/list.rs | 8 -------- src/libstd/sha1.rs | 8 -------- src/libstd/sort.rs | 8 -------- src/libstd/std.rc | 8 -------- src/libstd/term.rs | 7 ------- src/libstd/test.rs | 9 --------- src/libsyntax/ast.rs | 9 --------- src/libsyntax/ast_map.rs | 8 -------- src/libsyntax/ast_util.rs | 8 -------- src/libsyntax/attr.rs | 10 ---------- src/libsyntax/codemap.rs | 12 ------------ src/libsyntax/ext/asm.rs | 12 ------------ src/libsyntax/ext/base.rs | 10 ---------- src/libsyntax/ext/env.rs | 10 ---------- src/libsyntax/ext/expand.rs | 8 -------- src/libsyntax/ext/fmt.rs | 9 --------- src/libsyntax/ext/source_util.rs | 10 ---------- src/libsyntax/ext/tt/macro_parser.rs | 8 -------- src/libsyntax/fold.rs | 10 ---------- src/libsyntax/parse/attr.rs | 10 ---------- src/libsyntax/parse/lexer.rs | 10 ---------- src/libsyntax/parse/mod.rs | 10 ---------- src/libsyntax/parse/parser.rs | 11 ----------- src/libsyntax/parse/token.rs | 8 -------- src/libsyntax/print/pp.rs | 11 ----------- src/libsyntax/print/pprust.rs | 10 ---------- src/libsyntax/visit.rs | 8 -------- src/test/run-pass/item-attributes.rs | 10 ---------- src/test/run-pass/spawn.rs | 8 -------- src/test/run-pass/spawn2.rs | 8 -------- src/test/run-pass/task-killjoin-rsrc.rs | 8 -------- src/test/run-pass/task-killjoin.rs | 8 -------- 86 files changed, 775 deletions(-) (limited to 'src/test') diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc index 4392ce7ba28..b6d690f8307 100644 --- a/src/compiletest/compiletest.rc +++ b/src/compiletest/compiletest.rc @@ -223,10 +223,3 @@ pub fn make_test_closure(config: config, testfile: &Path) -> test::TestFn { let testfile = testfile.to_str(); test::DynTestFn(|| runtest::run(config, testfile)) } - -// Local Variables: -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 9a0419ebfc6..f410591fdc7 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -263,12 +263,3 @@ mod core { pub use sys; pub use pipes; } - - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/either.rs b/src/libcore/either.rs index 92f850cddd6..33b7e81ee85 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -263,13 +263,3 @@ fn test_partition_empty() { assert_eq!(vec::len(lefts), 0u); assert_eq!(vec::len(rights), 0u); } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 35ffd88c8f4..185b84a09c5 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -1954,13 +1954,3 @@ mod tests { } } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libcore/libc.rs b/src/libcore/libc.rs index 999a5d9b350..53aaf5726dd 100644 --- a/src/libcore/libc.rs +++ b/src/libcore/libc.rs @@ -1846,12 +1846,3 @@ pub mod funcs { } } } - - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/num/cmath.rs b/src/libcore/num/cmath.rs index 30b0c54dc2d..8a0a88235d2 100644 --- a/src/libcore/num/cmath.rs +++ b/src/libcore/num/cmath.rs @@ -267,14 +267,3 @@ pub mod c_double_targ_consts { } */ - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// - diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 04ddd63a177..a00225e85bc 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -986,13 +986,3 @@ mod tests { assert_eq!(Primitive::bytes::(), sys::size_of::()); } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 9f1944e3fad..c3bd89b0e03 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -1033,13 +1033,3 @@ mod tests { assert_eq!(Primitive::bytes::(), sys::size_of::()); } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index f163d67a69c..b487fa48782 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -1139,13 +1139,3 @@ mod tests { assert_eq!(to_str_digits(-infinity, 10u), ~"-inf"); } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 17192b4257b..47ec1fabcb8 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -565,11 +565,3 @@ fn test_get_or_zero() { let no_stuff: Option = None; assert!(no_stuff.get_or_zero() == 0); } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 94ba5ba31b7..80f69f067eb 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -1073,12 +1073,3 @@ mod tests { } } } - - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 37401788ca2..d0c495dd19e 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -639,11 +639,3 @@ mod tests { test_destroy_actually_kills(true); } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 8cad0a22886..c0c1ad6d896 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -343,11 +343,3 @@ mod tests { #[should_fail] fn fail_owned() { FailWithCause::fail_with(~"cause", file!(), line!()) } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/unstable/extfmt.rs b/src/libcore/unstable/extfmt.rs index b812be5575a..f65b1e6726e 100644 --- a/src/libcore/unstable/extfmt.rs +++ b/src/libcore/unstable/extfmt.rs @@ -688,11 +688,3 @@ mod test { let _s = fmt!("%s", s); } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/unstable/lang.rs b/src/libcore/unstable/lang.rs index 611862a79e7..a6599e03d6b 100644 --- a/src/libcore/unstable/lang.rs +++ b/src/libcore/unstable/lang.rs @@ -183,11 +183,3 @@ pub fn start(main: *u8, argc: int, argv: **c_char, crate_map: *c_void) -> c_int; } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libfuzzer/fuzzer.rc b/src/libfuzzer/fuzzer.rc index fc1efd3313c..7c93d867f50 100644 --- a/src/libfuzzer/fuzzer.rc +++ b/src/libfuzzer/fuzzer.rc @@ -693,10 +693,3 @@ pub fn main() { error!("Fuzzer done"); } - -// Local Variables: -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/back/abi.rs b/src/librustc/back/abi.rs index 70a029ede6f..842dd89a7cd 100644 --- a/src/librustc/back/abi.rs +++ b/src/librustc/back/abi.rs @@ -77,12 +77,3 @@ pub fn bzero_glue_name() -> ~str { return ~"rust_bzero_glue"; } pub fn yield_glue_name() -> ~str { return ~"rust_yield_glue"; } pub fn no_op_type_glue_name() -> ~str { return ~"rust_no_op_type_glue"; } -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/back/arm.rs b/src/librustc/back/arm.rs index 97c3a588a7f..dfe5751f21b 100644 --- a/src/librustc/back/arm.rs +++ b/src/librustc/back/arm.rs @@ -72,14 +72,3 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t { cc_args: ~[~"-marm"] }; } - - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index adaffe5873d..87e08a73fcb 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -949,13 +949,3 @@ pub fn link_args(sess: Session, return args; } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/back/mips.rs b/src/librustc/back/mips.rs index 93c1879eb0f..b15306a56b0 100644 --- a/src/librustc/back/mips.rs +++ b/src/librustc/back/mips.rs @@ -72,14 +72,3 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t { cc_args: ~[] }; } - - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/back/upcall.rs b/src/librustc/back/upcall.rs index 4cdd279e2fc..8fcc5234e8b 100644 --- a/src/librustc/back/upcall.rs +++ b/src/librustc/back/upcall.rs @@ -59,12 +59,3 @@ pub fn declare_upcalls(targ_cfg: @session::config, nothrow(dv(~"reset_stack_limit", ~[])) } } -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/back/x86.rs b/src/librustc/back/x86.rs index 2cc812c3d41..759f5f63c9e 100644 --- a/src/librustc/back/x86.rs +++ b/src/librustc/back/x86.rs @@ -55,13 +55,3 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t { cc_args: ~[~"-m32"] }; } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/back/x86_64.rs b/src/librustc/back/x86_64.rs index b68073974dc..ed6f1d28514 100644 --- a/src/librustc/back/x86_64.rs +++ b/src/librustc/back/x86_64.rs @@ -63,13 +63,3 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t { cc_args: ~[~"-m64"] }; } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 8c053c265fa..afd0e0acfe9 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -951,11 +951,3 @@ mod test { assert!((vec::len(test_items) == 1u)); } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index ff623049f75..b9e0eeb3466 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -430,10 +430,3 @@ mod test { assert!(building_library(lib_crate, crate, true)); } } - -// Local Variables: -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs index 75ae8724d72..2246dd9d2f0 100644 --- a/src/librustc/front/config.rs +++ b/src/librustc/front/config.rs @@ -194,11 +194,3 @@ pub fn metas_in_cfg(cfg: ast::crate_cfg, }) }) } - - -// Local Variables: -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 02e2a4c8734..4506feece2b 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -456,11 +456,3 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::expr { ); e } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index 31050448e75..fbb3380554d 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -2196,13 +2196,3 @@ pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter { } } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 0d0f0d7ab69..da7a2c15f30 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -328,11 +328,3 @@ fn resolve_crate_deps(e: @mut Env, cdata: @~[u8]) -> cstore::cnum_map { } return @mut cnum_map; } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index f8dc34f9cee..375989b0ebe 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -243,11 +243,3 @@ pub fn get_link_args_for_crate(cstore: @mut cstore::CStore, let cdata = cstore::get_crate_data(cstore, crate_num); decoder::get_link_args_for_crate(cdata) } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index 05275a4c665..21815a9ed47 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -161,11 +161,3 @@ pub fn get_dep_hashes(cstore: &CStore) -> ~[~str] { sorted.map(|ch| /*bad*/copy *ch.hash) } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index fb7b3f9c8b1..61454c802cc 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -1176,11 +1176,3 @@ pub fn get_link_args_for_crate(cdata: cmd) -> ~[~str] { } result } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index ba6a4f30857..2a4334781e4 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1420,12 +1420,3 @@ pub fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> ~str { tyencode::enc_ty(wr, cx, t); } } - - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 011ee115e8c..b12db430afc 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -567,13 +567,3 @@ fn parse_bounds(st: @mut PState, conv: conv_did) -> @~[ty::param_bound] { } @bounds } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index 763b1984b81..0548204b154 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -416,13 +416,3 @@ pub fn enc_type_param_def(w: @io::Writer, cx: @ctxt, v: &ty::TypeParameterDef) { w.write_char('|'); enc_bounds(w, cx, v.bounds); } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 6a47eedcea8..36be65ed63f 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -253,11 +253,3 @@ pub fn check_item_recursion(sess: Session, visit::visit_expr(e, env, v); } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 852eb1b50a4..e412a0e5102 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -862,11 +862,3 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, (vt.visit_pat)(*pat, false, vt); } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 86b7379bb69..63b9fcf7096 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -484,12 +484,3 @@ pub fn lit_expr_eq(tcx: middle::ty::ctxt, a: @expr, b: @expr) -> bool { pub fn lit_eq(a: @lit, b: @lit) -> bool { compare_const_vals(&lit_to_const(a), &lit_to_const(b)) == 0 } - - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index 4c8d36f93f4..419b75a2ad9 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -119,11 +119,3 @@ pub fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info { pub fn has_freevars(tcx: ty::ctxt, fid: ast::node_id) -> bool { return vec::len(*get_freevars(tcx, fid)) != 0u; } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 0925e8cdd63..90e6f7c6af9 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -587,13 +587,3 @@ pub fn check_kind_bounds_of_cast(cx: Context, source: @expr, target: @expr) { _ => {} // Nothing to do. } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index b67d74bc272..f6db25065b7 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -946,13 +946,3 @@ pub fn check_crate(tcx: ty::ctxt, crate: @ast::crate) { tcx.sess.abort_if_errors(); } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 3755cca8c35..197b537fe90 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1862,11 +1862,3 @@ pub fn bind_irrefutable_pat(bcx: block, } return bcx; } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 2090e50000b..0c3e3ba3cb6 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -3172,12 +3172,3 @@ pub fn trans_crate(sess: session::Session, return (llmod, link_meta); } } -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index f5c496484a0..a02ac96e520 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -1086,13 +1086,3 @@ pub fn AtomicRMW(cx: block, op: AtomicBinOp, llvm::LLVMBuildAtomicRMW(B(cx), op, dst, src, order) } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index f8fb0f4b7cf..d31caffe77a 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -1521,13 +1521,3 @@ pub fn dummy_substs(tps: ~[ty::t]) -> ty::substs { pub fn bool_to_i1(bcx: block, llval: ValueRef) -> ValueRef { build::ICmp(bcx, lib::llvm::IntNE, llval, C_bool(false)) } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 30a7648e7ea..da1cdfa4db1 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -594,13 +594,3 @@ pub fn iter_vec_unboxed(bcx: block, body_ptr: ValueRef, vec_ty: ty::t, let dataptr = get_dataptr(bcx, body_ptr); return iter_vec_raw(bcx, dataptr, vec_ty, fill, f); } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index ccd7cc6a8ab..1546c885a6d 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -4370,11 +4370,3 @@ pub fn visitor_object_ty(tcx: ctxt) -> (@TraitRef, t) { (trait_ref, mk_trait(tcx, trait_ref.def_id, copy trait_ref.substs, BoxTraitStore, ast::m_imm)) } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index 646b6412f55..b0e0b7319ac 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -426,12 +426,3 @@ pub fn check_crate(tcx: ty::ctxt, tcx.sess.abort_if_errors(); (ccx.method_map, ccx.vtable_map) } -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc index 54c51cf2e48..adb1c2fcc41 100644 --- a/src/librustc/rustc.rc +++ b/src/librustc/rustc.rc @@ -357,11 +357,3 @@ pub fn main() { run_compiler(&args, demitter); } } - - -// Local Variables: -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 38f55b2b6e4..b4a479fc597 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -112,13 +112,3 @@ pub fn pluralize(n: uint, s: ~str) -> ~str { // A set of node IDs (used to keep track of which node IDs are for statements) pub type stmt_set = @mut HashSet; - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index aa8c3f8fd1b..69849a8d51b 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -739,11 +739,3 @@ impl Repr for ty::vstore { vstore_to_str(tcx, *self) } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 5314c35419c..078ed6af5a0 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -1507,13 +1507,3 @@ mod tests { } } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs index 34dd6390ecc..4b2d2a60a68 100644 --- a/src/libstd/dbg.rs +++ b/src/libstd/dbg.rs @@ -76,11 +76,3 @@ fn test_breakpoint_should_not_abort_process_when_not_under_gdb() { // the process under normal circumstances breakpoint(); } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index fda5c105da5..c03042fe9c2 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -1374,11 +1374,3 @@ Options: assert!(usage == expected) } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 401cc121a62..2b6fa0bc056 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -242,11 +242,3 @@ mod tests { == list::append(list::from_vec(~[1,2]), list::from_vec(~[3,4]))); } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index 7371250b38a..a8e0f7d062a 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -412,11 +412,3 @@ mod tests { } } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 3e6011e80df..172532a2e5b 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -1202,11 +1202,3 @@ mod big_tests { } } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 0a5348d7976..ea099090eba 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -121,11 +121,3 @@ pub mod std { pub use serialize; pub use test; } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libstd/term.rs b/src/libstd/term.rs index 022f1f8564e..a79b9f4c849 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -76,10 +76,3 @@ pub fn fg(writer: @io::Writer, color: u8) { pub fn bg(writer: @io::Writer, color: u8) { return set_color(writer, '4' as u8, color); } - -// Local Variables: -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 278a326d1de..65fb0c7426a 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -960,12 +960,3 @@ mod tests { } } } - - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 4bb2d220ad6..a295952439f 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1346,12 +1346,3 @@ mod test { } */ -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index d2125cebb5e..69397276c4f 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -404,11 +404,3 @@ pub fn node_item_query(items: map, id: node_id, _ => fail!(error_msg) } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 2b3793e45e9..47ef7227842 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -832,11 +832,3 @@ mod test { } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 2f8405c6e96..f4f0def2843 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -341,13 +341,3 @@ pub fn require_unique_names(diagnostic: @span_handler, } } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 1194506a887..5f4967351e1 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -522,15 +522,3 @@ mod test { fm.next_line(BytePos(2)); } } - - - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index dfebf6f786a..53f40113532 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -187,15 +187,3 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) span: sp }) } - - - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 2d6d74b5c1e..1c03ad13759 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -543,13 +543,3 @@ mod test { assert_eq!(*(m.find(&@~"def").get()),16); } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index 5e5fd7d97b1..5b1e3737b23 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -34,13 +34,3 @@ pub fn expand_syntax_ext(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) }; MRExpr(e) } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index fde5a259422..02a698b283d 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -721,11 +721,3 @@ mod test { } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 9bbe617eb07..62641279f88 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -322,12 +322,3 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span, return mk_block(cx, fmt_sp, ~[], stms, Some(buf())); } -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 70aa9472c85..ab22b3152f4 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -150,13 +150,3 @@ fn res_rel_file(cx: @ext_ctxt, sp: codemap::span, arg: &Path) -> Path { copy *arg } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index e4e033e0fff..0c1e619985d 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -438,11 +438,3 @@ pub fn parse_nt(p: &Parser, name: ~str) -> nonterminal { _ => p.fatal(~"Unsupported builtin nonterminal parser: " + name) } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 36565395e59..229a8664d0c 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -859,13 +859,3 @@ impl AstFoldExtensions for @ast_fold { pub fn make_fold(afp: ast_fold_fns) -> @ast_fold { afp as @ast_fold } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index cc580155d70..037b2c089f4 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -179,13 +179,3 @@ impl parser_attr for Parser { } } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 60d6ce504fd..16a7ef71317 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -892,13 +892,3 @@ mod test { assert_eq!(tok, token::LIFETIME(id)); } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 5d51a54d770..74e4f562ce5 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -674,13 +674,3 @@ mod test { string_to_expr(@~"a::z.froob(b,@(987+3))"); } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a582748edb3..8459fc8c627 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4509,14 +4509,3 @@ pub impl Parser { } } } - - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 338b7c99d97..fe7bd5b3bc1 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -556,11 +556,3 @@ pub fn reserved_keyword_table() -> HashSet<~str> { } return words; } - - -// Local Variables: -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index e2ad5becb12..3fa615939b7 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -587,14 +587,3 @@ pub fn hardbreak_tok_offset(off: int) -> token { } pub fn hardbreak_tok() -> token { return hardbreak_tok_offset(0); } - - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ab958d8b5ce..76de109eebd 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2280,13 +2280,3 @@ mod test { assert_eq!(&varstr,&~"pub principal_skinner"); } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 71cfbab9108..9a0c97d7616 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -757,11 +757,3 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { v_struct_method(v.visit_struct_method, a, b, c) }); } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/test/run-pass/item-attributes.rs b/src/test/run-pass/item-attributes.rs index 24fe6713372..c616d46a833 100644 --- a/src/test/run-pass/item-attributes.rs +++ b/src/test/run-pass/item-attributes.rs @@ -195,13 +195,3 @@ fn test_fn_inner() { } pub fn main() { } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/test/run-pass/spawn.rs b/src/test/run-pass/spawn.rs index db4ca7b3ed8..63c2b7da38f 100644 --- a/src/test/run-pass/spawn.rs +++ b/src/test/run-pass/spawn.rs @@ -18,11 +18,3 @@ pub fn main() { } fn child(&&i: int) { error!(i); assert!((i == 10)); } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/test/run-pass/spawn2.rs b/src/test/run-pass/spawn2.rs index f9350746349..e748a1636ea 100644 --- a/src/test/run-pass/spawn2.rs +++ b/src/test/run-pass/spawn2.rs @@ -32,11 +32,3 @@ fn child(&&args: (int, int, int, int, int, int, int, int, int)) { assert!((i8 == 80)); assert!((i9 == 90)); } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs index 7cd08695da0..879f668577f 100644 --- a/src/test/run-pass/task-killjoin-rsrc.rs +++ b/src/test/run-pass/task-killjoin-rsrc.rs @@ -83,11 +83,3 @@ fn supervisor() { pub fn main() { join(joinable(supervisor)); } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/test/run-pass/task-killjoin.rs b/src/test/run-pass/task-killjoin.rs index 563e35be3d6..73c069e560c 100644 --- a/src/test/run-pass/task-killjoin.rs +++ b/src/test/run-pass/task-killjoin.rs @@ -33,11 +33,3 @@ fn supervisor() { pub fn main() { task::spawn_unlinked(supervisor) } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -- cgit 1.4.1-3-g733a5 From cce97ab8cb225c9ae5b9e8dca4f96bd750eebdb7 Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Thu, 2 May 2013 11:33:57 -0700 Subject: Add test for drop for newtype structs. --- src/test/run-pass/newtype-struct-drop-run.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/test/run-pass/newtype-struct-drop-run.rs (limited to 'src/test') diff --git a/src/test/run-pass/newtype-struct-drop-run.rs b/src/test/run-pass/newtype-struct-drop-run.rs new file mode 100644 index 00000000000..dd5da3b09bb --- /dev/null +++ b/src/test/run-pass/newtype-struct-drop-run.rs @@ -0,0 +1,28 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Make sure the destructor is run for newtype structs. + +struct Foo(@mut int); + +#[unsafe_destructor] +impl Drop for Foo { + fn finalize(&self) { + ***self = 23; + } +} + +fn main() { + let y = @mut 32; + { + let x = Foo(y); + } + assert_eq!(*y, 23); +} -- cgit 1.4.1-3-g733a5 From 32ebaacbc6dcd705562ac96af5c803f574284584 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 2 May 2013 14:12:55 -0700 Subject: re-xfail some tests that fail on x86 --- src/test/run-pass/tag-align-dyn-u64.rs | 2 ++ src/test/run-pass/tag-align-dyn-variants.rs | 2 ++ src/test/run-pass/tag-align-u64.rs | 1 + 3 files changed, 5 insertions(+) (limited to 'src/test') diff --git a/src/test/run-pass/tag-align-dyn-u64.rs b/src/test/run-pass/tag-align-dyn-u64.rs index 0fdf4e019a7..a09ee23f147 100644 --- a/src/test/run-pass/tag-align-dyn-u64.rs +++ b/src/test/run-pass/tag-align-dyn-u64.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-test + enum a_tag { a_tag(A) } diff --git a/src/test/run-pass/tag-align-dyn-variants.rs b/src/test/run-pass/tag-align-dyn-variants.rs index 96921f2a065..cd94bd30c21 100644 --- a/src/test/run-pass/tag-align-dyn-variants.rs +++ b/src/test/run-pass/tag-align-dyn-variants.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-test + enum a_tag { varA(A), varB(B) diff --git a/src/test/run-pass/tag-align-u64.rs b/src/test/run-pass/tag-align-u64.rs index 56d384e5fdb..ea60f389663 100644 --- a/src/test/run-pass/tag-align-u64.rs +++ b/src/test/run-pass/tag-align-u64.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-test enum a_tag { a_tag(u64) -- cgit 1.4.1-3-g733a5 From dc5df61bc1914224d50d92cdd5599b6337ac68f2 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 1 May 2013 17:54:54 -0700 Subject: librustc: Update the serializer to work properly with INHTWAMA, removing mutable fields in the process --- src/librustc/metadata/decoder.rs | 9 + src/librustc/metadata/encoder.rs | 1638 ++++++++++++++++++++++--- src/librustc/middle/astencode.rs | 888 ++++++++++++-- src/libstd/arena.rs | 4 +- src/libstd/ebml.rs | 818 +++++++++++- src/libstd/flatpipes.rs | 33 +- src/libstd/json.rs | 871 +++++++++++-- src/libstd/serialize.rs | 1145 ++++++++++++++++- src/libstd/workcache.rs | 53 +- src/libsyntax/ast.rs | 38 +- src/libsyntax/codemap.rs | 17 + src/libsyntax/ext/auto_encode.rs | 304 +++-- src/libsyntax/ext/deriving/decodable.rs | 49 +- src/libsyntax/ext/deriving/encodable.rs | 42 +- src/libsyntax/parse/mod.rs | 3 +- src/test/bench/shootout-binarytrees.rs | 23 +- src/test/run-pass/auto-encode.rs | 7 +- src/test/run-pass/issue-4036.rs | 3 +- src/test/run-pass/placement-new-arena.rs | 3 +- src/test/run-pass/regions-mock-trans-impls.rs | 28 +- 20 files changed, 5381 insertions(+), 595 deletions(-) (limited to 'src/test') diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 61454c802cc..1be49528b9e 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -272,12 +272,21 @@ fn item_ty_param_defs(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd, @bounds } +#[cfg(stage0)] fn item_ty_region_param(item: ebml::Doc) -> Option { reader::maybe_get_doc(item, tag_region_param).map(|doc| { Decodable::decode(&reader::Decoder(*doc)) }) } +#[cfg(not(stage0))] +fn item_ty_region_param(item: ebml::Doc) -> Option { + reader::maybe_get_doc(item, tag_region_param).map(|doc| { + let mut decoder = reader::Decoder(*doc); + Decodable::decode(&mut decoder) + }) +} + fn item_ty_param_count(item: ebml::Doc) -> uint { let mut n = 0u; reader::tagged_docs(item, tag_items_data_item_ty_param_bounds, diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 2a4334781e4..77373076137 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -42,11 +42,18 @@ use writer = std::ebml::writer; // used by astencode: type abbrev_map = @mut HashMap; +#[cfg(stage0)] pub type encode_inlined_item = @fn(ecx: @EncodeContext, ebml_w: &writer::Encoder, path: &[ast_map::path_elt], ii: ast::inlined_item); +#[cfg(not(stage0))] +pub type encode_inlined_item = @fn(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ast_map::path_elt], + ii: ast::inlined_item); + pub struct EncodeParams { diag: @span_handler, tcx: ty::ctxt, @@ -91,21 +98,47 @@ pub fn reachable(ecx: @EncodeContext, id: node_id) -> bool { ecx.reachable.contains(&id) } +#[cfg(stage0)] fn encode_name(ecx: @EncodeContext, ebml_w: &writer::Encoder, name: ident) { ebml_w.wr_tagged_str(tag_paths_data_name, *ecx.tcx.sess.str_of(name)); } -fn encode_impl_type_basename(ecx: @EncodeContext, ebml_w: &writer::Encoder, +#[cfg(not(stage0))] +fn encode_name(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + name: ident) { + ebml_w.wr_tagged_str(tag_paths_data_name, *ecx.tcx.sess.str_of(name)); +} + +#[cfg(stage0)] +fn encode_impl_type_basename(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + name: ident) { + ebml_w.wr_tagged_str(tag_item_impl_type_basename, + *ecx.tcx.sess.str_of(name)); +} + +#[cfg(not(stage0))] +fn encode_impl_type_basename(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, name: ident) { ebml_w.wr_tagged_str(tag_item_impl_type_basename, *ecx.tcx.sess.str_of(name)); } +#[cfg(stage0)] pub fn encode_def_id(ebml_w: &writer::Encoder, id: def_id) { ebml_w.wr_tagged_str(tag_def_id, def_to_str(id)); } -fn encode_region_param(ecx: @EncodeContext, ebml_w: &writer::Encoder, +#[cfg(not(stage0))] +pub fn encode_def_id(ebml_w: &mut writer::Encoder, id: def_id) { + ebml_w.wr_tagged_str(tag_def_id, def_to_str(id)); +} + +#[cfg(stage0)] +fn encode_region_param(ecx: @EncodeContext, + ebml_w: &writer::Encoder, it: @ast::item) { let opt_rp = ecx.tcx.region_paramd_items.find(&it.id); for opt_rp.each |rp| { @@ -115,6 +148,19 @@ fn encode_region_param(ecx: @EncodeContext, ebml_w: &writer::Encoder, } } +#[cfg(not(stage0))] +fn encode_region_param(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + it: @ast::item) { + let opt_rp = ecx.tcx.region_paramd_items.find(&it.id); + for opt_rp.each |rp| { + ebml_w.start_tag(tag_region_param); + rp.encode(ebml_w); + ebml_w.end_tag(); + } +} + +#[cfg(stage0)] fn encode_mutability(ebml_w: &writer::Encoder, mt: struct_mutability) { do ebml_w.wr_tag(tag_struct_mut) { let val = match mt { @@ -125,13 +171,45 @@ fn encode_mutability(ebml_w: &writer::Encoder, mt: struct_mutability) { } } +#[cfg(not(stage0))] +fn encode_mutability(ebml_w: &mut writer::Encoder, mt: struct_mutability) { + ebml_w.start_tag(tag_struct_mut); + let val = match mt { + struct_immutable => 'a', + struct_mutable => 'm' + }; + ebml_w.writer.write(&[val as u8]); + ebml_w.end_tag(); +} + struct entry { val: T, pos: uint } -fn add_to_index(ecx: @EncodeContext, ebml_w: &writer::Encoder, path: &[ident], - index: &mut ~[entry<~str>], name: ident) { +#[cfg(stage0)] +fn add_to_index(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + path: &[ident], + index: &mut ~[entry<~str>], + name: ident) { + let mut full_path = ~[]; + full_path.push_all(path); + full_path.push(name); + index.push( + entry { + val: ast_util::path_name_i(full_path, + ecx.tcx.sess.parse_sess.interner), + pos: ebml_w.writer.tell() + }); +} + +#[cfg(not(stage0))] +fn add_to_index(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ident], + index: &mut ~[entry<~str>], + name: ident) { let mut full_path = ~[]; full_path.push_all(path); full_path.push(name); @@ -143,11 +221,28 @@ fn add_to_index(ecx: @EncodeContext, ebml_w: &writer::Encoder, path: &[ident], }); } +#[cfg(stage0)] fn encode_trait_ref(ebml_w: &writer::Encoder, ecx: @EncodeContext, trait_ref: &ty::TraitRef, - tag: uint) -{ + tag: uint) { + let ty_str_ctxt = @tyencode::ctxt { + diag: ecx.diag, + ds: def_to_str, + tcx: ecx.tcx, + reachable: |a| reachable(ecx, a), + abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; + + ebml_w.start_tag(tag); + tyencode::enc_trait_ref(ebml_w.writer, ty_str_ctxt, trait_ref); + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_trait_ref(ebml_w: &mut writer::Encoder, + ecx: @EncodeContext, + trait_ref: &ty::TraitRef, + tag: uint) { let ty_str_ctxt = @tyencode::ctxt { diag: ecx.diag, ds: def_to_str, @@ -161,14 +256,26 @@ fn encode_trait_ref(ebml_w: &writer::Encoder, } // Item info table encoding +#[cfg(stage0)] fn encode_family(ebml_w: &writer::Encoder, c: char) { ebml_w.start_tag(tag_items_data_item_family); ebml_w.writer.write(&[c as u8]); ebml_w.end_tag(); } -pub fn def_to_str(did: def_id) -> ~str { fmt!("%d:%d", did.crate, did.node) } +// Item info table encoding +#[cfg(not(stage0))] +fn encode_family(ebml_w: &mut writer::Encoder, c: char) { + ebml_w.start_tag(tag_items_data_item_family); + ebml_w.writer.write(&[c as u8]); + ebml_w.end_tag(); +} + +pub fn def_to_str(did: def_id) -> ~str { + fmt!("%d:%d", did.crate, did.node) +} +#[cfg(stage0)] fn encode_ty_type_param_defs(ebml_w: &writer::Encoder, ecx: @EncodeContext, params: @~[ty::TypeParameterDef], @@ -186,6 +293,25 @@ fn encode_ty_type_param_defs(ebml_w: &writer::Encoder, } } +#[cfg(not(stage0))] +fn encode_ty_type_param_defs(ebml_w: &mut writer::Encoder, + ecx: @EncodeContext, + params: @~[ty::TypeParameterDef], + tag: uint) { + let ty_str_ctxt = @tyencode::ctxt { + diag: ecx.diag, + ds: def_to_str, + tcx: ecx.tcx, + reachable: |a| reachable(ecx, a), + abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; + for params.each |param| { + ebml_w.start_tag(tag); + tyencode::enc_type_param_def(ebml_w.writer, ty_str_ctxt, param); + ebml_w.end_tag(); + } +} + +#[cfg(stage0)] fn encode_type_param_bounds(ebml_w: &writer::Encoder, ecx: @EncodeContext, params: &OptVec) { @@ -195,13 +321,31 @@ fn encode_type_param_bounds(ebml_w: &writer::Encoder, tag_items_data_item_ty_param_bounds); } +#[cfg(not(stage0))] +fn encode_type_param_bounds(ebml_w: &mut writer::Encoder, + ecx: @EncodeContext, + params: &OptVec) { + let ty_param_defs = + @params.map_to_vec(|param| *ecx.tcx.ty_param_defs.get(¶m.id)); + encode_ty_type_param_defs(ebml_w, ecx, ty_param_defs, + tag_items_data_item_ty_param_bounds); +} +#[cfg(stage0)] fn encode_variant_id(ebml_w: &writer::Encoder, vid: def_id) { ebml_w.start_tag(tag_items_data_item_variant); ebml_w.writer.write(str::to_bytes(def_to_str(vid))); ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_variant_id(ebml_w: &mut writer::Encoder, vid: def_id) { + ebml_w.start_tag(tag_items_data_item_variant); + ebml_w.writer.write(str::to_bytes(def_to_str(vid))); + ebml_w.end_tag(); +} + +#[cfg(stage0)] pub fn write_type(ecx: @EncodeContext, ebml_w: &writer::Encoder, typ: ty::t) { let ty_str_ctxt = @tyencode::ctxt { diag: ecx.diag, @@ -212,7 +356,35 @@ pub fn write_type(ecx: @EncodeContext, ebml_w: &writer::Encoder, typ: ty::t) { tyencode::enc_ty(ebml_w.writer, ty_str_ctxt, typ); } -pub fn write_vstore(ecx: @EncodeContext, ebml_w: &writer::Encoder, +#[cfg(not(stage0))] +pub fn write_type(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + typ: ty::t) { + let ty_str_ctxt = @tyencode::ctxt { + diag: ecx.diag, + ds: def_to_str, + tcx: ecx.tcx, + reachable: |a| reachable(ecx, a), + abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; + tyencode::enc_ty(ebml_w.writer, ty_str_ctxt, typ); +} + +#[cfg(stage0)] +pub fn write_vstore(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + vstore: ty::vstore) { + let ty_str_ctxt = @tyencode::ctxt { + diag: ecx.diag, + ds: def_to_str, + tcx: ecx.tcx, + reachable: |a| reachable(ecx, a), + abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; + tyencode::enc_vstore(ebml_w.writer, ty_str_ctxt, vstore); +} + +#[cfg(not(stage0))] +pub fn write_vstore(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, vstore: ty::vstore) { let ty_str_ctxt = @tyencode::ctxt { diag: ecx.diag, @@ -223,16 +395,37 @@ pub fn write_vstore(ecx: @EncodeContext, ebml_w: &writer::Encoder, tyencode::enc_vstore(ebml_w.writer, ty_str_ctxt, vstore); } +#[cfg(stage0)] fn encode_type(ecx: @EncodeContext, ebml_w: &writer::Encoder, typ: ty::t) { ebml_w.start_tag(tag_items_data_item_type); write_type(ecx, ebml_w, typ); ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_type(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + typ: ty::t) { + ebml_w.start_tag(tag_items_data_item_type); + write_type(ecx, ebml_w, typ); + ebml_w.end_tag(); +} + +#[cfg(stage0)] fn encode_transformed_self_ty(ecx: @EncodeContext, ebml_w: &writer::Encoder, - opt_typ: Option) -{ + opt_typ: Option) { + for opt_typ.each |&typ| { + ebml_w.start_tag(tag_item_method_transformed_self_ty); + write_type(ecx, ebml_w, typ); + ebml_w.end_tag(); + } +} + +#[cfg(not(stage0))] +fn encode_transformed_self_ty(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + opt_typ: Option) { for opt_typ.each |&typ| { ebml_w.start_tag(tag_item_method_transformed_self_ty); write_type(ecx, ebml_w, typ); @@ -240,10 +433,27 @@ fn encode_transformed_self_ty(ecx: @EncodeContext, } } +#[cfg(stage0)] fn encode_method_fty(ecx: @EncodeContext, ebml_w: &writer::Encoder, - typ: &ty::BareFnTy) -{ + typ: &ty::BareFnTy) { + ebml_w.start_tag(tag_item_method_fty); + + let ty_str_ctxt = @tyencode::ctxt { + diag: ecx.diag, + ds: def_to_str, + tcx: ecx.tcx, + reachable: |a| reachable(ecx, a), + abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; + tyencode::enc_bare_fn_ty(ebml_w.writer, ty_str_ctxt, typ); + + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_method_fty(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + typ: &ty::BareFnTy) { ebml_w.start_tag(tag_item_method_fty); let ty_str_ctxt = @tyencode::ctxt { @@ -257,6 +467,7 @@ fn encode_method_fty(ecx: @EncodeContext, ebml_w.end_tag(); } +#[cfg(stage0)] fn encode_symbol(ecx: @EncodeContext, ebml_w: &writer::Encoder, id: node_id) { ebml_w.start_tag(tag_items_data_item_symbol); match ecx.item_symbols.find(&id) { @@ -272,28 +483,123 @@ fn encode_symbol(ecx: @EncodeContext, ebml_w: &writer::Encoder, id: node_id) { ebml_w.end_tag(); } -fn encode_discriminant(ecx: @EncodeContext, ebml_w: &writer::Encoder, +#[cfg(not(stage0))] +fn encode_symbol(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + id: node_id) { + ebml_w.start_tag(tag_items_data_item_symbol); + match ecx.item_symbols.find(&id) { + Some(x) => { + debug!("encode_symbol(id=%?, str=%s)", id, *x); + ebml_w.writer.write(str::to_bytes(*x)); + } + None => { + ecx.diag.handler().bug( + fmt!("encode_symbol: id not found %d", id)); + } + } + ebml_w.end_tag(); +} + +#[cfg(stage0)] +fn encode_discriminant(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + id: node_id) { + ebml_w.start_tag(tag_items_data_item_symbol); + ebml_w.writer.write(str::to_bytes(**ecx.discrim_symbols.get(&id))); + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_discriminant(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, id: node_id) { ebml_w.start_tag(tag_items_data_item_symbol); ebml_w.writer.write(str::to_bytes(**ecx.discrim_symbols.get(&id))); ebml_w.end_tag(); } -fn encode_disr_val(_ecx: @EncodeContext, ebml_w: &writer::Encoder, +#[cfg(stage0)] +fn encode_disr_val(_: @EncodeContext, + ebml_w: &writer::Encoder, disr_val: int) { ebml_w.start_tag(tag_disr_val); ebml_w.writer.write(str::to_bytes(int::to_str(disr_val))); ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_disr_val(_: @EncodeContext, + ebml_w: &mut writer::Encoder, + disr_val: int) { + ebml_w.start_tag(tag_disr_val); + ebml_w.writer.write(str::to_bytes(int::to_str(disr_val))); + ebml_w.end_tag(); +} + +#[cfg(stage0)] fn encode_parent_item(ebml_w: &writer::Encoder, id: def_id) { ebml_w.start_tag(tag_items_data_parent_item); ebml_w.writer.write(str::to_bytes(def_to_str(id))); ebml_w.end_tag(); } -fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: &writer::Encoder, - id: node_id, variants: &[variant], +#[cfg(not(stage0))] +fn encode_parent_item(ebml_w: &mut writer::Encoder, id: def_id) { + ebml_w.start_tag(tag_items_data_parent_item); + ebml_w.writer.write(str::to_bytes(def_to_str(id))); + ebml_w.end_tag(); +} + +#[cfg(stage0)] +fn encode_enum_variant_info(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + id: node_id, + variants: &[variant], + path: &[ast_map::path_elt], + index: @mut ~[entry], + generics: &ast::Generics) { + debug!("encode_enum_variant_info(id=%?)", id); + + let mut disr_val = 0; + let mut i = 0; + let vi = ty::enum_variants(ecx.tcx, + ast::def_id { crate: local_crate, node: id }); + for variants.each |variant| { + index.push(entry {val: variant.node.id, pos: ebml_w.writer.tell()}); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(variant.node.id)); + encode_family(ebml_w, 'v'); + encode_name(ecx, ebml_w, variant.node.name); + encode_parent_item(ebml_w, local_def(id)); + encode_type(ecx, ebml_w, + node_id_to_type(ecx.tcx, variant.node.id)); + match variant.node.kind { + ast::tuple_variant_kind(ref args) + if args.len() > 0 && generics.ty_params.len() == 0 => { + encode_symbol(ecx, ebml_w, variant.node.id); + } + ast::tuple_variant_kind(_) | ast::struct_variant_kind(_) => {} + } + encode_discriminant(ecx, ebml_w, variant.node.id); + if vi[i].disr_val != disr_val { + encode_disr_val(ecx, ebml_w, vi[i].disr_val); + disr_val = vi[i].disr_val; + } + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_path(ecx, ebml_w, path, + ast_map::path_name(variant.node.name)); + ebml_w.end_tag(); + disr_val += 1; + i += 1; + } +} + +#[cfg(not(stage0))] +fn encode_enum_variant_info(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + id: node_id, + variants: &[variant], path: &[ast_map::path_elt], index: @mut ~[entry], generics: &ast::Generics) { @@ -333,8 +639,11 @@ fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: &writer::Encoder, } } -fn encode_path(ecx: @EncodeContext, ebml_w: &writer::Encoder, - path: &[ast_map::path_elt], name: ast_map::path_elt) { +#[cfg(stage0)] +fn encode_path(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + path: &[ast_map::path_elt], + name: ast_map::path_elt) { fn encode_path_elt(ecx: @EncodeContext, ebml_w: &writer::Encoder, elt: ast_map::path_elt) { let (tag, name) = match elt { @@ -354,8 +663,37 @@ fn encode_path(ecx: @EncodeContext, ebml_w: &writer::Encoder, } } -fn encode_info_for_mod(ecx: @EncodeContext, ebml_w: &writer::Encoder, - md: &_mod, id: node_id, path: &[ast_map::path_elt], +#[cfg(not(stage0))] +fn encode_path(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ast_map::path_elt], + name: ast_map::path_elt) { + fn encode_path_elt(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + elt: ast_map::path_elt) { + let (tag, name) = match elt { + ast_map::path_mod(name) => (tag_path_elt_mod, name), + ast_map::path_name(name) => (tag_path_elt_name, name) + }; + + ebml_w.wr_tagged_str(tag, *ecx.tcx.sess.str_of(name)); + } + + ebml_w.start_tag(tag_path); + ebml_w.wr_tagged_u32(tag_path_len, (path.len() + 1) as u32); + for path.each |pe| { + encode_path_elt(ecx, ebml_w, *pe); + } + encode_path_elt(ecx, ebml_w, name); + ebml_w.end_tag(); +} + +#[cfg(stage0)] +fn encode_info_for_mod(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + md: &_mod, + id: node_id, + path: &[ast_map::path_elt], name: ident) { ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, local_def(id)); @@ -412,32 +750,164 @@ fn encode_info_for_mod(ecx: @EncodeContext, ebml_w: &writer::Encoder, ebml_w.end_tag(); } -fn encode_struct_field_family(ebml_w: &writer::Encoder, - visibility: visibility) { - encode_family(ebml_w, match visibility { - public => 'g', - private => 'j', - inherited => 'N' - }); -} - -fn encode_visibility(ebml_w: &writer::Encoder, visibility: visibility) { - ebml_w.start_tag(tag_items_data_item_visibility); - let ch = match visibility { - public => 'y', - private => 'n', - inherited => 'i', - }; - ebml_w.wr_str(str::from_char(ch)); - ebml_w.end_tag(); -} +#[cfg(not(stage0))] +fn encode_info_for_mod(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + md: &_mod, + id: node_id, + path: &[ast_map::path_elt], + name: ident) { + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(id)); + encode_family(ebml_w, 'm'); + encode_name(ecx, ebml_w, name); + debug!("(encoding info for module) encoding info for module ID %d", id); -fn encode_self_type(ebml_w: &writer::Encoder, self_type: ast::self_ty_) { - ebml_w.start_tag(tag_item_trait_method_self_ty); + // Encode info about all the module children. + for md.items.each |item| { + match item.node { + item_impl(*) => { + let (ident, did) = (item.ident, item.id); + debug!("(encoding info for module) ... encoding impl %s \ + (%?/%?)", + *ecx.tcx.sess.str_of(ident), + did, + ast_map::node_id_to_str(ecx.tcx.items, did, ecx.tcx + .sess.parse_sess.interner)); - // Encode the base self type. - match self_type { - sty_static => { + ebml_w.start_tag(tag_mod_impl); + ebml_w.wr_str(def_to_str(local_def(did))); + ebml_w.end_tag(); + } + _ => {} // FIXME #4573: Encode these too. + } + } + + encode_path(ecx, ebml_w, path, ast_map::path_mod(name)); + + // Encode the reexports of this module. + debug!("(encoding info for module) encoding reexports for %d", id); + match ecx.reexports2.find(&id) { + Some(ref exports) => { + debug!("(encoding info for module) found reexports for %d", id); + for exports.each |exp| { + debug!("(encoding info for module) reexport '%s' for %d", + *exp.name, id); + ebml_w.start_tag(tag_items_data_item_reexport); + ebml_w.start_tag(tag_items_data_item_reexport_def_id); + ebml_w.wr_str(def_to_str(exp.def_id)); + ebml_w.end_tag(); + ebml_w.start_tag(tag_items_data_item_reexport_name); + ebml_w.wr_str(*exp.name); + ebml_w.end_tag(); + ebml_w.end_tag(); + } + } + None => { + debug!("(encoding info for module) found no reexports for %d", + id); + } + } + + ebml_w.end_tag(); +} + +#[cfg(stage0)] +fn encode_struct_field_family(ebml_w: &writer::Encoder, + visibility: visibility) { + encode_family(ebml_w, match visibility { + public => 'g', + private => 'j', + inherited => 'N' + }); +} + +#[cfg(not(stage0))] +fn encode_struct_field_family(ebml_w: &mut writer::Encoder, + visibility: visibility) { + encode_family(ebml_w, match visibility { + public => 'g', + private => 'j', + inherited => 'N' + }); +} + +#[cfg(stage0)] +fn encode_visibility(ebml_w: &writer::Encoder, visibility: visibility) { + ebml_w.start_tag(tag_items_data_item_visibility); + let ch = match visibility { + public => 'y', + private => 'n', + inherited => 'i', + }; + ebml_w.wr_str(str::from_char(ch)); + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_visibility(ebml_w: &mut writer::Encoder, visibility: visibility) { + ebml_w.start_tag(tag_items_data_item_visibility); + let ch = match visibility { + public => 'y', + private => 'n', + inherited => 'i', + }; + ebml_w.wr_str(str::from_char(ch)); + ebml_w.end_tag(); +} + +#[cfg(stage0)] +fn encode_self_type(ebml_w: &writer::Encoder, self_type: ast::self_ty_) { + ebml_w.start_tag(tag_item_trait_method_self_ty); + + // Encode the base self type. + match self_type { + sty_static => { + ebml_w.writer.write(&[ 's' as u8 ]); + } + sty_value => { + ebml_w.writer.write(&[ 'v' as u8 ]); + } + sty_region(_, m) => { + // FIXME(#4846) encode custom lifetime + ebml_w.writer.write(&[ '&' as u8 ]); + encode_mutability(ebml_w, m); + } + sty_box(m) => { + ebml_w.writer.write(&[ '@' as u8 ]); + encode_mutability(ebml_w, m); + } + sty_uniq(m) => { + ebml_w.writer.write(&[ '~' as u8 ]); + encode_mutability(ebml_w, m); + } + } + + ebml_w.end_tag(); + + fn encode_mutability(ebml_w: &writer::Encoder, + m: ast::mutability) { + match m { + m_imm => { + ebml_w.writer.write(&[ 'i' as u8 ]); + } + m_mutbl => { + ebml_w.writer.write(&[ 'm' as u8 ]); + } + m_const => { + ebml_w.writer.write(&[ 'c' as u8 ]); + } + } + } +} + +#[cfg(not(stage0))] +fn encode_self_type(ebml_w: &mut writer::Encoder, self_type: ast::self_ty_) { + ebml_w.start_tag(tag_item_trait_method_self_ty); + + // Encode the base self type. + match self_type { + sty_static => { ebml_w.writer.write(&[ 's' as u8 ]); } sty_value => { @@ -476,17 +946,68 @@ fn encode_self_type(ebml_w: &writer::Encoder, self_type: ast::self_ty_) { } } +#[cfg(stage0)] fn encode_method_sort(ebml_w: &writer::Encoder, sort: char) { ebml_w.start_tag(tag_item_trait_method_sort); ebml_w.writer.write(&[ sort as u8 ]); ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_method_sort(ebml_w: &mut writer::Encoder, sort: char) { + ebml_w.start_tag(tag_item_trait_method_sort); + ebml_w.writer.write(&[ sort as u8 ]); + ebml_w.end_tag(); +} + /* Returns an index of items in this class */ -fn encode_info_for_struct(ecx: @EncodeContext, ebml_w: &writer::Encoder, - path: &[ast_map::path_elt], - fields: &[@struct_field], - global_index: @mut~[entry]) -> ~[entry] { +#[cfg(stage0)] +fn encode_info_for_struct(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + path: &[ast_map::path_elt], + fields: &[@struct_field], + global_index: @mut~[entry]) + -> ~[entry] { + /* Each class has its own index, since different classes + may have fields with the same name */ + let index = @mut ~[]; + let tcx = ecx.tcx; + /* We encode both private and public fields -- need to include + private fields to get the offsets right */ + for fields.each |field| { + let (nm, mt, vis) = match field.node.kind { + named_field(nm, mt, vis) => (nm, mt, vis), + unnamed_field => ( + special_idents::unnamed_field, + struct_immutable, + inherited + ) + }; + + let id = field.node.id; + index.push(entry {val: id, pos: ebml_w.writer.tell()}); + global_index.push(entry {val: id, pos: ebml_w.writer.tell()}); + ebml_w.start_tag(tag_items_data_item); + debug!("encode_info_for_struct: doing %s %d", + *tcx.sess.str_of(nm), id); + encode_struct_field_family(ebml_w, vis); + encode_name(ecx, ebml_w, nm); + encode_path(ecx, ebml_w, path, ast_map::path_name(nm)); + encode_type(ecx, ebml_w, node_id_to_type(tcx, id)); + encode_mutability(ebml_w, mt); + encode_def_id(ebml_w, local_def(id)); + ebml_w.end_tag(); + } + /*bad*/copy *index +} + +#[cfg(not(stage0))] +fn encode_info_for_struct(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ast_map::path_elt], + fields: &[@struct_field], + global_index: @mut ~[entry]) + -> ~[entry] { /* Each class has its own index, since different classes may have fields with the same name */ let index = @mut ~[]; @@ -521,6 +1042,7 @@ fn encode_info_for_struct(ecx: @EncodeContext, ebml_w: &writer::Encoder, } // This is for encoding info for ctors and dtors +#[cfg(stage0)] fn encode_info_for_ctor(ecx: @EncodeContext, ebml_w: &writer::Encoder, id: node_id, @@ -550,6 +1072,37 @@ fn encode_info_for_ctor(ecx: @EncodeContext, ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_info_for_ctor(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + id: node_id, + ident: ident, + path: &[ast_map::path_elt], + item: Option, + generics: &ast::Generics) { + ebml_w.start_tag(tag_items_data_item); + encode_name(ecx, ebml_w, ident); + encode_def_id(ebml_w, local_def(id)); + encode_family(ebml_w, purity_fn_family(ast::impure_fn)); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + let its_ty = node_id_to_type(ecx.tcx, id); + debug!("fn name = %s ty = %s its node id = %d", + *ecx.tcx.sess.str_of(ident), + ty_to_str(ecx.tcx, its_ty), id); + encode_type(ecx, ebml_w, its_ty); + encode_path(ecx, ebml_w, path, ast_map::path_name(ident)); + match item { + Some(it) => { + (ecx.encode_inlined_item)(ecx, ebml_w, path, it); + } + None => { + encode_symbol(ecx, ebml_w, id); + } + } + ebml_w.end_tag(); +} + +#[cfg(stage0)] fn encode_info_for_struct_ctor(ecx: @EncodeContext, ebml_w: &writer::Encoder, path: &[ast_map::path_elt], @@ -569,100 +1122,489 @@ fn encode_info_for_struct_ctor(ecx: @EncodeContext, encode_symbol(ecx, ebml_w, ctor_id); } - ebml_w.end_tag(); -} + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_info_for_struct_ctor(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ast_map::path_elt], + name: ast::ident, + ctor_id: node_id, + index: @mut ~[entry]) { + index.push(entry { val: ctor_id, pos: ebml_w.writer.tell() }); + + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(ctor_id)); + encode_family(ebml_w, 'f'); + encode_name(ecx, ebml_w, name); + encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, ctor_id)); + encode_path(ecx, ebml_w, path, ast_map::path_name(name)); + + if ecx.item_symbols.contains_key(&ctor_id) { + encode_symbol(ecx, ebml_w, ctor_id); + } + + ebml_w.end_tag(); +} + +#[cfg(stage0)] +fn encode_method_ty_fields(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + method_ty: &ty::method) { + encode_def_id(ebml_w, method_ty.def_id); + encode_name(ecx, ebml_w, method_ty.ident); + encode_ty_type_param_defs(ebml_w, ecx, + method_ty.generics.type_param_defs, + tag_item_method_tps); + encode_transformed_self_ty(ecx, ebml_w, method_ty.transformed_self_ty); + encode_method_fty(ecx, ebml_w, &method_ty.fty); + encode_visibility(ebml_w, method_ty.vis); + encode_self_type(ebml_w, method_ty.self_ty); +} + +#[cfg(not(stage0))] +fn encode_method_ty_fields(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + method_ty: &ty::method) { + encode_def_id(ebml_w, method_ty.def_id); + encode_name(ecx, ebml_w, method_ty.ident); + encode_ty_type_param_defs(ebml_w, ecx, + method_ty.generics.type_param_defs, + tag_item_method_tps); + encode_transformed_self_ty(ecx, ebml_w, method_ty.transformed_self_ty); + encode_method_fty(ecx, ebml_w, &method_ty.fty); + encode_visibility(ebml_w, method_ty.vis); + encode_self_type(ebml_w, method_ty.self_ty); +} + +#[cfg(stage0)] +fn encode_info_for_method(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + impl_path: &[ast_map::path_elt], + should_inline: bool, + parent_id: node_id, + m: @method, + owner_generics: &ast::Generics, + method_generics: &ast::Generics) { + debug!("encode_info_for_method: %d %s %u %u", m.id, + *ecx.tcx.sess.str_of(m.ident), + owner_generics.ty_params.len(), + method_generics.ty_params.len()); + ebml_w.start_tag(tag_items_data_item); + + let method_def_id = local_def(m.id); + let method_ty: @ty::method = ty::method(ecx.tcx, method_def_id); + encode_method_ty_fields(ecx, ebml_w, method_ty); + + match m.self_ty.node { + ast::sty_static => { + encode_family(ebml_w, purity_static_method_family(m.purity)); + } + _ => encode_family(ebml_w, purity_fn_family(m.purity)) + } + + let mut combined_ty_params = opt_vec::Empty; + combined_ty_params.push_all(&owner_generics.ty_params); + combined_ty_params.push_all(&method_generics.ty_params); + let len = combined_ty_params.len(); + encode_type_param_bounds(ebml_w, ecx, &combined_ty_params); + + encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, m.id)); + encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident)); + + if len > 0u || should_inline { + (ecx.encode_inlined_item)( + ecx, ebml_w, impl_path, + ii_method(local_def(parent_id), m)); + } else { + encode_symbol(ecx, ebml_w, m.id); + } + + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_info_for_method(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + impl_path: &[ast_map::path_elt], + should_inline: bool, + parent_id: node_id, + m: @method, + owner_generics: &ast::Generics, + method_generics: &ast::Generics) { + debug!("encode_info_for_method: %d %s %u %u", m.id, + *ecx.tcx.sess.str_of(m.ident), + owner_generics.ty_params.len(), + method_generics.ty_params.len()); + ebml_w.start_tag(tag_items_data_item); + + let method_def_id = local_def(m.id); + let method_ty: @ty::method = ty::method(ecx.tcx, method_def_id); + encode_method_ty_fields(ecx, ebml_w, method_ty); + + match m.self_ty.node { + ast::sty_static => { + encode_family(ebml_w, purity_static_method_family(m.purity)); + } + _ => encode_family(ebml_w, purity_fn_family(m.purity)) + } + + let mut combined_ty_params = opt_vec::Empty; + combined_ty_params.push_all(&owner_generics.ty_params); + combined_ty_params.push_all(&method_generics.ty_params); + let len = combined_ty_params.len(); + encode_type_param_bounds(ebml_w, ecx, &combined_ty_params); + + encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, m.id)); + encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident)); + + if len > 0u || should_inline { + (ecx.encode_inlined_item)( + ecx, ebml_w, impl_path, + ii_method(local_def(parent_id), m)); + } else { + encode_symbol(ecx, ebml_w, m.id); + } + + ebml_w.end_tag(); +} + +fn purity_fn_family(p: purity) -> char { + match p { + unsafe_fn => 'u', + pure_fn => 'p', + impure_fn => 'f', + extern_fn => 'e' + } +} + +fn purity_static_method_family(p: purity) -> char { + match p { + unsafe_fn => 'U', + pure_fn => 'P', + impure_fn => 'F', + _ => fail!(~"extern fn can't be static") + } +} + + +fn should_inline(attrs: &[attribute]) -> bool { + match attr::find_inline_attr(attrs) { + attr::ia_none | attr::ia_never => false, + attr::ia_hint | attr::ia_always => true + } +} + +#[cfg(stage0)] +fn encode_info_for_item(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + item: @item, + index: @mut ~[entry], + path: &[ast_map::path_elt]) { + let tcx = ecx.tcx; + let must_write = + match item.node { + item_enum(_, _) | item_impl(*) | item_trait(*) | item_struct(*) | + item_mod(*) | item_foreign_mod(*) | item_const(*) => true, + _ => false + }; + if !must_write && !reachable(ecx, item.id) { return; } + + fn add_to_index_(item: @item, ebml_w: &writer::Encoder, + index: @mut ~[entry]) { + index.push(entry { val: item.id, pos: ebml_w.writer.tell() }); + } + let add_to_index: &fn() = || add_to_index_(item, ebml_w, index); + + debug!("encoding info for item at %s", + ecx.tcx.sess.codemap.span_to_str(item.span)); + + match item.node { + item_const(_, _) => { + add_to_index(); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 'c'); + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + encode_symbol(ecx, ebml_w, item.id); + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item)); + ebml_w.end_tag(); + } + item_fn(_, purity, _, ref generics, _) => { + add_to_index(); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, purity_fn_family(purity)); + let tps_len = generics.ty_params.len(); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_attributes(ebml_w, item.attrs); + if tps_len > 0u || should_inline(item.attrs) { + (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item)); + } else { + encode_symbol(ecx, ebml_w, item.id); + } + ebml_w.end_tag(); + } + item_mod(ref m) => { + add_to_index(); + encode_info_for_mod(ecx, ebml_w, m, item.id, path, item.ident); + } + item_foreign_mod(_) => { + add_to_index(); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 'n'); + encode_name(ecx, ebml_w, item.ident); + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + ebml_w.end_tag(); + } + item_ty(_, ref generics) => { + add_to_index(); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 'y'); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + encode_name(ecx, ebml_w, item.ident); + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_region_param(ecx, ebml_w, item); + ebml_w.end_tag(); + } + item_enum(ref enum_definition, ref generics) => { + add_to_index(); + do ebml_w.wr_tag(tag_items_data_item) { + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 't'); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + encode_name(ecx, ebml_w, item.ident); + for (*enum_definition).variants.each |v| { + encode_variant_id(ebml_w, local_def(v.node.id)); + } + (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item)); + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_region_param(ecx, ebml_w, item); + } + encode_enum_variant_info(ecx, + ebml_w, + item.id, + (*enum_definition).variants, + path, + index, + generics); + } + item_struct(struct_def, ref generics) => { + /* First, encode the fields + These come first because we need to write them to make + the index, and the index needs to be in the item for the + class itself */ + let idx = encode_info_for_struct(ecx, ebml_w, path, + struct_def.fields, index); + + /* Index the class*/ + add_to_index(); + + /* Now, make an item for the class itself */ + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 'S'); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + + // If this is a tuple- or enum-like struct, encode the type of the + // constructor. + if struct_def.fields.len() > 0 && + struct_def.fields[0].node.kind == ast::unnamed_field { + let ctor_id = match struct_def.ctor_id { + Some(ctor_id) => ctor_id, + None => ecx.tcx.sess.bug(~"struct def didn't have ctor id"), + }; + + encode_info_for_struct_ctor(ecx, + ebml_w, + path, + item.ident, + ctor_id, + index); + } + + encode_name(ecx, ebml_w, item.ident); + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_region_param(ecx, ebml_w, item); + + /* Encode def_ids for each field and method + for methods, write all the stuff get_trait_method + needs to know*/ + for struct_def.fields.each |f| { + match f.node.kind { + named_field(ident, _, vis) => { + ebml_w.start_tag(tag_item_field); + encode_struct_field_family(ebml_w, vis); + encode_name(ecx, ebml_w, ident); + encode_def_id(ebml_w, local_def(f.node.id)); + ebml_w.end_tag(); + } + unnamed_field => { + ebml_w.start_tag(tag_item_unnamed_field); + encode_def_id(ebml_w, local_def(f.node.id)); + ebml_w.end_tag(); + } + } + } + + /* Each class has its own index -- encode it */ + let bkts = create_index(idx); + encode_index(ebml_w, bkts, write_int); + ebml_w.end_tag(); + } + item_impl(ref generics, opt_trait, ty, ref methods) => { + add_to_index(); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 'i'); + encode_region_param(ecx, ebml_w, item); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + encode_name(ecx, ebml_w, item.ident); + encode_attributes(ebml_w, item.attrs); + match ty.node { + ast::ty_path(path, _) if path.idents.len() == 1 => { + encode_impl_type_basename(ecx, ebml_w, + ast_util::path_to_ident(path)); + } + _ => {} + } + for methods.each |m| { + ebml_w.start_tag(tag_item_impl_method); + let method_def_id = local_def(m.id); + ebml_w.writer.write(str::to_bytes(def_to_str(method_def_id))); + ebml_w.end_tag(); + } + for opt_trait.each |ast_trait_ref| { + let trait_ref = ty::node_id_to_trait_ref(ecx.tcx, ast_trait_ref.ref_id); + encode_trait_ref(ebml_w, ecx, trait_ref, tag_item_trait_ref); + } + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + ebml_w.end_tag(); + + // >:-< + let mut impl_path = vec::append(~[], path); + impl_path += ~[ast_map::path_name(item.ident)]; + + for methods.each |m| { + index.push(entry {val: m.id, pos: ebml_w.writer.tell()}); + encode_info_for_method(ecx, + ebml_w, + impl_path, + should_inline(m.attrs), + item.id, + *m, + generics, + &m.generics); + } + } + item_trait(ref generics, ref super_traits, ref ms) => { + add_to_index(); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 'I'); + encode_region_param(ecx, ebml_w, item); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + let trait_def = ty::lookup_trait_def(tcx, local_def(item.id)); + encode_trait_ref(ebml_w, ecx, trait_def.trait_ref, tag_item_trait_ref); + encode_name(ecx, ebml_w, item.ident); + encode_attributes(ebml_w, item.attrs); + for ty::trait_method_def_ids(tcx, local_def(item.id)).each |&method_def_id| { + ebml_w.start_tag(tag_item_trait_method); + encode_def_id(ebml_w, method_def_id); + ebml_w.end_tag(); + } + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + for super_traits.each |ast_trait_ref| { + let trait_ref = ty::node_id_to_trait_ref(ecx.tcx, ast_trait_ref.ref_id); + encode_trait_ref(ebml_w, ecx, trait_ref, tag_item_super_trait_ref); + } + ebml_w.end_tag(); + + // Now output the method info for each method. + for ty::trait_method_def_ids(tcx, local_def(item.id)).eachi |i, &method_def_id| { + assert!(method_def_id.crate == ast::local_crate); -fn encode_method_ty_fields(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - method_ty: &ty::method) -{ - encode_def_id(ebml_w, method_ty.def_id); - encode_name(ecx, ebml_w, method_ty.ident); - encode_ty_type_param_defs(ebml_w, ecx, - method_ty.generics.type_param_defs, - tag_item_method_tps); - encode_transformed_self_ty(ecx, ebml_w, method_ty.transformed_self_ty); - encode_method_fty(ecx, ebml_w, &method_ty.fty); - encode_visibility(ebml_w, method_ty.vis); - encode_self_type(ebml_w, method_ty.self_ty); -} + let method_ty: @ty::method = ty::method(tcx, method_def_id); -fn encode_info_for_method(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - impl_path: &[ast_map::path_elt], - should_inline: bool, - parent_id: node_id, - m: @method, - owner_generics: &ast::Generics, - method_generics: &ast::Generics) { - debug!("encode_info_for_method: %d %s %u %u", m.id, - *ecx.tcx.sess.str_of(m.ident), - owner_generics.ty_params.len(), - method_generics.ty_params.len()); - ebml_w.start_tag(tag_items_data_item); + index.push(entry {val: method_def_id.node, pos: ebml_w.writer.tell()}); - let method_def_id = local_def(m.id); - let method_ty: @ty::method = ty::method(ecx.tcx, method_def_id); - encode_method_ty_fields(ecx, ebml_w, method_ty); + ebml_w.start_tag(tag_items_data_item); - match m.self_ty.node { - ast::sty_static => { - encode_family(ebml_w, purity_static_method_family(m.purity)); - } - _ => encode_family(ebml_w, purity_fn_family(m.purity)) - } + encode_method_ty_fields(ecx, ebml_w, method_ty); - let mut combined_ty_params = opt_vec::Empty; - combined_ty_params.push_all(&owner_generics.ty_params); - combined_ty_params.push_all(&method_generics.ty_params); - let len = combined_ty_params.len(); - encode_type_param_bounds(ebml_w, ecx, &combined_ty_params); + encode_parent_item(ebml_w, local_def(item.id)); - encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, m.id)); - encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident)); + let mut trait_path = vec::append(~[], path); + trait_path.push(ast_map::path_name(item.ident)); + encode_path(ecx, ebml_w, trait_path, ast_map::path_name(method_ty.ident)); - if len > 0u || should_inline { - (ecx.encode_inlined_item)( - ecx, ebml_w, impl_path, - ii_method(local_def(parent_id), m)); - } else { - encode_symbol(ecx, ebml_w, m.id); - } + match method_ty.self_ty { + sty_static => { + encode_family(ebml_w, + purity_static_method_family( + method_ty.fty.purity)); - ebml_w.end_tag(); -} + let tpt = ty::lookup_item_type(tcx, method_def_id); + encode_ty_type_param_defs(ebml_w, ecx, + tpt.generics.type_param_defs, + tag_items_data_item_ty_param_bounds); + encode_type(ecx, ebml_w, tpt.ty); + } -fn purity_fn_family(p: purity) -> char { - match p { - unsafe_fn => 'u', - pure_fn => 'p', - impure_fn => 'f', - extern_fn => 'e' - } -} + _ => { + encode_family(ebml_w, + purity_fn_family( + method_ty.fty.purity)); + } + } -fn purity_static_method_family(p: purity) -> char { - match p { - unsafe_fn => 'U', - pure_fn => 'P', - impure_fn => 'F', - _ => fail!(~"extern fn can't be static") - } -} + match ms[i] { + required(_) => { + encode_method_sort(ebml_w, 'r'); + } + provided(m) => { + // This is obviously a bogus assert but I don't think this + // ever worked before anyhow...near as I can tell, before + // we would emit two items. + if method_ty.self_ty == sty_static { + tcx.sess.span_unimpl( + item.span, + fmt!("Method %s is both provided and static", + *tcx.sess.intr().get(method_ty.ident))); + } + encode_type_param_bounds(ebml_w, ecx, + &m.generics.ty_params); + encode_method_sort(ebml_w, 'p'); + (ecx.encode_inlined_item)( + ecx, ebml_w, path, + ii_method(local_def(item.id), m)); + } + } -fn should_inline(attrs: &[attribute]) -> bool { - match attr::find_inline_attr(attrs) { - attr::ia_none | attr::ia_never => false, - attr::ia_hint | attr::ia_always => true + ebml_w.end_tag(); + } + } + item_mac(*) => fail!(~"item macros unimplemented") } } - -fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder, - item: @item, index: @mut ~[entry], +#[cfg(not(stage0))] +fn encode_info_for_item(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + item: @item, + index: @mut ~[entry], path: &[ast_map::path_elt]) { - let tcx = ecx.tcx; let must_write = match item.node { @@ -737,19 +1679,21 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder, } item_enum(ref enum_definition, ref generics) => { add_to_index(); - do ebml_w.wr_tag(tag_items_data_item) { - encode_def_id(ebml_w, local_def(item.id)); - encode_family(ebml_w, 't'); - encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); - encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); - encode_name(ecx, ebml_w, item.ident); - for (*enum_definition).variants.each |v| { - encode_variant_id(ebml_w, local_def(v.node.id)); - } - (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item)); - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); - encode_region_param(ecx, ebml_w, item); + + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 't'); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + encode_name(ecx, ebml_w, item.ident); + for (*enum_definition).variants.each |v| { + encode_variant_id(ebml_w, local_def(v.node.id)); } + (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item)); + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_region_param(ecx, ebml_w, item); + ebml_w.end_tag(); + encode_enum_variant_info(ecx, ebml_w, item.id, @@ -960,6 +1904,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder, } } +#[cfg(stage0)] fn encode_info_for_foreign_item(ecx: @EncodeContext, ebml_w: &writer::Encoder, nitem: @foreign_item, @@ -994,8 +1939,46 @@ fn encode_info_for_foreign_item(ecx: @EncodeContext, ebml_w.end_tag(); } -fn encode_info_for_items(ecx: @EncodeContext, ebml_w: &writer::Encoder, - crate: &crate) -> ~[entry] { +#[cfg(not(stage0))] +fn encode_info_for_foreign_item(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + nitem: @foreign_item, + index: @mut ~[entry], + path: ast_map::path, + abi: AbiSet) { + if !reachable(ecx, nitem.id) { return; } + index.push(entry { val: nitem.id, pos: ebml_w.writer.tell() }); + + ebml_w.start_tag(tag_items_data_item); + match nitem.node { + foreign_item_fn(_, purity, ref generics) => { + encode_def_id(ebml_w, local_def(nitem.id)); + encode_family(ebml_w, purity_fn_family(purity)); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, nitem.id)); + if abi.is_intrinsic() { + (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_foreign(nitem)); + } else { + encode_symbol(ecx, ebml_w, nitem.id); + } + encode_path(ecx, ebml_w, path, ast_map::path_name(nitem.ident)); + } + foreign_item_const(*) => { + encode_def_id(ebml_w, local_def(nitem.id)); + encode_family(ebml_w, 'c'); + encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, nitem.id)); + encode_symbol(ecx, ebml_w, nitem.id); + encode_path(ecx, ebml_w, path, ast_map::path_name(nitem.ident)); + } + } + ebml_w.end_tag(); +} + +#[cfg(stage0)] +fn encode_info_for_items(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + crate: &crate) + -> ~[entry] { let index = @mut ~[]; ebml_w.start_tag(tag_items_data); index.push(entry { val: crate_node_id, pos: ebml_w.writer.tell() }); @@ -1038,6 +2021,57 @@ fn encode_info_for_items(ecx: @EncodeContext, ebml_w: &writer::Encoder, return /*bad*/copy *index; } +#[cfg(not(stage0))] +fn encode_info_for_items(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + crate: &crate) + -> ~[entry] { + let index = @mut ~[]; + ebml_w.start_tag(tag_items_data); + index.push(entry { val: crate_node_id, pos: ebml_w.writer.tell() }); + encode_info_for_mod(ecx, ebml_w, &crate.node.module, + crate_node_id, ~[], + syntax::parse::token::special_idents::invalid); + visit::visit_crate(crate, (), visit::mk_vt(@visit::Visitor { + visit_expr: |_e, _cx, _v| { }, + visit_item: { + let ebml_w = copy *ebml_w; + |i, cx, v| { + visit::visit_item(i, cx, v); + match *ecx.tcx.items.get(&i.id) { + ast_map::node_item(_, pt) => { + let mut ebml_w = copy ebml_w; + encode_info_for_item(ecx, &mut ebml_w, i, index, *pt); + } + _ => fail!(~"bad item") + } + } + }, + visit_foreign_item: { + let ebml_w = copy *ebml_w; + |ni, cx, v| { + visit::visit_foreign_item(ni, cx, v); + match *ecx.tcx.items.get(&ni.id) { + ast_map::node_foreign_item(_, abi, _, pt) => { + let mut ebml_w = copy ebml_w; + encode_info_for_foreign_item(ecx, + &mut ebml_w, + ni, + index, + /*bad*/copy *pt, + abi); + } + // case for separate item and foreign-item tables + _ => fail!(~"bad foreign item") + } + } + }, + ..*visit::default_visitor() + })); + ebml_w.end_tag(); + return /*bad*/copy *index; +} + // Path and definition ID indexing @@ -1049,15 +2083,47 @@ fn create_index(index: ~[entry]) -> let h = elt.val.hash() as uint; buckets[h % 256].push(*elt); } - - let mut buckets_frozen = ~[]; - for buckets.each |bucket| { - buckets_frozen.push(@/*bad*/copy **bucket); + + let mut buckets_frozen = ~[]; + for buckets.each |bucket| { + buckets_frozen.push(@/*bad*/copy **bucket); + } + return buckets_frozen; +} + +#[cfg(stage0)] +fn encode_index(ebml_w: &writer::Encoder, + buckets: ~[@~[entry]], + write_fn: &fn(@io::Writer, &T)) { + let writer = ebml_w.writer; + ebml_w.start_tag(tag_index); + let mut bucket_locs: ~[uint] = ~[]; + ebml_w.start_tag(tag_index_buckets); + for buckets.each |bucket| { + bucket_locs.push(ebml_w.writer.tell()); + ebml_w.start_tag(tag_index_buckets_bucket); + for vec::each(**bucket) |elt| { + ebml_w.start_tag(tag_index_buckets_bucket_elt); + assert!(elt.pos < 0xffff_ffff); + writer.write_be_u32(elt.pos as u32); + write_fn(writer, &elt.val); + ebml_w.end_tag(); + } + ebml_w.end_tag(); + } + ebml_w.end_tag(); + ebml_w.start_tag(tag_index_table); + for bucket_locs.each |pos| { + assert!(*pos < 0xffff_ffff); + writer.write_be_u32(*pos as u32); } - return buckets_frozen; + ebml_w.end_tag(); + ebml_w.end_tag(); } -fn encode_index(ebml_w: &writer::Encoder, buckets: ~[@~[entry]], +#[cfg(not(stage0))] +fn encode_index(ebml_w: &mut writer::Encoder, + buckets: ~[@~[entry]], write_fn: &fn(@io::Writer, &T)) { let writer = ebml_w.writer; ebml_w.start_tag(tag_index); @@ -1085,13 +2151,16 @@ fn encode_index(ebml_w: &writer::Encoder, buckets: ~[@~[entry]], ebml_w.end_tag(); } -fn write_str(writer: @io::Writer, s: ~str) { writer.write_str(s); } +fn write_str(writer: @io::Writer, s: ~str) { + writer.write_str(s); +} fn write_int(writer: @io::Writer, &n: &int) { assert!(n < 0x7fff_ffff); writer.write_be_u32(n as u32); } +#[cfg(stage0)] fn encode_meta_item(ebml_w: &writer::Encoder, mi: @meta_item) { match mi.node { meta_word(name) => { @@ -1129,6 +2198,45 @@ fn encode_meta_item(ebml_w: &writer::Encoder, mi: @meta_item) { } } +#[cfg(not(stage0))] +fn encode_meta_item(ebml_w: &mut writer::Encoder, mi: @meta_item) { + match mi.node { + meta_word(name) => { + ebml_w.start_tag(tag_meta_item_word); + ebml_w.start_tag(tag_meta_item_name); + ebml_w.writer.write(str::to_bytes(*name)); + ebml_w.end_tag(); + ebml_w.end_tag(); + } + meta_name_value(name, value) => { + match value.node { + lit_str(value) => { + ebml_w.start_tag(tag_meta_item_name_value); + ebml_w.start_tag(tag_meta_item_name); + ebml_w.writer.write(str::to_bytes(*name)); + ebml_w.end_tag(); + ebml_w.start_tag(tag_meta_item_value); + ebml_w.writer.write(str::to_bytes(*value)); + ebml_w.end_tag(); + ebml_w.end_tag(); + } + _ => {/* FIXME (#623): encode other variants */ } + } + } + meta_list(name, ref items) => { + ebml_w.start_tag(tag_meta_item_list); + ebml_w.start_tag(tag_meta_item_name); + ebml_w.writer.write(str::to_bytes(*name)); + ebml_w.end_tag(); + for items.each |inner_item| { + encode_meta_item(ebml_w, *inner_item); + } + ebml_w.end_tag(); + } + } +} + +#[cfg(stage0)] fn encode_attributes(ebml_w: &writer::Encoder, attrs: &[attribute]) { ebml_w.start_tag(tag_attributes); for attrs.each |attr| { @@ -1139,6 +2247,17 @@ fn encode_attributes(ebml_w: &writer::Encoder, attrs: &[attribute]) { ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_attributes(ebml_w: &mut writer::Encoder, attrs: &[attribute]) { + ebml_w.start_tag(tag_attributes); + for attrs.each |attr| { + ebml_w.start_tag(tag_attribute); + encode_meta_item(ebml_w, attr.node.value); + ebml_w.end_tag(); + } + ebml_w.end_tag(); +} + // So there's a special crate attribute called 'link' which defines the // metadata that Rust cares about for linking crates. This attribute requires // 'name' and 'vers' items, so if the user didn't provide them we will throw @@ -1193,6 +2312,7 @@ fn synthesize_crate_attrs(ecx: @EncodeContext, return attrs; } +#[cfg(stage0)] fn encode_crate_deps(ecx: @EncodeContext, ebml_w: &writer::Encoder, cstore: @mut cstore::CStore) { @@ -1235,6 +2355,50 @@ fn encode_crate_deps(ecx: @EncodeContext, ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_crate_deps(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + cstore: @mut cstore::CStore) { + fn get_ordered_deps(ecx: @EncodeContext, cstore: @mut cstore::CStore) + -> ~[decoder::crate_dep] { + type numdep = decoder::crate_dep; + + // Pull the cnums and name,vers,hash out of cstore + let mut deps = ~[]; + do cstore::iter_crate_data(cstore) |key, val| { + let dep = decoder::crate_dep {cnum: key, + name: ecx.tcx.sess.ident_of(/*bad*/ copy *val.name), + vers: decoder::get_crate_vers(val.data), + hash: decoder::get_crate_hash(val.data)}; + deps.push(dep); + }; + + // Sort by cnum + std::sort::quick_sort(deps, |kv1, kv2| kv1.cnum <= kv2.cnum); + + // Sanity-check the crate numbers + let mut expected_cnum = 1; + for deps.each |n| { + assert!((n.cnum == expected_cnum)); + expected_cnum += 1; + } + + // mut -> immutable hack for vec::map + deps.slice(0, deps.len()).to_owned() + } + + // We're just going to write a list of crate 'name-hash-version's, with + // the assumption that they are numbered 1 to n. + // FIXME (#2166): This is not nearly enough to support correct versioning + // but is enough to get transitive crate dependencies working. + ebml_w.start_tag(tag_crate_deps); + for get_ordered_deps(ecx, cstore).each |dep| { + encode_crate_dep(ecx, ebml_w, *dep); + } + ebml_w.end_tag(); +} + +#[cfg(stage0)] fn encode_lang_items(ecx: @EncodeContext, ebml_w: &writer::Encoder) { ebml_w.start_tag(tag_lang_items); @@ -1259,8 +2423,47 @@ fn encode_lang_items(ecx: @EncodeContext, ebml_w: &writer::Encoder) { ebml_w.end_tag(); // tag_lang_items } -fn encode_link_args(ecx: @EncodeContext, - ebml_w: &writer::Encoder) { +#[cfg(not(stage0))] +fn encode_lang_items(ecx: @EncodeContext, ebml_w: &mut writer::Encoder) { + ebml_w.start_tag(tag_lang_items); + + for ecx.tcx.lang_items.each_item |def_id, i| { + if def_id.crate != local_crate { + loop; + } + + ebml_w.start_tag(tag_lang_items_item); + + ebml_w.start_tag(tag_lang_items_item_id); + ebml_w.writer.write_be_u32(i as u32); + ebml_w.end_tag(); // tag_lang_items_item_id + + ebml_w.start_tag(tag_lang_items_item_node_id); + ebml_w.writer.write_be_u32(def_id.node as u32); + ebml_w.end_tag(); // tag_lang_items_item_node_id + + ebml_w.end_tag(); // tag_lang_items_item + } + + ebml_w.end_tag(); // tag_lang_items +} + +#[cfg(stage0)] +fn encode_link_args(ecx: @EncodeContext, ebml_w: &writer::Encoder) { + ebml_w.start_tag(tag_link_args); + + let link_args = cstore::get_used_link_args(ecx.cstore); + for link_args.each |link_arg| { + ebml_w.start_tag(tag_link_args_arg); + ebml_w.writer.write_str(link_arg.to_str()); + ebml_w.end_tag(); + } + + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_link_args(ecx: @EncodeContext, ebml_w: &mut writer::Encoder) { ebml_w.start_tag(tag_link_args); let link_args = cstore::get_used_link_args(ecx.cstore); @@ -1273,7 +2476,26 @@ fn encode_link_args(ecx: @EncodeContext, ebml_w.end_tag(); } -fn encode_crate_dep(ecx: @EncodeContext, ebml_w: &writer::Encoder, +#[cfg(stage0)] +fn encode_crate_dep(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + dep: decoder::crate_dep) { + ebml_w.start_tag(tag_crate_dep); + ebml_w.start_tag(tag_crate_dep_name); + ebml_w.writer.write(str::to_bytes(*ecx.tcx.sess.str_of(dep.name))); + ebml_w.end_tag(); + ebml_w.start_tag(tag_crate_dep_vers); + ebml_w.writer.write(str::to_bytes(*dep.vers)); + ebml_w.end_tag(); + ebml_w.start_tag(tag_crate_dep_hash); + ebml_w.writer.write(str::to_bytes(*dep.hash)); + ebml_w.end_tag(); + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_crate_dep(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, dep: decoder::crate_dep) { ebml_w.start_tag(tag_crate_dep); ebml_w.start_tag(tag_crate_dep_name); @@ -1288,12 +2510,20 @@ fn encode_crate_dep(ecx: @EncodeContext, ebml_w: &writer::Encoder, ebml_w.end_tag(); } +#[cfg(stage0)] fn encode_hash(ebml_w: &writer::Encoder, hash: &str) { ebml_w.start_tag(tag_crate_hash); ebml_w.writer.write(str::to_bytes(hash)); ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_hash(ebml_w: &mut writer::Encoder, hash: &str) { + ebml_w.start_tag(tag_crate_hash); + ebml_w.writer.write(str::to_bytes(hash)); + ebml_w.end_tag(); +} + // NB: Increment this as you change the metadata encoding version. pub static metadata_encoding_version : &'static [u8] = &[0x72, //'r' as u8, @@ -1302,6 +2532,7 @@ pub static metadata_encoding_version : &'static [u8] = 0x74, //'t' as u8, 0, 0, 0, 1 ]; +#[cfg(stage0)] pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] { let wr = @io::BytesWriter(); let stats = Stats { @@ -1408,6 +2639,113 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] { }) + flate::deflate_bytes(wr.bytes) } +#[cfg(not(stage0))] +pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] { + let wr = @io::BytesWriter(); + let stats = Stats { + inline_bytes: 0, + attr_bytes: 0, + dep_bytes: 0, + lang_item_bytes: 0, + link_args_bytes: 0, + item_bytes: 0, + index_bytes: 0, + zero_bytes: 0, + total_bytes: 0, + n_inlines: 0 + }; + let EncodeParams{item_symbols, diag, tcx, reachable, reexports2, + discrim_symbols, cstore, encode_inlined_item, + link_meta, _} = parms; + let ecx = @EncodeContext { + diag: diag, + tcx: tcx, + stats: @mut stats, + reachable: reachable, + reexports2: reexports2, + item_symbols: item_symbols, + discrim_symbols: discrim_symbols, + link_meta: link_meta, + cstore: cstore, + encode_inlined_item: encode_inlined_item, + type_abbrevs: @mut HashMap::new() + }; + + let mut ebml_w = writer::Encoder(wr as @io::Writer); + + encode_hash(&mut ebml_w, ecx.link_meta.extras_hash); + + let mut i = wr.pos; + let crate_attrs = synthesize_crate_attrs(ecx, crate); + encode_attributes(&mut ebml_w, crate_attrs); + ecx.stats.attr_bytes = wr.pos - i; + + i = wr.pos; + encode_crate_deps(ecx, &mut ebml_w, ecx.cstore); + ecx.stats.dep_bytes = wr.pos - i; + + // Encode the language items. + i = wr.pos; + encode_lang_items(ecx, &mut ebml_w); + ecx.stats.lang_item_bytes = wr.pos - i; + + // Encode the link args. + i = wr.pos; + encode_link_args(ecx, &mut ebml_w); + ecx.stats.link_args_bytes = wr.pos - i; + + // Encode and index the items. + ebml_w.start_tag(tag_items); + i = wr.pos; + let items_index = encode_info_for_items(ecx, &mut ebml_w, crate); + ecx.stats.item_bytes = wr.pos - i; + + i = wr.pos; + let items_buckets = create_index(items_index); + encode_index(&mut ebml_w, items_buckets, write_int); + ecx.stats.index_bytes = wr.pos - i; + ebml_w.end_tag(); + + ecx.stats.total_bytes = wr.pos; + + if (tcx.sess.meta_stats()) { + + do wr.bytes.each |e| { + if *e == 0 { + ecx.stats.zero_bytes += 1; + } + true + } + + io::println("metadata stats:"); + io::println(fmt!(" inline bytes: %u", ecx.stats.inline_bytes)); + io::println(fmt!(" attribute bytes: %u", ecx.stats.attr_bytes)); + io::println(fmt!(" dep bytes: %u", ecx.stats.dep_bytes)); + io::println(fmt!(" lang item bytes: %u", ecx.stats.lang_item_bytes)); + io::println(fmt!(" link args bytes: %u", ecx.stats.link_args_bytes)); + io::println(fmt!(" item bytes: %u", ecx.stats.item_bytes)); + io::println(fmt!(" index bytes: %u", ecx.stats.index_bytes)); + io::println(fmt!(" zero bytes: %u", ecx.stats.zero_bytes)); + io::println(fmt!(" total bytes: %u", ecx.stats.total_bytes)); + } + + // Pad this, since something (LLVM, presumably) is cutting off the + // remaining % 4 bytes. + wr.write(&[0u8, 0u8, 0u8, 0u8]); + + // FIXME #3396: weird bug here, for reasons unclear this emits random + // looking bytes (mostly 0x1) if we use the version byte-array constant + // above; so we use a string constant inline instead. + // + // Should be: + // + // vec::from_slice(metadata_encoding_version) + + + (do str::as_bytes(&~"rust\x00\x00\x00\x01") |bytes| { + vec::slice(*bytes, 0, 8).to_vec() + }) + flate::deflate_bytes(wr.bytes) +} + // Get the encoded string for a type pub fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> ~str { let cx = @tyencode::ctxt { diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 2f753523a7b..2a9f19fc846 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -77,6 +77,7 @@ trait tr_intern { // ______________________________________________________________________ // Top-level methods. +#[cfg(stage0)] pub fn encode_inlined_item(ecx: @e::EncodeContext, ebml_w: &writer::Encoder, path: &[ast_map::path_elt], @@ -100,6 +101,32 @@ pub fn encode_inlined_item(ecx: @e::EncodeContext, ebml_w.writer.tell()); } +#[cfg(not(stage0))] +pub fn encode_inlined_item(ecx: @e::EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ast_map::path_elt], + ii: ast::inlined_item, + maps: Maps) { + debug!("> Encoding inlined item: %s::%s (%u)", + ast_map::path_to_str(path, ecx.tcx.sess.parse_sess.interner), + *ecx.tcx.sess.str_of(ii.ident()), + ebml_w.writer.tell()); + + let id_range = ast_util::compute_id_range_for_inlined_item(&ii); + + ebml_w.start_tag(c::tag_ast as uint); + id_range.encode(ebml_w); + encode_ast(ebml_w, simplify_ast(&ii)); + encode_side_tables_for_ii(ecx, maps, ebml_w, &ii); + ebml_w.end_tag(); + + debug!("< Encoded inlined fn: %s::%s (%u)", + ast_map::path_to_str(path, ecx.tcx.sess.parse_sess.interner), + *ecx.tcx.sess.str_of(ii.ident()), + ebml_w.writer.tell()); +} + +#[cfg(stage0)] pub fn decode_inlined_item(cdata: @cstore::crate_metadata, tcx: ty::ctxt, maps: Maps, @@ -145,6 +172,52 @@ pub fn decode_inlined_item(cdata: @cstore::crate_metadata, } } +#[cfg(not(stage0))] +pub fn decode_inlined_item(cdata: @cstore::crate_metadata, + tcx: ty::ctxt, + maps: Maps, + path: ast_map::path, + par_doc: ebml::Doc) + -> Option { + let dcx = @DecodeContext { + cdata: cdata, + tcx: tcx, + maps: maps + }; + match par_doc.opt_child(c::tag_ast) { + None => None, + Some(ast_doc) => { + debug!("> Decoding inlined fn: %s::?", + ast_map::path_to_str(path, tcx.sess.parse_sess.interner)); + let mut ast_dsr = reader::Decoder(ast_doc); + let from_id_range = Decodable::decode(&mut ast_dsr); + let to_id_range = reserve_id_range(dcx.tcx.sess, from_id_range); + let xcx = @ExtendedDecodeContext { + dcx: dcx, + from_id_range: from_id_range, + to_id_range: to_id_range + }; + let raw_ii = decode_ast(ast_doc); + let ii = renumber_ast(xcx, raw_ii); + debug!("Fn named: %s", *tcx.sess.str_of(ii.ident())); + debug!("< Decoded inlined fn: %s::%s", + ast_map::path_to_str(path, tcx.sess.parse_sess.interner), + *tcx.sess.str_of(ii.ident())); + ast_map::map_decoded_item(tcx.sess.diagnostic(), + dcx.tcx.items, path, &ii); + decode_side_tables(xcx, ast_doc); + match ii { + ast::ii_item(i) => { + debug!(">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<", + syntax::print::pprust::item_to_str(i, tcx.sess.intr())); + } + _ => { } + } + Some(ii) + } + } +} + // ______________________________________________________________________ // Enumerating the IDs which appear in an AST @@ -236,28 +309,56 @@ impl tr for span { } } +#[cfg(stage0)] trait def_id_encoder_helpers { fn emit_def_id(&self, did: ast::def_id); } +#[cfg(not(stage0))] +trait def_id_encoder_helpers { + fn emit_def_id(&mut self, did: ast::def_id); +} + +#[cfg(stage0)] impl def_id_encoder_helpers for S { fn emit_def_id(&self, did: ast::def_id) { did.encode(self) } } +#[cfg(not(stage0))] +impl def_id_encoder_helpers for S { + fn emit_def_id(&mut self, did: ast::def_id) { + did.encode(self) + } +} + +#[cfg(stage0)] trait def_id_decoder_helpers { fn read_def_id(&self, xcx: @ExtendedDecodeContext) -> ast::def_id; } -impl def_id_decoder_helpers for D { +#[cfg(not(stage0))] +trait def_id_decoder_helpers { + fn read_def_id(&mut self, xcx: @ExtendedDecodeContext) -> ast::def_id; +} +#[cfg(stage0)] +impl def_id_decoder_helpers for D { fn read_def_id(&self, xcx: @ExtendedDecodeContext) -> ast::def_id { let did: ast::def_id = Decodable::decode(self); did.tr(xcx) } } +#[cfg(not(stage0))] +impl def_id_decoder_helpers for D { + fn read_def_id(&mut self, xcx: @ExtendedDecodeContext) -> ast::def_id { + let did: ast::def_id = Decodable::decode(self); + did.tr(xcx) + } +} + // ______________________________________________________________________ // Encoding and decoding the AST itself // @@ -273,12 +374,20 @@ impl def_id_decoder_helpers for D { // We also have to adjust the spans: for now we just insert a dummy span, // but eventually we should add entries to the local codemap as required. +#[cfg(stage0)] fn encode_ast(ebml_w: &writer::Encoder, item: ast::inlined_item) { do ebml_w.wr_tag(c::tag_tree as uint) { item.encode(ebml_w) } } +#[cfg(not(stage0))] +fn encode_ast(ebml_w: &mut writer::Encoder, item: ast::inlined_item) { + ebml_w.start_tag(c::tag_tree as uint); + item.encode(ebml_w); + ebml_w.end_tag(); +} + // Produces a simplified copy of the AST which does not include things // that we do not need to or do not want to export. For example, we // do not include any nested items: if these nested items are to be @@ -330,12 +439,20 @@ fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item { } } +#[cfg(stage0)] fn decode_ast(par_doc: ebml::Doc) -> ast::inlined_item { let chi_doc = par_doc.get(c::tag_tree as uint); let d = &reader::Decoder(chi_doc); Decodable::decode(d) } +#[cfg(not(stage0))] +fn decode_ast(par_doc: ebml::Doc) -> ast::inlined_item { + let chi_doc = par_doc.get(c::tag_tree as uint); + let mut d = reader::Decoder(chi_doc); + Decodable::decode(&mut d) +} + fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item) -> ast::inlined_item { let fld = fold::make_fold(@fold::AstFoldFns{ @@ -360,16 +477,30 @@ fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item) // ______________________________________________________________________ // Encoding and decoding of ast::def +#[cfg(stage0)] fn encode_def(ebml_w: &writer::Encoder, def: ast::def) { def.encode(ebml_w) } +#[cfg(not(stage0))] +fn encode_def(ebml_w: &mut writer::Encoder, def: ast::def) { + def.encode(ebml_w) +} + +#[cfg(stage0)] fn decode_def(xcx: @ExtendedDecodeContext, doc: ebml::Doc) -> ast::def { let dsr = &reader::Decoder(doc); let def: ast::def = Decodable::decode(dsr); def.tr(xcx) } +#[cfg(not(stage0))] +fn decode_def(xcx: @ExtendedDecodeContext, doc: ebml::Doc) -> ast::def { + let mut dsr = reader::Decoder(doc); + let def: ast::def = Decodable::decode(&mut dsr); + def.tr(xcx) +} + impl tr for ast::def { fn tr(&self, xcx: @ExtendedDecodeContext) -> ast::def { match *self { @@ -471,18 +602,41 @@ impl tr for ty::bound_region { // ______________________________________________________________________ // Encoding and decoding of freevar information +#[cfg(stage0)] fn encode_freevar_entry(ebml_w: &writer::Encoder, fv: @freevar_entry) { (*fv).encode(ebml_w) } +#[cfg(not(stage0))] +fn encode_freevar_entry(ebml_w: &mut writer::Encoder, fv: @freevar_entry) { + (*fv).encode(ebml_w) +} + +#[cfg(stage0)] trait ebml_decoder_helper { fn read_freevar_entry(&self, xcx: @ExtendedDecodeContext) - -> freevar_entry; + -> freevar_entry; +} + +#[cfg(not(stage0))] +trait ebml_decoder_helper { + fn read_freevar_entry(&mut self, xcx: @ExtendedDecodeContext) + -> freevar_entry; } +#[cfg(stage0)] impl ebml_decoder_helper for reader::Decoder { fn read_freevar_entry(&self, xcx: @ExtendedDecodeContext) - -> freevar_entry { + -> freevar_entry { + let fv: freevar_entry = Decodable::decode(self); + fv.tr(xcx) + } +} + +#[cfg(not(stage0))] +impl ebml_decoder_helper for reader::Decoder { + fn read_freevar_entry(&mut self, xcx: @ExtendedDecodeContext) + -> freevar_entry { let fv: freevar_entry = Decodable::decode(self); fv.tr(xcx) } @@ -500,14 +654,31 @@ impl tr for freevar_entry { // ______________________________________________________________________ // Encoding and decoding of CaptureVar information +#[cfg(stage0)] trait capture_var_helper { fn read_capture_var(&self, xcx: @ExtendedDecodeContext) - -> moves::CaptureVar; + -> moves::CaptureVar; } +#[cfg(not(stage0))] +trait capture_var_helper { + fn read_capture_var(&mut self, xcx: @ExtendedDecodeContext) + -> moves::CaptureVar; +} + +#[cfg(stage0)] impl capture_var_helper for reader::Decoder { fn read_capture_var(&self, xcx: @ExtendedDecodeContext) - -> moves::CaptureVar { + -> moves::CaptureVar { + let cvar: moves::CaptureVar = Decodable::decode(self); + cvar.tr(xcx) + } +} + +#[cfg(not(stage0))] +impl capture_var_helper for reader::Decoder { + fn read_capture_var(&mut self, xcx: @ExtendedDecodeContext) + -> moves::CaptureVar { let cvar: moves::CaptureVar = Decodable::decode(self); cvar.tr(xcx) } @@ -527,14 +698,18 @@ impl tr for moves::CaptureVar { // Encoding and decoding of method_map_entry trait read_method_map_entry_helper { + #[cfg(stage0)] fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext) - -> method_map_entry; + -> method_map_entry; + #[cfg(not(stage0))] + fn read_method_map_entry(&mut self, xcx: @ExtendedDecodeContext) + -> method_map_entry; } #[cfg(stage0)] fn encode_method_map_entry(ecx: @e::EncodeContext, - ebml_w: &writer::Encoder, - mme: method_map_entry) { + ebml_w: &writer::Encoder, + mme: method_map_entry) { do ebml_w.emit_struct("method_map_entry", 3) { do ebml_w.emit_field(~"self_arg", 0u) { ebml_w.emit_arg(ecx, mme.self_arg); @@ -551,23 +726,21 @@ fn encode_method_map_entry(ecx: @e::EncodeContext, } } -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] +#[cfg(not(stage0))] fn encode_method_map_entry(ecx: @e::EncodeContext, - ebml_w: &writer::Encoder, - mme: method_map_entry) { - do ebml_w.emit_struct("method_map_entry", 3) { - do ebml_w.emit_struct_field("self_arg", 0u) { + ebml_w: &mut writer::Encoder, + mme: method_map_entry) { + do ebml_w.emit_struct("method_map_entry", 3) |ebml_w| { + do ebml_w.emit_struct_field("self_arg", 0u) |ebml_w| { ebml_w.emit_arg(ecx, mme.self_arg); } - do ebml_w.emit_struct_field("explicit_self", 2u) { + do ebml_w.emit_struct_field("explicit_self", 2u) |ebml_w| { mme.explicit_self.encode(ebml_w); } - do ebml_w.emit_struct_field("origin", 1u) { + do ebml_w.emit_struct_field("origin", 1u) |ebml_w| { mme.origin.encode(ebml_w); } - do ebml_w.emit_struct_field("self_mode", 3) { + do ebml_w.emit_struct_field("self_mode", 3) |ebml_w| { mme.self_mode.encode(ebml_w); } } @@ -576,7 +749,7 @@ fn encode_method_map_entry(ecx: @e::EncodeContext, impl read_method_map_entry_helper for reader::Decoder { #[cfg(stage0)] fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext) - -> method_map_entry { + -> method_map_entry { do self.read_struct("method_map_entry", 3) { method_map_entry { self_arg: self.read_field(~"self_arg", 0u, || { @@ -599,27 +772,27 @@ impl read_method_map_entry_helper for reader::Decoder { } } - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext) - -> method_map_entry { - do self.read_struct("method_map_entry", 3) { + #[cfg(not(stage0))] + fn read_method_map_entry(&mut self, xcx: @ExtendedDecodeContext) + -> method_map_entry { + do self.read_struct("method_map_entry", 3) |this| { method_map_entry { - self_arg: self.read_struct_field("self_arg", 0u, || { - self.read_arg(xcx) + self_arg: this.read_struct_field("self_arg", 0, |this| { + this.read_arg(xcx) }), - explicit_self: self.read_struct_field("explicit_self", 2, || { - let self_type: ast::self_ty_ = Decodable::decode(self); + explicit_self: this.read_struct_field("explicit_self", + 2, + |this| { + let self_type: ast::self_ty_ = Decodable::decode(this); self_type }), - origin: self.read_struct_field("origin", 1u, || { + origin: this.read_struct_field("origin", 1, |this| { let method_origin: method_origin = - Decodable::decode(self); + Decodable::decode(this); method_origin.tr(xcx) }), - self_mode: self.read_struct_field("self_mode", 3, || { - let self_mode: ty::SelfMode = Decodable::decode(self); + self_mode: this.read_struct_field("self_mode", 3, |this| { + let self_mode: ty::SelfMode = Decodable::decode(this); self_mode }), } @@ -657,6 +830,7 @@ impl tr for method_origin { // ______________________________________________________________________ // Encoding and decoding vtable_res +#[cfg(stage0)] fn encode_vtable_res(ecx: @e::EncodeContext, ebml_w: &writer::Encoder, dr: typeck::vtable_res) { @@ -669,6 +843,20 @@ fn encode_vtable_res(ecx: @e::EncodeContext, } } +#[cfg(not(stage0))] +fn encode_vtable_res(ecx: @e::EncodeContext, + ebml_w: &mut writer::Encoder, + dr: typeck::vtable_res) { + // can't autogenerate this code because automatic code of + // ty::t doesn't work, and there is no way (atm) to have + // hand-written encoding routines combine with auto-generated + // ones. perhaps we should fix this. + do ebml_w.emit_from_vec(*dr) |ebml_w, vtable_origin| { + encode_vtable_origin(ecx, ebml_w, vtable_origin) + } +} + +#[cfg(stage0)] fn encode_vtable_origin(ecx: @e::EncodeContext, ebml_w: &writer::Encoder, vtable_origin: &typeck::vtable_origin) { @@ -699,24 +887,72 @@ fn encode_vtable_origin(ecx: @e::EncodeContext, } } } +} +#[cfg(not(stage0))] +fn encode_vtable_origin(ecx: @e::EncodeContext, + ebml_w: &mut writer::Encoder, + vtable_origin: &typeck::vtable_origin) { + do ebml_w.emit_enum(~"vtable_origin") |ebml_w| { + match *vtable_origin { + typeck::vtable_static(def_id, ref tys, vtable_res) => { + do ebml_w.emit_enum_variant(~"vtable_static", 0u, 3u) |ebml_w| { + do ebml_w.emit_enum_variant_arg(0u) |ebml_w| { + ebml_w.emit_def_id(def_id) + } + do ebml_w.emit_enum_variant_arg(1u) |ebml_w| { + ebml_w.emit_tys(ecx, /*bad*/copy *tys); + } + do ebml_w.emit_enum_variant_arg(2u) |ebml_w| { + encode_vtable_res(ecx, ebml_w, vtable_res); + } + } + } + typeck::vtable_param(pn, bn) => { + do ebml_w.emit_enum_variant(~"vtable_param", 1u, 2u) |ebml_w| { + do ebml_w.emit_enum_variant_arg(0u) |ebml_w| { + ebml_w.emit_uint(pn); + } + do ebml_w.emit_enum_variant_arg(1u) |ebml_w| { + ebml_w.emit_uint(bn); + } + } + } + } + } } trait vtable_decoder_helpers { + #[cfg(stage0)] fn read_vtable_res(&self, xcx: @ExtendedDecodeContext) -> typeck::vtable_res; + #[cfg(not(stage0))] + fn read_vtable_res(&mut self, xcx: @ExtendedDecodeContext) + -> typeck::vtable_res; + #[cfg(stage0)] fn read_vtable_origin(&self, xcx: @ExtendedDecodeContext) - -> typeck::vtable_origin; + -> typeck::vtable_origin; + #[cfg(not(stage0))] + fn read_vtable_origin(&mut self, xcx: @ExtendedDecodeContext) + -> typeck::vtable_origin; } impl vtable_decoder_helpers for reader::Decoder { + #[cfg(stage0)] fn read_vtable_res(&self, xcx: @ExtendedDecodeContext) -> typeck::vtable_res { - @self.read_to_vec(|| self.read_vtable_origin(xcx) ) + @self.read_to_vec(|| self.read_vtable_origin(xcx)) } + #[cfg(not(stage0))] + fn read_vtable_res(&mut self, xcx: @ExtendedDecodeContext) + -> typeck::vtable_res { + @self.read_to_vec(|this| this.read_vtable_origin(xcx)) + } + + #[cfg(stage0)] fn read_vtable_origin(&self, xcx: @ExtendedDecodeContext) - -> typeck::vtable_origin { + -> typeck::vtable_origin { do self.read_enum("vtable_origin") { do self.read_enum_variant(["vtable_static", "vtable_param"]) |i| { match i { @@ -749,6 +985,43 @@ impl vtable_decoder_helpers for reader::Decoder { } } } + + #[cfg(not(stage0))] + fn read_vtable_origin(&mut self, xcx: @ExtendedDecodeContext) + -> typeck::vtable_origin { + do self.read_enum("vtable_origin") |this| { + do this.read_enum_variant(["vtable_static", "vtable_param"]) + |this, i| { + match i { + 0 => { + typeck::vtable_static( + do this.read_enum_variant_arg(0u) |this| { + this.read_def_id(xcx) + }, + do this.read_enum_variant_arg(1u) |this| { + this.read_tys(xcx) + }, + do this.read_enum_variant_arg(2u) |this| { + this.read_vtable_res(xcx) + } + ) + } + 1 => { + typeck::vtable_param( + do this.read_enum_variant_arg(0u) |this| { + this.read_uint() + }, + do this.read_enum_variant_arg(1u) |this| { + this.read_uint() + } + ) + } + // hard to avoid - user input + _ => fail!(~"bad enum variant") + } + } + } + } } // ______________________________________________________________________ @@ -769,6 +1042,7 @@ impl get_ty_str_ctxt for e::EncodeContext { } } +#[cfg(stage0)] trait ebml_writer_helpers { fn emit_arg(&self, ecx: @e::EncodeContext, arg: ty::arg); fn emit_ty(&self, ecx: @e::EncodeContext, ty: ty::t); @@ -781,31 +1055,78 @@ trait ebml_writer_helpers { tpbt: ty::ty_param_bounds_and_ty); } +#[cfg(not(stage0))] +trait ebml_writer_helpers { + fn emit_arg(&mut self, ecx: @e::EncodeContext, arg: ty::arg); + fn emit_ty(&mut self, ecx: @e::EncodeContext, ty: ty::t); + fn emit_vstore(&mut self, ecx: @e::EncodeContext, vstore: ty::vstore); + fn emit_tys(&mut self, ecx: @e::EncodeContext, tys: ~[ty::t]); + fn emit_type_param_def(&mut self, + ecx: @e::EncodeContext, + type_param_def: &ty::TypeParameterDef); + fn emit_tpbt(&mut self, + ecx: @e::EncodeContext, + tpbt: ty::ty_param_bounds_and_ty); +} + impl ebml_writer_helpers for writer::Encoder { + #[cfg(stage0)] fn emit_ty(&self, ecx: @e::EncodeContext, ty: ty::t) { do self.emit_opaque { e::write_type(ecx, self, ty) } } + #[cfg(not(stage0))] + fn emit_ty(&mut self, ecx: @e::EncodeContext, ty: ty::t) { + do self.emit_opaque |this| { + e::write_type(ecx, this, ty) + } + } + + #[cfg(stage0)] fn emit_vstore(&self, ecx: @e::EncodeContext, vstore: ty::vstore) { do self.emit_opaque { e::write_vstore(ecx, self, vstore) } } + #[cfg(not(stage0))] + fn emit_vstore(&mut self, ecx: @e::EncodeContext, vstore: ty::vstore) { + do self.emit_opaque |this| { + e::write_vstore(ecx, this, vstore) + } + } + + #[cfg(stage0)] fn emit_arg(&self, ecx: @e::EncodeContext, arg: ty::arg) { do self.emit_opaque { tyencode::enc_arg(self.writer, ecx.ty_str_ctxt(), arg); } } + #[cfg(not(stage0))] + fn emit_arg(&mut self, ecx: @e::EncodeContext, arg: ty::arg) { + do self.emit_opaque |this| { + tyencode::enc_arg(this.writer, ecx.ty_str_ctxt(), arg); + } + } + + #[cfg(stage0)] fn emit_tys(&self, ecx: @e::EncodeContext, tys: ~[ty::t]) { do self.emit_from_vec(tys) |ty| { self.emit_ty(ecx, *ty) } } + #[cfg(not(stage0))] + fn emit_tys(&mut self, ecx: @e::EncodeContext, tys: ~[ty::t]) { + do self.emit_from_vec(tys) |this, ty| { + this.emit_ty(ecx, *ty) + } + } + + #[cfg(stage0)] fn emit_type_param_def(&self, ecx: @e::EncodeContext, type_param_def: &ty::TypeParameterDef) { @@ -815,16 +1136,27 @@ impl ebml_writer_helpers for writer::Encoder { } } + #[cfg(not(stage0))] + fn emit_type_param_def(&mut self, + ecx: @e::EncodeContext, + type_param_def: &ty::TypeParameterDef) { + do self.emit_opaque |this| { + tyencode::enc_type_param_def(this.writer, + ecx.ty_str_ctxt(), + type_param_def) + } + } + #[cfg(stage0)] - fn emit_tpbt(&self, ecx: @e::EncodeContext, + fn emit_tpbt(&self, + ecx: @e::EncodeContext, tpbt: ty::ty_param_bounds_and_ty) { do self.emit_struct("ty_param_bounds_and_ty", 2) { do self.emit_field(~"generics", 0) { do self.emit_struct("Generics", 2) { do self.emit_field(~"type_param_defs", 0) { do self.emit_from_vec(*tpbt.generics.type_param_defs) - |type_param_def| - { + |type_param_def| { self.emit_type_param_def(ecx, type_param_def); } } @@ -839,38 +1171,44 @@ impl ebml_writer_helpers for writer::Encoder { } } - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn emit_tpbt(&self, ecx: @e::EncodeContext, + #[cfg(not(stage0))] + fn emit_tpbt(&mut self, + ecx: @e::EncodeContext, tpbt: ty::ty_param_bounds_and_ty) { - do self.emit_struct("ty_param_bounds_and_ty", 2) { - do self.emit_struct_field("generics", 0) { - do self.emit_struct("Generics", 2) { - do self.emit_struct_field("type_param_defs", 0) { - do self.emit_from_vec(*tpbt.generics.type_param_defs) - |type_param_def| - { - self.emit_type_param_def(ecx, type_param_def); + do self.emit_struct("ty_param_bounds_and_ty", 2) |this| { + do this.emit_struct_field(~"generics", 0) |this| { + do this.emit_struct("Generics", 2) |this| { + do this.emit_struct_field(~"type_param_defs", 0) |this| { + do this.emit_from_vec(*tpbt.generics.type_param_defs) + |this, type_param_def| { + this.emit_type_param_def(ecx, type_param_def); } } - do self.emit_struct_field("region_param", 1) { - tpbt.generics.region_param.encode(self); + do this.emit_struct_field(~"region_param", 1) |this| { + tpbt.generics.region_param.encode(this); } } } - do self.emit_struct_field("ty", 1) { - self.emit_ty(ecx, tpbt.ty); + do this.emit_struct_field(~"ty", 1) |this| { + this.emit_ty(ecx, tpbt.ty); } } } } +#[cfg(stage0)] trait write_tag_and_id { fn tag(&self, tag_id: c::astencode_tag, f: &fn()); fn id(&self, id: ast::node_id); } +#[cfg(not(stage0))] +trait write_tag_and_id { + fn tag(&mut self, tag_id: c::astencode_tag, f: &fn(&mut Self)); + fn id(&mut self, id: ast::node_id); +} + +#[cfg(stage0)] impl write_tag_and_id for writer::Encoder { fn tag(&self, tag_id: c::astencode_tag, f: &fn()) { do self.wr_tag(tag_id as uint) { f() } @@ -881,6 +1219,22 @@ impl write_tag_and_id for writer::Encoder { } } +#[cfg(not(stage0))] +impl write_tag_and_id for writer::Encoder { + fn tag(&mut self, + tag_id: c::astencode_tag, + f: &fn(&mut writer::Encoder)) { + self.start_tag(tag_id as uint); + f(self); + self.end_tag(); + } + + fn id(&mut self, id: ast::node_id) { + self.wr_tagged_u64(c::tag_table_id as uint, id as u64) + } +} + +#[cfg(stage0)] fn encode_side_tables_for_ii(ecx: @e::EncodeContext, maps: Maps, ebml_w: &writer::Encoder, @@ -899,6 +1253,26 @@ fn encode_side_tables_for_ii(ecx: @e::EncodeContext, } } +#[cfg(not(stage0))] +fn encode_side_tables_for_ii(ecx: @e::EncodeContext, + maps: Maps, + ebml_w: &mut writer::Encoder, + ii: &ast::inlined_item) { + ebml_w.start_tag(c::tag_table as uint); + let new_ebml_w = copy *ebml_w; + ast_util::visit_ids_for_inlined_item( + ii, + |id: ast::node_id| { + // Note: this will cause a copy of ebml_w, which is bad as + // it is mutable. But I believe it's harmless since we generate + // balanced EBML. + let mut new_ebml_w = copy new_ebml_w; + encode_side_tables_for_id(ecx, maps, &mut new_ebml_w, id) + }); + ebml_w.end_tag(); +} + +#[cfg(stage0)] fn encode_side_tables_for_id(ecx: @e::EncodeContext, maps: Maps, ebml_w: &writer::Encoder, @@ -1028,6 +1402,136 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext, } } +#[cfg(not(stage0))] +fn encode_side_tables_for_id(ecx: @e::EncodeContext, + maps: Maps, + ebml_w: &mut writer::Encoder, + id: ast::node_id) { + let tcx = ecx.tcx; + + debug!("Encoding side tables for id %d", id); + + for tcx.def_map.find(&id).each |def| { + do ebml_w.tag(c::tag_table_def) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + (*def).encode(ebml_w) + } + } + } + + for tcx.node_types.find(&(id as uint)).each |&ty| { + do ebml_w.tag(c::tag_table_node_type) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + ebml_w.emit_ty(ecx, *ty); + } + } + } + + for tcx.node_type_substs.find(&id).each |tys| { + do ebml_w.tag(c::tag_table_node_type_subst) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + // FIXME(#5562): removing this copy causes a segfault + // before stage2 + ebml_w.emit_tys(ecx, /*bad*/copy **tys) + } + } + } + + for tcx.freevars.find(&id).each |&fv| { + do ebml_w.tag(c::tag_table_freevars) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + do ebml_w.emit_from_vec(**fv) |ebml_w, fv_entry| { + encode_freevar_entry(ebml_w, *fv_entry) + } + } + } + } + + let lid = ast::def_id { crate: ast::local_crate, node: id }; + for tcx.tcache.find(&lid).each |&tpbt| { + do ebml_w.tag(c::tag_table_tcache) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + ebml_w.emit_tpbt(ecx, *tpbt); + } + } + } + + for tcx.ty_param_defs.find(&id).each |&type_param_def| { + do ebml_w.tag(c::tag_table_param_defs) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + ebml_w.emit_type_param_def(ecx, type_param_def) + } + } + } + + if maps.mutbl_map.contains(&id) { + do ebml_w.tag(c::tag_table_mutbl) |ebml_w| { + ebml_w.id(id); + } + } + + for maps.last_use_map.find(&id).each |&m| { + do ebml_w.tag(c::tag_table_last_use) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + do ebml_w.emit_from_vec(/*bad*/ copy **m) |ebml_w, id| { + id.encode(ebml_w); + } + } + } + } + + for maps.method_map.find(&id).each |&mme| { + do ebml_w.tag(c::tag_table_method_map) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + encode_method_map_entry(ecx, ebml_w, *mme) + } + } + } + + for maps.vtable_map.find(&id).each |&dr| { + do ebml_w.tag(c::tag_table_vtable_map) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + encode_vtable_res(ecx, ebml_w, *dr); + } + } + } + + for tcx.adjustments.find(&id).each |adj| { + do ebml_w.tag(c::tag_table_adjustments) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + (**adj).encode(ebml_w) + } + } + } + + if maps.moves_map.contains(&id) { + do ebml_w.tag(c::tag_table_moves_map) |ebml_w| { + ebml_w.id(id); + } + } + + for maps.capture_map.find(&id).each |&cap_vars| { + do ebml_w.tag(c::tag_table_capture_map) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + do ebml_w.emit_from_vec(*cap_vars) |ebml_w, cap_var| { + cap_var.encode(ebml_w); + } + } + } + } +} + trait doc_decoder_helpers { fn as_int(&self) -> int; fn opt_child(&self, tag: c::astencode_tag) -> Option; @@ -1040,6 +1544,7 @@ impl doc_decoder_helpers for ebml::Doc { } } +#[cfg(stage0)] trait ebml_decoder_decoder_helpers { fn read_arg(&self, xcx: @ExtendedDecodeContext) -> ty::arg; fn read_ty(&self, xcx: @ExtendedDecodeContext) -> ty::t; @@ -1052,7 +1557,24 @@ trait ebml_decoder_decoder_helpers { did: ast::def_id) -> ast::def_id; } +#[cfg(not(stage0))] +trait ebml_decoder_decoder_helpers { + fn read_arg(&mut self, xcx: @ExtendedDecodeContext) -> ty::arg; + fn read_ty(&mut self, xcx: @ExtendedDecodeContext) -> ty::t; + fn read_tys(&mut self, xcx: @ExtendedDecodeContext) -> ~[ty::t]; + fn read_type_param_def(&mut self, xcx: @ExtendedDecodeContext) + -> ty::TypeParameterDef; + fn read_ty_param_bounds_and_ty(&mut self, xcx: @ExtendedDecodeContext) + -> ty::ty_param_bounds_and_ty; + fn convert_def_id(&mut self, + xcx: @ExtendedDecodeContext, + source: DefIdSource, + did: ast::def_id) + -> ast::def_id; +} + impl ebml_decoder_decoder_helpers for reader::Decoder { + #[cfg(stage0)] fn read_arg(&self, xcx: @ExtendedDecodeContext) -> ty::arg { do self.read_opaque |doc| { tydecode::parse_arg_data( @@ -1061,6 +1583,19 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } + #[cfg(not(stage0))] + fn read_arg(&mut self, xcx: @ExtendedDecodeContext) -> ty::arg { + do self.read_opaque |this, doc| { + tydecode::parse_arg_data( + doc.data, + xcx.dcx.cdata.cnum, + doc.start, + xcx.dcx.tcx, + |s, a| this.convert_def_id(xcx, s, a)) + } + } + + #[cfg(stage0)] fn read_ty(&self, xcx: @ExtendedDecodeContext) -> ty::t { // Note: regions types embed local node ids. In principle, we // should translate these node ids into the new decode @@ -1088,11 +1623,50 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } + #[cfg(not(stage0))] + fn read_ty(&mut self, xcx: @ExtendedDecodeContext) -> ty::t { + // Note: regions types embed local node ids. In principle, we + // should translate these node ids into the new decode + // context. However, we do not bother, because region types + // are not used during trans. + + return do self.read_opaque |this, doc| { + let ty = tydecode::parse_ty_data( + doc.data, + xcx.dcx.cdata.cnum, + doc.start, + xcx.dcx.tcx, + |s, a| this.convert_def_id(xcx, s, a)); + + debug!("read_ty(%s) = %s", + type_string(doc), + ty_to_str(xcx.dcx.tcx, ty)); + + ty + }; + + fn type_string(doc: ebml::Doc) -> ~str { + let mut str = ~""; + for uint::range(doc.start, doc.end) |i| { + str::push_char(&mut str, doc.data[i] as char); + } + str + } + } + + #[cfg(stage0)] fn read_tys(&self, xcx: @ExtendedDecodeContext) -> ~[ty::t] { self.read_to_vec(|| self.read_ty(xcx) ) } - fn read_type_param_def(&self, xcx: @ExtendedDecodeContext) -> ty::TypeParameterDef { + #[cfg(not(stage0))] + fn read_tys(&mut self, xcx: @ExtendedDecodeContext) -> ~[ty::t] { + self.read_to_vec(|this| this.read_ty(xcx) ) + } + + #[cfg(stage0)] + fn read_type_param_def(&self, xcx: @ExtendedDecodeContext) + -> ty::TypeParameterDef { do self.read_opaque |doc| { tydecode::parse_type_param_def_data( doc.data, doc.start, xcx.dcx.cdata.cnum, xcx.dcx.tcx, @@ -1100,20 +1674,34 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } + #[cfg(not(stage0))] + fn read_type_param_def(&mut self, xcx: @ExtendedDecodeContext) + -> ty::TypeParameterDef { + do self.read_opaque |this, doc| { + tydecode::parse_type_param_def_data( + doc.data, + doc.start, + xcx.dcx.cdata.cnum, + xcx.dcx.tcx, + |s, a| this.convert_def_id(xcx, s, a)) + } + } + #[cfg(stage0)] fn read_ty_param_bounds_and_ty(&self, xcx: @ExtendedDecodeContext) - -> ty::ty_param_bounds_and_ty - { + -> ty::ty_param_bounds_and_ty { do self.read_struct("ty_param_bounds_and_ty", 2) { ty::ty_param_bounds_and_ty { - generics: do self.read_struct("Generics", 2) { - ty::Generics { - type_param_defs: self.read_field("type_param_defs", 0, || { - @self.read_to_vec(|| self.read_type_param_def(xcx)) - }), - region_param: self.read_field(~"region_param", 1, || { - Decodable::decode(self) - }) + generics: do self.read_field("generics", 0) { + do self.read_struct("Generics", 2) { + ty::Generics { + type_param_defs: self.read_field("type_param_defs", 0, || { + @self.read_to_vec(|| self.read_type_param_def(xcx)) + }), + region_param: self.read_field(~"region_param", 1, || { + Decodable::decode(self) + }) + } } }, ty: self.read_field(~"ty", 1, || { @@ -1123,34 +1711,71 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn read_ty_param_bounds_and_ty(&self, xcx: @ExtendedDecodeContext) - -> ty::ty_param_bounds_and_ty - { - do self.read_struct("ty_param_bounds_and_ty", 2) { + #[cfg(not(stage0))] + fn read_ty_param_bounds_and_ty(&mut self, xcx: @ExtendedDecodeContext) + -> ty::ty_param_bounds_and_ty { + do self.read_struct("ty_param_bounds_and_ty", 2) |this| { ty::ty_param_bounds_and_ty { - generics: do self.read_struct("Generics", 2) { - ty::Generics { - type_param_defs: self.read_struct_field("type_param_defs", 0, || { - @self.read_to_vec(|| self.read_type_param_def(xcx)) - }), - region_param: self.read_struct_field(~"region_param", 1, || { - Decodable::decode(self) - }) + generics: do this.read_struct_field("generics", 0) |this| { + do this.read_struct("Generics", 2) |this| { + ty::Generics { + type_param_defs: + this.read_struct_field("type_param_defs", + 0, + |this| { + @this.read_to_vec(|this| + this.read_type_param_def(xcx)) + }), + region_param: + this.read_struct_field("region_param", + 1, + |this| { + Decodable::decode(this) + }) + } } }, - ty: self.read_struct_field("ty", 1, || { - self.read_ty(xcx) + ty: this.read_struct_field("ty", 1, |this| { + this.read_ty(xcx) }) } } } - fn convert_def_id(&self, xcx: @ExtendedDecodeContext, + #[cfg(stage0)] + fn convert_def_id(&self, + xcx: @ExtendedDecodeContext, source: tydecode::DefIdSource, - did: ast::def_id) -> ast::def_id { + did: ast::def_id) + -> ast::def_id { + /*! + * + * Converts a def-id that appears in a type. The correct + * translation will depend on what kind of def-id this is. + * This is a subtle point: type definitions are not + * inlined into the current crate, so if the def-id names + * a nominal type or type alias, then it should be + * translated to refer to the source crate. + * + * However, *type parameters* are cloned along with the function + * they are attached to. So we should translate those def-ids + * to refer to the new, cloned copy of the type parameter. + */ + + let r = match source { + NominalType | TypeWithId => xcx.tr_def_id(did), + TypeParameter => xcx.tr_intern_def_id(did) + }; + debug!("convert_def_id(source=%?, did=%?)=%?", source, did, r); + return r; + } + + #[cfg(not(stage0))] + fn convert_def_id(&mut self, + xcx: @ExtendedDecodeContext, + source: tydecode::DefIdSource, + did: ast::def_id) + -> ast::def_id { /*! * * Converts a def-id that appears in a type. The correct @@ -1174,6 +1799,7 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } +#[cfg(stage0)] fn decode_side_tables(xcx: @ExtendedDecodeContext, ast_doc: ebml::Doc) { let dcx = xcx.dcx; @@ -1248,21 +1874,97 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext, } } +#[cfg(not(stage0))] +fn decode_side_tables(xcx: @ExtendedDecodeContext, + ast_doc: ebml::Doc) { + let dcx = xcx.dcx; + let tbl_doc = ast_doc.get(c::tag_table as uint); + for reader::docs(tbl_doc) |tag, entry_doc| { + let id0 = entry_doc.get(c::tag_table_id as uint).as_int(); + let id = xcx.tr_id(id0); + + debug!(">> Side table document with tag 0x%x \ + found for id %d (orig %d)", + tag, id, id0); + + if tag == (c::tag_table_mutbl as uint) { + dcx.maps.mutbl_map.insert(id); + } else if tag == (c::tag_table_moves_map as uint) { + dcx.maps.moves_map.insert(id); + } else { + let val_doc = entry_doc.get(c::tag_table_val as uint); + let mut val_dsr = reader::Decoder(val_doc); + let val_dsr = &mut val_dsr; + if tag == (c::tag_table_def as uint) { + let def = decode_def(xcx, val_doc); + dcx.tcx.def_map.insert(id, def); + } else if tag == (c::tag_table_node_type as uint) { + let ty = val_dsr.read_ty(xcx); + debug!("inserting ty for node %?: %s", + id, ty_to_str(dcx.tcx, ty)); + dcx.tcx.node_types.insert(id as uint, ty); + } else if tag == (c::tag_table_node_type_subst as uint) { + let tys = val_dsr.read_tys(xcx); + dcx.tcx.node_type_substs.insert(id, tys); + } else if tag == (c::tag_table_freevars as uint) { + let fv_info = @val_dsr.read_to_vec(|val_dsr| { + @val_dsr.read_freevar_entry(xcx) + }); + dcx.tcx.freevars.insert(id, fv_info); + } else if tag == (c::tag_table_tcache as uint) { + let tpbt = val_dsr.read_ty_param_bounds_and_ty(xcx); + let lid = ast::def_id { crate: ast::local_crate, node: id }; + dcx.tcx.tcache.insert(lid, tpbt); + } else if tag == (c::tag_table_param_defs as uint) { + let bounds = val_dsr.read_type_param_def(xcx); + dcx.tcx.ty_param_defs.insert(id, bounds); + } else if tag == (c::tag_table_last_use as uint) { + let ids = val_dsr.read_to_vec(|val_dsr| { + xcx.tr_id(val_dsr.read_int()) + }); + dcx.maps.last_use_map.insert(id, @mut ids); + } else if tag == (c::tag_table_method_map as uint) { + dcx.maps.method_map.insert( + id, + val_dsr.read_method_map_entry(xcx)); + } else if tag == (c::tag_table_vtable_map as uint) { + dcx.maps.vtable_map.insert(id, + val_dsr.read_vtable_res(xcx)); + } else if tag == (c::tag_table_adjustments as uint) { + let adj: @ty::AutoAdjustment = @Decodable::decode(val_dsr); + adj.tr(xcx); + dcx.tcx.adjustments.insert(id, adj); + } else if tag == (c::tag_table_capture_map as uint) { + let cvars = + at_vec::from_owned( + val_dsr.read_to_vec( + |val_dsr| val_dsr.read_capture_var(xcx))); + dcx.maps.capture_map.insert(id, cvars); + } else { + xcx.dcx.tcx.sess.bug( + fmt!("unknown tag found in side tables: %x", tag)); + } + } + + debug!(">< Side table doc loaded"); + } +} + // ______________________________________________________________________ // Testing of astencode_gen #[cfg(test)] -fn encode_item_ast(ebml_w: &writer::Encoder, item: @ast::item) { - do ebml_w.wr_tag(c::tag_tree as uint) { - (*item).encode(ebml_w) - } +fn encode_item_ast(ebml_w: &mut writer::Encoder, item: @ast::item) { + ebml_w.start_tag(c::tag_tree as uint); + (*item).encode(ebml_w); + ebml_w.end_tag(); } #[cfg(test)] fn decode_item_ast(par_doc: ebml::Doc) -> @ast::item { let chi_doc = par_doc.get(c::tag_tree as uint); - let d = &reader::Decoder(chi_doc); - @Decodable::decode(d) + let mut d = reader::Decoder(chi_doc); + @Decodable::decode(&mut d) } #[cfg(test)] @@ -1303,8 +2005,8 @@ fn roundtrip(in_item: Option<@ast::item>) { let in_item = in_item.get(); let bytes = do io::with_bytes_writer |wr| { - let ebml_w = writer::Encoder(wr); - encode_item_ast(&ebml_w, in_item); + let mut ebml_w = writer::Encoder(wr); + encode_item_ast(&mut ebml_w, in_item); }; let ebml_doc = reader::Doc(@bytes); let out_item = decode_item_ast(ebml_doc); diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index bea7935d5c3..0e9b2ed3da8 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -348,7 +348,7 @@ pub impl Arena { #[test] fn test_arena_destructors() { - let arena = Arena(); + let mut arena = Arena(); for uint::range(0, 10) |i| { // Arena allocate something with drop glue to make sure it // doesn't leak. @@ -363,7 +363,7 @@ fn test_arena_destructors() { #[should_fail] #[ignore(cfg(windows))] fn test_arena_destructors_fail() { - let arena = Arena(); + let mut arena = Arena(); // Put some stuff in the arena. for uint::range(0, 10) |i| { // Arena allocate something with drop glue to make sure it diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 2598e96a141..41c5a0f7690 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -36,13 +36,27 @@ pub struct TaggedDoc { } pub enum EbmlEncoderTag { - EsUint, EsU64, EsU32, EsU16, EsU8, - EsInt, EsI64, EsI32, EsI16, EsI8, - EsBool, - EsStr, - EsF64, EsF32, EsFloat, - EsEnum, EsEnumVid, EsEnumBody, - EsVec, EsVecLen, EsVecElt, + EsUint, // 0 + EsU64, // 1 + EsU32, // 2 + EsU16, // 3 + EsU8, // 4 + EsInt, // 5 + EsI64, // 6 + EsI32, // 7 + EsI16, // 8 + EsI8, // 9 + EsBool, // 10 + EsStr, // 11 + EsF64, // 12 + EsF32, // 13 + EsFloat, // 14 + EsEnum, // 15 + EsEnumVid, // 16 + EsEnumBody, // 17 + EsVec, // 18 + EsVecLen, // 19 + EsVecElt, // 20 EsOpaque, @@ -249,17 +263,27 @@ pub mod reader { pub fn doc_as_i32(d: Doc) -> i32 { doc_as_u32(d) as i32 } pub fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 } - + #[cfg(stage0)] pub struct Decoder { priv mut parent: Doc, priv mut pos: uint, } + #[cfg(not(stage0))] + pub struct Decoder { + priv parent: Doc, + priv pos: uint, + } + pub fn Decoder(d: Doc) -> Decoder { - Decoder { parent: d, pos: d.start } + Decoder { + parent: d, + pos: d.start + } } priv impl Decoder { + #[cfg(stage0)] fn _check_label(&self, lbl: &str) { if self.pos < self.parent.end { let TaggedDoc { tag: r_tag, doc: r_doc } = @@ -269,13 +293,33 @@ pub mod reader { self.pos = r_doc.end; let str = doc_as_str(r_doc); if lbl != str { - fail!(fmt!("Expected label %s but found %s", lbl, - str)); + fail!(fmt!("Expected label %s but found %s", + lbl, + str)); + } + } + } + } + + #[cfg(not(stage0))] + fn _check_label(&mut self, lbl: &str) { + if self.pos < self.parent.end { + let TaggedDoc { tag: r_tag, doc: r_doc } = + doc_at(self.parent.data, self.pos); + + if r_tag == (EsLabel as uint) { + self.pos = r_doc.end; + let str = doc_as_str(r_doc); + if lbl != str { + fail!(fmt!("Expected label %s but found %s", + lbl, + str)); } } } } + #[cfg(stage0)] fn next_doc(&self, exp_tag: EbmlEncoderTag) -> Doc { debug!(". next_doc(exp_tag=%?)", exp_tag); if self.pos >= self.parent.end { @@ -298,6 +342,30 @@ pub mod reader { r_doc } + #[cfg(not(stage0))] + fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> Doc { + debug!(". next_doc(exp_tag=%?)", exp_tag); + if self.pos >= self.parent.end { + fail!(~"no more documents in current node!"); + } + let TaggedDoc { tag: r_tag, doc: r_doc } = + doc_at(self.parent.data, self.pos); + debug!("self.parent=%?-%? self.pos=%? r_tag=%? r_doc=%?-%?", + copy self.parent.start, copy self.parent.end, + copy self.pos, r_tag, r_doc.start, r_doc.end); + if r_tag != (exp_tag as uint) { + fail!(fmt!("expected EBML doc with tag %? but found tag %?", + exp_tag, r_tag)); + } + if r_doc.end > self.parent.end { + fail!(fmt!("invalid EBML, child extends to 0x%x, \ + parent to 0x%x", r_doc.end, self.parent.end)); + } + self.pos = r_doc.end; + r_doc + } + + #[cfg(stage0)] fn push_doc(&self, d: Doc, f: &fn() -> T) -> T { let old_parent = self.parent; let old_pos = self.pos; @@ -309,21 +377,58 @@ pub mod reader { r } + #[cfg(not(stage0))] + fn push_doc(&mut self, d: Doc, f: &fn() -> T) -> T { + let old_parent = self.parent; + let old_pos = self.pos; + self.parent = d; + self.pos = d.start; + let r = f(); + self.parent = old_parent; + self.pos = old_pos; + r + } + + #[cfg(stage0)] fn _next_uint(&self, exp_tag: EbmlEncoderTag) -> uint { let r = doc_as_u32(self.next_doc(exp_tag)); debug!("_next_uint exp_tag=%? result=%?", exp_tag, r); r as uint } + + #[cfg(not(stage0))] + fn _next_uint(&mut self, exp_tag: EbmlEncoderTag) -> uint { + let r = doc_as_u32(self.next_doc(exp_tag)); + debug!("_next_uint exp_tag=%? result=%?", exp_tag, r); + r as uint + } } pub impl Decoder { + #[cfg(stage0)] fn read_opaque(&self, op: &fn(Doc) -> R) -> R { do self.push_doc(self.next_doc(EsOpaque)) { op(copy self.parent) } } + + #[cfg(not(stage0))] + fn read_opaque(&mut self, op: &fn(&mut Decoder, Doc) -> R) -> R { + let doc = self.next_doc(EsOpaque); + + let (old_parent, old_pos) = (self.parent, self.pos); + self.parent = doc; + self.pos = doc.start; + + let result = op(self, doc); + + self.parent = old_parent; + self.pos = old_pos; + result + } } + #[cfg(stage0)] impl serialize::Decoder for Decoder { fn read_nil(&self) -> () { () } @@ -339,10 +444,18 @@ pub mod reader { v as uint } - fn read_i64(&self) -> i64 { doc_as_u64(self.next_doc(EsI64)) as i64 } - fn read_i32(&self) -> i32 { doc_as_u32(self.next_doc(EsI32)) as i32 } - fn read_i16(&self) -> i16 { doc_as_u16(self.next_doc(EsI16)) as i16 } - fn read_i8 (&self) -> i8 { doc_as_u8 (self.next_doc(EsI8 )) as i8 } + fn read_i64(&self) -> i64 { + doc_as_u64(self.next_doc(EsI64)) as i64 + } + fn read_i32(&self) -> i32 { + doc_as_u32(self.next_doc(EsI32)) as i32 + } + fn read_i16(&self) -> i16 { + doc_as_u16(self.next_doc(EsI16)) as i16 + } + fn read_i8 (&self) -> i8 { + doc_as_u8(self.next_doc(EsI8 )) as i8 + } fn read_int(&self) -> int { let v = doc_as_u64(self.next_doc(EsInt)) as i64; if v > (int::max_value as i64) || v < (int::min_value as i64) { @@ -351,8 +464,9 @@ pub mod reader { v as int } - fn read_bool(&self) -> bool { doc_as_u8(self.next_doc(EsBool)) - as bool } + fn read_bool(&self) -> bool { + doc_as_u8(self.next_doc(EsBool)) as bool + } fn read_f64(&self) -> f64 { fail!(~"read_f64()"); } fn read_f32(&self) -> f32 { fail!(~"read_f32()"); } @@ -367,7 +481,10 @@ pub mod reader { self.push_doc(self.next_doc(EsEnum), f) } - fn read_enum_variant(&self, _names: &[&str], f: &fn(uint) -> T) -> T { + fn read_enum_variant(&self, + _: &[&str], + f: &fn(uint) -> T) + -> T { debug!("read_enum_variant()"); let idx = self._next_uint(EsEnumVid); debug!(" idx=%u", idx); @@ -376,12 +493,17 @@ pub mod reader { } } - fn read_enum_variant_arg(&self, idx: uint, f: &fn() -> T) -> T { + fn read_enum_variant_arg(&self, + idx: uint, + f: &fn() -> T) -> T { debug!("read_enum_variant_arg(idx=%u)", idx); f() } - fn read_enum_struct_variant(&self, _names: &[&str], f: &fn(uint) -> T) -> T { + fn read_enum_struct_variant(&self, + _: &[&str], + f: &fn(uint) -> T) + -> T { debug!("read_enum_struct_variant()"); let idx = self._next_uint(EsEnumVid); debug!(" idx=%u", idx); @@ -390,32 +512,34 @@ pub mod reader { } } - fn read_enum_struct_variant_field(&self, name: &str, idx: uint, f: &fn() -> T) -> T { + fn read_enum_struct_variant_field(&self, + name: &str, + idx: uint, + f: &fn() -> T) + -> T { debug!("read_enum_struct_variant_arg(name=%?, idx=%u)", name, idx); f() } - fn read_struct(&self, name: &str, _len: uint, f: &fn() -> T) -> T { + fn read_struct(&self, + name: &str, + _: uint, + f: &fn() -> T) + -> T { debug!("read_struct(name=%s)", name); f() } - #[cfg(stage0)] - fn read_field(&self, name: &str, idx: uint, f: &fn() -> T) -> T { + fn read_field(&self, + name: &str, + idx: uint, + f: &fn() -> T) + -> T { debug!("read_field(name=%?, idx=%u)", name, idx); self._check_label(name); f() } - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn read_struct_field(&self, name: &str, idx: uint, f: &fn() -> T) -> T { - debug!("read_struct_field(name=%?, idx=%u)", name, idx); - self._check_label(name); - f() - } - fn read_tuple(&self, f: &fn(uint) -> T) -> T { debug!("read_tuple()"); self.read_seq(f) @@ -426,12 +550,18 @@ pub mod reader { self.read_seq_elt(idx, f) } - fn read_tuple_struct(&self, name: &str, f: &fn(uint) -> T) -> T { + fn read_tuple_struct(&self, + name: &str, + f: &fn(uint) -> T) + -> T { debug!("read_tuple_struct(name=%?)", name); self.read_tuple(f) } - fn read_tuple_struct_arg(&self, idx: uint, f: &fn() -> T) -> T { + fn read_tuple_struct_arg(&self, + idx: uint, + f: &fn() -> T) + -> T { debug!("read_tuple_struct_arg(idx=%u)", idx); self.read_tuple_arg(idx, f) } @@ -478,6 +608,245 @@ pub mod reader { fail!(~"read_map_elt_val is unimplemented"); } } + + #[cfg(not(stage0))] + impl serialize::Decoder for Decoder { + fn read_nil(&mut self) -> () { () } + + fn read_u64(&mut self) -> u64 { doc_as_u64(self.next_doc(EsU64)) } + fn read_u32(&mut self) -> u32 { doc_as_u32(self.next_doc(EsU32)) } + fn read_u16(&mut self) -> u16 { doc_as_u16(self.next_doc(EsU16)) } + fn read_u8 (&mut self) -> u8 { doc_as_u8 (self.next_doc(EsU8 )) } + fn read_uint(&mut self) -> uint { + let v = doc_as_u64(self.next_doc(EsUint)); + if v > (::core::uint::max_value as u64) { + fail!(fmt!("uint %? too large for this architecture", v)); + } + v as uint + } + + fn read_i64(&mut self) -> i64 { + doc_as_u64(self.next_doc(EsI64)) as i64 + } + fn read_i32(&mut self) -> i32 { + doc_as_u32(self.next_doc(EsI32)) as i32 + } + fn read_i16(&mut self) -> i16 { + doc_as_u16(self.next_doc(EsI16)) as i16 + } + fn read_i8 (&mut self) -> i8 { + doc_as_u8(self.next_doc(EsI8 )) as i8 + } + fn read_int(&mut self) -> int { + let v = doc_as_u64(self.next_doc(EsInt)) as i64; + if v > (int::max_value as i64) || v < (int::min_value as i64) { + fail!(fmt!("int %? out of range for this architecture", v)); + } + v as int + } + + fn read_bool(&mut self) -> bool { + doc_as_u8(self.next_doc(EsBool)) as bool + } + + fn read_f64(&mut self) -> f64 { fail!(~"read_f64()"); } + fn read_f32(&mut self) -> f32 { fail!(~"read_f32()"); } + fn read_float(&mut self) -> float { fail!(~"read_float()"); } + fn read_char(&mut self) -> char { fail!(~"read_char()"); } + fn read_str(&mut self) -> ~str { doc_as_str(self.next_doc(EsStr)) } + + // Compound types: + fn read_enum(&mut self, + name: &str, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_enum(%s)", name); + self._check_label(name); + + let doc = self.next_doc(EsEnum); + + let (old_parent, old_pos) = (self.parent, self.pos); + self.parent = doc; + self.pos = self.parent.start; + + let result = f(self); + + self.parent = old_parent; + self.pos = old_pos; + result + } + + fn read_enum_variant(&mut self, + _: &[&str], + f: &fn(&mut Decoder, uint) -> T) + -> T { + debug!("read_enum_variant()"); + let idx = self._next_uint(EsEnumVid); + debug!(" idx=%u", idx); + + let doc = self.next_doc(EsEnumBody); + + let (old_parent, old_pos) = (self.parent, self.pos); + self.parent = doc; + self.pos = self.parent.start; + + let result = f(self, idx); + + self.parent = old_parent; + self.pos = old_pos; + result + } + + fn read_enum_variant_arg(&mut self, + idx: uint, + f: &fn(&mut Decoder) -> T) -> T { + debug!("read_enum_variant_arg(idx=%u)", idx); + f(self) + } + + fn read_enum_struct_variant(&mut self, + _: &[&str], + f: &fn(&mut Decoder, uint) -> T) + -> T { + debug!("read_enum_struct_variant()"); + let idx = self._next_uint(EsEnumVid); + debug!(" idx=%u", idx); + + let doc = self.next_doc(EsEnumBody); + + let (old_parent, old_pos) = (self.parent, self.pos); + self.parent = doc; + self.pos = self.parent.start; + + let result = f(self, idx); + + self.parent = old_parent; + self.pos = old_pos; + result + } + + fn read_enum_struct_variant_field(&mut self, + name: &str, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_enum_struct_variant_arg(name=%?, idx=%u)", name, idx); + f(self) + } + + fn read_struct(&mut self, + name: &str, + _: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_struct(name=%s)", name); + f(self) + } + + fn read_struct_field(&mut self, + name: &str, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_struct_field(name=%?, idx=%u)", name, idx); + self._check_label(name); + f(self) + } + + fn read_tuple(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T { + debug!("read_tuple()"); + self.read_seq(f) + } + + fn read_tuple_arg(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_tuple_arg(idx=%u)", idx); + self.read_seq_elt(idx, f) + } + + fn read_tuple_struct(&mut self, + name: &str, + f: &fn(&mut Decoder, uint) -> T) + -> T { + debug!("read_tuple_struct(name=%?)", name); + self.read_tuple(f) + } + + fn read_tuple_struct_arg(&mut self, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_tuple_struct_arg(idx=%u)", idx); + self.read_tuple_arg(idx, f) + } + + fn read_option(&mut self, f: &fn(&mut Decoder, bool) -> T) -> T { + debug!("read_option()"); + do self.read_enum("Option") |this| { + do this.read_enum_variant(["None", "Some"]) |this, idx| { + match idx { + 0 => f(this, false), + 1 => f(this, true), + _ => fail!(), + } + } + } + } + + fn read_seq(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T { + debug!("read_seq()"); + let doc = self.next_doc(EsVec); + + let (old_parent, old_pos) = (self.parent, self.pos); + self.parent = doc; + self.pos = self.parent.start; + + let len = self._next_uint(EsVecLen); + debug!(" len=%u", len); + let result = f(self, len); + + self.parent = old_parent; + self.pos = old_pos; + result + } + + fn read_seq_elt(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_seq_elt(idx=%u)", idx); + let doc = self.next_doc(EsVecElt); + + let (old_parent, old_pos) = (self.parent, self.pos); + self.parent = doc; + self.pos = self.parent.start; + + let result = f(self); + + self.parent = old_parent; + self.pos = old_pos; + result + } + + fn read_map(&mut self, _: &fn(&mut Decoder, uint) -> T) -> T { + debug!("read_map()"); + fail!(~"read_map is unimplemented"); + } + + fn read_map_elt_key(&mut self, + idx: uint, + _: &fn(&mut Decoder) -> T) + -> T { + debug!("read_map_elt_key(idx=%u)", idx); + fail!(~"read_map_elt_val is unimplemented"); + } + + fn read_map_elt_val(&mut self, + idx: uint, + _: &fn(&mut Decoder) -> T) + -> T { + debug!("read_map_elt_val(idx=%u)", idx); + fail!(~"read_map_elt_val is unimplemented"); + } + } } pub mod writer { @@ -522,6 +891,7 @@ pub mod writer { } // FIXME (#2741): Provide a function to write the standard ebml header. + #[cfg(stage0)] pub impl Encoder { fn start_tag(&self, tag_id: uint) { debug!("Start tag %u", tag_id); @@ -617,13 +987,111 @@ pub mod writer { } } + // FIXME (#2741): Provide a function to write the standard ebml header. + #[cfg(not(stage0))] + pub impl Encoder { + fn start_tag(&mut self, tag_id: uint) { + debug!("Start tag %u", tag_id); + + // Write the enum ID: + write_vuint(self.writer, tag_id); + + // Write a placeholder four-byte size. + self.size_positions.push(self.writer.tell()); + let zeroes: &[u8] = &[0u8, 0u8, 0u8, 0u8]; + self.writer.write(zeroes); + } + + fn end_tag(&mut self) { + let last_size_pos = self.size_positions.pop(); + let cur_pos = self.writer.tell(); + self.writer.seek(last_size_pos as int, io::SeekSet); + let size = (cur_pos - last_size_pos - 4u); + write_sized_vuint(self.writer, size, 4u); + self.writer.seek(cur_pos as int, io::SeekSet); + + debug!("End tag (size = %u)", size); + } + + fn wr_tag(&mut self, tag_id: uint, blk: &fn()) { + self.start_tag(tag_id); + blk(); + self.end_tag(); + } + + fn wr_tagged_bytes(&mut self, tag_id: uint, b: &[u8]) { + write_vuint(self.writer, tag_id); + write_vuint(self.writer, vec::len(b)); + self.writer.write(b); + } + + fn wr_tagged_u64(&mut self, tag_id: uint, v: u64) { + do io::u64_to_be_bytes(v, 8u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_u32(&mut self, tag_id: uint, v: u32) { + do io::u64_to_be_bytes(v as u64, 4u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_u16(&mut self, tag_id: uint, v: u16) { + do io::u64_to_be_bytes(v as u64, 2u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_u8(&mut self, tag_id: uint, v: u8) { + self.wr_tagged_bytes(tag_id, &[v]); + } + + fn wr_tagged_i64(&mut self, tag_id: uint, v: i64) { + do io::u64_to_be_bytes(v as u64, 8u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_i32(&mut self, tag_id: uint, v: i32) { + do io::u64_to_be_bytes(v as u64, 4u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_i16(&mut self, tag_id: uint, v: i16) { + do io::u64_to_be_bytes(v as u64, 2u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_i8(&mut self, tag_id: uint, v: i8) { + self.wr_tagged_bytes(tag_id, &[v as u8]); + } + + fn wr_tagged_str(&mut self, tag_id: uint, v: &str) { + str::byte_slice(v, |b| self.wr_tagged_bytes(tag_id, b)); + } + + fn wr_bytes(&mut self, b: &[u8]) { + debug!("Write %u bytes", vec::len(b)); + self.writer.write(b); + } + + fn wr_str(&mut self, s: &str) { + debug!("Write str: %?", s); + self.writer.write(str::to_bytes(s)); + } + } + // FIXME (#2743): optionally perform "relaxations" on end_tag to more // efficiently encode sizes; this is a fixed point iteration // Set to true to generate more debugging in EBML code. // Totally lame approach. - static debug: bool = false; + static debug: bool = true; + #[cfg(stage0)] priv impl Encoder { // used internally to emit things like the vector length and so on fn _emit_tagged_uint(&self, t: EbmlEncoderTag, v: uint) { @@ -642,6 +1110,26 @@ pub mod writer { } } + #[cfg(not(stage0))] + priv impl Encoder { + // used internally to emit things like the vector length and so on + fn _emit_tagged_uint(&mut self, t: EbmlEncoderTag, v: uint) { + assert!(v <= 0xFFFF_FFFF_u); + self.wr_tagged_u32(t as uint, v as u32); + } + + fn _emit_label(&mut self, label: &str) { + // There are various strings that we have access to, such as + // the name of a record field, which do not actually appear in + // the encoded EBML (normally). This is just for + // efficiency. When debugging, though, we can emit such + // labels and then they will be checked by decoder to + // try and check failures more quickly. + if debug { self.wr_tagged_str(EsLabel as uint, label) } + } + } + + #[cfg(stage0)] pub impl Encoder { fn emit_opaque(&self, f: &fn()) { do self.wr_tag(EsOpaque as uint) { @@ -650,24 +1138,50 @@ pub mod writer { } } + #[cfg(not(stage0))] + pub impl Encoder { + fn emit_opaque(&mut self, f: &fn(&mut Encoder)) { + self.start_tag(EsOpaque as uint); + f(self); + self.end_tag(); + } + } + + #[cfg(stage0)] impl ::serialize::Encoder for Encoder { fn emit_nil(&self) {} fn emit_uint(&self, v: uint) { self.wr_tagged_u64(EsUint as uint, v as u64); } - fn emit_u64(&self, v: u64) { self.wr_tagged_u64(EsU64 as uint, v); } - fn emit_u32(&self, v: u32) { self.wr_tagged_u32(EsU32 as uint, v); } - fn emit_u16(&self, v: u16) { self.wr_tagged_u16(EsU16 as uint, v); } - fn emit_u8(&self, v: u8) { self.wr_tagged_u8 (EsU8 as uint, v); } + fn emit_u64(&self, v: u64) { + self.wr_tagged_u64(EsU64 as uint, v); + } + fn emit_u32(&self, v: u32) { + self.wr_tagged_u32(EsU32 as uint, v); + } + fn emit_u16(&self, v: u16) { + self.wr_tagged_u16(EsU16 as uint, v); + } + fn emit_u8(&self, v: u8) { + self.wr_tagged_u8(EsU8 as uint, v); + } fn emit_int(&self, v: int) { self.wr_tagged_i64(EsInt as uint, v as i64); } - fn emit_i64(&self, v: i64) { self.wr_tagged_i64(EsI64 as uint, v); } - fn emit_i32(&self, v: i32) { self.wr_tagged_i32(EsI32 as uint, v); } - fn emit_i16(&self, v: i16) { self.wr_tagged_i16(EsI16 as uint, v); } - fn emit_i8(&self, v: i8) { self.wr_tagged_i8 (EsI8 as uint, v); } + fn emit_i64(&self, v: i64) { + self.wr_tagged_i64(EsI64 as uint, v); + } + fn emit_i32(&self, v: i32) { + self.wr_tagged_i32(EsI32 as uint, v); + } + fn emit_i16(&self, v: i16) { + self.wr_tagged_i16(EsI16 as uint, v); + } + fn emit_i8(&self, v: i8) { + self.wr_tagged_i8(EsI8 as uint, v); + } fn emit_bool(&self, v: bool) { self.wr_tagged_u8(EsBool as uint, v as u8) @@ -697,41 +1211,56 @@ pub mod writer { self.wr_tag(EsEnum as uint, f) } - fn emit_enum_variant(&self, _v_name: &str, v_id: uint, _cnt: uint, + fn emit_enum_variant(&self, + _: &str, + v_id: uint, + _: uint, f: &fn()) { self._emit_tagged_uint(EsEnumVid, v_id); self.wr_tag(EsEnumBody as uint, f) } - fn emit_enum_variant_arg(&self, _idx: uint, f: &fn()) { f() } + fn emit_enum_variant_arg(&self, _: uint, f: &fn()) { + f() + } - fn emit_enum_struct_variant(&self, v_name: &str, v_id: uint, cnt: uint, f: &fn()) { + fn emit_enum_struct_variant(&self, + v_name: &str, + v_id: uint, + cnt: uint, + f: &fn()) { self.emit_enum_variant(v_name, v_id, cnt, f) } - fn emit_enum_struct_variant_field(&self, _f_name: &str, idx: uint, f: &fn()) { + fn emit_enum_struct_variant_field(&self, + _: &str, + idx: uint, + f: &fn()) { self.emit_enum_variant_arg(idx, f) } - fn emit_struct(&self, _name: &str, _len: uint, f: &fn()) { f() } - #[cfg(stage0)] - fn emit_field(&self, name: &str, _idx: uint, f: &fn()) { - self._emit_label(name); + fn emit_struct(&self, _: &str, _len: uint, f: &fn()) { f() } - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn emit_struct_field(&self, name: &str, _idx: uint, f: &fn()) { + + fn emit_field(&self, name: &str, _idx: uint, f: &fn()) { self._emit_label(name); f() } - fn emit_tuple(&self, len: uint, f: &fn()) { self.emit_seq(len, f) } - fn emit_tuple_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) } + fn emit_tuple(&self, len: uint, f: &fn()) { + self.emit_seq(len, f) + } + fn emit_tuple_arg(&self, idx: uint, f: &fn()) { + self.emit_seq_elt(idx, f) + } - fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { self.emit_seq(len, f) } - fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) } + fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { + self.emit_seq(len, f) + } + fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { + self.emit_seq_elt(idx, f) + } fn emit_option(&self, f: &fn()) { self.emit_enum("Option", f); @@ -766,6 +1295,167 @@ pub mod writer { fail!(~"emit_map_elt_val is unimplemented"); } } + + #[cfg(not(stage0))] + impl ::serialize::Encoder for Encoder { + fn emit_nil(&mut self) {} + + fn emit_uint(&mut self, v: uint) { + self.wr_tagged_u64(EsUint as uint, v as u64); + } + fn emit_u64(&mut self, v: u64) { + self.wr_tagged_u64(EsU64 as uint, v); + } + fn emit_u32(&mut self, v: u32) { + self.wr_tagged_u32(EsU32 as uint, v); + } + fn emit_u16(&mut self, v: u16) { + self.wr_tagged_u16(EsU16 as uint, v); + } + fn emit_u8(&mut self, v: u8) { + self.wr_tagged_u8(EsU8 as uint, v); + } + + fn emit_int(&mut self, v: int) { + self.wr_tagged_i64(EsInt as uint, v as i64); + } + fn emit_i64(&mut self, v: i64) { + self.wr_tagged_i64(EsI64 as uint, v); + } + fn emit_i32(&mut self, v: i32) { + self.wr_tagged_i32(EsI32 as uint, v); + } + fn emit_i16(&mut self, v: i16) { + self.wr_tagged_i16(EsI16 as uint, v); + } + fn emit_i8(&mut self, v: i8) { + self.wr_tagged_i8(EsI8 as uint, v); + } + + fn emit_bool(&mut self, v: bool) { + self.wr_tagged_u8(EsBool as uint, v as u8) + } + + // FIXME (#2742): implement these + fn emit_f64(&mut self, _v: f64) { + fail!(~"Unimplemented: serializing an f64"); + } + fn emit_f32(&mut self, _v: f32) { + fail!(~"Unimplemented: serializing an f32"); + } + fn emit_float(&mut self, _v: float) { + fail!(~"Unimplemented: serializing a float"); + } + + fn emit_char(&mut self, _v: char) { + fail!(~"Unimplemented: serializing a char"); + } + + fn emit_str(&mut self, v: &str) { + self.wr_tagged_str(EsStr as uint, v) + } + + fn emit_enum(&mut self, name: &str, f: &fn(&mut Encoder)) { + self._emit_label(name); + self.start_tag(EsEnum as uint); + f(self); + self.end_tag(); + } + + fn emit_enum_variant(&mut self, + _: &str, + v_id: uint, + _: uint, + f: &fn(&mut Encoder)) { + self._emit_tagged_uint(EsEnumVid, v_id); + self.start_tag(EsEnumBody as uint); + f(self); + self.end_tag(); + } + + fn emit_enum_variant_arg(&mut self, _: uint, f: &fn(&mut Encoder)) { + f(self) + } + + fn emit_enum_struct_variant(&mut self, + v_name: &str, + v_id: uint, + cnt: uint, + f: &fn(&mut Encoder)) { + self.emit_enum_variant(v_name, v_id, cnt, f) + } + + fn emit_enum_struct_variant_field(&mut self, + _: &str, + idx: uint, + f: &fn(&mut Encoder)) { + self.emit_enum_variant_arg(idx, f) + } + + fn emit_struct(&mut self, _: &str, _len: uint, f: &fn(&mut Encoder)) { + f(self) + } + + fn emit_struct_field(&mut self, + name: &str, + _: uint, + f: &fn(&mut Encoder)) { + self._emit_label(name); + f(self) + } + + fn emit_tuple(&mut self, len: uint, f: &fn(&mut Encoder)) { + self.emit_seq(len, f) + } + fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) { + self.emit_seq_elt(idx, f) + } + + fn emit_tuple_struct(&mut self, + _: &str, + len: uint, + f: &fn(&mut Encoder)) { + self.emit_seq(len, f) + } + fn emit_tuple_struct_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) { + self.emit_seq_elt(idx, f) + } + + fn emit_option(&mut self, f: &fn(&mut Encoder)) { + self.emit_enum("Option", f); + } + fn emit_option_none(&mut self) { + self.emit_enum_variant("None", 0, 0, |_| ()) + } + fn emit_option_some(&mut self, f: &fn(&mut Encoder)) { + self.emit_enum_variant("Some", 1, 1, f) + } + + fn emit_seq(&mut self, len: uint, f: &fn(&mut Encoder)) { + self.start_tag(EsVec as uint); + self._emit_tagged_uint(EsVecLen, len); + f(self); + self.end_tag(); + } + + fn emit_seq_elt(&mut self, _idx: uint, f: &fn(&mut Encoder)) { + self.start_tag(EsVecElt as uint); + f(self); + self.end_tag(); + } + + fn emit_map(&mut self, _len: uint, _f: &fn(&mut Encoder)) { + fail!(~"emit_map is unimplemented"); + } + + fn emit_map_elt_key(&mut self, _idx: uint, _f: &fn(&mut Encoder)) { + fail!(~"emit_map_elt_key is unimplemented"); + } + + fn emit_map_elt_val(&mut self, _idx: uint, _f: &fn(&mut Encoder)) { + fail!(~"emit_map_elt_val is unimplemented"); + } + } } // ___________________________________________________________________________ @@ -786,12 +1476,12 @@ mod tests { fn test_v(v: Option) { debug!("v == %?", v); let bytes = do io::with_bytes_writer |wr| { - let ebml_w = writer::Encoder(wr); - v.encode(&ebml_w) + let mut ebml_w = writer::Encoder(wr); + v.encode(&mut ebml_w) }; let ebml_doc = reader::Doc(@bytes); - let deser = reader::Decoder(ebml_doc); - let v1 = serialize::Decodable::decode(&deser); + let mut deser = reader::Decoder(ebml_doc); + let v1 = serialize::Decodable::decode(&mut deser); debug!("v1 == %?", v1); assert!(v == v1); } diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index bd0acb849fc..55ea9c2948b 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -438,8 +438,11 @@ pub mod flatteners { SerializingFlattener */ + #[cfg(stage0)] pub fn deserialize_buffer>(buf: &[u8]) -> T { + T: Decodable>( + buf: &[u8]) + -> T { let buf = vec::from_slice(buf); let buf_reader = @BufReader::new(buf); let reader = buf_reader as @Reader; @@ -447,14 +450,40 @@ pub mod flatteners { Decodable::decode(&deser) } + #[cfg(not(stage0))] + pub fn deserialize_buffer>( + buf: &[u8]) + -> T { + let buf = vec::from_slice(buf); + let buf_reader = @BufReader::new(buf); + let reader = buf_reader as @Reader; + let mut deser: D = FromReader::from_reader(reader); + Decodable::decode(&mut deser) + } + + #[cfg(stage0)] pub fn serialize_value>(val: &T) -> ~[u8] { + T: Encodable>( + val: &T) + -> ~[u8] { do io::with_bytes_writer |writer| { let ser = FromWriter::from_writer(writer); val.encode(&ser); } } + #[cfg(not(stage0))] + pub fn serialize_value>( + val: &T) + -> ~[u8] { + do io::with_bytes_writer |writer| { + let mut ser = FromWriter::from_writer(writer); + val.encode(&mut ser); + } + } + pub trait FromReader { fn from_reader(r: @Reader) -> Self; } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 7353bec7333..6951ee377c9 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -72,9 +72,12 @@ pub struct Encoder { } pub fn Encoder(wr: @io::Writer) -> Encoder { - Encoder { wr: wr } + Encoder { + wr: wr + } } +#[cfg(stage0)] impl serialize::Encoder for Encoder { fn emit_nil(&self) { self.wr.write_str("null") } @@ -109,7 +112,11 @@ impl serialize::Encoder for Encoder { fn emit_enum(&self, _name: &str, f: &fn()) { f() } - fn emit_enum_variant(&self, name: &str, _id: uint, cnt: uint, f: &fn()) { + fn emit_enum_variant(&self, + name: &str, + _id: uint, + cnt: uint, + f: &fn()) { // enums are encoded as strings or vectors: // Bunny => "Bunny" // Kangaroo(34,"William") => ["Kangaroo",[34,"William"]] @@ -130,19 +137,27 @@ impl serialize::Encoder for Encoder { f(); } - fn emit_enum_struct_variant(&self, name: &str, id: uint, cnt: uint, f: &fn()) { + fn emit_enum_struct_variant(&self, + name: &str, + id: uint, + cnt: uint, + f: &fn()) { self.emit_enum_variant(name, id, cnt, f) } - fn emit_enum_struct_variant_field(&self, _field: &str, idx: uint, f: &fn()) { + fn emit_enum_struct_variant_field(&self, + _: &str, + idx: uint, + f: &fn()) { self.emit_enum_variant_arg(idx, f) } - fn emit_struct(&self, _name: &str, _len: uint, f: &fn()) { + fn emit_struct(&self, _: &str, _: uint, f: &fn()) { self.wr.write_char('{'); f(); self.wr.write_char('}'); } + #[cfg(stage0)] fn emit_field(&self, name: &str, idx: uint, f: &fn()) { if idx != 0 { self.wr.write_char(','); } @@ -150,6 +165,7 @@ impl serialize::Encoder for Encoder { self.wr.write_char(':'); f(); } + #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] @@ -161,10 +177,16 @@ impl serialize::Encoder for Encoder { } fn emit_tuple(&self, len: uint, f: &fn()) { self.emit_seq(len, f) } - fn emit_tuple_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) } + fn emit_tuple_arg(&self, idx: uint, f: &fn()) { + self.emit_seq_elt(idx, f) + } - fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { self.emit_seq(len, f) } - fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) } + fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { + self.emit_seq(len, f) + } + fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { + self.emit_seq_elt(idx, f) + } fn emit_option(&self, f: &fn()) { f(); } fn emit_option_none(&self) { self.emit_nil(); } @@ -198,15 +220,163 @@ impl serialize::Encoder for Encoder { } } +#[cfg(not(stage0))] +impl serialize::Encoder for Encoder { + fn emit_nil(&mut self) { self.wr.write_str("null") } + + fn emit_uint(&mut self, v: uint) { self.emit_float(v as float); } + fn emit_u64(&mut self, v: u64) { self.emit_float(v as float); } + fn emit_u32(&mut self, v: u32) { self.emit_float(v as float); } + fn emit_u16(&mut self, v: u16) { self.emit_float(v as float); } + fn emit_u8(&mut self, v: u8) { self.emit_float(v as float); } + + fn emit_int(&mut self, v: int) { self.emit_float(v as float); } + fn emit_i64(&mut self, v: i64) { self.emit_float(v as float); } + fn emit_i32(&mut self, v: i32) { self.emit_float(v as float); } + fn emit_i16(&mut self, v: i16) { self.emit_float(v as float); } + fn emit_i8(&mut self, v: i8) { self.emit_float(v as float); } + + fn emit_bool(&mut self, v: bool) { + if v { + self.wr.write_str("true"); + } else { + self.wr.write_str("false"); + } + } + + fn emit_f64(&mut self, v: f64) { self.emit_float(v as float); } + fn emit_f32(&mut self, v: f32) { self.emit_float(v as float); } + fn emit_float(&mut self, v: float) { + self.wr.write_str(float::to_str_digits(v, 6u)); + } + + fn emit_char(&mut self, v: char) { self.emit_str(str::from_char(v)) } + fn emit_str(&mut self, v: &str) { self.wr.write_str(escape_str(v)) } + + fn emit_enum(&mut self, _name: &str, f: &fn(&mut Encoder)) { f(self) } + + fn emit_enum_variant(&mut self, + name: &str, + _id: uint, + cnt: uint, + f: &fn(&mut Encoder)) { + // enums are encoded as strings or vectors: + // Bunny => "Bunny" + // Kangaroo(34,"William") => ["Kangaroo",[34,"William"]] + + if cnt == 0 { + self.wr.write_str(escape_str(name)); + } else { + self.wr.write_char('['); + self.wr.write_str(escape_str(name)); + self.wr.write_char(','); + f(self); + self.wr.write_char(']'); + } + } + + fn emit_enum_variant_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) { + if idx != 0 { + self.wr.write_char(','); + } + f(self); + } + + fn emit_enum_struct_variant(&mut self, + name: &str, + id: uint, + cnt: uint, + f: &fn(&mut Encoder)) { + self.emit_enum_variant(name, id, cnt, f) + } + + fn emit_enum_struct_variant_field(&mut self, + _: &str, + idx: uint, + f: &fn(&mut Encoder)) { + self.emit_enum_variant_arg(idx, f) + } + + fn emit_struct(&mut self, _: &str, _: uint, f: &fn(&mut Encoder)) { + self.wr.write_char('{'); + f(self); + self.wr.write_char('}'); + } + + fn emit_struct_field(&mut self, + name: &str, + idx: uint, + f: &fn(&mut Encoder)) { + if idx != 0 { self.wr.write_char(','); } + self.wr.write_str(escape_str(name)); + self.wr.write_char(':'); + f(self); + } + + fn emit_tuple(&mut self, len: uint, f: &fn(&mut Encoder)) { + self.emit_seq(len, f) + } + fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) { + self.emit_seq_elt(idx, f) + } + + fn emit_tuple_struct(&mut self, + _name: &str, + len: uint, + f: &fn(&mut Encoder)) { + self.emit_seq(len, f) + } + fn emit_tuple_struct_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) { + self.emit_seq_elt(idx, f) + } + + fn emit_option(&mut self, f: &fn(&mut Encoder)) { f(self); } + fn emit_option_none(&mut self) { self.emit_nil(); } + fn emit_option_some(&mut self, f: &fn(&mut Encoder)) { f(self); } + + fn emit_seq(&mut self, _len: uint, f: &fn(&mut Encoder)) { + self.wr.write_char('['); + f(self); + self.wr.write_char(']'); + } + + fn emit_seq_elt(&mut self, idx: uint, f: &fn(&mut Encoder)) { + if idx != 0 { + self.wr.write_char(','); + } + f(self) + } + + fn emit_map(&mut self, _len: uint, f: &fn(&mut Encoder)) { + self.wr.write_char('{'); + f(self); + self.wr.write_char('}'); + } + + fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut Encoder)) { + if idx != 0 { self.wr.write_char(','); } + f(self) + } + + fn emit_map_elt_val(&mut self, _idx: uint, f: &fn(&mut Encoder)) { + self.wr.write_char(':'); + f(self) + } +} + pub struct PrettyEncoder { priv wr: @io::Writer, priv mut indent: uint, } pub fn PrettyEncoder(wr: @io::Writer) -> PrettyEncoder { - PrettyEncoder { wr: wr, indent: 0 } + PrettyEncoder { + wr: wr, + indent: 0, + } } +#[cfg(stage0)] impl serialize::Encoder for PrettyEncoder { fn emit_nil(&self) { self.wr.write_str("null") } @@ -241,7 +411,11 @@ impl serialize::Encoder for PrettyEncoder { fn emit_enum(&self, _name: &str, f: &fn()) { f() } - fn emit_enum_variant(&self, name: &str, _id: uint, cnt: uint, f: &fn()) { + fn emit_enum_variant(&self, + name: &str, + _: uint, + cnt: uint, + f: &fn()) { if cnt == 0 { self.wr.write_str(escape_str(name)); } else { @@ -267,11 +441,18 @@ impl serialize::Encoder for PrettyEncoder { f() } - fn emit_enum_struct_variant(&self, name: &str, id: uint, cnt: uint, f: &fn()) { + fn emit_enum_struct_variant(&self, + name: &str, + id: uint, + cnt: uint, + f: &fn()) { self.emit_enum_variant(name, id, cnt, f) } - fn emit_enum_struct_variant_field(&self, _field: &str, idx: uint, f: &fn()) { + fn emit_enum_struct_variant_field(&self, + _: &str, + idx: uint, + f: &fn()) { self.emit_enum_variant_arg(idx, f) } @@ -289,6 +470,7 @@ impl serialize::Encoder for PrettyEncoder { self.wr.write_char('}'); } } + #[cfg(stage0)] fn emit_field(&self, name: &str, idx: uint, f: &fn()) { if idx == 0 { @@ -301,6 +483,7 @@ impl serialize::Encoder for PrettyEncoder { self.wr.write_str(": "); f(); } + #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] @@ -316,11 +499,19 @@ impl serialize::Encoder for PrettyEncoder { f(); } - fn emit_tuple(&self, len: uint, f: &fn()) { self.emit_seq(len, f) } - fn emit_tuple_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) } + fn emit_tuple(&self, len: uint, f: &fn()) { + self.emit_seq(len, f) + } + fn emit_tuple_arg(&self, idx: uint, f: &fn()) { + self.emit_seq_elt(idx, f) + } - fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { self.emit_seq(len, f) } - fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) } + fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { + self.emit_seq(len, f) + } + fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { + self.emit_seq_elt(idx, f) + } fn emit_option(&self, f: &fn()) { f(); } fn emit_option_none(&self) { self.emit_nil(); } @@ -339,6 +530,7 @@ impl serialize::Encoder for PrettyEncoder { self.wr.write_char(']'); } } + fn emit_seq_elt(&self, idx: uint, f: &fn()) { if idx == 0 { self.wr.write_char('\n'); @@ -362,6 +554,7 @@ impl serialize::Encoder for PrettyEncoder { self.wr.write_char('}'); } } + fn emit_map_elt_key(&self, idx: uint, f: &fn()) { if idx == 0 { self.wr.write_char('\n'); @@ -378,6 +571,201 @@ impl serialize::Encoder for PrettyEncoder { } } +#[cfg(not(stage0))] +impl serialize::Encoder for PrettyEncoder { + fn emit_nil(&mut self) { self.wr.write_str("null") } + + fn emit_uint(&mut self, v: uint) { self.emit_float(v as float); } + fn emit_u64(&mut self, v: u64) { self.emit_float(v as float); } + fn emit_u32(&mut self, v: u32) { self.emit_float(v as float); } + fn emit_u16(&mut self, v: u16) { self.emit_float(v as float); } + fn emit_u8(&mut self, v: u8) { self.emit_float(v as float); } + + fn emit_int(&mut self, v: int) { self.emit_float(v as float); } + fn emit_i64(&mut self, v: i64) { self.emit_float(v as float); } + fn emit_i32(&mut self, v: i32) { self.emit_float(v as float); } + fn emit_i16(&mut self, v: i16) { self.emit_float(v as float); } + fn emit_i8(&mut self, v: i8) { self.emit_float(v as float); } + + fn emit_bool(&mut self, v: bool) { + if v { + self.wr.write_str("true"); + } else { + self.wr.write_str("false"); + } + } + + fn emit_f64(&mut self, v: f64) { self.emit_float(v as float); } + fn emit_f32(&mut self, v: f32) { self.emit_float(v as float); } + fn emit_float(&mut self, v: float) { + self.wr.write_str(float::to_str_digits(v, 6u)); + } + + fn emit_char(&mut self, v: char) { self.emit_str(str::from_char(v)) } + fn emit_str(&mut self, v: &str) { self.wr.write_str(escape_str(v)); } + + fn emit_enum(&mut self, _name: &str, f: &fn(&mut PrettyEncoder)) { + f(self) + } + + fn emit_enum_variant(&mut self, + name: &str, + _: uint, + cnt: uint, + f: &fn(&mut PrettyEncoder)) { + if cnt == 0 { + self.wr.write_str(escape_str(name)); + } else { + self.wr.write_char('['); + self.indent += 2; + self.wr.write_char('\n'); + self.wr.write_str(spaces(self.indent)); + self.wr.write_str(escape_str(name)); + self.wr.write_str(",\n"); + f(self); + self.wr.write_char('\n'); + self.indent -= 2; + self.wr.write_str(spaces(self.indent)); + self.wr.write_char(']'); + } + } + + fn emit_enum_variant_arg(&mut self, + idx: uint, + f: &fn(&mut PrettyEncoder)) { + if idx != 0 { + self.wr.write_str(",\n"); + } + self.wr.write_str(spaces(self.indent)); + f(self) + } + + fn emit_enum_struct_variant(&mut self, + name: &str, + id: uint, + cnt: uint, + f: &fn(&mut PrettyEncoder)) { + self.emit_enum_variant(name, id, cnt, f) + } + + fn emit_enum_struct_variant_field(&mut self, + _: &str, + idx: uint, + f: &fn(&mut PrettyEncoder)) { + self.emit_enum_variant_arg(idx, f) + } + + + fn emit_struct(&mut self, + _: &str, + len: uint, + f: &fn(&mut PrettyEncoder)) { + if len == 0 { + self.wr.write_str("{}"); + } else { + self.wr.write_char('{'); + self.indent += 2; + f(self); + self.wr.write_char('\n'); + self.indent -= 2; + self.wr.write_str(spaces(self.indent)); + self.wr.write_char('}'); + } + } + + fn emit_struct_field(&mut self, + name: &str, + idx: uint, + f: &fn(&mut PrettyEncoder)) { + if idx == 0 { + self.wr.write_char('\n'); + } else { + self.wr.write_str(",\n"); + } + self.wr.write_str(spaces(self.indent)); + self.wr.write_str(escape_str(name)); + self.wr.write_str(": "); + f(self); + } + + fn emit_tuple(&mut self, len: uint, f: &fn(&mut PrettyEncoder)) { + self.emit_seq(len, f) + } + fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut PrettyEncoder)) { + self.emit_seq_elt(idx, f) + } + + fn emit_tuple_struct(&mut self, + _: &str, + len: uint, + f: &fn(&mut PrettyEncoder)) { + self.emit_seq(len, f) + } + fn emit_tuple_struct_arg(&mut self, + idx: uint, + f: &fn(&mut PrettyEncoder)) { + self.emit_seq_elt(idx, f) + } + + fn emit_option(&mut self, f: &fn(&mut PrettyEncoder)) { f(self); } + fn emit_option_none(&mut self) { self.emit_nil(); } + fn emit_option_some(&mut self, f: &fn(&mut PrettyEncoder)) { f(self); } + + fn emit_seq(&mut self, len: uint, f: &fn(&mut PrettyEncoder)) { + if len == 0 { + self.wr.write_str("[]"); + } else { + self.wr.write_char('['); + self.indent += 2; + f(self); + self.wr.write_char('\n'); + self.indent -= 2; + self.wr.write_str(spaces(self.indent)); + self.wr.write_char(']'); + } + } + + fn emit_seq_elt(&mut self, idx: uint, f: &fn(&mut PrettyEncoder)) { + if idx == 0 { + self.wr.write_char('\n'); + } else { + self.wr.write_str(",\n"); + } + self.wr.write_str(spaces(self.indent)); + f(self) + } + + fn emit_map(&mut self, len: uint, f: &fn(&mut PrettyEncoder)) { + if len == 0 { + self.wr.write_str("{}"); + } else { + self.wr.write_char('{'); + self.indent += 2; + f(self); + self.wr.write_char('\n'); + self.indent -= 2; + self.wr.write_str(spaces(self.indent)); + self.wr.write_char('}'); + } + } + + fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut PrettyEncoder)) { + if idx == 0 { + self.wr.write_char('\n'); + } else { + self.wr.write_str(",\n"); + } + self.wr.write_str(spaces(self.indent)); + f(self); + } + + fn emit_map_elt_val(&mut self, _idx: uint, f: &fn(&mut PrettyEncoder)) { + self.wr.write_str(": "); + f(self); + } +} + +#[cfg(stage0)] impl serialize::Encodable for Json { fn encode(&self, e: &E) { match *self { @@ -391,9 +779,32 @@ impl serialize::Encodable for Json { } } +#[cfg(not(stage0))] +impl serialize::Encodable for Json { + fn encode(&self, e: &mut E) { + match *self { + Number(v) => v.encode(e), + String(ref v) => v.encode(e), + Boolean(v) => v.encode(e), + List(ref v) => v.encode(e), + Object(ref v) => v.encode(e), + Null => e.emit_nil(), + } + } +} + /// Encodes a json value into a io::writer +#[cfg(stage0)] pub fn to_writer(wr: @io::Writer, json: &Json) { - json.encode(&Encoder(wr)) + let encoder = Encoder(wr); + json.encode(&encoder) +} + +/// Encodes a json value into a io::writer +#[cfg(not(stage0))] +pub fn to_writer(wr: @io::Writer, json: &Json) { + let mut encoder = Encoder(wr); + json.encode(&mut encoder) } /// Encodes a json value into a string @@ -402,8 +813,17 @@ pub fn to_str(json: &Json) -> ~str { } /// Encodes a json value into a io::writer +#[cfg(stage0)] pub fn to_pretty_writer(wr: @io::Writer, json: &Json) { - json.encode(&PrettyEncoder(wr)) + let encoder = PrettyEncoder(wr); + json.encode(&encoder) +} + +/// Encodes a json value into a io::writer +#[cfg(not(stage0))] +pub fn to_pretty_writer(wr: @io::Writer, json: &Json) { + let mut encoder = PrettyEncoder(wr); + json.encode(&mut encoder) } /// Encodes a json value into a string @@ -794,9 +1214,12 @@ pub struct Decoder { } pub fn Decoder(json: Json) -> Decoder { - Decoder { stack: ~[json] } + Decoder { + stack: ~[json] + } } +#[cfg(stage0)] impl serialize::Decoder for Decoder { fn read_nil(&self) -> () { debug!("read_nil"); @@ -856,7 +1279,10 @@ impl serialize::Decoder for Decoder { f() } - fn read_enum_variant(&self, names: &[&str], f: &fn(uint) -> T) -> T { + fn read_enum_variant(&self, + names: &[&str], + f: &fn(uint) -> T) + -> T { debug!("read_enum_variant(names=%?)", names); let name = match self.stack.pop() { String(s) => s, @@ -883,13 +1309,20 @@ impl serialize::Decoder for Decoder { f() } - fn read_enum_struct_variant(&self, names: &[&str], f: &fn(uint) -> T) -> T { + fn read_enum_struct_variant(&self, + names: &[&str], + f: &fn(uint) -> T) + -> T { debug!("read_enum_struct_variant(names=%?)", names); self.read_enum_variant(names, f) } - fn read_enum_struct_variant_field(&self, name: &str, idx: uint, f: &fn() -> T) -> T { + fn read_enum_struct_variant_field(&self, + name: &str, + idx: uint, + f: &fn() -> T) + -> T { debug!("read_enum_struct_variant_field(name=%?, idx=%u)", name, idx); self.read_enum_variant_arg(idx, f) } @@ -924,7 +1357,11 @@ impl serialize::Decoder for Decoder { #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] - fn read_struct_field(&self, name: &str, idx: uint, f: &fn() -> T) -> T { + fn read_struct_field(&self, + name: &str, + idx: uint, + f: &fn() -> T) + -> T { debug!("read_struct_field(name=%?, idx=%u)", name, idx); match self.stack.pop() { Object(obj) => { @@ -1018,6 +1455,262 @@ impl serialize::Decoder for Decoder { } } +#[cfg(not(stage0))] +impl serialize::Decoder for Decoder { + fn read_nil(&mut self) -> () { + debug!("read_nil"); + match self.stack.pop() { + Null => (), + value => fail!(fmt!("not a null: %?", value)) + } + } + + fn read_u64(&mut self) -> u64 { self.read_float() as u64 } + fn read_u32(&mut self) -> u32 { self.read_float() as u32 } + fn read_u16(&mut self) -> u16 { self.read_float() as u16 } + fn read_u8 (&mut self) -> u8 { self.read_float() as u8 } + fn read_uint(&mut self) -> uint { self.read_float() as uint } + + fn read_i64(&mut self) -> i64 { self.read_float() as i64 } + fn read_i32(&mut self) -> i32 { self.read_float() as i32 } + fn read_i16(&mut self) -> i16 { self.read_float() as i16 } + fn read_i8 (&mut self) -> i8 { self.read_float() as i8 } + fn read_int(&mut self) -> int { self.read_float() as int } + + fn read_bool(&mut self) -> bool { + debug!("read_bool"); + match self.stack.pop() { + Boolean(b) => b, + value => fail!(fmt!("not a boolean: %?", value)) + } + } + + fn read_f64(&mut self) -> f64 { self.read_float() as f64 } + fn read_f32(&mut self) -> f32 { self.read_float() as f32 } + fn read_float(&mut self) -> float { + debug!("read_float"); + match self.stack.pop() { + Number(f) => f, + value => fail!(fmt!("not a number: %?", value)) + } + } + + fn read_char(&mut self) -> char { + let mut v = ~[]; + for str::each_char(self.read_str()) |c| { v.push(c) } + if v.len() != 1 { fail!(~"string must have one character") } + v[0] + } + + fn read_str(&mut self) -> ~str { + debug!("read_str"); + match self.stack.pop() { + String(s) => s, + json => fail!(fmt!("not a string: %?", json)) + } + } + + fn read_enum(&mut self, name: &str, f: &fn(&mut Decoder) -> T) -> T { + debug!("read_enum(%s)", name); + f(self) + } + + fn read_enum_variant(&mut self, + names: &[&str], + f: &fn(&mut Decoder, uint) -> T) + -> T { + debug!("read_enum_variant(names=%?)", names); + let name = match self.stack.pop() { + String(s) => s, + List(list) => { + do vec::consume_reverse(list) |_i, v| { + self.stack.push(v); + } + match self.stack.pop() { + String(s) => s, + value => fail!(fmt!("invalid variant name: %?", value)), + } + } + ref json => fail!(fmt!("invalid variant: %?", *json)), + }; + let idx = match vec::position(names, |n| str::eq_slice(*n, name)) { + Some(idx) => idx, + None => fail!(fmt!("Unknown variant name: %?", name)), + }; + f(self, idx) + } + + fn read_enum_variant_arg(&mut self, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_enum_variant_arg(idx=%u)", idx); + f(self) + } + + fn read_enum_struct_variant(&mut self, + names: &[&str], + f: &fn(&mut Decoder, uint) -> T) + -> T { + debug!("read_enum_struct_variant(names=%?)", names); + self.read_enum_variant(names, f) + } + + + fn read_enum_struct_variant_field(&mut self, + name: &str, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_enum_struct_variant_field(name=%?, idx=%u)", name, idx); + self.read_enum_variant_arg(idx, f) + } + + fn read_struct(&mut self, + name: &str, + len: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_struct(name=%s, len=%u)", name, len); + let value = f(self); + self.stack.pop(); + value + } + + #[cfg(stage0)] + fn read_field(&mut self, name: &str, idx: uint, f: &fn() -> T) -> T { + debug!("read_field(name=%?, idx=%u)", name, idx); + match self.stack.pop() { + Object(obj) => { + let mut obj = obj; + let value = match obj.pop(&name.to_owned()) { + None => fail!(fmt!("no such field: %s", name)), + Some(json) => { + self.stack.push(json); + f() + } + }; + self.stack.push(Object(obj)); + value + } + value => fail!(fmt!("not an object: %?", value)) + } + } + + #[cfg(stage1)] + #[cfg(stage2)] + #[cfg(stage3)] + fn read_struct_field(&mut self, + name: &str, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_struct_field(name=%?, idx=%u)", name, idx); + match self.stack.pop() { + Object(obj) => { + let mut obj = obj; + let value = match obj.pop(&name.to_owned()) { + None => fail!(fmt!("no such field: %s", name)), + Some(json) => { + self.stack.push(json); + f(self) + } + }; + self.stack.push(Object(obj)); + value + } + value => fail!(fmt!("not an object: %?", value)) + } + } + + fn read_tuple(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T { + debug!("read_tuple()"); + self.read_seq(f) + } + + fn read_tuple_arg(&mut self, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_tuple_arg(idx=%u)", idx); + self.read_seq_elt(idx, f) + } + + fn read_tuple_struct(&mut self, + name: &str, + f: &fn(&mut Decoder, uint) -> T) + -> T { + debug!("read_tuple_struct(name=%?)", name); + self.read_tuple(f) + } + + fn read_tuple_struct_arg(&mut self, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_tuple_struct_arg(idx=%u)", idx); + self.read_tuple_arg(idx, f) + } + + fn read_option(&mut self, f: &fn(&mut Decoder, bool) -> T) -> T { + match self.stack.pop() { + Null => f(self, false), + value => { self.stack.push(value); f(self, true) } + } + } + + fn read_seq(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T { + debug!("read_seq()"); + let len = match self.stack.pop() { + List(list) => { + let len = list.len(); + do vec::consume_reverse(list) |_i, v| { + self.stack.push(v); + } + len + } + _ => fail!(~"not a list"), + }; + f(self, len) + } + + fn read_seq_elt(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) -> T { + debug!("read_seq_elt(idx=%u)", idx); + f(self) + } + + fn read_map(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T { + debug!("read_map()"); + let len = match self.stack.pop() { + Object(obj) => { + let mut obj = obj; + let len = obj.len(); + do obj.consume |key, value| { + self.stack.push(value); + self.stack.push(String(key)); + } + len + } + json => fail!(fmt!("not an object: %?", json)), + }; + f(self, len) + } + + fn read_map_elt_key(&mut self, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_map_elt_key(idx=%u)", idx); + f(self) + } + + fn read_map_elt_val(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_map_elt_val(idx=%u)", idx); + f(self) + } +} + impl Eq for Json { fn eq(&self, other: &Json) -> bool { match (self) { @@ -1452,15 +2145,15 @@ mod tests { let animal = Dog; assert_eq!( do io::with_str_writer |wr| { - let encoder = Encoder(wr); - animal.encode(&encoder); + let mut encoder = Encoder(wr); + animal.encode(&mut encoder); }, ~"\"Dog\"" ); assert_eq!( do io::with_str_writer |wr| { - let encoder = PrettyEncoder(wr); - animal.encode(&encoder); + let mut encoder = PrettyEncoder(wr); + animal.encode(&mut encoder); }, ~"\"Dog\"" ); @@ -1468,15 +2161,15 @@ mod tests { let animal = Frog(~"Henry", 349); assert_eq!( do io::with_str_writer |wr| { - let encoder = Encoder(wr); - animal.encode(&encoder); + let mut encoder = Encoder(wr); + animal.encode(&mut encoder); }, ~"[\"Frog\",\"Henry\",349]" ); assert_eq!( do io::with_str_writer |wr| { - let encoder = PrettyEncoder(wr); - animal.encode(&encoder); + let mut encoder = PrettyEncoder(wr); + animal.encode(&mut encoder); }, ~"\ [\n \ @@ -1491,15 +2184,15 @@ mod tests { fn test_write_some() { let value = Some(~"jodhpurs"); let s = do io::with_str_writer |wr| { - let encoder = Encoder(wr); - value.encode(&encoder); + let mut encoder = Encoder(wr); + value.encode(&mut encoder); }; assert_eq!(s, ~"\"jodhpurs\""); let value = Some(~"jodhpurs"); let s = do io::with_str_writer |wr| { - let encoder = PrettyEncoder(wr); - value.encode(&encoder); + let mut encoder = PrettyEncoder(wr); + value.encode(&mut encoder); }; assert_eq!(s, ~"\"jodhpurs\""); } @@ -1508,14 +2201,14 @@ mod tests { fn test_write_none() { let value: Option<~str> = None; let s = do io::with_str_writer |wr| { - let encoder = Encoder(wr); - value.encode(&encoder); + let mut encoder = Encoder(wr); + value.encode(&mut encoder); }; assert_eq!(s, ~"null"); let s = do io::with_str_writer |wr| { - let encoder = Encoder(wr); - value.encode(&encoder); + let mut encoder = Encoder(wr); + value.encode(&mut encoder); }; assert_eq!(s, ~"null"); } @@ -1563,13 +2256,16 @@ mod tests { #[test] fn test_decode_identifiers() { - let v: () = Decodable::decode(&Decoder(from_str(~"null").unwrap())); + let mut decoder = Decoder(from_str(~"null").unwrap()); + let v: () = Decodable::decode(&mut decoder); assert_eq!(v, ()); - let v: bool = Decodable::decode(&Decoder(from_str(~"true").unwrap())); + let mut decoder = Decoder(from_str(~"true").unwrap()); + let v: bool = Decodable::decode(&mut decoder); assert_eq!(v, true); - let v: bool = Decodable::decode(&Decoder(from_str(~"false").unwrap())); + let mut decoder = Decoder(from_str(~"false").unwrap()); + let v: bool = Decodable::decode(&mut decoder); assert_eq!(v, false); } @@ -1603,25 +2299,32 @@ mod tests { #[test] fn test_decode_numbers() { - let v: float = Decodable::decode(&Decoder(from_str(~"3").unwrap())); + let mut decoder = Decoder(from_str(~"3").unwrap()); + let v: float = Decodable::decode(&mut decoder); assert_eq!(v, 3f); - let v: float = Decodable::decode(&Decoder(from_str(~"3.1").unwrap())); + let mut decoder = Decoder(from_str(~"3.1").unwrap()); + let v: float = Decodable::decode(&mut decoder); assert_eq!(v, 3.1f); - let v: float = Decodable::decode(&Decoder(from_str(~"-1.2").unwrap())); + let mut decoder = Decoder(from_str(~"-1.2").unwrap()); + let v: float = Decodable::decode(&mut decoder); assert_eq!(v, -1.2f); - let v: float = Decodable::decode(&Decoder(from_str(~"0.4").unwrap())); + let mut decoder = Decoder(from_str(~"0.4").unwrap()); + let v: float = Decodable::decode(&mut decoder); assert_eq!(v, 0.4f); - let v: float = Decodable::decode(&Decoder(from_str(~"0.4e5").unwrap())); + let mut decoder = Decoder(from_str(~"0.4e5").unwrap()); + let v: float = Decodable::decode(&mut decoder); assert_eq!(v, 0.4e5f); - let v: float = Decodable::decode(&Decoder(from_str(~"0.4e15").unwrap())); + let mut decoder = Decoder(from_str(~"0.4e15").unwrap()); + let v: float = Decodable::decode(&mut decoder); assert_eq!(v, 0.4e15f); - let v: float = Decodable::decode(&Decoder(from_str(~"0.4e-01").unwrap())); + let mut decoder = Decoder(from_str(~"0.4e-01").unwrap()); + let v: float = Decodable::decode(&mut decoder); assert_eq!(v, 0.4e-01f); } @@ -1648,31 +2351,40 @@ mod tests { #[test] fn test_decode_str() { - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~""); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"foo\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"foo\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"foo"); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\\"\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\\\"\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"\""); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\b\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\\b\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"\x08"); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\n\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\\n\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"\n"); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\r\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\\r\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"\r"); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\t\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\\t\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"\t"); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\u12ab\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\\u12ab\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"\u12ab"); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\uAB12\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\\uAB12\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"\uAB12"); } @@ -1704,23 +2416,28 @@ mod tests { #[test] fn test_decode_list() { - let v: ~[()] = Decodable::decode(&Decoder(from_str(~"[]").unwrap())); + let mut decoder = Decoder(from_str(~"[]").unwrap()); + let v: ~[()] = Decodable::decode(&mut decoder); assert_eq!(v, ~[]); - let v: ~[()] = Decodable::decode(&Decoder(from_str(~"[null]").unwrap())); + let mut decoder = Decoder(from_str(~"[null]").unwrap()); + let v: ~[()] = Decodable::decode(&mut decoder); assert_eq!(v, ~[()]); - - let v: ~[bool] = Decodable::decode(&Decoder(from_str(~"[true]").unwrap())); + let mut decoder = Decoder(from_str(~"[true]").unwrap()); + let v: ~[bool] = Decodable::decode(&mut decoder); assert_eq!(v, ~[true]); - let v: ~[bool] = Decodable::decode(&Decoder(from_str(~"[true]").unwrap())); + let mut decoder = Decoder(from_str(~"[true]").unwrap()); + let v: ~[bool] = Decodable::decode(&mut decoder); assert_eq!(v, ~[true]); - let v: ~[int] = Decodable::decode(&Decoder(from_str(~"[3, 1]").unwrap())); + let mut decoder = Decoder(from_str(~"[3, 1]").unwrap()); + let v: ~[int] = Decodable::decode(&mut decoder); assert_eq!(v, ~[3, 1]); - let v: ~[~[uint]] = Decodable::decode(&Decoder(from_str(~"[[3], [1, 2]]").unwrap())); + let mut decoder = Decoder(from_str(~"[[3], [1, 2]]").unwrap()); + let v: ~[~[uint]] = Decodable::decode(&mut decoder); assert_eq!(v, ~[~[3], ~[1, 2]]); } @@ -1822,7 +2539,8 @@ mod tests { { \"a\": null, \"b\": 2, \"c\": [\"abc\", \"xyz\"] } ] }"; - let v: Outer = Decodable::decode(&Decoder(from_str(s).unwrap())); + let mut decoder = Decoder(from_str(s).unwrap()); + let v: Outer = Decodable::decode(&mut decoder); assert_eq!( v, Outer { @@ -1835,31 +2553,32 @@ mod tests { #[test] fn test_decode_option() { - let decoder = Decoder(from_str(~"null").unwrap()); - let value: Option<~str> = Decodable::decode(&decoder); + let mut decoder = Decoder(from_str(~"null").unwrap()); + let value: Option<~str> = Decodable::decode(&mut decoder); assert_eq!(value, None); - let decoder = Decoder(from_str(~"\"jodhpurs\"").unwrap()); - let value: Option<~str> = Decodable::decode(&decoder); + let mut decoder = Decoder(from_str(~"\"jodhpurs\"").unwrap()); + let value: Option<~str> = Decodable::decode(&mut decoder); assert_eq!(value, Some(~"jodhpurs")); } #[test] fn test_decode_enum() { - let decoder = Decoder(from_str(~"\"Dog\"").unwrap()); - let value: Animal = Decodable::decode(&decoder); + let mut decoder = Decoder(from_str(~"\"Dog\"").unwrap()); + let value: Animal = Decodable::decode(&mut decoder); assert_eq!(value, Dog); - let decoder = Decoder(from_str(~"[\"Frog\",\"Henry\",349]").unwrap()); - let value: Animal = Decodable::decode(&decoder); + let mut decoder = + Decoder(from_str(~"[\"Frog\",\"Henry\",349]").unwrap()); + let value: Animal = Decodable::decode(&mut decoder); assert_eq!(value, Frog(~"Henry", 349)); } #[test] fn test_decode_map() { let s = ~"{\"a\": \"Dog\", \"b\": [\"Frog\", \"Henry\", 349]}"; - let decoder = Decoder(from_str(s).unwrap()); - let mut map: HashMap<~str, Animal> = Decodable::decode(&decoder); + let mut decoder = Decoder(from_str(s).unwrap()); + let mut map: HashMap<~str, Animal> = Decodable::decode(&mut decoder); assert_eq!(map.pop(&~"a"), Some(Dog)); assert_eq!(map.pop(&~"b"), Some(Frog(~"Henry", 349))); diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index 1ad581ba993..33efb2c6a5a 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -25,6 +25,7 @@ use dlist::DList; #[cfg(stage3)] use treemap::{TreeMap, TreeSet}; +#[cfg(stage0)] pub trait Encoder { // Primitive types: fn emit_nil(&self); @@ -48,11 +49,22 @@ pub trait Encoder { // Compound types: fn emit_enum(&self, name: &str, f: &fn()); - fn emit_enum_variant(&self, v_name: &str, v_id: uint, len: uint, f: &fn()); + fn emit_enum_variant(&self, + v_name: &str, + v_id: uint, + len: uint, + f: &fn()); fn emit_enum_variant_arg(&self, a_idx: uint, f: &fn()); - fn emit_enum_struct_variant(&self, v_name: &str, v_id: uint, len: uint, f: &fn()); - fn emit_enum_struct_variant_field(&self, f_name: &str, f_idx: uint, f: &fn()); + fn emit_enum_struct_variant(&self, + v_name: &str, + v_id: uint, + len: uint, + f: &fn()); + fn emit_enum_struct_variant_field(&self, + f_name: &str, + f_idx: uint, + f: &fn()); fn emit_struct(&self, name: &str, len: uint, f: &fn()); #[cfg(stage0)] @@ -81,6 +93,73 @@ pub trait Encoder { fn emit_map_elt_val(&self, idx: uint, f: &fn()); } +#[cfg(not(stage0))] +pub trait Encoder { + // Primitive types: + fn emit_nil(&mut self); + fn emit_uint(&mut self, v: uint); + fn emit_u64(&mut self, v: u64); + fn emit_u32(&mut self, v: u32); + fn emit_u16(&mut self, v: u16); + fn emit_u8(&mut self, v: u8); + fn emit_int(&mut self, v: int); + fn emit_i64(&mut self, v: i64); + fn emit_i32(&mut self, v: i32); + fn emit_i16(&mut self, v: i16); + fn emit_i8(&mut self, v: i8); + fn emit_bool(&mut self, v: bool); + fn emit_float(&mut self, v: float); + fn emit_f64(&mut self, v: f64); + fn emit_f32(&mut self, v: f32); + fn emit_char(&mut self, v: char); + fn emit_str(&mut self, v: &str); + + // Compound types: + fn emit_enum(&mut self, name: &str, f: &fn(&mut Self)); + + fn emit_enum_variant(&mut self, + v_name: &str, + v_id: uint, + len: uint, + f: &fn(&mut Self)); + fn emit_enum_variant_arg(&mut self, a_idx: uint, f: &fn(&mut Self)); + + fn emit_enum_struct_variant(&mut self, + v_name: &str, + v_id: uint, + len: uint, + f: &fn(&mut Self)); + fn emit_enum_struct_variant_field(&mut self, + f_name: &str, + f_idx: uint, + f: &fn(&mut Self)); + + fn emit_struct(&mut self, name: &str, len: uint, f: &fn(&mut Self)); + fn emit_struct_field(&mut self, + f_name: &str, + f_idx: uint, + f: &fn(&mut Self)); + + fn emit_tuple(&mut self, len: uint, f: &fn(&mut Self)); + fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut Self)); + + fn emit_tuple_struct(&mut self, name: &str, len: uint, f: &fn(&mut Self)); + fn emit_tuple_struct_arg(&mut self, f_idx: uint, f: &fn(&mut Self)); + + // Specialized types: + fn emit_option(&mut self, f: &fn(&mut Self)); + fn emit_option_none(&mut self); + fn emit_option_some(&mut self, f: &fn(&mut Self)); + + fn emit_seq(&mut self, len: uint, f: &fn(this: &mut Self)); + fn emit_seq_elt(&mut self, idx: uint, f: &fn(this: &mut Self)); + + fn emit_map(&mut self, len: uint, f: &fn(&mut Self)); + fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut Self)); + fn emit_map_elt_val(&mut self, idx: uint, f: &fn(&mut Self)); +} + +#[cfg(stage0)] pub trait Decoder { // Primitive types: fn read_nil(&self) -> (); @@ -104,19 +183,37 @@ pub trait Decoder { // Compound types: fn read_enum(&self, name: &str, f: &fn() -> T) -> T; - fn read_enum_variant(&self, names: &[&str], f: &fn(uint) -> T) -> T; + fn read_enum_variant(&self, + names: &[&str], + f: &fn(uint) -> T) + -> T; fn read_enum_variant_arg(&self, a_idx: uint, f: &fn() -> T) -> T; - fn read_enum_struct_variant(&self, names: &[&str], f: &fn(uint) -> T) -> T; - fn read_enum_struct_variant_field(&self, &f_name: &str, f_idx: uint, f: &fn() -> T) -> T; + fn read_enum_struct_variant(&self, + names: &[&str], + f: &fn(uint) -> T) + -> T; + fn read_enum_struct_variant_field(&self, + &f_name: &str, + f_idx: uint, + f: &fn() -> T) + -> T; fn read_struct(&self, s_name: &str, len: uint, f: &fn() -> T) -> T; #[cfg(stage0)] - fn read_field(&self, f_name: &str, f_idx: uint, f: &fn() -> T) -> T; + fn read_field(&self, + f_name: &str, + f_idx: uint, + f: &fn() -> T) + -> T; #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] - fn read_struct_field(&self, f_name: &str, f_idx: uint, f: &fn() -> T) -> T; + fn read_struct_field(&self, + f_name: &str, + f_idx: uint, + f: &fn() -> T) + -> T; fn read_tuple(&self, f: &fn(uint) -> T) -> T; fn read_tuple_arg(&self, a_idx: uint, f: &fn() -> T) -> T; @@ -135,215 +232,673 @@ pub trait Decoder { fn read_map_elt_val(&self, idx: uint, f: &fn() -> T) -> T; } +#[cfg(not(stage0))] +pub trait Decoder { + // Primitive types: + fn read_nil(&mut self) -> (); + fn read_uint(&mut self) -> uint; + fn read_u64(&mut self) -> u64; + fn read_u32(&mut self) -> u32; + fn read_u16(&mut self) -> u16; + fn read_u8(&mut self) -> u8; + fn read_int(&mut self) -> int; + fn read_i64(&mut self) -> i64; + fn read_i32(&mut self) -> i32; + fn read_i16(&mut self) -> i16; + fn read_i8(&mut self) -> i8; + fn read_bool(&mut self) -> bool; + fn read_f64(&mut self) -> f64; + fn read_f32(&mut self) -> f32; + fn read_float(&mut self) -> float; + fn read_char(&mut self) -> char; + fn read_str(&mut self) -> ~str; + + // Compound types: + fn read_enum(&mut self, name: &str, f: &fn(&mut Self) -> T) -> T; + + fn read_enum_variant(&mut self, + names: &[&str], + f: &fn(&mut Self, uint) -> T) + -> T; + fn read_enum_variant_arg(&mut self, + a_idx: uint, + f: &fn(&mut Self) -> T) + -> T; + + fn read_enum_struct_variant(&mut self, + names: &[&str], + f: &fn(&mut Self, uint) -> T) + -> T; + fn read_enum_struct_variant_field(&mut self, + &f_name: &str, + f_idx: uint, + f: &fn(&mut Self) -> T) + -> T; + + fn read_struct(&mut self, + s_name: &str, + len: uint, + f: &fn(&mut Self) -> T) + -> T; + #[cfg(stage0)] + fn read_field(&mut self, + f_name: &str, + f_idx: uint, + f: &fn() -> T) + -> T; + #[cfg(stage1)] + #[cfg(stage2)] + #[cfg(stage3)] + fn read_struct_field(&mut self, + f_name: &str, + f_idx: uint, + f: &fn(&mut Self) -> T) + -> T; + + fn read_tuple(&mut self, f: &fn(&mut Self, uint) -> T) -> T; + fn read_tuple_arg(&mut self, a_idx: uint, f: &fn(&mut Self) -> T) -> T; + + fn read_tuple_struct(&mut self, + s_name: &str, + f: &fn(&mut Self, uint) -> T) + -> T; + fn read_tuple_struct_arg(&mut self, + a_idx: uint, + f: &fn(&mut Self) -> T) + -> T; + + // Specialized types: + fn read_option(&mut self, f: &fn(&mut Self, bool) -> T) -> T; + + fn read_seq(&mut self, f: &fn(&mut Self, uint) -> T) -> T; + fn read_seq_elt(&mut self, idx: uint, f: &fn(&mut Self) -> T) -> T; + + fn read_map(&mut self, f: &fn(&mut Self, uint) -> T) -> T; + fn read_map_elt_key(&mut self, idx: uint, f: &fn(&mut Self) -> T) -> T; + fn read_map_elt_val(&mut self, idx: uint, f: &fn(&mut Self) -> T) -> T; +} + +#[cfg(stage0)] pub trait Encodable { fn encode(&self, s: &S); } +#[cfg(not(stage0))] +pub trait Encodable { + fn encode(&self, s: &mut S); +} + +#[cfg(stage0)] pub trait Decodable { fn decode(d: &D) -> Self; } +#[cfg(not(stage0))] +pub trait Decodable { + fn decode(d: &mut D) -> Self; +} + +#[cfg(stage0)] impl Encodable for uint { - fn encode(&self, s: &S) { s.emit_uint(*self) } + fn encode(&self, s: &S) { + s.emit_uint(*self) + } } +#[cfg(not(stage0))] +impl Encodable for uint { + fn encode(&self, s: &mut S) { + s.emit_uint(*self) + } +} + +#[cfg(stage0)] impl Decodable for uint { fn decode(d: &D) -> uint { d.read_uint() } } +#[cfg(not(stage0))] +impl Decodable for uint { + fn decode(d: &mut D) -> uint { + d.read_uint() + } +} + +#[cfg(stage0)] impl Encodable for u8 { - fn encode(&self, s: &S) { s.emit_u8(*self) } + fn encode(&self, s: &S) { + s.emit_u8(*self) + } +} + +#[cfg(not(stage0))] +impl Encodable for u8 { + fn encode(&self, s: &mut S) { + s.emit_u8(*self) + } } +#[cfg(stage0)] impl Decodable for u8 { fn decode(d: &D) -> u8 { d.read_u8() } } +#[cfg(not(stage0))] +impl Decodable for u8 { + fn decode(d: &mut D) -> u8 { + d.read_u8() + } +} + +#[cfg(stage0)] impl Encodable for u16 { - fn encode(&self, s: &S) { s.emit_u16(*self) } + fn encode(&self, s: &S) { + s.emit_u16(*self) + } +} + +#[cfg(not(stage0))] +impl Encodable for u16 { + fn encode(&self, s: &mut S) { + s.emit_u16(*self) + } } +#[cfg(stage0)] impl Decodable for u16 { fn decode(d: &D) -> u16 { d.read_u16() } } +#[cfg(not(stage0))] +impl Decodable for u16 { + fn decode(d: &mut D) -> u16 { + d.read_u16() + } +} + +#[cfg(stage0)] impl Encodable for u32 { - fn encode(&self, s: &S) { s.emit_u32(*self) } + fn encode(&self, s: &S) { + s.emit_u32(*self) + } +} + +#[cfg(not(stage0))] +impl Encodable for u32 { + fn encode(&self, s: &mut S) { + s.emit_u32(*self) + } } +#[cfg(stage0)] impl Decodable for u32 { fn decode(d: &D) -> u32 { d.read_u32() } } +#[cfg(not(stage0))] +impl Decodable for u32 { + fn decode(d: &mut D) -> u32 { + d.read_u32() + } +} + +#[cfg(stage0)] +impl Encodable for u64 { + fn encode(&self, s: &S) { + s.emit_u64(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for u64 { - fn encode(&self, s: &S) { s.emit_u64(*self) } + fn encode(&self, s: &mut S) { + s.emit_u64(*self) + } } +#[cfg(stage0)] impl Decodable for u64 { fn decode(d: &D) -> u64 { d.read_u64() } } +#[cfg(not(stage0))] +impl Decodable for u64 { + fn decode(d: &mut D) -> u64 { + d.read_u64() + } +} + +#[cfg(stage0)] impl Encodable for int { - fn encode(&self, s: &S) { s.emit_int(*self) } + fn encode(&self, s: &S) { + s.emit_int(*self) + } } +#[cfg(not(stage0))] +impl Encodable for int { + fn encode(&self, s: &mut S) { + s.emit_int(*self) + } +} + +#[cfg(stage0)] impl Decodable for int { fn decode(d: &D) -> int { d.read_int() } } +#[cfg(not(stage0))] +impl Decodable for int { + fn decode(d: &mut D) -> int { + d.read_int() + } +} + +#[cfg(stage0)] +impl Encodable for i8 { + fn encode(&self, s: &S) { + s.emit_i8(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for i8 { - fn encode(&self, s: &S) { s.emit_i8(*self) } + fn encode(&self, s: &mut S) { + s.emit_i8(*self) + } } +#[cfg(stage0)] impl Decodable for i8 { fn decode(d: &D) -> i8 { d.read_i8() } } +#[cfg(not(stage0))] +impl Decodable for i8 { + fn decode(d: &mut D) -> i8 { + d.read_i8() + } +} + +#[cfg(stage0)] +impl Encodable for i16 { + fn encode(&self, s: &S) { + s.emit_i16(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for i16 { - fn encode(&self, s: &S) { s.emit_i16(*self) } + fn encode(&self, s: &mut S) { + s.emit_i16(*self) + } } +#[cfg(stage0)] impl Decodable for i16 { fn decode(d: &D) -> i16 { d.read_i16() } } +#[cfg(not(stage0))] +impl Decodable for i16 { + fn decode(d: &mut D) -> i16 { + d.read_i16() + } +} + +#[cfg(stage0)] +impl Encodable for i32 { + fn encode(&self, s: &S) { + s.emit_i32(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for i32 { - fn encode(&self, s: &S) { s.emit_i32(*self) } + fn encode(&self, s: &mut S) { + s.emit_i32(*self) + } } +#[cfg(stage0)] impl Decodable for i32 { fn decode(d: &D) -> i32 { d.read_i32() } } +#[cfg(not(stage0))] +impl Decodable for i32 { + fn decode(d: &mut D) -> i32 { + d.read_i32() + } +} + +#[cfg(stage0)] impl Encodable for i64 { - fn encode(&self, s: &S) { s.emit_i64(*self) } + fn encode(&self, s: &S) { + s.emit_i64(*self) + } +} + +#[cfg(not(stage0))] +impl Encodable for i64 { + fn encode(&self, s: &mut S) { + s.emit_i64(*self) + } } +#[cfg(stage0)] impl Decodable for i64 { fn decode(d: &D) -> i64 { d.read_i64() } } +#[cfg(not(stage0))] +impl Decodable for i64 { + fn decode(d: &mut D) -> i64 { + d.read_i64() + } +} + +#[cfg(stage0)] impl<'self, S:Encoder> Encodable for &'self str { - fn encode(&self, s: &S) { s.emit_str(*self) } + fn encode(&self, s: &S) { + s.emit_str(*self) + } } +#[cfg(not(stage0))] +impl<'self, S:Encoder> Encodable for &'self str { + fn encode(&self, s: &mut S) { + s.emit_str(*self) + } +} + +#[cfg(stage0)] +impl Encodable for ~str { + fn encode(&self, s: &S) { + s.emit_str(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for ~str { - fn encode(&self, s: &S) { s.emit_str(*self) } + fn encode(&self, s: &mut S) { + s.emit_str(*self) + } } +#[cfg(stage0)] impl Decodable for ~str { fn decode(d: &D) -> ~str { d.read_str() } } +#[cfg(not(stage0))] +impl Decodable for ~str { + fn decode(d: &mut D) -> ~str { + d.read_str() + } +} + +#[cfg(stage0)] +impl Encodable for @str { + fn encode(&self, s: &S) { + s.emit_str(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for @str { - fn encode(&self, s: &S) { s.emit_str(*self) } + fn encode(&self, s: &mut S) { + s.emit_str(*self) + } } +#[cfg(stage0)] impl Decodable for @str { - fn decode(d: &D) -> @str { d.read_str().to_managed() } + fn decode(d: &D) -> @str { + d.read_str().to_managed() + } } +#[cfg(not(stage0))] +impl Decodable for @str { + fn decode(d: &mut D) -> @str { + d.read_str().to_managed() + } +} + +#[cfg(stage0)] impl Encodable for float { - fn encode(&self, s: &S) { s.emit_float(*self) } + fn encode(&self, s: &S) { + s.emit_float(*self) + } } +#[cfg(not(stage0))] +impl Encodable for float { + fn encode(&self, s: &mut S) { + s.emit_float(*self) + } +} + +#[cfg(stage0)] impl Decodable for float { fn decode(d: &D) -> float { d.read_float() } } +#[cfg(not(stage0))] +impl Decodable for float { + fn decode(d: &mut D) -> float { + d.read_float() + } +} + +#[cfg(stage0)] +impl Encodable for f32 { + fn encode(&self, s: &S) { + s.emit_f32(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for f32 { - fn encode(&self, s: &S) { s.emit_f32(*self) } + fn encode(&self, s: &mut S) { + s.emit_f32(*self) + } } +#[cfg(stage0)] impl Decodable for f32 { fn decode(d: &D) -> f32 { - d.read_f32() } + d.read_f32() + } } +#[cfg(not(stage0))] +impl Decodable for f32 { + fn decode(d: &mut D) -> f32 { + d.read_f32() + } +} + +#[cfg(stage0)] +impl Encodable for f64 { + fn encode(&self, s: &S) { + s.emit_f64(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for f64 { - fn encode(&self, s: &S) { s.emit_f64(*self) } + fn encode(&self, s: &mut S) { + s.emit_f64(*self) + } } +#[cfg(stage0)] impl Decodable for f64 { fn decode(d: &D) -> f64 { d.read_f64() } } +#[cfg(not(stage0))] +impl Decodable for f64 { + fn decode(d: &mut D) -> f64 { + d.read_f64() + } +} + +#[cfg(stage0)] +impl Encodable for bool { + fn encode(&self, s: &S) { + s.emit_bool(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for bool { - fn encode(&self, s: &S) { s.emit_bool(*self) } + fn encode(&self, s: &mut S) { + s.emit_bool(*self) + } } +#[cfg(stage0)] impl Decodable for bool { fn decode(d: &D) -> bool { d.read_bool() } } +#[cfg(not(stage0))] +impl Decodable for bool { + fn decode(d: &mut D) -> bool { + d.read_bool() + } +} + +#[cfg(stage0)] impl Encodable for () { - fn encode(&self, s: &S) { s.emit_nil() } + fn encode(&self, s: &S) { + s.emit_nil() + } } +#[cfg(not(stage0))] +impl Encodable for () { + fn encode(&self, s: &mut S) { + s.emit_nil() + } +} + +#[cfg(stage0)] impl Decodable for () { fn decode(d: &D) -> () { d.read_nil() } } +#[cfg(not(stage0))] +impl Decodable for () { + fn decode(d: &mut D) -> () { + d.read_nil() + } +} + +#[cfg(stage0)] impl<'self, S:Encoder,T:Encodable> Encodable for &'self T { fn encode(&self, s: &S) { (**self).encode(s) } } +#[cfg(not(stage0))] +impl<'self, S:Encoder,T:Encodable> Encodable for &'self T { + fn encode(&self, s: &mut S) { + (**self).encode(s) + } +} + +#[cfg(stage0)] impl> Encodable for ~T { fn encode(&self, s: &S) { (**self).encode(s) } } +#[cfg(not(stage0))] +impl> Encodable for ~T { + fn encode(&self, s: &mut S) { + (**self).encode(s) + } +} + +#[cfg(stage0)] impl> Decodable for ~T { fn decode(d: &D) -> ~T { ~Decodable::decode(d) } } +#[cfg(not(stage0))] +impl> Decodable for ~T { + fn decode(d: &mut D) -> ~T { + ~Decodable::decode(d) + } +} + +#[cfg(stage0)] impl> Encodable for @T { fn encode(&self, s: &S) { (**self).encode(s) } } +#[cfg(not(stage0))] +impl> Encodable for @T { + fn encode(&self, s: &mut S) { + (**self).encode(s) + } +} + +#[cfg(stage0)] impl> Decodable for @T { fn decode(d: &D) -> @T { @Decodable::decode(d) } } +#[cfg(not(stage0))] +impl> Decodable for @T { + fn decode(d: &mut D) -> @T { + @Decodable::decode(d) + } +} + +#[cfg(stage0)] impl<'self, S:Encoder,T:Encodable> Encodable for &'self [T] { fn encode(&self, s: &S) { do s.emit_seq(self.len()) { @@ -354,6 +909,18 @@ impl<'self, S:Encoder,T:Encodable> Encodable for &'self [T] { } } +#[cfg(not(stage0))] +impl<'self, S:Encoder,T:Encodable> Encodable for &'self [T] { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.len()) |s| { + for self.eachi |i, e| { + s.emit_seq_elt(i, |s| e.encode(s)) + } + } + } +} + +#[cfg(stage0)] impl> Encodable for ~[T] { fn encode(&self, s: &S) { do s.emit_seq(self.len()) { @@ -364,6 +931,18 @@ impl> Encodable for ~[T] { } } +#[cfg(not(stage0))] +impl> Encodable for ~[T] { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.len()) |s| { + for self.eachi |i, e| { + s.emit_seq_elt(i, |s| e.encode(s)) + } + } + } +} + +#[cfg(stage0)] impl> Decodable for ~[T] { fn decode(d: &D) -> ~[T] { do d.read_seq |len| { @@ -374,6 +953,18 @@ impl> Decodable for ~[T] { } } +#[cfg(not(stage0))] +impl> Decodable for ~[T] { + fn decode(d: &mut D) -> ~[T] { + do d.read_seq |d, len| { + do vec::from_fn(len) |i| { + d.read_seq_elt(i, |d| Decodable::decode(d)) + } + } + } +} + +#[cfg(stage0)] impl> Encodable for @[T] { fn encode(&self, s: &S) { do s.emit_seq(self.len()) { @@ -384,6 +975,18 @@ impl> Encodable for @[T] { } } +#[cfg(not(stage0))] +impl> Encodable for @[T] { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.len()) |s| { + for self.eachi |i, e| { + s.emit_seq_elt(i, |s| e.encode(s)) + } + } + } +} + +#[cfg(stage0)] impl> Decodable for @[T] { fn decode(d: &D) -> @[T] { do d.read_seq |len| { @@ -394,6 +997,18 @@ impl> Decodable for @[T] { } } +#[cfg(not(stage0))] +impl> Decodable for @[T] { + fn decode(d: &mut D) -> @[T] { + do d.read_seq |d, len| { + do at_vec::from_fn(len) |i| { + d.read_seq_elt(i, |d| Decodable::decode(d)) + } + } + } +} + +#[cfg(stage0)] impl> Encodable for Option { fn encode(&self, s: &S) { do s.emit_option { @@ -405,6 +1020,19 @@ impl> Encodable for Option { } } +#[cfg(not(stage0))] +impl> Encodable for Option { + fn encode(&self, s: &mut S) { + do s.emit_option |s| { + match *self { + None => s.emit_option_none(), + Some(ref v) => s.emit_option_some(|s| v.encode(s)), + } + } + } +} + +#[cfg(stage0)] impl> Decodable for Option { fn decode(d: &D) -> Option { do d.read_option |b| { @@ -417,6 +1045,20 @@ impl> Decodable for Option { } } +#[cfg(not(stage0))] +impl> Decodable for Option { + fn decode(d: &mut D) -> Option { + do d.read_option |d, b| { + if b { + Some(Decodable::decode(d)) + } else { + None + } + } + } +} + +#[cfg(stage0)] impl,T1:Encodable> Encodable for (T0, T1) { fn encode(&self, s: &S) { match *self { @@ -430,6 +1072,21 @@ impl,T1:Encodable> Encodable for (T0, T1) { } } +#[cfg(not(stage0))] +impl,T1:Encodable> Encodable for (T0, T1) { + fn encode(&self, s: &mut S) { + match *self { + (ref t0, ref t1) => { + do s.emit_seq(2) |s| { + s.emit_seq_elt(0, |s| t0.encode(s)); + s.emit_seq_elt(1, |s| t1.encode(s)); + } + } + } + } +} + +#[cfg(stage0)] impl,T1:Decodable> Decodable for (T0, T1) { fn decode(d: &D) -> (T0, T1) { do d.read_seq |len| { @@ -442,6 +1099,20 @@ impl,T1:Decodable> Decodable for (T0, T1) { } } +#[cfg(not(stage0))] +impl,T1:Decodable> Decodable for (T0, T1) { + fn decode(d: &mut D) -> (T0, T1) { + do d.read_seq |d, len| { + assert!(len == 2); + ( + d.read_seq_elt(0, |d| Decodable::decode(d)), + d.read_seq_elt(1, |d| Decodable::decode(d)) + ) + } + } +} + +#[cfg(stage0)] impl< S: Encoder, T0: Encodable, @@ -461,6 +1132,27 @@ impl< } } +#[cfg(not(stage0))] +impl< + S: Encoder, + T0: Encodable, + T1: Encodable, + T2: Encodable +> Encodable for (T0, T1, T2) { + fn encode(&self, s: &mut S) { + match *self { + (ref t0, ref t1, ref t2) => { + do s.emit_seq(3) |s| { + s.emit_seq_elt(0, |s| t0.encode(s)); + s.emit_seq_elt(1, |s| t1.encode(s)); + s.emit_seq_elt(2, |s| t2.encode(s)); + } + } + } + } +} + +#[cfg(stage0)] impl< D: Decoder, T0: Decodable, @@ -479,6 +1171,26 @@ impl< } } +#[cfg(not(stage0))] +impl< + D: Decoder, + T0: Decodable, + T1: Decodable, + T2: Decodable +> Decodable for (T0, T1, T2) { + fn decode(d: &mut D) -> (T0, T1, T2) { + do d.read_seq |d, len| { + assert!(len == 3); + ( + d.read_seq_elt(0, |d| Decodable::decode(d)), + d.read_seq_elt(1, |d| Decodable::decode(d)), + d.read_seq_elt(2, |d| Decodable::decode(d)) + ) + } + } +} + +#[cfg(stage0)] impl< S: Encoder, T0: Encodable, @@ -500,6 +1212,29 @@ impl< } } +#[cfg(not(stage0))] +impl< + S: Encoder, + T0: Encodable, + T1: Encodable, + T2: Encodable, + T3: Encodable +> Encodable for (T0, T1, T2, T3) { + fn encode(&self, s: &mut S) { + match *self { + (ref t0, ref t1, ref t2, ref t3) => { + do s.emit_seq(4) |s| { + s.emit_seq_elt(0, |s| t0.encode(s)); + s.emit_seq_elt(1, |s| t1.encode(s)); + s.emit_seq_elt(2, |s| t2.encode(s)); + s.emit_seq_elt(3, |s| t3.encode(s)); + } + } + } + } +} + +#[cfg(stage0)] impl< D: Decoder, T0: Decodable, @@ -520,6 +1255,28 @@ impl< } } +#[cfg(not(stage0))] +impl< + D: Decoder, + T0: Decodable, + T1: Decodable, + T2: Decodable, + T3: Decodable +> Decodable for (T0, T1, T2, T3) { + fn decode(d: &mut D) -> (T0, T1, T2, T3) { + do d.read_seq |d, len| { + assert!(len == 4); + ( + d.read_seq_elt(0, |d| Decodable::decode(d)), + d.read_seq_elt(1, |d| Decodable::decode(d)), + d.read_seq_elt(2, |d| Decodable::decode(d)), + d.read_seq_elt(3, |d| Decodable::decode(d)) + ) + } + } +} + +#[cfg(stage0)] impl< S: Encoder, T0: Encodable, @@ -543,6 +1300,31 @@ impl< } } +#[cfg(not(stage0))] +impl< + S: Encoder, + T0: Encodable, + T1: Encodable, + T2: Encodable, + T3: Encodable, + T4: Encodable +> Encodable for (T0, T1, T2, T3, T4) { + fn encode(&self, s: &mut S) { + match *self { + (ref t0, ref t1, ref t2, ref t3, ref t4) => { + do s.emit_seq(5) |s| { + s.emit_seq_elt(0, |s| t0.encode(s)); + s.emit_seq_elt(1, |s| t1.encode(s)); + s.emit_seq_elt(2, |s| t2.encode(s)); + s.emit_seq_elt(3, |s| t3.encode(s)); + s.emit_seq_elt(4, |s| t4.encode(s)); + } + } + } + } +} + +#[cfg(stage0)] impl< D: Decoder, T0: Decodable, @@ -551,8 +1333,7 @@ impl< T3: Decodable, T4: Decodable > Decodable for (T0, T1, T2, T3, T4) { - fn decode(d: &D) - -> (T0, T1, T2, T3, T4) { + fn decode(d: &D) -> (T0, T1, T2, T3, T4) { do d.read_seq |len| { assert!(len == 5); ( @@ -566,6 +1347,30 @@ impl< } } +#[cfg(not(stage0))] +impl< + D: Decoder, + T0: Decodable, + T1: Decodable, + T2: Decodable, + T3: Decodable, + T4: Decodable +> Decodable for (T0, T1, T2, T3, T4) { + fn decode(d: &mut D) -> (T0, T1, T2, T3, T4) { + do d.read_seq |d, len| { + assert!(len == 5); + ( + d.read_seq_elt(0, |d| Decodable::decode(d)), + d.read_seq_elt(1, |d| Decodable::decode(d)), + d.read_seq_elt(2, |d| Decodable::decode(d)), + d.read_seq_elt(3, |d| Decodable::decode(d)), + d.read_seq_elt(4, |d| Decodable::decode(d)) + ) + } + } +} + +#[cfg(stage0)] impl< S: Encoder, T: Encodable + Copy @@ -581,6 +1386,23 @@ impl< } } +#[cfg(not(stage0))] +impl< + S: Encoder, + T: Encodable + Copy +> Encodable for @mut DList { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.size) |s| { + let mut i = 0; + for self.each |e| { + s.emit_seq_elt(i, |s| e.encode(s)); + i += 1; + } + } + } +} + +#[cfg(stage0)] impl> Decodable for @mut DList { fn decode(d: &D) -> @mut DList { let list = DList(); @@ -593,6 +1415,20 @@ impl> Decodable for @mut DList { } } +#[cfg(not(stage0))] +impl> Decodable for @mut DList { + fn decode(d: &mut D) -> @mut DList { + let list = DList(); + do d.read_seq |d, len| { + for uint::range(0, len) |i| { + list.push(d.read_seq_elt(i, |d| Decodable::decode(d))); + } + } + list + } +} + +#[cfg(stage0)] impl< S: Encoder, T: Encodable @@ -606,6 +1442,21 @@ impl< } } +#[cfg(not(stage0))] +impl< + S: Encoder, + T: Encodable +> Encodable for Deque { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.len()) |s| { + for self.eachi |i, e| { + s.emit_seq_elt(i, |s| e.encode(s)); + } + } + } +} + +#[cfg(stage0)] impl> Decodable for Deque { fn decode(d: &D) -> Deque { let mut deque = Deque::new(); @@ -618,6 +1469,20 @@ impl> Decodable for Deque { } } +#[cfg(not(stage0))] +impl> Decodable for Deque { + fn decode(d: &mut D) -> Deque { + let mut deque = Deque::new(); + do d.read_seq |d, len| { + for uint::range(0, len) |i| { + deque.add_back(d.read_seq_elt(i, |d| Decodable::decode(d))); + } + } + deque + } +} + +#[cfg(stage0)] impl< E: Encoder, K: Encodable + Hash + IterBytes + Eq, @@ -635,6 +1500,25 @@ impl< } } +#[cfg(not(stage0))] +impl< + E: Encoder, + K: Encodable + Hash + IterBytes + Eq, + V: Encodable +> Encodable for HashMap { + fn encode(&self, e: &mut E) { + do e.emit_map(self.len()) |e| { + let mut i = 0; + for self.each |key, val| { + e.emit_map_elt_key(i, |e| key.encode(e)); + e.emit_map_elt_val(i, |e| val.encode(e)); + i += 1; + } + } + } +} + +#[cfg(stage0)] impl< D: Decoder, K: Decodable + Hash + IterBytes + Eq, @@ -653,6 +1537,26 @@ impl< } } +#[cfg(not(stage0))] +impl< + D: Decoder, + K: Decodable + Hash + IterBytes + Eq, + V: Decodable +> Decodable for HashMap { + fn decode(d: &mut D) -> HashMap { + do d.read_map |d, len| { + let mut map = HashMap::with_capacity(len); + for uint::range(0, len) |i| { + let key = d.read_map_elt_key(i, |d| Decodable::decode(d)); + let val = d.read_map_elt_val(i, |d| Decodable::decode(d)); + map.insert(key, val); + } + map + } + } +} + +#[cfg(stage0)] impl< S: Encoder, T: Encodable + Hash + IterBytes + Eq @@ -668,6 +1572,23 @@ impl< } } +#[cfg(not(stage0))] +impl< + S: Encoder, + T: Encodable + Hash + IterBytes + Eq +> Encodable for HashSet { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.len()) |s| { + let mut i = 0; + for self.each |e| { + s.emit_seq_elt(i, |s| e.encode(s)); + i += 1; + } + } + } +} + +#[cfg(stage0)] impl< D: Decoder, T: Decodable + Hash + IterBytes + Eq @@ -683,6 +1604,23 @@ impl< } } +#[cfg(not(stage0))] +impl< + D: Decoder, + T: Decodable + Hash + IterBytes + Eq +> Decodable for HashSet { + fn decode(d: &mut D) -> HashSet { + do d.read_seq |d, len| { + let mut set = HashSet::with_capacity(len); + for uint::range(0, len) |i| { + set.insert(d.read_seq_elt(i, |d| Decodable::decode(d))); + } + set + } + } +} + +#[cfg(stage0)] impl< E: Encoder, V: Encodable @@ -699,6 +1637,24 @@ impl< } } +#[cfg(not(stage0))] +impl< + E: Encoder, + V: Encodable +> Encodable for TrieMap { + fn encode(&self, e: &mut E) { + do e.emit_map(self.len()) |e| { + let mut i = 0; + for self.each |key, val| { + e.emit_map_elt_key(i, |e| key.encode(e)); + e.emit_map_elt_val(i, |e| val.encode(e)); + i += 1; + } + } + } +} + +#[cfg(stage0)] impl< D: Decoder, V: Decodable @@ -716,6 +1672,25 @@ impl< } } +#[cfg(not(stage0))] +impl< + D: Decoder, + V: Decodable +> Decodable for TrieMap { + fn decode(d: &mut D) -> TrieMap { + do d.read_map |d, len| { + let mut map = TrieMap::new(); + for uint::range(0, len) |i| { + let key = d.read_map_elt_key(i, |d| Decodable::decode(d)); + let val = d.read_map_elt_val(i, |d| Decodable::decode(d)); + map.insert(key, val); + } + map + } + } +} + +#[cfg(stage0)] impl Encodable for TrieSet { fn encode(&self, s: &S) { do s.emit_seq(self.len()) { @@ -728,6 +1703,20 @@ impl Encodable for TrieSet { } } +#[cfg(not(stage0))] +impl Encodable for TrieSet { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.len()) |s| { + let mut i = 0; + for self.each |e| { + s.emit_seq_elt(i, |s| e.encode(s)); + i += 1; + } + } + } +} + +#[cfg(stage0)] impl Decodable for TrieSet { fn decode(d: &D) -> TrieSet { do d.read_seq |len| { @@ -740,40 +1729,49 @@ impl Decodable for TrieSet { } } -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] +#[cfg(not(stage0))] +impl Decodable for TrieSet { + fn decode(d: &mut D) -> TrieSet { + do d.read_seq |d, len| { + let mut set = TrieSet::new(); + for uint::range(0, len) |i| { + set.insert(d.read_seq_elt(i, |d| Decodable::decode(d))); + } + set + } + } +} + +#[cfg(not(stage0))] impl< E: Encoder, K: Encodable + Eq + TotalOrd, V: Encodable + Eq > Encodable for TreeMap { - fn encode(&self, e: &E) { - do e.emit_map(self.len()) { + fn encode(&self, e: &mut E) { + do e.emit_map(self.len()) |e| { let mut i = 0; for self.each |key, val| { - e.emit_map_elt_key(i, || key.encode(e)); - e.emit_map_elt_val(i, || val.encode(e)); + e.emit_map_elt_key(i, |e| key.encode(e)); + e.emit_map_elt_val(i, |e| val.encode(e)); i += 1; } } } } -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] +#[cfg(not(stage0))] impl< D: Decoder, K: Decodable + Eq + TotalOrd, V: Decodable + Eq > Decodable for TreeMap { - fn decode(d: &D) -> TreeMap { - do d.read_map |len| { + fn decode(d: &mut D) -> TreeMap { + do d.read_map |d, len| { let mut map = TreeMap::new(); for uint::range(0, len) |i| { - let key = d.read_map_elt_key(i, || Decodable::decode(d)); - let val = d.read_map_elt_val(i, || Decodable::decode(d)); + let key = d.read_map_elt_key(i, |d| Decodable::decode(d)); + let val = d.read_map_elt_val(i, |d| Decodable::decode(d)); map.insert(key, val); } map @@ -781,36 +1779,32 @@ impl< } } -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] +#[cfg(not(stage0))] impl< S: Encoder, T: Encodable + Eq + TotalOrd > Encodable for TreeSet { - fn encode(&self, s: &S) { - do s.emit_seq(self.len()) { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.len()) |s| { let mut i = 0; for self.each |e| { - s.emit_seq_elt(i, || e.encode(s)); + s.emit_seq_elt(i, |s| e.encode(s)); i += 1; } } } } -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] +#[cfg(not(stage0))] impl< D: Decoder, T: Decodable + Eq + TotalOrd > Decodable for TreeSet { - fn decode(d: &D) -> TreeSet { - do d.read_seq |len| { + fn decode(d: &mut D) -> TreeSet { + do d.read_seq |d, len| { let mut set = TreeSet::new(); for uint::range(0, len) |i| { - set.insert(d.read_seq_elt(i, || Decodable::decode(d))); + set.insert(d.read_seq_elt(i, |d| Decodable::decode(d))); } set } @@ -822,10 +1816,17 @@ impl< // // In some cases, these should eventually be coded as traits. +#[cfg(stage0)] pub trait EncoderHelpers { fn emit_from_vec(&self, v: &[T], f: &fn(v: &T)); } +#[cfg(not(stage0))] +pub trait EncoderHelpers { + fn emit_from_vec(&mut self, v: &[T], f: &fn(&mut Self, v: &T)); +} + +#[cfg(stage0)] impl EncoderHelpers for S { fn emit_from_vec(&self, v: &[T], f: &fn(v: &T)) { do self.emit_seq(v.len()) { @@ -838,10 +1839,30 @@ impl EncoderHelpers for S { } } +#[cfg(not(stage0))] +impl EncoderHelpers for S { + fn emit_from_vec(&mut self, v: &[T], f: &fn(&mut S, &T)) { + do self.emit_seq(v.len()) |this| { + for v.eachi |i, e| { + do this.emit_seq_elt(i) |this| { + f(this, e) + } + } + } + } +} + +#[cfg(stage0)] pub trait DecoderHelpers { fn read_to_vec(&self, f: &fn() -> T) -> ~[T]; } +#[cfg(not(stage0))] +pub trait DecoderHelpers { + fn read_to_vec(&mut self, f: &fn(&mut Self) -> T) -> ~[T]; +} + +#[cfg(stage0)] impl DecoderHelpers for D { fn read_to_vec(&self, f: &fn() -> T) -> ~[T] { do self.read_seq |len| { @@ -851,3 +1872,15 @@ impl DecoderHelpers for D { } } } + +#[cfg(not(stage0))] +impl DecoderHelpers for D { + fn read_to_vec(&mut self, f: &fn(&mut D) -> T) -> ~[T] { + do self.read_seq |this, len| { + do vec::from_fn(len) |i| { + this.read_seq_elt(i, |this| f(this)) + } + } + } +} + diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index bb4a9e97ea1..2cdf36c71c7 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -140,6 +140,7 @@ impl WorkMap { fn new() -> WorkMap { WorkMap(HashMap::new()) } } +#[cfg(stage0)] impl Encodable for WorkMap { fn encode(&self, s: &S) { let mut d = ~[]; @@ -151,6 +152,19 @@ impl Encodable for WorkMap { } } +#[cfg(not(stage0))] +impl Encodable for WorkMap { + fn encode(&self, s: &mut S) { + let mut d = ~[]; + for self.each |k, v| { + d.push((copy *k, copy *v)) + } + sort::tim_sort(d); + d.encode(s) + } +} + +#[cfg(stage0)] impl Decodable for WorkMap { fn decode(d: &D) -> WorkMap { let v : ~[(WorkKey,~str)] = Decodable::decode(d); @@ -162,6 +176,18 @@ impl Decodable for WorkMap { } } +#[cfg(not(stage0))] +impl Decodable for WorkMap { + fn decode(d: &mut D) -> WorkMap { + let v : ~[(WorkKey,~str)] = Decodable::decode(d); + let mut w = WorkMap::new(); + for v.each |&(k, v)| { + w.insert(copy k, copy v); + } + w + } +} + struct Database { db_filename: Path, db_cache: HashMap<~str, ~str>, @@ -171,8 +197,8 @@ struct Database { pub impl Database { fn prepare(&mut self, fn_name: &str, - declared_inputs: &WorkMap) -> Option<(WorkMap, WorkMap, ~str)> - { + declared_inputs: &WorkMap) + -> Option<(WorkMap, WorkMap, ~str)> { let k = json_encode(&(fn_name, declared_inputs)); match self.db_cache.find(&k) { None => None, @@ -229,17 +255,38 @@ struct Work { res: Option>> } +#[cfg(stage0)] fn json_encode>(t: &T) -> ~str { do io::with_str_writer |wr| { t.encode(&json::Encoder(wr)); } } +#[cfg(not(stage0))] +fn json_encode>(t: &T) -> ~str { + do io::with_str_writer |wr| { + let mut encoder = json::Encoder(wr); + t.encode(&mut encoder); + } +} + +// FIXME(#5121) +#[cfg(stage0)] +fn json_decode>(s: &str) -> T { + do io::with_str_reader(s) |rdr| { + let j = result::unwrap(json::from_reader(rdr)); + let decoder = json::Decoder(j); + Decodable::decode(&decoder) + } +} + // FIXME(#5121) +#[cfg(not(stage0))] fn json_decode>(s: &str) -> T { do io::with_str_reader(s) |rdr| { let j = result::unwrap(json::from_reader(rdr)); - Decodable::decode(&json::Decoder(j)) + let mut decoder = json::Decoder(j); + Decodable::decode(&mut decoder) } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a295952439f..77e79866160 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -70,21 +70,53 @@ pub type Name = uint; // with a macro expansion pub type Mrk = uint; +#[cfg(stage0)] impl Encodable for ident { fn encode(&self, s: &S) { + unsafe { + let intr = + match task::local_data::local_data_get(interner_key!()) { + None => fail!(~"encode: TLS interner not set up"), + Some(intr) => intr + }; + + s.emit_str(*(*intr).get(*self)); + } + } +} + +#[cfg(not(stage0))] +impl Encodable for ident { + fn encode(&self, s: &mut S) { + unsafe { + let intr = + match task::local_data::local_data_get(interner_key!()) { + None => fail!(~"encode: TLS interner not set up"), + Some(intr) => intr + }; + + s.emit_str(*(*intr).get(*self)); + } + } +} + +#[cfg(stage0)] +impl Decodable for ident { + fn decode(d: &D) -> ident { let intr = match unsafe { task::local_data::local_data_get(interner_key!()) } { - None => fail!(~"encode: TLS interner not set up"), + None => fail!(~"decode: TLS interner not set up"), Some(intr) => intr }; - s.emit_str(*(*intr).get(*self)); + (*intr).intern(@d.read_str()) } } +#[cfg(not(stage0))] impl Decodable for ident { - fn decode(d: &D) -> ident { + fn decode(d: &mut D) -> ident { let intr = match unsafe { task::local_data::local_data_get(interner_key!()) } { diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 5f4967351e1..bbb390e9dc9 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -125,17 +125,34 @@ impl cmp::Eq for span { fn ne(&self, other: &span) -> bool { !(*self).eq(other) } } +#[cfg(stage0)] impl Encodable for span { /* Note #1972 -- spans are encoded but not decoded */ fn encode(&self, _s: &S) { _s.emit_nil() } } +#[cfg(not(stage0))] +impl Encodable for span { + /* Note #1972 -- spans are encoded but not decoded */ + fn encode(&self, s: &mut S) { + s.emit_nil() + } +} + +#[cfg(stage0)] impl Decodable for span { fn decode(_d: &D) -> span { dummy_sp() } } +#[cfg(not(stage0))] +impl Decodable for span { + fn decode(_d: &mut D) -> span { + dummy_sp() + } +} + pub fn spanned(lo: BytePos, hi: BytePos, t: T) -> spanned { respan(mk_sp(lo, hi), t) } diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index 2ceb6f0c4bb..bdf0a2a1dd0 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -238,7 +238,8 @@ trait ExtCtxtMethods { fn stmt(&self, expr: @ast::expr) -> @ast::stmt; fn lit_str(&self, span: span, s: @~str) -> @ast::expr; fn lit_uint(&self, span: span, i: uint) -> @ast::expr; - fn lambda(&self, blk: ast::blk) -> @ast::expr; + fn lambda0(&self, blk: ast::blk) -> @ast::expr; + fn lambda1(&self, blk: ast::blk, ident: ast::ident) -> @ast::expr; fn blk(&self, span: span, stmts: ~[@ast::stmt]) -> ast::blk; fn expr_blk(&self, expr: @ast::expr) -> ast::blk; fn expr_path(&self, span: span, strs: ~[ast::ident]) -> @ast::expr; @@ -254,8 +255,15 @@ trait ExtCtxtMethods { ident: ast::ident, args: ~[@ast::expr]) -> @ast::expr; - fn lambda_expr(&self, expr: @ast::expr) -> @ast::expr; - fn lambda_stmts(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr; + fn lambda_expr_0(&self, expr: @ast::expr) -> @ast::expr; + fn lambda_expr_1(&self, expr: @ast::expr, ident: ast::ident) + -> @ast::expr; + fn lambda_stmts_0(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr; + fn lambda_stmts_1(&self, + span: span, + stmts: ~[@ast::stmt], + ident: ast::ident) + -> @ast::expr; } impl ExtCtxtMethods for @ext_ctxt { @@ -388,12 +396,18 @@ impl ExtCtxtMethods for @ext_ctxt { span: span})) } - fn lambda(&self, blk: ast::blk) -> @ast::expr { + fn lambda0(&self, blk: ast::blk) -> @ast::expr { let ext_cx = *self; let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk)); quote_expr!( || $blk_e ) } + fn lambda1(&self, blk: ast::blk, ident: ast::ident) -> @ast::expr { + let ext_cx = *self; + let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk)); + quote_expr!( |$ident| $blk_e ) + } + fn blk(&self, span: span, stmts: ~[@ast::stmt]) -> ast::blk { codemap::spanned { node: ast::blk_ { @@ -461,15 +475,29 @@ impl ExtCtxtMethods for @ext_ctxt { ident: ast::ident, args: ~[@ast::expr] ) -> @ast::expr { - self.expr(span, ast::expr_method_call(expr, ident, ~[], args, ast::NoSugar)) + self.expr(span, + ast::expr_method_call(expr, ident, ~[], args, ast::NoSugar)) + } + + fn lambda_expr_0(&self, expr: @ast::expr) -> @ast::expr { + self.lambda0(self.expr_blk(expr)) + } + + fn lambda_expr_1(&self, expr: @ast::expr, ident: ast::ident) + -> @ast::expr { + self.lambda1(self.expr_blk(expr), ident) } - fn lambda_expr(&self, expr: @ast::expr) -> @ast::expr { - self.lambda(self.expr_blk(expr)) + fn lambda_stmts_0(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr { + self.lambda0(self.blk(span, stmts)) } - fn lambda_stmts(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr { - self.lambda(self.blk(span, stmts)) + fn lambda_stmts_1(&self, + span: span, + stmts: ~[@ast::stmt], + ident: ast::ident) + -> @ast::expr { + self.lambda1(self.blk(span, stmts), ident) } } @@ -644,7 +672,7 @@ fn mk_ser_method( None, ast::mt { ty: cx.ty_path(span, ~[cx.ident_of(~"__S")], ~[]), - mutbl: ast::m_imm + mutbl: ast::m_mutbl } ), span: span, @@ -706,7 +734,7 @@ fn mk_deser_method( None, ast::mt { ty: cx.ty_path(span, ~[cx.ident_of(~"__D")], ~[]), - mutbl: ast::m_imm + mutbl: ast::m_mutbl } ), span: span, @@ -758,8 +786,8 @@ fn mk_struct_ser_impl( generics: &ast::Generics ) -> @ast::item { let fields = do mk_struct_fields(fields).mapi |idx, field| { - // ast for `|| self.$(name).encode(__s)` - let expr_lambda = cx.lambda_expr( + // ast for `|__s| self.$(name).encode(__s)` + let expr_lambda = cx.lambda_expr_1( cx.expr_method_call( span, cx.expr_field( @@ -769,7 +797,8 @@ fn mk_struct_ser_impl( ), cx.ident_of(~"encode"), ~[cx.expr_var(span, ~"__s")] - ) + ), + cx.ident_of(~"__s") ); // ast for `__s.emit_struct_field($(name), $(idx), $(expr_lambda))` @@ -787,7 +816,7 @@ fn mk_struct_ser_impl( ) }; - // ast for `__s.emit_struct($(name), || $(fields))` + // ast for `__s.emit_struct($(name), |__s| $(fields))` let ser_body = cx.expr_method_call( span, cx.expr_var(span, ~"__s"), @@ -795,7 +824,7 @@ fn mk_struct_ser_impl( ~[ cx.lit_str(span, @cx.str_of(ident)), cx.lit_uint(span, vec::len(fields)), - cx.lambda_stmts(span, fields), + cx.lambda_stmts_1(span, fields, cx.ident_of(~"__s")), ] ); @@ -810,8 +839,8 @@ fn mk_struct_deser_impl( generics: &ast::Generics ) -> @ast::item { let fields = do mk_struct_fields(fields).mapi |idx, field| { - // ast for `|| std::serialize::decode(__d)` - let expr_lambda = cx.lambda( + // ast for `|__d| std::serialize::decode(__d)` + let expr_lambda = cx.lambda1( cx.expr_blk( cx.expr_call( span, @@ -823,7 +852,8 @@ fn mk_struct_deser_impl( ]), ~[cx.expr_var(span, ~"__d")] ) - ) + ), + cx.ident_of(~"__d") ); // ast for `__d.read_struct_field($(name), $(idx), $(expr_lambda))` @@ -848,7 +878,7 @@ fn mk_struct_deser_impl( } }; - // ast for `read_struct($(name), || $(fields))` + // ast for `read_struct($(name), |__d| $(fields))` let body = cx.expr_method_call( span, cx.expr_var(span, ~"__d"), @@ -856,7 +886,7 @@ fn mk_struct_deser_impl( ~[ cx.lit_str(span, @cx.str_of(ident)), cx.lit_uint(span, vec::len(fields)), - cx.lambda_expr( + cx.lambda_expr_1( cx.expr( span, ast::expr_struct( @@ -864,7 +894,8 @@ fn mk_struct_deser_impl( fields, None ) - ) + ), + cx.ident_of(~"__d") ), ] ); @@ -974,14 +1005,15 @@ fn ser_variant( cx.ident_of(~"emit_enum_variant_arg") ); - // ast for `|| $(v).encode(__s)` - let expr_encode = cx.lambda_expr( - cx.expr_method_call( + // ast for `|__s| $(v).encode(__s)` + let expr_encode = cx.lambda_expr_1( + cx.expr_method_call( span, cx.expr_path(span, ~[names[a_idx]]), cx.ident_of(~"encode"), ~[cx.expr_var(span, ~"__s")] - ) + ), + cx.ident_of(~"__s") ); // ast for `$(expr_emit)($(a_idx), $(expr_encode))` @@ -1003,7 +1035,7 @@ fn ser_variant( cx.lit_str(span, @cx.str_of(v_name)), cx.lit_uint(span, v_idx), cx.lit_uint(span, stmts.len()), - cx.lambda_stmts(span, stmts), + cx.lambda_stmts_1(span, stmts, cx.ident_of(~"__s")), ] ); @@ -1050,7 +1082,7 @@ fn mk_enum_ser_body( cx.ident_of(~"emit_enum"), ~[ cx.lit_str(span, @cx.str_of(name)), - cx.lambda_expr(match_expr), + cx.lambda_expr_1(match_expr, cx.ident_of(~"__s")), ] ) } @@ -1062,8 +1094,8 @@ fn mk_enum_deser_variant_nary( args: ~[ast::variant_arg] ) -> @ast::expr { let args = do args.mapi |idx, _arg| { - // ast for `|| std::serialize::decode(__d)` - let expr_lambda = cx.lambda_expr( + // ast for `|__s| std::serialize::decode(__d)` + let expr_lambda = cx.lambda_expr_1( cx.expr_call( span, cx.expr_path_global(span, ~[ @@ -1073,7 +1105,8 @@ fn mk_enum_deser_variant_nary( cx.ident_of(~"decode"), ]), ~[cx.expr_var(span, ~"__d")] - ) + ), + cx.ident_of(~"__d") ); // ast for `__d.read_enum_variant_arg($(a_idx), $(expr_lambda))` @@ -1163,24 +1196,44 @@ fn mk_enum_deser_body( span, ast::expr_fn_block( ast::fn_decl { - inputs: ~[ast::arg { - is_mutbl: false, - ty: @ast::Ty { + inputs: ~[ + ast::arg { + is_mutbl: false, + ty: @ast::Ty { + id: ext_cx.next_id(), + node: ast::ty_infer, + span: span + }, + pat: @ast::pat { + id: ext_cx.next_id(), + node: ast::pat_ident( + ast::bind_by_copy, + ast_util::ident_to_path(span, + ext_cx.ident_of(~"__d")), + None), + span: span, + }, id: ext_cx.next_id(), - node: ast::ty_infer, - span: span }, - pat: @ast::pat { + ast::arg { + is_mutbl: false, + ty: @ast::Ty { + id: ext_cx.next_id(), + node: ast::ty_infer, + span: span + }, + pat: @ast::pat { + id: ext_cx.next_id(), + node: ast::pat_ident( + ast::bind_by_copy, + ast_util::ident_to_path(span, + ext_cx.ident_of(~"i")), + None), + span: span, + }, id: ext_cx.next_id(), - node: ast::pat_ident( - ast::bind_by_copy, - ast_util::ident_to_path(span, - ext_cx.ident_of(~"i")), - None), - span: span, - }, - id: ext_cx.next_id(), - }], + } + ], output: @ast::Ty { id: ext_cx.next_id(), node: ast::ty_infer, @@ -1198,13 +1251,14 @@ fn mk_enum_deser_body( ); // ast for `__d.read_enum_variant($expr_arm_names, $(expr_lambda))` - let expr_lambda = ext_cx.lambda_expr( + let expr_lambda = ext_cx.lambda_expr_1( ext_cx.expr_method_call( span, ext_cx.expr_var(span, ~"__d"), ext_cx.ident_of(~"read_enum_variant"), ~[expr_arm_names, expr_lambda] - ) + ), + ext_cx.ident_of(~"__d") ); // ast for `__d.read_enum($(e_name), $(expr_lambda))` @@ -1256,105 +1310,147 @@ mod test { } impl Encoder for TestEncoder { - fn emit_nil(&self) { self.add_to_log(CallToEmitNil) } + fn emit_nil(&mut self) { self.add_to_log(CallToEmitNil) } - fn emit_uint(&self, v: uint) {self.add_to_log(CallToEmitUint(v)); } - fn emit_u64(&self, _v: u64) { self.add_unknown_to_log(); } - fn emit_u32(&self, _v: u32) { self.add_unknown_to_log(); } - fn emit_u16(&self, _v: u16) { self.add_unknown_to_log(); } - fn emit_u8(&self, _v: u8) { self.add_unknown_to_log(); } + fn emit_uint(&mut self, v: uint) { + self.add_to_log(CallToEmitUint(v)); + } + fn emit_u64(&mut self, _v: u64) { self.add_unknown_to_log(); } + fn emit_u32(&mut self, _v: u32) { self.add_unknown_to_log(); } + fn emit_u16(&mut self, _v: u16) { self.add_unknown_to_log(); } + fn emit_u8(&mut self, _v: u8) { self.add_unknown_to_log(); } - fn emit_int(&self, _v: int) { self.add_unknown_to_log(); } - fn emit_i64(&self, _v: i64) { self.add_unknown_to_log(); } - fn emit_i32(&self, _v: i32) { self.add_unknown_to_log(); } - fn emit_i16(&self, _v: i16) { self.add_unknown_to_log(); } - fn emit_i8(&self, _v: i8) { self.add_unknown_to_log(); } + fn emit_int(&mut self, _v: int) { self.add_unknown_to_log(); } + fn emit_i64(&mut self, _v: i64) { self.add_unknown_to_log(); } + fn emit_i32(&mut self, _v: i32) { self.add_unknown_to_log(); } + fn emit_i16(&mut self, _v: i16) { self.add_unknown_to_log(); } + fn emit_i8(&mut self, _v: i8) { self.add_unknown_to_log(); } - fn emit_bool(&self, _v: bool) { self.add_unknown_to_log(); } + fn emit_bool(&mut self, _v: bool) { self.add_unknown_to_log(); } - fn emit_f64(&self, _v: f64) { self.add_unknown_to_log(); } - fn emit_f32(&self, _v: f32) { self.add_unknown_to_log(); } - fn emit_float(&self, _v: float) { self.add_unknown_to_log(); } + fn emit_f64(&mut self, _v: f64) { self.add_unknown_to_log(); } + fn emit_f32(&mut self, _v: f32) { self.add_unknown_to_log(); } + fn emit_float(&mut self, _v: float) { self.add_unknown_to_log(); } - fn emit_char(&self, _v: char) { self.add_unknown_to_log(); } - fn emit_str(&self, _v: &str) { self.add_unknown_to_log(); } + fn emit_char(&mut self, _v: char) { self.add_unknown_to_log(); } + fn emit_str(&mut self, _v: &str) { self.add_unknown_to_log(); } - fn emit_enum(&self, name: &str, f: &fn()) { - self.add_to_log(CallToEmitEnum(name.to_str())); f(); } + fn emit_enum(&mut self, name: &str, f: &fn(&mut TestEncoder)) { + self.add_to_log(CallToEmitEnum(name.to_str())); + f(self); + } - fn emit_enum_variant(&self, name: &str, id: uint, - cnt: uint, f: &fn()) { - self.add_to_log(CallToEmitEnumVariant (name.to_str(),id,cnt)); - f(); + fn emit_enum_variant(&mut self, + name: &str, + id: uint, + cnt: uint, + f: &fn(&mut TestEncoder)) { + self.add_to_log(CallToEmitEnumVariant(name.to_str(), id, cnt)); + f(self); } - fn emit_enum_variant_arg(&self, idx: uint, f: &fn()) { - self.add_to_log(CallToEmitEnumVariantArg (idx)); f(); + fn emit_enum_variant_arg(&mut self, + idx: uint, + f: &fn(&mut TestEncoder)) { + self.add_to_log(CallToEmitEnumVariantArg(idx)); + f(self); } - fn emit_enum_struct_variant(&self, name: &str, id: uint, cnt: uint, f: &fn()) { + fn emit_enum_struct_variant(&mut self, + name: &str, + id: uint, + cnt: uint, + f: &fn(&mut TestEncoder)) { self.emit_enum_variant(name, id, cnt, f) } - fn emit_enum_struct_variant_field(&self, _name: &str, idx: uint, f: &fn()) { + fn emit_enum_struct_variant_field(&mut self, + _name: &str, + idx: uint, + f: &fn(&mut TestEncoder)) { self.emit_enum_variant_arg(idx, f) } - fn emit_struct(&self, name: &str, len: uint, f: &fn()) { - self.add_to_log(CallToEmitStruct (name.to_str(),len)); f(); + fn emit_struct(&mut self, + name: &str, + len: uint, + f: &fn(&mut TestEncoder)) { + self.add_to_log(CallToEmitStruct (name.to_str(),len)); + f(self); } - fn emit_struct_field(&self, name: &str, idx: uint, f: &fn()) { - self.add_to_log(CallToEmitField (name.to_str(),idx)); f(); + fn emit_struct_field(&mut self, + name: &str, + idx: uint, + f: &fn(&mut TestEncoder)) { + self.add_to_log(CallToEmitField (name.to_str(),idx)); + f(self); } - fn emit_tuple(&self, _len: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_tuple(&mut self, _len: uint, f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_tuple_arg(&self, _idx: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_tuple_arg(&mut self, _idx: uint, f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_tuple_struct(&self, _name: &str, _len: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_tuple_struct(&mut self, + _name: &str, + _len: uint, + f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_tuple_struct_arg(&self, _idx: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + + fn emit_tuple_struct_arg(&mut self, + _idx: uint, + f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_option(&self, f: &fn()) { + fn emit_option(&mut self, f: &fn(&mut TestEncoder)) { self.add_to_log(CallToEmitOption); - f(); + f(self); } - fn emit_option_none(&self) { + fn emit_option_none(&mut self) { self.add_to_log(CallToEmitOptionNone); } - fn emit_option_some(&self, f: &fn()) { + fn emit_option_some(&mut self, f: &fn(&mut TestEncoder)) { self.add_to_log(CallToEmitOptionSome); - f(); + f(self); } - fn emit_seq(&self, _len: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_seq(&mut self, _len: uint, f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_seq_elt(&self, _idx: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_seq_elt(&mut self, _idx: uint, f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_map(&self, _len: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_map(&mut self, _len: uint, f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_map_elt_key(&self, _idx: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_map_elt_key(&mut self, _idx: uint, f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_map_elt_val(&self, _idx: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_map_elt_val(&mut self, _idx: uint, f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } } fn to_call_log>(val: E) -> ~[call] { - let mut te = TestEncoder {call_log: @mut ~[]}; - val.encode(&te); + let mut te = TestEncoder { + call_log: @mut ~[] + }; + val.encode(&mut te); copy *te.call_log } diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index 48f6d5baa8b..fe270abc2e4 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -96,7 +96,7 @@ fn create_decode_method( cx, span, build::mk_simple_ty_path(cx, span, cx.ident_of(~"__D")), - ast::m_imm + ast::m_mutbl ); let d_ident = cx.ident_of(~"__d"); let d_arg = build::mk_arg(cx, span, d_ident, d_arg_type); @@ -219,6 +219,11 @@ fn create_read_struct_field( // Call the substructure method. let decode_expr = call_substructure_decode_method(cx, span); + let d_arg = build::mk_arg(cx, + span, + cx.ident_of(~"__d"), + build::mk_ty_infer(cx, span)); + let call_expr = build::mk_method_call( cx, span, @@ -227,7 +232,11 @@ fn create_read_struct_field( ~[ build::mk_base_str(cx, span, cx.str_of(ident)), build::mk_uint(cx, span, idx), - build::mk_lambda_no_args(cx, span, decode_expr), + build::mk_lambda(cx, + span, + build::mk_fn_decl(~[d_arg], + build::mk_ty_infer(cx, span)), + decode_expr), ] ); @@ -282,6 +291,11 @@ fn expand_deriving_decodable_struct_method( i += 1; } + let d_arg = build::mk_arg(cx, + span, + cx.ident_of(~"__d"), + build::mk_ty_infer(cx, span)); + let read_struct_expr = build::mk_method_call( cx, span, @@ -294,9 +308,10 @@ fn expand_deriving_decodable_struct_method( ~[ build::mk_base_str(cx, span, cx.str_of(type_ident)), build::mk_uint(cx, span, fields.len()), - build::mk_lambda_no_args( + build::mk_lambda( cx, span, + build::mk_fn_decl(~[d_arg], build::mk_ty_infer(cx, span)), build::mk_struct_e( cx, span, @@ -334,6 +349,12 @@ fn create_read_variant_arg( // Call the substructure method. let expr = call_substructure_decode_method(cx, span); + let d_arg = build::mk_arg(cx, + span, + cx.ident_of(~"__d"), + build::mk_ty_infer(cx, span)); + let t_infer = build::mk_ty_infer(cx, span); + let call_expr = build::mk_method_call( cx, span, @@ -341,7 +362,10 @@ fn create_read_variant_arg( cx.ident_of(~"read_enum_variant_arg"), ~[ build::mk_uint(cx, span, j), - build::mk_lambda_no_args(cx, span, expr), + build::mk_lambda(cx, + span, + build::mk_fn_decl(~[d_arg], t_infer), + expr), ] ); @@ -399,6 +423,12 @@ fn create_read_enum_variant( span, build::mk_fn_decl( ~[ + build::mk_arg( + cx, + span, + cx.ident_of(~"__d"), + build::mk_ty_infer(cx, span) + ), build::mk_arg( cx, span, @@ -434,6 +464,11 @@ fn expand_deriving_decodable_enum_method( enum_definition ); + let d_arg = build::mk_arg(cx, + span, + cx.ident_of(~"__d"), + build::mk_ty_infer(cx, span)); + // Create the read_enum expression let read_enum_expr = build::mk_method_call( cx, @@ -442,7 +477,11 @@ fn expand_deriving_decodable_enum_method( cx.ident_of(~"read_enum"), ~[ build::mk_base_str(cx, span, cx.str_of(type_ident)), - build::mk_lambda_no_args(cx, span, read_enum_variant_expr), + build::mk_lambda(cx, + span, + build::mk_fn_decl(~[d_arg], + build::mk_ty_infer(cx, span)), + read_enum_variant_expr), ] ); diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 640d0d0ff2d..8f8139790ad 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -94,10 +94,9 @@ fn create_encode_method( cx, span, build::mk_simple_ty_path(cx, span, cx.ident_of(~"__E")), - ast::m_imm + ast::m_mutbl ); - let e_ident = cx.ident_of(~"__e"); - let e_arg = build::mk_arg(cx, span, e_ident, e_arg_type); + let e_arg = build::mk_arg(cx, span, cx.ident_of(~"__e"), e_arg_type); // Create the type of the return value. let output_type = @ast::Ty { id: cx.next_id(), node: ty_nil, span: span }; @@ -226,10 +225,16 @@ fn expand_deriving_encodable_struct_method( self_field ); + let e_ident = cx.ident_of(~"__e"); + let e_arg = build::mk_arg(cx, + span, + e_ident, + build::mk_ty_infer(cx, span)); + let blk_expr = build::mk_lambda( cx, span, - build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)), + build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)), encode_expr ); @@ -257,6 +262,11 @@ fn expand_deriving_encodable_struct_method( idx += 1; } + let e_arg = build::mk_arg(cx, + span, + cx.ident_of(~"__e"), + build::mk_ty_infer(cx, span)); + let emit_struct_stmt = build::mk_method_call( cx, span, @@ -272,7 +282,7 @@ fn expand_deriving_encodable_struct_method( build::mk_lambda_stmts( cx, span, - build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)), + build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)), statements ), ] @@ -309,10 +319,16 @@ fn expand_deriving_encodable_enum_method( // Call the substructure method. let expr = call_substructure_encode_method(cx, span, field); + let e_ident = cx.ident_of(~"__e"); + let e_arg = build::mk_arg(cx, + span, + e_ident, + build::mk_ty_infer(cx, span)); + let blk_expr = build::mk_lambda( cx, span, - build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)), + build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)), expr ); @@ -331,6 +347,10 @@ fn expand_deriving_encodable_enum_method( } // Create the pattern body. + let e_arg = build::mk_arg(cx, + span, + cx.ident_of(~"__e"), + build::mk_ty_infer(cx, span)); let call_expr = build::mk_method_call( cx, span, @@ -343,7 +363,7 @@ fn expand_deriving_encodable_enum_method( build::mk_lambda_stmts( cx, span, - build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)), + build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)), stmts ) ] @@ -359,11 +379,17 @@ fn expand_deriving_encodable_enum_method( } }; + let e_ident = cx.ident_of(~"__e"); + let e_arg = build::mk_arg(cx, + span, + e_ident, + build::mk_ty_infer(cx, span)); + // Create the method body. let lambda_expr = build::mk_lambda( cx, span, - build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)), + build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)), expand_enum_or_struct_match(cx, span, arms) ); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 4f1d41a4a7a..0c024958a24 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -420,7 +420,8 @@ mod test { #[cfg(test)] fn to_json_str>(val: @E) -> ~str { do io::with_str_writer |writer| { - val.encode(~std::json::Encoder(writer)); + let mut encoder = std::json::Encoder(writer); + val.encode(&mut encoder); } } diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index 8d0675d0884..c420e0cbb2f 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -1,3 +1,7 @@ +// xfail-test + +// Broken due to arena API problems. + // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. @@ -10,7 +14,6 @@ extern mod std; use std::arena; -use methods = std::arena::Arena; enum tree<'self> { nil, @@ -26,9 +29,7 @@ fn item_check(t: &tree) -> int { } } -fn bottom_up_tree<'r>(arena: &'r arena::Arena, - item: int, - depth: int) +fn bottom_up_tree<'r>(arena: &'r mut arena::Arena, item: int, depth: int) -> &'r tree<'r> { if depth > 0 { return arena.alloc( @@ -58,25 +59,25 @@ fn main() { max_depth = n; } - let stretch_arena = arena::Arena(); + let mut stretch_arena = arena::Arena(); let stretch_depth = max_depth + 1; - let stretch_tree = bottom_up_tree(&stretch_arena, 0, stretch_depth); + let stretch_tree = bottom_up_tree(&mut stretch_arena, 0, stretch_depth); io::println(fmt!("stretch tree of depth %d\t check: %d", stretch_depth, item_check(stretch_tree))); - let long_lived_arena = arena::Arena(); - let long_lived_tree = bottom_up_tree(&long_lived_arena, 0, max_depth); + let mut long_lived_arena = arena::Arena(); + let long_lived_tree = bottom_up_tree(&mut long_lived_arena, 0, max_depth); let mut depth = min_depth; while depth <= max_depth { let iterations = int::pow(2, (max_depth - depth + min_depth) as uint); let mut chk = 0; let mut i = 1; while i <= iterations { - let mut temp_tree = bottom_up_tree(&long_lived_arena, i, depth); + let mut temp_tree = bottom_up_tree(&mut long_lived_arena, i, depth); chk += item_check(temp_tree); - temp_tree = bottom_up_tree(&long_lived_arena, -i, depth); + temp_tree = bottom_up_tree(&mut long_lived_arena, -i, depth); chk += item_check(temp_tree); i += 1; } @@ -87,5 +88,5 @@ fn main() { } io::println(fmt!("long lived trees of depth %d\t check: %d", max_depth, - item_check(long_lived_tree))); + item_check(long_lived_tree))); } diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index bfc15acaa76..cfac8e8cd06 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -31,11 +31,12 @@ fn test_ebml >(a1: &A) { let bytes = do io::with_bytes_writer |wr| { - let ebml_w = &EBWriter::Encoder(wr); - a1.encode(ebml_w) + let mut ebml_w = EBWriter::Encoder(wr); + a1.encode(&mut ebml_w) }; let d = EBReader::Doc(@bytes); - let a2: A = Decodable::decode(&EBReader::Decoder(d)); + let mut decoder = EBReader::Decoder(d); + let a2: A = Decodable::decode(&mut decoder); assert!(*a1 == a2); } diff --git a/src/test/run-pass/issue-4036.rs b/src/test/run-pass/issue-4036.rs index f24875cbf8e..8b514b11625 100644 --- a/src/test/run-pass/issue-4036.rs +++ b/src/test/run-pass/issue-4036.rs @@ -17,5 +17,6 @@ use self::std::serialize; pub fn main() { let json = json::from_str("[1]").unwrap(); - let _x: ~[int] = serialize::Decodable::decode(&json::Decoder(json)); + let mut decoder = json::Decoder(json); + let _x: ~[int] = serialize::Decodable::decode(&mut decoder); } diff --git a/src/test/run-pass/placement-new-arena.rs b/src/test/run-pass/placement-new-arena.rs index 12c80421932..166435cbc3d 100644 --- a/src/test/run-pass/placement-new-arena.rs +++ b/src/test/run-pass/placement-new-arena.rs @@ -14,7 +14,8 @@ extern mod std; use std::arena; pub fn main() { - let p = &arena::Arena(); + let mut arena = arena::Arena(); + let p = &mut arena; let x = p.alloc(|| 4u); io::print(fmt!("%u", *x)); assert!(*x == 4u); diff --git a/src/test/run-pass/regions-mock-trans-impls.rs b/src/test/run-pass/regions-mock-trans-impls.rs index c1f7a713ca6..e9163505748 100644 --- a/src/test/run-pass/regions-mock-trans-impls.rs +++ b/src/test/run-pass/regions-mock-trans-impls.rs @@ -21,7 +21,7 @@ struct Bcx<'self> { } struct Fcx<'self> { - arena: &'self Arena, + arena: &'self mut Arena, ccx: &'self Ccx } @@ -29,23 +29,27 @@ struct Ccx { x: int } -fn h<'r>(bcx : &'r Bcx<'r>) -> &'r Bcx<'r> { - return bcx.fcx.arena.alloc(|| Bcx { fcx: bcx.fcx }); +fn h<'r>(bcx : &'r mut Bcx<'r>) -> &'r mut Bcx<'r> { + // XXX: Arena has a bad interface here; it should return mutable pointers. + // But this patch is too big to roll that in. + unsafe { + cast::transmute(bcx.fcx.arena.alloc(|| Bcx { fcx: bcx.fcx })) + } } -fn g(fcx : &Fcx) { - let bcx = Bcx { fcx: fcx }; - h(&bcx); +fn g(fcx: &mut Fcx) { + let mut bcx = Bcx { fcx: fcx }; + h(&mut bcx); } -fn f(ccx : &Ccx) { - let a = Arena(); - let fcx = &Fcx { arena: &a, ccx: ccx }; - return g(fcx); +fn f(ccx: &mut Ccx) { + let mut a = Arena(); + let mut fcx = Fcx { arena: &mut a, ccx: ccx }; + return g(&mut fcx); } pub fn main() { - let ccx = Ccx { x: 0 }; - f(&ccx); + let mut ccx = Ccx { x: 0 }; + f(&mut ccx); } -- cgit 1.4.1-3-g733a5 From c0f587de34f30b060df8a88c4068740e587b9340 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 2 May 2013 18:41:57 -0700 Subject: librustc: Make uninhabited enums not castable to int --- src/librustc/middle/ty.rs | 15 +++++++++------ src/test/compile-fail/uninhabited-enum-cast.rs | 7 +++++++ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 src/test/compile-fail/uninhabited-enum-cast.rs (limited to 'src/test') diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index c42c4c3cf07..d28efcd55b0 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2509,12 +2509,15 @@ pub fn type_is_enum(ty: t) -> bool { // constructors pub fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool { match get(ty).sty { - ty_enum(did, _) => { - let variants = enum_variants(cx, did); - let some_n_ary = vec::any(*variants, |v| vec::len(v.args) > 0u); - return !some_n_ary; - } - _ => return false + ty_enum(did, _) => { + let variants = enum_variants(cx, did); + if variants.len() == 0 { + false + } else { + variants.all(|v| v.args.len() == 0) + } + } + _ => false } } diff --git a/src/test/compile-fail/uninhabited-enum-cast.rs b/src/test/compile-fail/uninhabited-enum-cast.rs new file mode 100644 index 00000000000..c4a5dc4710c --- /dev/null +++ b/src/test/compile-fail/uninhabited-enum-cast.rs @@ -0,0 +1,7 @@ +enum E {} + +fn f(e: E) { + println((e as int).to_str()); //~ ERROR non-scalar cast +} + +fn main() {} -- cgit 1.4.1-3-g733a5 From 13df2ea69c332d7a20c7ab394020430a09dad507 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 2 May 2013 15:38:19 -0700 Subject: rustc: Handle struct patterns where the expected type is an enum Previously, rustc would ICE if you matched on an enum-typed thing with a structure pattern. Error out correctly. --- src/librustc/middle/typeck/check/_match.rs | 78 ++++++++++++++++++------------ src/libsyntax/ast_util.rs | 6 +-- src/test/compile-fail/issue-5358-1.rs | 18 +++++++ src/test/compile-fail/issue-5358.rs | 17 +++++++ 4 files changed, 85 insertions(+), 34 deletions(-) create mode 100644 src/test/compile-fail/issue-5358-1.rs create mode 100644 src/test/compile-fail/issue-5358.rs (limited to 'src/test') diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index de384d02dc3..3937e54853e 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -114,37 +114,53 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path, ty::ty_enum(_, ref expected_substs) => { // Lookup the enum and variant def ids: let v_def = lookup_def(pcx.fcx, pat.span, pat.id); - let (enm, var) = ast_util::variant_def_ids(v_def); - - // Assign the pattern the type of the *enum*, not the variant. - let enum_tpt = ty::lookup_item_type(tcx, enm); - instantiate_path(pcx.fcx, path, enum_tpt, pat.span, pat.id, - pcx.block_region); - - // check that the type of the value being matched is a subtype - // of the type of the pattern: - let pat_ty = fcx.node_ty(pat.id); - demand::subtype(fcx, pat.span, expected, pat_ty); - - // Get the expected types of the arguments. - arg_types = { - let vinfo = - ty::enum_variant_with_id(tcx, enm, var); - let var_tpt = ty::lookup_item_type(tcx, var); - vinfo.args.map(|t| { - if var_tpt.generics.type_param_defs.len() == - expected_substs.tps.len() - { - ty::subst(tcx, expected_substs, *t) - } - else { - *t // In this case, an error was already signaled - // anyway - } - }) - }; - - kind_name = "variant"; + match ast_util::variant_def_ids(v_def) { + Some((enm, var)) => { + // Assign the pattern the type of the *enum*, not the variant. + let enum_tpt = ty::lookup_item_type(tcx, enm); + instantiate_path(pcx.fcx, path, enum_tpt, pat.span, pat.id, + pcx.block_region); + + // check that the type of the value being matched is a subtype + // of the type of the pattern: + let pat_ty = fcx.node_ty(pat.id); + demand::subtype(fcx, pat.span, expected, pat_ty); + + // Get the expected types of the arguments. + arg_types = { + let vinfo = + ty::enum_variant_with_id(tcx, enm, var); + let var_tpt = ty::lookup_item_type(tcx, var); + vinfo.args.map(|t| { + if var_tpt.generics.type_param_defs.len() == + expected_substs.tps.len() + { + ty::subst(tcx, expected_substs, *t) + } + else { + *t // In this case, an error was already signaled + // anyway + } + }) + }; + + kind_name = "variant"; + } + None => { + let resolved_expected = + fcx.infcx().ty_to_str(fcx.infcx().resolve_type_vars_if_possible(expected)); + fcx.infcx().type_error_message_str(pat.span, + |actual| { + fmt!("mismatched types: expected `%s` but found %s", + resolved_expected, actual)}, + ~"a structure pattern", + None); + fcx.write_error(pat.id); + kind_name = "[error]"; + arg_types = (copy subpats).get_or_default(~[]).map(|_| + ty::mk_err()); + } + } } ty::ty_struct(struct_def_id, ref expected_substs) => { // Lookup the struct ctor def id diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 47ef7227842..10350413f2d 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -41,12 +41,12 @@ pub fn stmt_id(s: &stmt) -> node_id { } } -pub fn variant_def_ids(d: def) -> (def_id, def_id) { +pub fn variant_def_ids(d: def) -> Option<(def_id, def_id)> { match d { def_variant(enum_id, var_id) => { - return (enum_id, var_id); + Some((enum_id, var_id)) } - _ => fail!(~"non-variant in variant_def_ids") + _ => None } } diff --git a/src/test/compile-fail/issue-5358-1.rs b/src/test/compile-fail/issue-5358-1.rs new file mode 100644 index 00000000000..0b6e2fb0ff5 --- /dev/null +++ b/src/test/compile-fail/issue-5358-1.rs @@ -0,0 +1,18 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S(Either); + +fn main() { + match S(Left(5)) { + Right(_) => {} //~ ERROR mismatched types: expected `S` but found `core::either::Either + _ => {} + } +} diff --git a/src/test/compile-fail/issue-5358.rs b/src/test/compile-fail/issue-5358.rs new file mode 100644 index 00000000000..7d11a127f9a --- /dev/null +++ b/src/test/compile-fail/issue-5358.rs @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S(Either); + +fn main() { + match *S(Left(5)) { + S(_) => {} //~ ERROR mismatched types: expected `core::either::Either` but found a structure pattern + } +} -- cgit 1.4.1-3-g733a5 From 86efd97a10fda1f81f5bead0de36e3343a9faa0e Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 3 May 2013 19:25:04 -0400 Subject: add gitattributes and fix whitespace issues --- .gitattributes | 9 ++++++ COPYRIGHT | 1 - RELEASES.txt | 6 ++-- doc/README | 6 ++-- doc/rust.md | 1 - doc/tutorial-macros.md | 1 - doc/tutorial-tasks.md | 1 - doc/tutorial.md | 8 ++--- doc/version_info.html.template | 1 - mk/platform.mk | 6 ++-- mk/rt.mk | 12 +++---- mk/stage0.mk | 6 ++-- mk/tests.mk | 5 ++- src/etc/check-links.pl | 5 ++- src/etc/gedit/readme.txt | 1 - .../gtksourceview-3.0/language-specs/rust.lang | 5 ++- src/etc/gedit/share/mime/packages/rust.xml | 2 +- src/etc/indenter | 1 - src/etc/latest-unix-snaps.py | 2 -- src/etc/libc.c | 1 - src/etc/licenseck.py | 1 - src/etc/local_stage0.sh | 4 +-- src/etc/mirror-all-snapshots.py | 3 -- src/etc/monodebug.pl | 1 - src/etc/sugarise-doc-comments.py | 1 - src/etc/tidy.py | 1 - src/etc/x86.supp | 4 +-- src/libcore/cleanup.rs | 1 - src/libcore/logging.rs | 1 - src/libcore/owned.rs | 1 - src/libcore/rt/context.rs | 1 - src/libcore/rt/io/comm_adapters.rs | 1 - src/libcore/rt/io/net/ip.rs | 1 - src/libcore/rt/io/net/udp.rs | 1 - src/libcore/rt/io/net/unix.rs | 1 - src/libcore/rt/local_heap.rs | 1 - src/libcore/rt/sched/local_sched.rs | 1 - src/libcore/stackwalk.rs | 1 - src/libcore/unicode.rs | 1 - src/libcore/unstable/exchange_alloc.rs | 1 - src/libcore/unstable/weak_task.rs | 1 - src/librustc/metadata/common.rs | 1 - src/librustc/metadata/mod.rs | 1 - src/librustc/middle/borrowck/check_loans.rs | 1 - src/librustc/middle/borrowck/gather_loans.rs | 1 - src/librustc/middle/borrowck/loan.rs | 1 - src/librustc/middle/lang_items.rs | 1 - src/librustc/middle/mem_categorization.rs | 1 - src/librustc/middle/pat_util.rs | 1 - src/librustc/middle/privacy.rs | 1 - src/librustc/middle/region.rs | 1 - src/librustc/middle/subst.rs | 1 - src/librustc/middle/trans/cabi.rs | 1 - src/librustc/middle/trans/callee.rs | 1 - src/librustc/middle/trans/closure.rs | 1 - src/librustc/middle/trans/controlflow.rs | 1 - src/librustc/middle/trans/datum.rs | 1 - src/librustc/middle/trans/inline.rs | 1 - src/librustc/middle/trans/machine.rs | 1 - src/librustc/middle/trans/macros.rs | 1 - src/librustc/middle/trans/reachable.rs | 1 - src/librustc/middle/trans/reflect.rs | 1 - src/librustc/middle/trans/shape.rs | 1 - src/librustc/middle/trans/type_use.rs | 1 - src/librustc/middle/typeck/check/_match.rs | 1 - src/librustc/middle/typeck/check/demand.rs | 2 -- src/librustc/middle/typeck/check/vtable.rs | 2 -- src/librustc/middle/typeck/coherence.rs | 1 - src/librustc/middle/typeck/infer/combine.rs | 1 - src/librustc/middle/typeck/infer/glb.rs | 1 - src/librustc/middle/typeck/infer/macros.rs | 1 - .../middle/typeck/infer/region_inference.rs | 1 - src/librustc/middle/typeck/infer/resolve.rs | 1 - src/librustc/middle/typeck/infer/sub.rs | 1 - src/librustc/middle/typeck/infer/unify.rs | 2 -- src/librustdoc/path_pass.rs | 1 - src/librustpkg/testsuite/pass/commands.txt | 1 - .../pass/src/deeply/nested/path/foo/src/main.rs | 1 - src/libstd/num/bigint.rs | 1 - src/libstd/serialize.rs | 1 - src/libstd/task_pool.rs | 1 - src/libsyntax/ext/pipes/check.rs | 1 - src/libsyntax/ext/pipes/liveness.rs | 1 - src/libsyntax/ext/pipes/mod.rs | 1 - src/libsyntax/ext/pipes/proto.rs | 1 - src/libsyntax/ext/quote.rs | 1 - src/libsyntax/parse/obsolete.rs | 1 - src/libsyntax/syntax.rc | 1 - src/rt/arch/arm/_context.S | 2 -- src/rt/arch/arm/gpr.cpp | 1 - src/rt/arch/arm/gpr.h | 1 - src/rt/arch/arm/morestack.S | 4 +-- src/rt/arch/arm/record_sp.S | 1 - src/rt/arch/arm/regs.h | 2 -- src/rt/arch/i386/_context.S | 2 -- src/rt/arch/i386/gpr.cpp | 1 - src/rt/arch/i386/gpr.h | 1 - src/rt/arch/i386/morestack.S | 3 +- src/rt/arch/mips/gpr.h | 1 - src/rt/arch/x86_64/_context.S | 1 - src/rt/arch/x86_64/gpr.cpp | 1 - src/rt/arch/x86_64/gpr.h | 1 - src/rt/arch/x86_64/regs.h | 2 -- src/rt/isaac/rand.h | 2 -- src/rt/rust_abi.cpp | 1 - src/rt/rust_abi.h | 1 - src/rt/rust_android_dummy.h | 1 - src/rt/rust_debug.cpp | 1 - src/rt/rust_debug.h | 1 - src/rt/rust_gpr_base.h | 1 - src/rustllvm/README | 1 - src/rustllvm/RustWrapper.cpp | 22 ++++++------- src/snapshots.txt | 2 +- src/test/auxiliary/anon_trait_static_method_lib.rs | 1 - src/test/auxiliary/cci_class_2.rs | 1 - src/test/auxiliary/cci_class_6.rs | 1 - src/test/auxiliary/cci_class_cast.rs | 2 -- src/test/auxiliary/cci_no_inline_lib.rs | 1 - src/test/auxiliary/explicit_self_xcrate.rs | 2 -- src/test/auxiliary/extern_mod_ordering_lib.rs | 1 - src/test/auxiliary/foreign_lib.rs | 1 - src/test/auxiliary/impl_privacy_xc_1.rs | 1 - src/test/auxiliary/impl_privacy_xc_2.rs | 2 -- src/test/auxiliary/issue-2414-a.rs | 1 - src/test/auxiliary/issue-2414-b.rs | 1 - src/test/auxiliary/issue-2526.rs | 1 - src/test/auxiliary/issue_2316_b.rs | 2 -- src/test/auxiliary/issue_3136_a.rs | 5 ++- src/test/auxiliary/issue_3882.rs | 2 +- src/test/auxiliary/moves_based_on_type_lib.rs | 1 - src/test/auxiliary/newtype_struct_xc.rs | 1 - src/test/auxiliary/pub_use_mods_xcrate.rs | 1 - src/test/auxiliary/static_fn_inline_xc_aux.rs | 1 - .../auxiliary/struct_destructuring_cross_crate.rs | 1 - .../auxiliary/trait_inheritance_auto_xc_2_aux.rs | 2 -- .../auxiliary/trait_inheritance_overloading_xc.rs | 1 - src/test/auxiliary/xc_private_method_lib.rs | 1 - src/test/bench/msgsend-pipes-shared.rs | 2 +- src/test/bench/msgsend-pipes.rs | 2 +- src/test/bench/msgsend-ring-mutex-arcs.rs | 2 +- src/test/bench/msgsend-ring-pipes.rs | 2 +- src/test/bench/msgsend-ring-rw-arcs.rs | 2 +- src/test/bench/pingpong.rs | 2 +- src/test/bench/shootout-chameneos-redux.rs | 1 - src/test/bench/shootout-fannkuch-redux.rs | 1 - src/test/bench/shootout-fasta-redux.rs | 1 - src/test/bench/shootout-k-nucleotide-pipes.rs | 1 - src/test/bench/shootout-k-nucleotide.rs | 3 +- src/test/bench/shootout-mandelbrot.rs | 1 - src/test/bench/shootout-pidigits.rs | 1 - src/test/bench/shootout-reverse-complement.rs | 1 - src/test/bench/sudoku.rs | 1 - src/test/compile-fail/alt-tag-nullary.rs | 1 - src/test/compile-fail/alt-tag-unary.rs | 1 - src/test/compile-fail/auto-ref-borrowck-failure.rs | 1 - src/test/compile-fail/bogus-tag.rs | 1 - src/test/compile-fail/borrowck-assign-comp-idx.rs | 1 - src/test/compile-fail/borrowck-assign-comp.rs | 1 - .../borrowck-call-method-from-mut-aliasable.rs | 1 - .../borrowck-loan-local-as-both-mut-and-imm.rs | 2 +- .../borrowck-loan-rcvr-overloaded-op.rs | 3 +- src/test/compile-fail/borrowck-loan-rcvr.rs | 1 - src/test/compile-fail/borrowck-mut-boxed-vec.rs | 1 - src/test/compile-fail/borrowck-ref-into-rvalue.rs | 5 ++- src/test/compile-fail/borrowck-uniq-via-box.rs | 1 - .../borrowck-vec-pattern-loan-from-mut.rs | 1 - .../compile-fail/borrowck-vec-pattern-nesting.rs | 1 - .../borrowck-wg-borrow-mut-to-imm-fail-2.rs | 1 - .../borrowck-wg-borrow-mut-to-imm-fail-3.rs | 1 - .../borrowck-wg-borrow-mut-to-imm-fail.rs | 1 - src/test/compile-fail/borrowck-wg-move-base-2.rs | 2 -- src/test/compile-fail/by-move-pattern-binding.rs | 1 - src/test/compile-fail/dead-code-ret.rs | 1 - src/test/compile-fail/does-nothing.rs | 1 - src/test/compile-fail/drop-on-non-struct.rs | 2 -- src/test/compile-fail/explicit-call-to-dtor.rs | 1 - .../explicit-call-to-supertrait-dtor.rs | 2 -- .../float-literal-inference-restrictions.rs | 1 - src/test/compile-fail/foreign-unsafe-fn-called.rs | 1 - src/test/compile-fail/foreign-unsafe-fn.rs | 2 -- src/test/compile-fail/issue-1451.rs | 1 - src/test/compile-fail/issue-2951.rs | 1 - src/test/compile-fail/issue-3044.rs | 1 - src/test/compile-fail/issue-3096-2.rs | 2 +- src/test/compile-fail/issue-3991.rs | 4 +-- src/test/compile-fail/issue-4265.rs | 4 +-- src/test/compile-fail/issue-4366.rs | 1 - src/test/compile-fail/issue-4968.rs | 1 - src/test/compile-fail/kindck-destructor-owned.rs | 1 - src/test/compile-fail/lint-default-methods.rs | 1 - src/test/compile-fail/lint-type-limits.rs | 1 - src/test/compile-fail/liveness-if-no-else.rs | 4 +-- src/test/compile-fail/liveness-return.rs | 4 +-- .../compile-fail/liveness-uninit-after-item.rs | 1 - src/test/compile-fail/liveness-uninit.rs | 4 +-- src/test/compile-fail/macro-with-seps-err-msg.rs | 2 -- src/test/compile-fail/missing-derivable-attr.rs | 1 - src/test/compile-fail/missing-return.rs | 1 - .../compile-fail/moves-based-on-type-block-bad.rs | 1 - .../moves-based-on-type-capture-clause-bad.rs | 1 - .../moves-based-on-type-cyclic-types-issue-4821.rs | 1 - src/test/compile-fail/no-capture-arc.rs | 2 +- src/test/compile-fail/noexporttypeexe.rs | 1 - .../compile-fail/non-exhaustive-match-nested.rs | 1 - src/test/compile-fail/once-fn-subtyping.rs | 1 - src/test/compile-fail/private-impl-method.rs | 1 - src/test/compile-fail/private-item-simple.rs | 1 - src/test/compile-fail/private-method-inherited.rs | 1 - src/test/compile-fail/private-struct-field-ctor.rs | 1 - .../compile-fail/private-struct-field-pattern.rs | 1 - src/test/compile-fail/qquote-1.rs | 1 - src/test/compile-fail/qquote-2.rs | 1 - .../compile-fail/refutable-pattern-in-fn-arg.rs | 1 - src/test/compile-fail/regions-addr-of-self.rs | 1 - .../regions-infer-borrow-scope-too-big.rs | 1 - .../regions-infer-borrow-scope-within-loop.rs | 4 +-- src/test/compile-fail/regions-ret.rs | 1 - src/test/compile-fail/repeat-to-run-dtor-twice.rs | 1 - src/test/compile-fail/static-method-privacy.rs | 1 - src/test/compile-fail/static-region-bound.rs | 1 - .../compile-fail/struct-like-enum-nonexhaustive.rs | 2 -- src/test/compile-fail/super-at-top-level.rs | 2 -- .../compile-fail/trait-impl-method-mismatch.rs | 4 --- .../trait-inheritance-missing-requirement.rs | 1 - .../compile-fail/tuple-struct-nonexhaustive.rs | 2 -- .../compile-fail/tutorial-suffix-inference-test.rs | 4 +-- src/test/compile-fail/unique-object-noncopyable.rs | 1 - .../compile-fail/use-after-move-based-on-type.rs | 1 - .../use-after-move-self-based-on-type.rs | 1 - src/test/compile-fail/use-after-move-self.rs | 1 - src/test/compile-fail/view-items-at-top.rs | 1 - src/test/compile-fail/while-type-error.rs | 1 - src/test/compile-fail/xc-private-method.rs | 1 - src/test/pretty/doc-comments.rs | 2 +- src/test/run-fail/assert-as-macro.rs | 1 - src/test/run-fail/borrowck-wg-fail-3.rs | 1 - src/test/run-fail/borrowck-wg-fail.rs | 1 - src/test/run-fail/unwind-resource-fail3.rs | 2 +- src/test/run-pass-fulldeps/qquote.rs | 1 - src/test/run-pass-fulldeps/quote-tokens.rs | 1 - src/test/run-pass/anon-trait-static-method.rs | 1 - src/test/run-pass/anon_trait_static_method_exe.rs | 3 -- src/test/run-pass/auto-ref-newtype.rs | 1 - src/test/run-pass/auto-ref.rs | 1 - .../autoderef-and-borrow-method-receiver.rs | 1 - src/test/run-pass/bare-static-string.rs | 1 - src/test/run-pass/binops.rs | 2 +- src/test/run-pass/block-arg-in-parentheses.rs | 1 - src/test/run-pass/borrow-by-val-method-receiver.rs | 1 - src/test/run-pass/borrowck-wg-simple.rs | 1 - src/test/run-pass/boxed-trait-with-vstore.rs | 1 - src/test/run-pass/break.rs | 6 ++-- .../run-pass/class-cast-to-trait-cross-crate-2.rs | 1 - .../run-pass/class-impl-parameterized-trait.rs | 2 +- src/test/run-pass/cleanup-copy-mode.rs | 1 - src/test/run-pass/clone-with-exterior.rs | 2 +- src/test/run-pass/conditional-compile.rs | 2 +- src/test/run-pass/const-enum-vec-index.rs | 2 +- src/test/run-pass/const-enum-vec-ptr.rs | 2 +- src/test/run-pass/const-enum-vector.rs | 2 +- .../run-pass/const-expr-in-fixed-length-vec.rs | 2 +- src/test/run-pass/const-expr-in-vec-repeat.rs | 2 +- src/test/run-pass/const-tuple-struct.rs | 1 - src/test/run-pass/const-unit-struct.rs | 1 - src/test/run-pass/const-vec-syntax.rs | 1 - src/test/run-pass/consts-in-patterns.rs | 1 - src/test/run-pass/cycle-collection.rs | 1 - src/test/run-pass/default-method-simple.rs | 1 - src/test/run-pass/deriving-clone-enum.rs | 1 - src/test/run-pass/deriving-clone-generic-enum.rs | 1 - src/test/run-pass/deriving-clone-generic-struct.rs | 1 - .../deriving-clone-generic-tuple-struct.rs | 1 - src/test/run-pass/deriving-clone-tuple-struct.rs | 1 - src/test/run-pass/deriving-via-extension-c-enum.rs | 1 - src/test/run-pass/deriving-via-extension-enum.rs | 1 - .../deriving-via-extension-iter-bytes-enum.rs | 1 - .../deriving-via-extension-iter-bytes-struct.rs | 2 -- ...iving-via-extension-struct-like-enum-variant.rs | 1 - src/test/run-pass/deriving-via-extension-struct.rs | 1 - .../run-pass/deriving-via-extension-type-params.rs | 1 - src/test/run-pass/drop-trait-generic.rs | 1 - src/test/run-pass/drop-trait.rs | 1 - src/test/run-pass/enum-discrim-range-overflow.rs | 24 +++++++------- src/test/run-pass/enum-disr-val-pretty.rs | 1 - src/test/run-pass/enum-export-inheritance.rs | 1 - .../run-pass/enum-nullable-simplifycfg-misopt.rs | 6 ++-- src/test/run-pass/explicit-self-generic.rs | 1 - src/test/run-pass/explicit-self-objects-box.rs | 2 -- src/test/run-pass/explicit-self-objects-simple.rs | 2 -- src/test/run-pass/explicit-self-objects-uniq.rs | 2 -- src/test/run-pass/explicit_self_xcrate_exe.rs | 1 - src/test/run-pass/expr-repeat-vstore.rs | 1 - src/test/run-pass/extern-mod-abi.rs | 1 - src/test/run-pass/extern-mod-ordering-exe.rs | 1 - src/test/run-pass/extern-mod-syntax.rs | 1 - src/test/run-pass/extern-pass-TwoU16s.rs | 1 - src/test/run-pass/extern-pass-TwoU32s.rs | 1 - src/test/run-pass/extern-pass-TwoU64s-ref.rs | 1 - src/test/run-pass/extern-pass-TwoU64s.rs | 1 - src/test/run-pass/extern-pass-TwoU8s.rs | 1 - src/test/run-pass/extern-pass-char.rs | 1 - src/test/run-pass/extern-pass-double.rs | 1 - src/test/run-pass/extern-pass-u32.rs | 1 - src/test/run-pass/extern-pass-u64.rs | 1 - src/test/run-pass/extern-pub.rs | 2 -- src/test/run-pass/fat-arrow-alt.rs | 1 - src/test/run-pass/fixed_length_copy.rs | 2 +- src/test/run-pass/float-literal-inference.rs | 1 - src/test/run-pass/fn-pattern-expected-type-2.rs | 1 - src/test/run-pass/fn-pattern-expected-type.rs | 1 - src/test/run-pass/foreign-mod-unused-const.rs | 1 - src/test/run-pass/functional-struct-update.rs | 1 - src/test/run-pass/generic-ivec-leak.rs | 1 - src/test/run-pass/generic-ivec.rs | 1 - src/test/run-pass/generic-newtype-struct.rs | 1 - src/test/run-pass/generic-object.rs | 1 - src/test/run-pass/global-scope.rs | 1 - src/test/run-pass/impl-privacy-xc-1.rs | 1 - src/test/run-pass/impl-privacy-xc-2.rs | 1 - src/test/run-pass/infinite-loops.rs | 4 +-- src/test/run-pass/instantiable.rs | 1 - src/test/run-pass/int-conversion-coherence.rs | 1 - src/test/run-pass/intrinsics-integer.rs | 2 +- src/test/run-pass/intrinsics-math.rs | 4 +-- src/test/run-pass/issue-1516.rs | 1 - src/test/run-pass/issue-2185.rs | 4 +-- src/test/run-pass/issue-2216.rs | 2 +- src/test/run-pass/issue-2526-a.rs | 1 - src/test/run-pass/issue-2734.rs | 4 +-- src/test/run-pass/issue-2904.rs | 2 +- src/test/run-pass/issue-3176.rs | 4 +-- src/test/run-pass/issue-3250.rs | 2 -- src/test/run-pass/issue-3429.rs | 1 - src/test/run-pass/issue-3461.rs | 2 +- src/test/run-pass/issue-3556.rs | 8 ++--- src/test/run-pass/issue-3563-3.rs | 5 ++- src/test/run-pass/issue-3609.rs | 1 - src/test/run-pass/issue-3860.rs | 2 +- src/test/run-pass/issue-3895.rs | 2 +- src/test/run-pass/issue-3979-2.rs | 1 - src/test/run-pass/issue-4241.rs | 2 +- src/test/run-pass/issue-4875.rs | 1 - src/test/run-pass/issue-868.rs | 1 - src/test/run-pass/issue_3136_b.rs | 1 - src/test/run-pass/ivec-add.rs | 1 - src/test/run-pass/ivec-pass-by-value.rs | 1 - src/test/run-pass/labeled-break.rs | 1 - src/test/run-pass/let-assignability.rs | 1 - .../liveness-assign-imm-local-after-loop.rs | 2 +- src/test/run-pass/log-linearized.rs | 1 - src/test/run-pass/max-min-classes.rs | 1 - .../module-qualified-struct-destructure.rs | 1 - src/test/run-pass/move-self.rs | 1 - .../run-pass/moves-based-on-type-capture-clause.rs | 1 - src/test/run-pass/multiple-trait-bounds.rs | 1 - src/test/run-pass/mut-vstore-expr.rs | 1 - src/test/run-pass/nested-class.rs | 22 ++++++------- src/test/run-pass/new-impl-syntax.rs | 1 - src/test/run-pass/new-import-syntax.rs | 1 - src/test/run-pass/new-style-constants.rs | 1 - src/test/run-pass/new-style-fixed-length-vec.rs | 3 -- src/test/run-pass/new-vstore-mut-box-syntax.rs | 1 - src/test/run-pass/newtype-struct-with-dtor.rs | 2 -- src/test/run-pass/newtype-struct-xc-2.rs | 1 - src/test/run-pass/newtype-struct-xc.rs | 1 - .../run-pass/nullable-pointer-iotareduction.rs | 2 +- src/test/run-pass/one-tuple.rs | 1 - src/test/run-pass/pattern-in-closure.rs | 1 - src/test/run-pass/pipe-detect-term.rs | 4 +-- src/test/run-pass/pipe-pingpong-bounded.rs | 2 +- src/test/run-pass/pipe-pingpong-proto.rs | 2 +- src/test/run-pass/pipe-select.rs | 6 ++-- src/test/run-pass/pipe-sleep.rs | 2 +- src/test/run-pass/pub-use-xcrate.rs | 1 - src/test/run-pass/pub_use_mods_xcrate_exe.rs | 1 - src/test/run-pass/reexport-star.rs | 1 - .../regions-addr-of-interior-of-unique-box.rs | 1 - src/test/run-pass/regions-addr-of-ret.rs | 1 - src/test/run-pass/regions-fn-subtyping-2.rs | 4 +-- .../run-pass/regions-infer-borrow-scope-addr-of.rs | 16 +++++----- .../run-pass/regions-infer-borrow-scope-view.rs | 1 - .../regions-infer-borrow-scope-within-loop-ok.rs | 2 +- src/test/run-pass/regions-infer-borrow-scope.rs | 1 - src/test/run-pass/regions-mock-trans-impls.rs | 1 - src/test/run-pass/regions-mock-trans.rs | 1 - src/test/run-pass/regions-self-impls.rs | 1 - src/test/run-pass/regions-self-in-enums.rs | 1 - src/test/run-pass/regions-simple.rs | 2 -- src/test/run-pass/repeated-vector-syntax.rs | 1 - src/test/run-pass/resource-cycle.rs | 4 +-- src/test/run-pass/resource-cycle3.rs | 4 +-- src/test/run-pass/self-type-param.rs | 1 - src/test/run-pass/static-methods-in-traits.rs | 37 +++++++++++----------- src/test/run-pass/struct-deref.rs | 1 - src/test/run-pass/struct-field-assignability.rs | 1 - src/test/run-pass/struct-like-variant-construct.rs | 1 - src/test/run-pass/struct-like-variant-match.rs | 1 - src/test/run-pass/struct-pattern-matching.rs | 3 -- src/test/run-pass/super.rs | 1 - src/test/run-pass/tag-disr-val-shape.rs | 1 - src/test/run-pass/tag-variant-disr-val.rs | 2 -- src/test/run-pass/threads.rs | 1 - src/test/run-pass/trait-composition-trivial.rs | 2 -- src/test/run-pass/trait-inheritance-auto-xc-2.rs | 1 - src/test/run-pass/trait-inheritance-auto-xc.rs | 1 - src/test/run-pass/trait-inheritance-auto.rs | 1 - .../trait-inheritance-call-bound-inherited.rs | 1 - .../trait-inheritance-call-bound-inherited2.rs | 1 - ...-inheritance-cast-without-call-to-supertrait.rs | 1 - src/test/run-pass/trait-inheritance-cast.rs | 1 - .../trait-inheritance-cross-trait-call-xc.rs | 1 - .../run-pass/trait-inheritance-cross-trait-call.rs | 1 - .../trait-inheritance-overloading-simple.rs | 1 - .../trait-inheritance-overloading-xc-exe.rs | 1 - src/test/run-pass/trait-inheritance-overloading.rs | 1 - src/test/run-pass/trait-inheritance-self.rs | 1 - src/test/run-pass/trait-inheritance-simple.rs | 1 - src/test/run-pass/trait-inheritance-subst.rs | 1 - src/test/run-pass/trait-inheritance-subst2.rs | 1 - src/test/run-pass/trait-inheritance2.rs | 1 - src/test/run-pass/trait-region-pointer-simple.rs | 1 - .../run-pass/trait-static-method-overwriting.rs | 6 ++-- src/test/run-pass/traits.rs | 1 - src/test/run-pass/tuple-struct-construct.rs | 1 - src/test/run-pass/tuple-struct-destructuring.rs | 1 - src/test/run-pass/tuple-struct-matching.rs | 1 - src/test/run-pass/tuple-struct-trivial.rs | 1 - src/test/run-pass/typeclasses-eq-example-static.rs | 2 +- src/test/run-pass/typeclasses-eq-example.rs | 2 +- src/test/run-pass/unique-object.rs | 1 - src/test/run-pass/unit-like-struct.rs | 1 - src/test/run-pass/unsafe-pointer-assignability.rs | 3 -- src/test/run-pass/vec-fixed-length.rs | 1 - 433 files changed, 196 insertions(+), 597 deletions(-) create mode 100644 .gitattributes (limited to 'src/test') diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000000..52370e4a509 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +[attr]rust text eol=lf whitespace=tab-in-indent,trailing-space,tabwidth=4 + +* text=auto +*.cpp rust +*.h rust +*.rs rust +src/rt/msvc/* -whitespace +src/rt/vg/* -whitespace +src/rt/linenoise/* -whitespace diff --git a/COPYRIGHT b/COPYRIGHT index 2315c6fe3cb..ffbfadaa339 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -367,4 +367,3 @@ their own copyright notices and license terms: has chosen for the collective work, enumerated at the top of this file. The only difference is the retention of copyright itself, held by the contributor. - diff --git a/RELEASES.txt b/RELEASES.txt index 13e4e0c2039..fb2bbb45e7c 100644 --- a/RELEASES.txt +++ b/RELEASES.txt @@ -250,7 +250,7 @@ Version 0.3 (July 2012) * Slices and fixed-size, interior-allocated vectors * #!-comments for lang versioning, shell execution * Destructors and iface implementation for classes; - type-parameterized classes and class methods + type-parameterized classes and class methods * 'const' type kind for types that can be used to implement shared-memory concurrency patterns @@ -261,7 +261,7 @@ Version 0.3 (July 2012) 'crust', 'native' (now 'extern'), 'cont' (now 'again') * Constructs: do-while loops ('do' repurposed), fn binding, - resources (replaced by destructors) + resources (replaced by destructors) * Compiler reorganization * Syntax-layer of compiler split into separate crate @@ -276,7 +276,7 @@ Version 0.3 (July 2012) * Extensive work on libuv interface * Much vector code moved to libraries * Syntax extensions: #line, #col, #file, #mod, #stringify, - #include, #include_str, #include_bin + #include, #include_str, #include_bin * Tool improvements * Cargo automatically resolves dependencies diff --git a/doc/README b/doc/README index 505b5383dcd..c3bb28a9e85 100644 --- a/doc/README +++ b/doc/README @@ -1,6 +1,6 @@ The markdown docs are only generated by make when node is installed (use -`make doc`). If you don't have node installed you can generate them yourself. -Unfortunately there's no real standard for markdown and all the tools work +`make doc`). If you don't have node installed you can generate them yourself. +Unfortunately there's no real standard for markdown and all the tools work differently. pandoc is one that seems to work well. To generate an html version of a doc do something like: @@ -10,4 +10,4 @@ The syntax for pandoc flavored markdown can be found at: http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown A nice quick reference (for non-pandoc markdown) is at: -http://kramdown.rubyforge.org/quickref.html \ No newline at end of file +http://kramdown.rubyforge.org/quickref.html diff --git a/doc/rust.md b/doc/rust.md index e23613e149c..ac7125be424 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -3351,4 +3351,3 @@ Additional specific influences can be seen from the following languages: * The typeclass system of Haskell. * The lexical identifier rule of Python. * The block syntax of Ruby. - diff --git a/doc/tutorial-macros.md b/doc/tutorial-macros.md index 24e9f4abc38..63fa7e06bae 100644 --- a/doc/tutorial-macros.md +++ b/doc/tutorial-macros.md @@ -402,4 +402,3 @@ tricky. Invoking the `log_syntax!` macro can help elucidate intermediate states, invoking `trace_macros!(true)` will automatically print those intermediate states out, and passing the flag `--pretty expanded` as a command-line argument to the compiler will show the result of expansion. - diff --git a/doc/tutorial-tasks.md b/doc/tutorial-tasks.md index bed69674830..053d9e6d988 100644 --- a/doc/tutorial-tasks.md +++ b/doc/tutorial-tasks.md @@ -511,4 +511,3 @@ The parent task first calls `DuplexStream` to create a pair of bidirectional endpoints. It then uses `task::spawn` to create the child task, which captures one end of the communication channel. As a result, both parent and child can send and receive data to and from the other. - diff --git a/doc/tutorial.md b/doc/tutorial.md index 07eb3bc7681..90ae41affc9 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1006,9 +1006,9 @@ let mut d = @mut 5; // mutable variable, mutable box d = @mut 15; ~~~~ -A mutable variable and an immutable variable can refer to the same box, given -that their types are compatible. Mutability of a box is a property of its type, -however, so for example a mutable handle to an immutable box cannot be +A mutable variable and an immutable variable can refer to the same box, given +that their types are compatible. Mutability of a box is a property of its type, +however, so for example a mutable handle to an immutable box cannot be assigned a reference to a mutable box. ~~~~ @@ -1041,7 +1041,7 @@ let y = x.clone(); // y is a newly allocated box let z = x; // no new memory allocated, x can no longer be used ~~~~ -Since in owned boxes mutability is a property of the owner, not the +Since in owned boxes mutability is a property of the owner, not the box, mutable boxes may become immutable when they are moved, and vice-versa. ~~~~ diff --git a/doc/version_info.html.template b/doc/version_info.html.template index 9376b29bcdf..aa44097a337 100644 --- a/doc/version_info.html.template +++ b/doc/version_info.html.template @@ -7,4 +7,3 @@ - diff --git a/mk/platform.mk b/mk/platform.mk index 1e102587bf4..e03b7c15247 100644 --- a/mk/platform.mk +++ b/mk/platform.mk @@ -11,7 +11,7 @@ # Create variables HOST_ containing the host part # of each target triple. For example, the triple i686-darwin-macos -# would create a variable HOST_i686-darwin-macos with the value +# would create a variable HOST_i686-darwin-macos with the value # i386. define DEF_HOST_VAR HOST_$(1) = $(subst i686,i386,$(word 1,$(subst -, ,$(1)))) @@ -276,8 +276,8 @@ CFG_GCCISH_CFLAGS_i686-pc-mingw32 := -Wall -Werror -g -march=i686 CFG_GCCISH_CXXFLAGS_i686-pc-mingw32 := -fno-rtti CFG_GCCISH_LINK_FLAGS_i686-pc-mingw32 := -shared -fPIC -g CFG_GCCISH_DEF_FLAG_i686-pc-mingw32 := -CFG_GCCISH_PRE_LIB_FLAGS_i686-pc-mingw32 := -CFG_GCCISH_POST_LIB_FLAGS_i686-pc-mingw32 := +CFG_GCCISH_PRE_LIB_FLAGS_i686-pc-mingw32 := +CFG_GCCISH_POST_LIB_FLAGS_i686-pc-mingw32 := CFG_DEF_SUFFIX_i686-pc-mingw32 := .mingw32.def CFG_INSTALL_NAME_i686-pc-mingw32 = CFG_LIBUV_LINK_FLAGS_i686-pc-mingw32 := -lWs2_32 -lpsapi -liphlpapi diff --git a/mk/rt.mk b/mk/rt.mk index c4c80b99fc0..30dda2fb276 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -1,27 +1,27 @@ # This is a procedure to define the targets for building -# the runtime. +# the runtime. # # Argument 1 is the target triple. # # This is not really the right place to explain this, but # for those of you who are not Makefile gurus, let me briefly -# cover the $ expansion system in use here, because it +# cover the $ expansion system in use here, because it # confused me for a while! The variable DEF_RUNTIME_TARGETS # will be defined once and then expanded with different # values substituted for $(1) each time it is called. -# That resulting text is then eval'd. +# That resulting text is then eval'd. # # For most variables, you could use a single $ sign. The result # is that the substitution would occur when the CALL occurs, # I believe. The problem is that the automatic variables $< and $@ # need to be expanded-per-rule. Therefore, for those variables at -# least, you need $$< and $$@ in the variable text. This way, after +# least, you need $$< and $$@ in the variable text. This way, after # the CALL substitution occurs, you will have $< and $@. This text # will then be evaluated, and all will work as you like. # # Reader beware, this explanantion could be wrong, but it seems to -# fit the experimental data (i.e., I was able to get the system -# working under these assumptions). +# fit the experimental data (i.e., I was able to get the system +# working under these assumptions). # Hack for passing flags into LIBUV, see below. LIBUV_FLAGS_i386 = -m32 -fPIC diff --git a/mk/stage0.mk b/mk/stage0.mk index 7b5cbef1d72..ac1b3e86ac9 100644 --- a/mk/stage0.mk +++ b/mk/stage0.mk @@ -7,16 +7,16 @@ $(HBIN0_H_$(CFG_BUILD_TRIPLE))/rustc$(X_$(CFG_BUILD_TRIPLE)): \ $(S)src/etc/get-snapshot.py $(MKFILE_DEPS) @$(call E, fetch: $@) # Note: the variable "SNAPSHOT_FILE" is generally not set, and so -# we generally only pass one argument to this script. +# we generally only pass one argument to this script. ifdef CFG_ENABLE_LOCAL_RUST $(Q)$(S)src/etc/local_stage0.sh $(CFG_BUILD_TRIPLE) $(CFG_LOCAL_RUST_ROOT) -else +else $(Q)$(CFG_PYTHON) $(S)src/etc/get-snapshot.py $(CFG_BUILD_TRIPLE) $(SNAPSHOT_FILE) ifdef CFG_ENABLE_PAX_FLAGS @$(call E, apply PaX flags: $@) @"$(CFG_PAXCTL)" -cm "$@" endif -endif +endif $(Q)touch $@ # Host libs will be extracted by the above rule diff --git a/mk/tests.mk b/mk/tests.mk index f96b7325f60..175e33c6654 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -179,9 +179,9 @@ tidy: $(Q)find $(S)src/etc -name '*.py' \ | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py $(Q)echo $(ALL_CS) \ - | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py + | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py $(Q)echo $(ALL_HS) \ - | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py + | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py endif @@ -709,4 +709,3 @@ endef $(foreach host,$(CFG_HOST_TRIPLES), \ $(eval $(call DEF_CHECK_FAST_FOR_H,$(host)))) - diff --git a/src/etc/check-links.pl b/src/etc/check-links.pl index a280ed55ba9..6492be53d34 100755 --- a/src/etc/check-links.pl +++ b/src/etc/check-links.pl @@ -9,7 +9,7 @@ my $anchors = {}; my $i = 0; foreach $line (@lines) { $i++; - if ($line =~ m/id="([^"]+)"/) { + if ($line =~ m/id="([^"]+)"/) { $anchors->{$1} = $i; } } @@ -17,10 +17,9 @@ foreach $line (@lines) { $i = 0; foreach $line (@lines) { $i++; - while ($line =~ m/href="#([^"]+)"/g) { + while ($line =~ m/href="#([^"]+)"/g) { if (! exists($anchors->{$1})) { print "$file:$i: $1 referenced\n"; } } } - diff --git a/src/etc/gedit/readme.txt b/src/etc/gedit/readme.txt index 735b0236276..e394f191608 100644 --- a/src/etc/gedit/readme.txt +++ b/src/etc/gedit/readme.txt @@ -8,4 +8,3 @@ Instructions for Ubuntu Linux 12.04+ 2) Copy the included "share" folder into "~/.local/" 3) Open a shell in "~/.local/share/" and run "update-mime-database mime" - diff --git a/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang b/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang index 0b23808b765..a413d0a9062 100644 --- a/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang +++ b/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang @@ -123,11 +123,11 @@ mode_t ssize_t - + self - + true false @@ -261,4 +261,3 @@ - diff --git a/src/etc/gedit/share/mime/packages/rust.xml b/src/etc/gedit/share/mime/packages/rust.xml index 65168aae1d9..d75cffe9600 100644 --- a/src/etc/gedit/share/mime/packages/rust.xml +++ b/src/etc/gedit/share/mime/packages/rust.xml @@ -2,6 +2,6 @@ Rust Source - + diff --git a/src/etc/indenter b/src/etc/indenter index 017cb926981..1a3a4465335 100755 --- a/src/etc/indenter +++ b/src/etc/indenter @@ -14,4 +14,3 @@ while (<>) { $indent -= 1; } } - diff --git a/src/etc/latest-unix-snaps.py b/src/etc/latest-unix-snaps.py index 7a2ddba3a16..7cecf837161 100755 --- a/src/etc/latest-unix-snaps.py +++ b/src/etc/latest-unix-snaps.py @@ -52,5 +52,3 @@ def download_new_file (date, rev, platform, hsh): for ff in newestSet["files"]: download_new_file (newestSet["date"], newestSet["rev"], ff["platform"], ff["hash"]) - - diff --git a/src/etc/libc.c b/src/etc/libc.c index 9acc122f32b..e341f495eeb 100644 --- a/src/etc/libc.c +++ b/src/etc/libc.c @@ -243,4 +243,3 @@ int main() { extra_consts(); printf("}\n"); } - diff --git a/src/etc/licenseck.py b/src/etc/licenseck.py index 973b7deb960..1e0c541cd89 100644 --- a/src/etc/licenseck.py +++ b/src/etc/licenseck.py @@ -96,4 +96,3 @@ def check_license(name, contents): return True return False - diff --git a/src/etc/local_stage0.sh b/src/etc/local_stage0.sh index 5898bc561aa..8d2fd887e3f 100755 --- a/src/etc/local_stage0.sh +++ b/src/etc/local_stage0.sh @@ -1,13 +1,13 @@ #!/bin/sh -TARG_DIR=$1 +TARG_DIR=$1 PREFIX=$2 BINDIR=bin LIBDIR=lib OS=`uname -s` -case $OS in +case $OS in ("Linux"|"FreeBSD") BIN_SUF= LIB_SUF=.so diff --git a/src/etc/mirror-all-snapshots.py b/src/etc/mirror-all-snapshots.py index f1fce7a94b5..3b5f66c4117 100644 --- a/src/etc/mirror-all-snapshots.py +++ b/src/etc/mirror-all-snapshots.py @@ -33,6 +33,3 @@ for line in f.readlines(): print("got download with ok hash") else: raise Exception("bad hash on download") - - - diff --git a/src/etc/monodebug.pl b/src/etc/monodebug.pl index 324c576a4bd..a2d27591cad 100755 --- a/src/etc/monodebug.pl +++ b/src/etc/monodebug.pl @@ -77,4 +77,3 @@ while (my ($key, $substs) = each %funcs) { } print "\n"; } - diff --git a/src/etc/sugarise-doc-comments.py b/src/etc/sugarise-doc-comments.py index 6399cff6b88..7bd4175fbf0 100755 --- a/src/etc/sugarise-doc-comments.py +++ b/src/etc/sugarise-doc-comments.py @@ -80,4 +80,3 @@ def sugarise_file(path): for (dirpath, dirnames, filenames) in os.walk('.'): for name in fnmatch.filter(filenames, '*.r[sc]'): sugarise_file(os.path.join(dirpath, name)) - diff --git a/src/etc/tidy.py b/src/etc/tidy.py index a5cf6141567..06fcb5cb945 100644 --- a/src/etc/tidy.py +++ b/src/etc/tidy.py @@ -81,4 +81,3 @@ except UnicodeDecodeError, e: sys.exit(err) - diff --git a/src/etc/x86.supp b/src/etc/x86.supp index 417f4c9d2c1..def1c5a53c1 100644 --- a/src/etc/x86.supp +++ b/src/etc/x86.supp @@ -366,7 +366,7 @@ ... } -{ +{ llvm-user-new-leak Memcheck:Leak fun:_Znwj @@ -401,7 +401,7 @@ Helgrind:Race fun:_ZN15lock_and_signal27lock_held_by_current_threadEv ... -} +} { lock_and_signal-probably-threadsafe-access-outside-of-lock2 diff --git a/src/libcore/cleanup.rs b/src/libcore/cleanup.rs index a07c6b4811b..bf92d605f2b 100644 --- a/src/libcore/cleanup.rs +++ b/src/libcore/cleanup.rs @@ -226,4 +226,3 @@ pub mod rustrt { pub unsafe fn rust_get_task() -> *c_void; } } - diff --git a/src/libcore/logging.rs b/src/libcore/logging.rs index ba976de50ab..afe8338f2ce 100644 --- a/src/libcore/logging.rs +++ b/src/libcore/logging.rs @@ -59,4 +59,3 @@ pub fn log_type(level: u32, object: &T) { rustrt::rust_log_str(level, transmute(vec::raw::to_ptr(bytes)), len); } } - diff --git a/src/libcore/owned.rs b/src/libcore/owned.rs index c483ec79e21..599591e2f6d 100644 --- a/src/libcore/owned.rs +++ b/src/libcore/owned.rs @@ -31,4 +31,3 @@ impl Ord for ~T { #[inline(always)] fn gt(&self, other: &~T) -> bool { *(*self) > *(*other) } } - diff --git a/src/libcore/rt/context.rs b/src/libcore/rt/context.rs index 4714be9e3d5..9c1e566f218 100644 --- a/src/libcore/rt/context.rs +++ b/src/libcore/rt/context.rs @@ -207,4 +207,3 @@ pub fn mut_offset(ptr: *mut T, count: int) -> *mut T { use core::sys::size_of; (ptr as int + count * (size_of::() as int)) as *mut T } - diff --git a/src/libcore/rt/io/comm_adapters.rs b/src/libcore/rt/io/comm_adapters.rs index 1d6893b3ca6..7e891f1718e 100644 --- a/src/libcore/rt/io/comm_adapters.rs +++ b/src/libcore/rt/io/comm_adapters.rs @@ -56,4 +56,3 @@ impl WriterChan { impl GenericChan<~[u8]> for WriterChan { fn send(&self, _x: ~[u8]) { fail!() } } - diff --git a/src/libcore/rt/io/net/ip.rs b/src/libcore/rt/io/net/ip.rs index d9b7f4e6e40..df1dfe4d38a 100644 --- a/src/libcore/rt/io/net/ip.rs +++ b/src/libcore/rt/io/net/ip.rs @@ -12,4 +12,3 @@ pub enum IpAddr { Ipv4(u8, u8, u8, u8, u16), Ipv6 } - diff --git a/src/libcore/rt/io/net/udp.rs b/src/libcore/rt/io/net/udp.rs index 0cb2978fb1a..1f1254a7029 100644 --- a/src/libcore/rt/io/net/udp.rs +++ b/src/libcore/rt/io/net/udp.rs @@ -47,4 +47,3 @@ impl UdpListener { impl Listener for UdpListener { fn accept(&mut self) -> Option { fail!() } } - diff --git a/src/libcore/rt/io/net/unix.rs b/src/libcore/rt/io/net/unix.rs index 262816beecc..f449a857467 100644 --- a/src/libcore/rt/io/net/unix.rs +++ b/src/libcore/rt/io/net/unix.rs @@ -47,4 +47,3 @@ impl UnixListener { impl Listener for UnixListener { fn accept(&mut self) -> Option { fail!() } } - diff --git a/src/libcore/rt/local_heap.rs b/src/libcore/rt/local_heap.rs index fbd4a77d79b..6bf228a1b22 100644 --- a/src/libcore/rt/local_heap.rs +++ b/src/libcore/rt/local_heap.rs @@ -78,4 +78,3 @@ extern { size: size_t) -> *OpaqueBox; fn rust_boxed_region_free(region: *BoxedRegion, box: *OpaqueBox); } - diff --git a/src/libcore/rt/sched/local_sched.rs b/src/libcore/rt/sched/local_sched.rs index 2d1e06163be..a7e02f30e01 100644 --- a/src/libcore/rt/sched/local_sched.rs +++ b/src/libcore/rt/sched/local_sched.rs @@ -143,4 +143,3 @@ fn borrow_smoke_test() { } let _scheduler = take(); } - diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index ebf36e4e09a..272bdca8654 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -99,4 +99,3 @@ pub mod rusti { pub fn frame_address(+f: &once fn(x: *u8)); } } - diff --git a/src/libcore/unicode.rs b/src/libcore/unicode.rs index 34175f9888f..d6e2c5eee6a 100644 --- a/src/libcore/unicode.rs +++ b/src/libcore/unicode.rs @@ -2642,4 +2642,3 @@ pub mod derived_property { bsearch_range_table(c, XID_Start_table) } } - diff --git a/src/libcore/unstable/exchange_alloc.rs b/src/libcore/unstable/exchange_alloc.rs index 8ca5486d929..57ed579e88d 100644 --- a/src/libcore/unstable/exchange_alloc.rs +++ b/src/libcore/unstable/exchange_alloc.rs @@ -81,4 +81,3 @@ extern { #[rust_stack] fn rust_get_exchange_count_ptr() -> *mut int; } - diff --git a/src/libcore/unstable/weak_task.rs b/src/libcore/unstable/weak_task.rs index 7a30bb92111..6edbdcb51b0 100644 --- a/src/libcore/unstable/weak_task.rs +++ b/src/libcore/unstable/weak_task.rs @@ -205,4 +205,3 @@ fn test_select_stream_and_oneshot() { chan.send(()); waitport.recv(); } - diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index 111c201d502..d2b71447f47 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -169,4 +169,3 @@ pub struct LinkMeta { vers: @str, extras_hash: @str } - diff --git a/src/librustc/metadata/mod.rs b/src/librustc/metadata/mod.rs index 78d5be4d4ae..24007380fee 100644 --- a/src/librustc/metadata/mod.rs +++ b/src/librustc/metadata/mod.rs @@ -18,4 +18,3 @@ pub mod cstore; pub mod csearch; pub mod loader; pub mod filesearch; - diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 526a5a3a9dd..4ab24a17d31 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -802,4 +802,3 @@ fn check_loans_in_block(blk: &ast::blk, visit::visit_block(blk, self, vt); } } - diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index da048534118..fd1f6f5c450 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -639,4 +639,3 @@ fn add_stmt_to_map(stmt: @ast::stmt, } visit::visit_stmt(stmt, self, vt); } - diff --git a/src/librustc/middle/borrowck/loan.rs b/src/librustc/middle/borrowck/loan.rs index 4dd727390aa..641571373bd 100644 --- a/src/librustc/middle/borrowck/loan.rs +++ b/src/librustc/middle/borrowck/loan.rs @@ -309,4 +309,3 @@ pub impl LoanContext { } } } - diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 7298064e1c0..f6d138a4a69 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -423,4 +423,3 @@ pub fn collect_language_items(crate: @crate, collector.collect(); copy items } - diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 866bd5377b9..29ca875806f 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -1179,4 +1179,3 @@ pub impl categorization { } } } - diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index 3ca79982b7b..b87adb75bc3 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -86,4 +86,3 @@ pub fn pat_binding_ids(dm: resolve::DefMap, pat: @pat) -> ~[node_id] { pat_bindings(dm, pat, |_bm, b_id, _sp, _pt| found.push(b_id) ); return found; } - diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index be981956219..083c436c83e 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -603,4 +603,3 @@ pub fn check_crate(tcx: ty::ctxt, }); visit::visit_crate(crate, method_map, visitor); } - diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 4faa2150003..753a6d25cbb 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -968,4 +968,3 @@ pub fn determine_rp_in_crate(sess: Session, // return final set return cx.region_paramd_items; } - diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index c3a79373931..bf64134704a 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -186,4 +186,3 @@ impl Subst for ty::ty_param_bounds_and_ty { } } } - diff --git a/src/librustc/middle/trans/cabi.rs b/src/librustc/middle/trans/cabi.rs index ed028d14bd6..d49e8e0969a 100644 --- a/src/librustc/middle/trans/cabi.rs +++ b/src/librustc/middle/trans/cabi.rs @@ -190,4 +190,3 @@ pub impl FnType { Store(bcx, llretval, llretptr); } } - diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index ed7f91bf04a..fc645e2bb6c 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -799,4 +799,3 @@ pub fn trans_arg_expr(bcx: block, debug!("--- trans_arg_expr passing %s", val_str(bcx.ccx().tn, val)); return rslt(bcx, val); } - diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index e35fef6b6f6..84100d7195e 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -599,4 +599,3 @@ pub fn make_opaque_cbox_free_glue( } } } - diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 113136fa58d..c9a4f078c79 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -398,4 +398,3 @@ pub fn trans_fail_bounds_check(bcx: block, sp: span, Unreachable(bcx); return bcx; } - diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index cf5fbb6e216..c6b32930c5f 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -855,4 +855,3 @@ pub impl DatumBlock { self.datum.to_str(self.ccx()) } } - diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc/middle/trans/inline.rs index ad06a9715b4..35136410268 100644 --- a/src/librustc/middle/trans/inline.rs +++ b/src/librustc/middle/trans/inline.rs @@ -122,4 +122,3 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::def_id, } } } - diff --git a/src/librustc/middle/trans/machine.rs b/src/librustc/middle/trans/machine.rs index 3ae2421a555..b1349104e54 100644 --- a/src/librustc/middle/trans/machine.rs +++ b/src/librustc/middle/trans/machine.rs @@ -153,4 +153,3 @@ pub fn static_size_of_enum(cx: @CrateContext, t: ty::t) -> uint { _ => cx.sess.bug(~"static_size_of_enum called on non-enum") } } - diff --git a/src/librustc/middle/trans/macros.rs b/src/librustc/middle/trans/macros.rs index 14ed7692661..43cc66c5568 100644 --- a/src/librustc/middle/trans/macros.rs +++ b/src/librustc/middle/trans/macros.rs @@ -51,4 +51,3 @@ macro_rules! trace( } ) ) - diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index f301a7d2973..217eda870be 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -242,4 +242,3 @@ fn traverse_all_resources_and_impls(cx: &ctx, crate_mod: &_mod) { ..*visit::default_visitor() })); } - diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 7e59f580a2c..9bae0560918 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -404,4 +404,3 @@ pub fn ast_purity_constant(purity: ast::purity) -> uint { ast::extern_fn => 3u } } - diff --git a/src/librustc/middle/trans/shape.rs b/src/librustc/middle/trans/shape.rs index 08337c918b0..6ff9e1cfc57 100644 --- a/src/librustc/middle/trans/shape.rs +++ b/src/librustc/middle/trans/shape.rs @@ -74,4 +74,3 @@ pub fn add_substr(dest: &mut ~[u8], src: ~[u8]) { add_u16(&mut *dest, vec::len(src) as u16); *dest += src; } - diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index e19eba6ca98..794912d8307 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -383,4 +383,3 @@ pub fn handle_body(cx: Context, body: &blk) { }); (v.visit_block)(body, cx, v); } - diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index de384d02dc3..8eadf3acc98 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -633,4 +633,3 @@ pub fn check_pointer_pat(pcx: &pat_ctxt, #[deriving(Eq)] enum PointerKind { Managed, Owned, Borrowed } - diff --git a/src/librustc/middle/typeck/check/demand.rs b/src/librustc/middle/typeck/check/demand.rs index 1bb71c156c3..3fa551e4b05 100644 --- a/src/librustc/middle/typeck/check/demand.rs +++ b/src/librustc/middle/typeck/check/demand.rs @@ -66,5 +66,3 @@ pub fn coerce(fcx: @mut FnCtxt, } } } - - diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 532638faa68..7f390de1f49 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -666,5 +666,3 @@ pub fn resolve_in_block(fcx: @mut FnCtxt, bl: &ast::blk) { .. *visit::default_visitor() })); } - - diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 7fff756b01d..fe07dc9412d 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -1119,4 +1119,3 @@ pub fn check_coherence(crate_context: @mut CrateCtxt, crate: @crate) { let coherence_checker = @CoherenceChecker(crate_context); coherence_checker.check_coherence(crate); } - diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index de3ffcd63ab..362104e98b0 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -635,4 +635,3 @@ pub fn super_trait_refs( }) } } - diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index 2bbcd24595c..dc1e3e845df 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -313,4 +313,3 @@ impl Combine for Glb { super_trait_refs(self, a, b) } } - diff --git a/src/librustc/middle/typeck/infer/macros.rs b/src/librustc/middle/typeck/infer/macros.rs index e02772d951c..306f124be3c 100644 --- a/src/librustc/middle/typeck/infer/macros.rs +++ b/src/librustc/middle/typeck/infer/macros.rs @@ -18,4 +18,3 @@ macro_rules! if_ok( } ) ) - diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index 25e65d7a18b..1ee59c3fe06 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -1746,4 +1746,3 @@ fn iterate_until_fixed_point( } debug!("---- %s Complete after %u iteration(s)", tag, iteration); } - diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs index 9b648f6a053..2b88825c49a 100644 --- a/src/librustc/middle/typeck/infer/resolve.rs +++ b/src/librustc/middle/typeck/infer/resolve.rs @@ -278,4 +278,3 @@ pub impl ResolveState { } } } - diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index 266d157c4d0..48d7765f88e 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -269,4 +269,3 @@ impl Combine for Sub { super_trait_refs(self, a, b) } } - diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index bc130744224..e50f2089e4f 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -265,5 +265,3 @@ impl SimplyUnifiable for ast::float_ty { return ty::terr_float_mismatch(err); } } - - diff --git a/src/librustdoc/path_pass.rs b/src/librustdoc/path_pass.rs index 629c6955566..5560f21af61 100644 --- a/src/librustdoc/path_pass.rs +++ b/src/librustdoc/path_pass.rs @@ -112,4 +112,3 @@ fn should_record_fn_paths() { assert!(doc.cratemod().mods()[0].fns()[0].path() == ~[~"a"]); } } - diff --git a/src/librustpkg/testsuite/pass/commands.txt b/src/librustpkg/testsuite/pass/commands.txt index e1a1b2462b2..baeaef1e3c7 100644 --- a/src/librustpkg/testsuite/pass/commands.txt +++ b/src/librustpkg/testsuite/pass/commands.txt @@ -32,4 +32,3 @@ Commands that should succeed: 15. `rustpkg test foo` runs tests and prints their output, if foo contains #[test]s. 16. If foo is installed, `rustpkg uninstall foo; rustpkg list` doesn't include foo in the list - diff --git a/src/librustpkg/testsuite/pass/src/deeply/nested/path/foo/src/main.rs b/src/librustpkg/testsuite/pass/src/deeply/nested/path/foo/src/main.rs index 41041ccb509..62785c06db3 100644 --- a/src/librustpkg/testsuite/pass/src/deeply/nested/path/foo/src/main.rs +++ b/src/librustpkg/testsuite/pass/src/deeply/nested/path/foo/src/main.rs @@ -15,4 +15,3 @@ The test runner should check that, after `rustpkg install deeply/nested/path/foo */ fn main() {} - diff --git a/src/libstd/num/bigint.rs b/src/libstd/num/bigint.rs index 497ce7f41aa..cd347098e25 100644 --- a/src/libstd/num/bigint.rs +++ b/src/libstd/num/bigint.rs @@ -1957,4 +1957,3 @@ mod bigint_tests { assert!(-Zero::zero::() == Zero::zero::()); } } - diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index 33efb2c6a5a..39fb5a45d7e 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -1883,4 +1883,3 @@ impl DecoderHelpers for D { } } } - diff --git a/src/libstd/task_pool.rs b/src/libstd/task_pool.rs index 82053602755..661247df1c1 100644 --- a/src/libstd/task_pool.rs +++ b/src/libstd/task_pool.rs @@ -100,4 +100,3 @@ fn test_task_pool() { pool.execute(|i| io::println(fmt!("Hello from thread %u!", *i))); } } - diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs index c2c0c06342b..38e43d1ade5 100644 --- a/src/libsyntax/ext/pipes/check.rs +++ b/src/libsyntax/ext/pipes/check.rs @@ -80,4 +80,3 @@ impl proto::visitor<(), (), ()> for @ext_ctxt { } } } - diff --git a/src/libsyntax/ext/pipes/liveness.rs b/src/libsyntax/ext/pipes/liveness.rs index 4597dab89cb..18faab8c88d 100644 --- a/src/libsyntax/ext/pipes/liveness.rs +++ b/src/libsyntax/ext/pipes/liveness.rs @@ -104,4 +104,3 @@ pub fn analyze(proto: protocol, _cx: @ext_ctxt) { proto.bounded = Some(true); } } - diff --git a/src/libsyntax/ext/pipes/mod.rs b/src/libsyntax/ext/pipes/mod.rs index 81b2442ea82..85c578bc2ce 100644 --- a/src/libsyntax/ext/pipes/mod.rs +++ b/src/libsyntax/ext/pipes/mod.rs @@ -85,4 +85,3 @@ pub fn expand_proto(cx: @ext_ctxt, _sp: span, id: ast::ident, // compile base::MRItem(proto.compile(cx)) } - diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 79072a2f577..64e2f1041c1 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -217,4 +217,3 @@ pub fn visit>( }; visitor.visit_proto(proto, states) } - diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index f7412a4502c..2bf4b05aa6b 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -760,4 +760,3 @@ fn expand_parse_call(cx: @ext_ctxt, id_ext(cx, parse_method), arg_exprs) } - diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index c1afc53def0..e486a6254e7 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -298,4 +298,3 @@ pub impl Parser { } } - diff --git a/src/libsyntax/syntax.rc b/src/libsyntax/syntax.rc index a401d9eb8ac..d00719b2590 100644 --- a/src/libsyntax/syntax.rc +++ b/src/libsyntax/syntax.rc @@ -90,4 +90,3 @@ pub mod ext { pub mod trace_macros; } - diff --git a/src/rt/arch/arm/_context.S b/src/rt/arch/arm/_context.S index 9097ebfc070..6441f59a4d3 100644 --- a/src/rt/arch/arm/_context.S +++ b/src/rt/arch/arm/_context.S @@ -48,5 +48,3 @@ swap_registers: msr cpsr_cxsf, r2 mov pc, lr - - diff --git a/src/rt/arch/arm/gpr.cpp b/src/rt/arch/arm/gpr.cpp index 6dd385fb330..77ec9d5182a 100644 --- a/src/rt/arch/arm/gpr.cpp +++ b/src/rt/arch/arm/gpr.cpp @@ -14,4 +14,3 @@ void rust_gpr::load() { LOAD(r8); LOAD(r9); LOAD(r10); LOAD(r11); LOAD(r12); LOAD(r13); LOAD(r14); LOAD(r15); } - diff --git a/src/rt/arch/arm/gpr.h b/src/rt/arch/arm/gpr.h index 49db1429903..c8a3e916a37 100644 --- a/src/rt/arch/arm/gpr.h +++ b/src/rt/arch/arm/gpr.h @@ -21,4 +21,3 @@ public: }; #endif - diff --git a/src/rt/arch/arm/morestack.S b/src/rt/arch/arm/morestack.S index 4f1431a3392..f0ec3f4b7a5 100644 --- a/src/rt/arch/arm/morestack.S +++ b/src/rt/arch/arm/morestack.S @@ -35,7 +35,7 @@ __morestack: mov r0, r4 // The amount of stack needed add r1, fp, #20 // Address of stack arguments mov r2, r5 // Size of stack arguments - + // Create new stack bl upcall_new_stack@plt @@ -64,7 +64,7 @@ __morestack: // Restore return value mov r0, r4 mov r1, r5 - + // Return pop {r6, fp, lr} mov pc, lr diff --git a/src/rt/arch/arm/record_sp.S b/src/rt/arch/arm/record_sp.S index fe680004a89..95fce8746a1 100644 --- a/src/rt/arch/arm/record_sp.S +++ b/src/rt/arch/arm/record_sp.S @@ -28,4 +28,3 @@ get_sp_limit: get_sp: mov r0, sp mov pc, lr - diff --git a/src/rt/arch/arm/regs.h b/src/rt/arch/arm/regs.h index 2b44bd3af35..0d1c24e0fb7 100644 --- a/src/rt/arch/arm/regs.h +++ b/src/rt/arch/arm/regs.h @@ -19,5 +19,3 @@ # define RUSTRT_ARG1_S r1 # define RUSTRT_ARG2_S r2 # define RUSTRT_ARG3_S r3 - - diff --git a/src/rt/arch/i386/_context.S b/src/rt/arch/i386/_context.S index d2643d07c3d..e2e4ffe35b4 100644 --- a/src/rt/arch/i386/_context.S +++ b/src/rt/arch/i386/_context.S @@ -63,5 +63,3 @@ SWAP_REGISTERS: // Return! jmp *48(%eax) - - diff --git a/src/rt/arch/i386/gpr.cpp b/src/rt/arch/i386/gpr.cpp index bebf8019427..e5a59d664b0 100644 --- a/src/rt/arch/i386/gpr.cpp +++ b/src/rt/arch/i386/gpr.cpp @@ -20,4 +20,3 @@ void rust_gpr::load() { LOAD(eax); LOAD(ebx); LOAD(ecx); LOAD(edx); LOAD(esi); LOAD(edi); LOAD(ebp); LOAD(esi); } - diff --git a/src/rt/arch/i386/gpr.h b/src/rt/arch/i386/gpr.h index 6ae53e113f4..1953170301c 100644 --- a/src/rt/arch/i386/gpr.h +++ b/src/rt/arch/i386/gpr.h @@ -29,4 +29,3 @@ public: }; #endif - diff --git a/src/rt/arch/i386/morestack.S b/src/rt/arch/i386/morestack.S index e8a9c1312ed..c1cd11fa432 100644 --- a/src/rt/arch/i386/morestack.S +++ b/src/rt/arch/i386/morestack.S @@ -97,7 +97,7 @@ #endif .globl MORESTACK -// FIXME: What about _WIN32? +// FIXME: What about _WIN32? #if defined(__linux__) || defined(__FreeBSD__) .hidden MORESTACK #else @@ -253,4 +253,3 @@ L_upcall_del_stack$stub: .subsections_via_symbols #endif - diff --git a/src/rt/arch/mips/gpr.h b/src/rt/arch/mips/gpr.h index 4ff0729633a..b48c1d4e732 100644 --- a/src/rt/arch/mips/gpr.h +++ b/src/rt/arch/mips/gpr.h @@ -30,4 +30,3 @@ public: }; #endif - diff --git a/src/rt/arch/x86_64/_context.S b/src/rt/arch/x86_64/_context.S index bedd6855467..f718cac9634 100644 --- a/src/rt/arch/x86_64/_context.S +++ b/src/rt/arch/x86_64/_context.S @@ -121,4 +121,3 @@ SWAP_REGISTERS: // Jump to the instruction pointer // found in regs: jmp *(RUSTRT_IP*8)(ARG1) - diff --git a/src/rt/arch/x86_64/gpr.cpp b/src/rt/arch/x86_64/gpr.cpp index cf43125923a..37247d1dfdc 100644 --- a/src/rt/arch/x86_64/gpr.cpp +++ b/src/rt/arch/x86_64/gpr.cpp @@ -22,4 +22,3 @@ void rust_gpr::load() { LOAD(r8); LOAD(r9); LOAD(r10); LOAD(r11); LOAD(r12); LOAD(r13); LOAD(r14); LOAD(r15); } - diff --git a/src/rt/arch/x86_64/gpr.h b/src/rt/arch/x86_64/gpr.h index 75c3b081e77..18ef77dbba6 100644 --- a/src/rt/arch/x86_64/gpr.h +++ b/src/rt/arch/x86_64/gpr.h @@ -30,4 +30,3 @@ public: }; #endif - diff --git a/src/rt/arch/x86_64/regs.h b/src/rt/arch/x86_64/regs.h index 7d0efd1eec8..1aca452df10 100644 --- a/src/rt/arch/x86_64/regs.h +++ b/src/rt/arch/x86_64/regs.h @@ -43,5 +43,3 @@ # define RUSTRT_ARG4_S %r8 # define RUSTRT_ARG5_S %r9 #endif - - diff --git a/src/rt/isaac/rand.h b/src/rt/isaac/rand.h index 3da2d71b20b..c28b35e688d 100644 --- a/src/rt/isaac/rand.h +++ b/src/rt/isaac/rand.h @@ -52,5 +52,3 @@ void isaac(randctx *r); (r)->randrsl[(r)->randcnt]) #endif /* RAND */ - - diff --git a/src/rt/rust_abi.cpp b/src/rt/rust_abi.cpp index ca8448b39a1..fd1b7860b29 100644 --- a/src/rt/rust_abi.cpp +++ b/src/rt/rust_abi.cpp @@ -86,4 +86,3 @@ symbolicate(const std::vector &frames) { } } // end namespace stack_walk - diff --git a/src/rt/rust_abi.h b/src/rt/rust_abi.h index c56bf96291f..4179bf75157 100644 --- a/src/rt/rust_abi.h +++ b/src/rt/rust_abi.h @@ -76,4 +76,3 @@ std::string symbolicate(const std::vector &frames); uint32_t get_abi_version(); #endif - diff --git a/src/rt/rust_android_dummy.h b/src/rt/rust_android_dummy.h index 95a1774894b..3d6c949fd34 100644 --- a/src/rt/rust_android_dummy.h +++ b/src/rt/rust_android_dummy.h @@ -12,4 +12,3 @@ char **backtrace_symbols (void *__const *__array, int __size); void backtrace_symbols_fd (void *__const *__array, int __size, int __fd); #endif - diff --git a/src/rt/rust_debug.cpp b/src/rt/rust_debug.cpp index 5c5be45bef8..f403b0434b6 100644 --- a/src/rt/rust_debug.cpp +++ b/src/rt/rust_debug.cpp @@ -58,4 +58,3 @@ dump_origin(rust_task *task, void *ptr) { } } // end namespace debug - diff --git a/src/rt/rust_debug.h b/src/rt/rust_debug.h index c9aad098d38..7f025bb908e 100644 --- a/src/rt/rust_debug.h +++ b/src/rt/rust_debug.h @@ -70,4 +70,3 @@ void dump_origin(rust_task *task, void *ptr); } // end namespace debug #endif - diff --git a/src/rt/rust_gpr_base.h b/src/rt/rust_gpr_base.h index 4df6ea3e9ad..7ec2dda9cd4 100644 --- a/src/rt/rust_gpr_base.h +++ b/src/rt/rust_gpr_base.h @@ -31,4 +31,3 @@ public: #endif - diff --git a/src/rustllvm/README b/src/rustllvm/README index 31495f22c0a..c0db3f68a76 100644 --- a/src/rustllvm/README +++ b/src/rustllvm/README @@ -1,3 +1,2 @@ This directory currently contains some LLVM support code. This will generally be sent upstream to LLVM in time; for now it lives here. - diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 451a390876c..04e616de223 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -120,18 +120,18 @@ void LLVMRustInitializeTargets() { LLVMInitializeX86TargetMC(); LLVMInitializeX86AsmPrinter(); LLVMInitializeX86AsmParser(); - + LLVMInitializeARMTargetInfo(); LLVMInitializeARMTarget(); LLVMInitializeARMTargetMC(); LLVMInitializeARMAsmPrinter(); - LLVMInitializeARMAsmParser(); + LLVMInitializeARMAsmParser(); LLVMInitializeMipsTargetInfo(); LLVMInitializeMipsTarget(); LLVMInitializeMipsTargetMC(); LLVMInitializeMipsAsmPrinter(); - LLVMInitializeMipsAsmParser(); + LLVMInitializeMipsAsmParser(); } // Custom memory manager for MCJITting. It needs special features @@ -438,7 +438,7 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR, const char *path, TargetMachine::CodeGenFileType FileType, CodeGenOpt::Level OptLevel, - bool EnableSegmentedStacks) { + bool EnableSegmentedStacks) { LLVMRustInitializeTargets(); @@ -449,7 +449,7 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR, if (!EnableARMEHABI) { int argc = 3; const char* argv[] = {"rustc", "-arm-enable-ehabi", - "-arm-enable-ehabi-descriptors"}; + "-arm-enable-ehabi-descriptors"}; cl::ParseCommandLineOptions(argc, argv); } @@ -467,8 +467,8 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR, const Target *TheTarget = TargetRegistry::lookupTarget(Trip, Err); TargetMachine *Target = TheTarget->createTargetMachine(Trip, CPUStr, FeaturesStr, - Options, Reloc::PIC_, - CodeModel::Default, OptLevel); + Options, Reloc::PIC_, + CodeModel::Default, OptLevel); Target->addAnalysisPasses(*PM); bool NoVerify = false; @@ -511,10 +511,10 @@ extern "C" LLVMValueRef LLVMRustConstSmallInt(LLVMTypeRef IntTy, unsigned N, return LLVMConstInt(IntTy, (unsigned long long)N, SignExtend); } -extern "C" LLVMValueRef LLVMRustConstInt(LLVMTypeRef IntTy, - unsigned N_hi, - unsigned N_lo, - LLVMBool SignExtend) { +extern "C" LLVMValueRef LLVMRustConstInt(LLVMTypeRef IntTy, + unsigned N_hi, + unsigned N_lo, + LLVMBool SignExtend) { unsigned long long N = N_hi; N <<= 32; N |= N_lo; diff --git a/src/snapshots.txt b/src/snapshots.txt index fafd5467655..00cabe90d84 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -151,7 +151,7 @@ S 2012-10-03 5585514 winnt-i386 25680d15a358cf4163e08f4e56e54fb497de5eb4 S 2012-10-02 4d30b34 - macos-i386 2bcce3cde8a7e53df202972cda85b0b59ce4e50d + macos-i386 2bcce3cde8a7e53df202972cda85b0b59ce4e50d macos-x86_64 fc5592828392f9eabe8b51cc59639be6d709cc26 freebsd-x86_64 5e09dad0800f16f5d79286330bcb82b6d2b8782e linux-i386 92fc541d4dde19fe2af5930d72a5a50ca67bad60 diff --git a/src/test/auxiliary/anon_trait_static_method_lib.rs b/src/test/auxiliary/anon_trait_static_method_lib.rs index 9a778b18874..6e111381cba 100644 --- a/src/test/auxiliary/anon_trait_static_method_lib.rs +++ b/src/test/auxiliary/anon_trait_static_method_lib.rs @@ -17,4 +17,3 @@ pub impl Foo { Foo { x: 3 } } } - diff --git a/src/test/auxiliary/cci_class_2.rs b/src/test/auxiliary/cci_class_2.rs index 9dc27054ef7..b120a4d759f 100644 --- a/src/test/auxiliary/cci_class_2.rs +++ b/src/test/auxiliary/cci_class_2.rs @@ -27,4 +27,3 @@ pub mod kitties { } } } - diff --git a/src/test/auxiliary/cci_class_6.rs b/src/test/auxiliary/cci_class_6.rs index 80990099cda..b09606ea1e2 100644 --- a/src/test/auxiliary/cci_class_6.rs +++ b/src/test/auxiliary/cci_class_6.rs @@ -31,4 +31,3 @@ pub mod kitties { } } } - diff --git a/src/test/auxiliary/cci_class_cast.rs b/src/test/auxiliary/cci_class_cast.rs index edda0644b16..ae0407a5bed 100644 --- a/src/test/auxiliary/cci_class_cast.rs +++ b/src/test/auxiliary/cci_class_cast.rs @@ -56,5 +56,3 @@ pub mod kitty { } } } - - diff --git a/src/test/auxiliary/cci_no_inline_lib.rs b/src/test/auxiliary/cci_no_inline_lib.rs index 407f62adb02..f79227d87cd 100644 --- a/src/test/auxiliary/cci_no_inline_lib.rs +++ b/src/test/auxiliary/cci_no_inline_lib.rs @@ -19,4 +19,3 @@ pub fn iter(v: ~[uint], f: &fn(uint)) { i += 1u; } } - diff --git a/src/test/auxiliary/explicit_self_xcrate.rs b/src/test/auxiliary/explicit_self_xcrate.rs index c790252244f..058cb53f918 100644 --- a/src/test/auxiliary/explicit_self_xcrate.rs +++ b/src/test/auxiliary/explicit_self_xcrate.rs @@ -23,5 +23,3 @@ impl Foo for Bar { io::println((*self).x); } } - - diff --git a/src/test/auxiliary/extern_mod_ordering_lib.rs b/src/test/auxiliary/extern_mod_ordering_lib.rs index 8276cea465f..d04351203da 100644 --- a/src/test/auxiliary/extern_mod_ordering_lib.rs +++ b/src/test/auxiliary/extern_mod_ordering_lib.rs @@ -3,4 +3,3 @@ pub mod extern_mod_ordering_lib { pub fn f() {} } - diff --git a/src/test/auxiliary/foreign_lib.rs b/src/test/auxiliary/foreign_lib.rs index 1561ec51ede..fe5b9e45593 100644 --- a/src/test/auxiliary/foreign_lib.rs +++ b/src/test/auxiliary/foreign_lib.rs @@ -15,4 +15,3 @@ pub mod rustrt { pub fn rust_get_argc() -> libc::c_int; } } - diff --git a/src/test/auxiliary/impl_privacy_xc_1.rs b/src/test/auxiliary/impl_privacy_xc_1.rs index 92452cbe8fd..4d98c4d9d2b 100644 --- a/src/test/auxiliary/impl_privacy_xc_1.rs +++ b/src/test/auxiliary/impl_privacy_xc_1.rs @@ -7,4 +7,3 @@ pub struct Fish { pub impl Fish { fn swim(&self) {} } - diff --git a/src/test/auxiliary/impl_privacy_xc_2.rs b/src/test/auxiliary/impl_privacy_xc_2.rs index 0fa15fa14f6..7ef36b1fb66 100644 --- a/src/test/auxiliary/impl_privacy_xc_2.rs +++ b/src/test/auxiliary/impl_privacy_xc_2.rs @@ -11,5 +11,3 @@ mod unexported { fn ne(&self, _: &Fish) -> bool { false } } } - - diff --git a/src/test/auxiliary/issue-2414-a.rs b/src/test/auxiliary/issue-2414-a.rs index 9f4f369b70d..54bb39fd2df 100644 --- a/src/test/auxiliary/issue-2414-a.rs +++ b/src/test/auxiliary/issue-2414-a.rs @@ -20,4 +20,3 @@ trait foo { impl foo for ~str { fn foo(&self) {} } - diff --git a/src/test/auxiliary/issue-2414-b.rs b/src/test/auxiliary/issue-2414-b.rs index 4bebe4e1420..f4ef02a2b7f 100644 --- a/src/test/auxiliary/issue-2414-b.rs +++ b/src/test/auxiliary/issue-2414-b.rs @@ -14,4 +14,3 @@ #[crate_type = "lib"]; extern mod a; - diff --git a/src/test/auxiliary/issue-2526.rs b/src/test/auxiliary/issue-2526.rs index fa32b9603a5..0e9cf39929f 100644 --- a/src/test/auxiliary/issue-2526.rs +++ b/src/test/auxiliary/issue-2526.rs @@ -55,4 +55,3 @@ fn context_res() -> context_res { } pub type context = arc_destruct; - diff --git a/src/test/auxiliary/issue_2316_b.rs b/src/test/auxiliary/issue_2316_b.rs index ed8e69cb4da..32283e5373c 100644 --- a/src/test/auxiliary/issue_2316_b.rs +++ b/src/test/auxiliary/issue_2316_b.rs @@ -17,5 +17,3 @@ pub mod cloth { gingham, flannel, calico } } - - diff --git a/src/test/auxiliary/issue_3136_a.rs b/src/test/auxiliary/issue_3136_a.rs index f7c866da9ae..55de208cc90 100644 --- a/src/test/auxiliary/issue_3136_a.rs +++ b/src/test/auxiliary/issue_3136_a.rs @@ -12,7 +12,7 @@ trait x { fn use_x(&self); } struct y(()); -impl x for y { +impl x for y { fn use_x(&self) { struct foo { //~ ERROR quux i: () @@ -20,6 +20,5 @@ impl x for y { fn new_foo(i: ()) -> foo { foo { i: i } } - } + } } - diff --git a/src/test/auxiliary/issue_3882.rs b/src/test/auxiliary/issue_3882.rs index 63275a05598..bb75758c741 100644 --- a/src/test/auxiliary/issue_3882.rs +++ b/src/test/auxiliary/issue_3882.rs @@ -12,7 +12,7 @@ mod issue_3882 { struct Completions { len: libc::size_t, } - + mod c { extern { fn linenoiseAddCompletion(lc: *mut Completions); diff --git a/src/test/auxiliary/moves_based_on_type_lib.rs b/src/test/auxiliary/moves_based_on_type_lib.rs index 826bd0db129..857593a84d2 100644 --- a/src/test/auxiliary/moves_based_on_type_lib.rs +++ b/src/test/auxiliary/moves_based_on_type_lib.rs @@ -25,4 +25,3 @@ pub fn f() { let y = x; let z = y; } - diff --git a/src/test/auxiliary/newtype_struct_xc.rs b/src/test/auxiliary/newtype_struct_xc.rs index 90036e0f96c..e0d2541dbe3 100644 --- a/src/test/auxiliary/newtype_struct_xc.rs +++ b/src/test/auxiliary/newtype_struct_xc.rs @@ -1,4 +1,3 @@ #[crate_type="lib"]; pub struct Au(int); - diff --git a/src/test/auxiliary/pub_use_mods_xcrate.rs b/src/test/auxiliary/pub_use_mods_xcrate.rs index e085f2312dc..e4890f4fe2d 100644 --- a/src/test/auxiliary/pub_use_mods_xcrate.rs +++ b/src/test/auxiliary/pub_use_mods_xcrate.rs @@ -18,4 +18,3 @@ pub mod a { } } } - diff --git a/src/test/auxiliary/static_fn_inline_xc_aux.rs b/src/test/auxiliary/static_fn_inline_xc_aux.rs index 5fc6621f186..a17a78bcea7 100644 --- a/src/test/auxiliary/static_fn_inline_xc_aux.rs +++ b/src/test/auxiliary/static_fn_inline_xc_aux.rs @@ -21,4 +21,3 @@ pub mod float { fn from_int2(n: int) -> float { return n as float; } } } - diff --git a/src/test/auxiliary/struct_destructuring_cross_crate.rs b/src/test/auxiliary/struct_destructuring_cross_crate.rs index ab7b1a636d3..8887cbee3fe 100644 --- a/src/test/auxiliary/struct_destructuring_cross_crate.rs +++ b/src/test/auxiliary/struct_destructuring_cross_crate.rs @@ -14,4 +14,3 @@ pub struct S { x: int, y: int } - diff --git a/src/test/auxiliary/trait_inheritance_auto_xc_2_aux.rs b/src/test/auxiliary/trait_inheritance_auto_xc_2_aux.rs index 1c7ebd941c3..7d6178db485 100644 --- a/src/test/auxiliary/trait_inheritance_auto_xc_2_aux.rs +++ b/src/test/auxiliary/trait_inheritance_auto_xc_2_aux.rs @@ -17,5 +17,3 @@ pub struct A { x: int } impl Foo for A { fn f(&self) -> int { 10 } } impl Bar for A { fn g(&self) -> int { 20 } } impl Baz for A { fn h(&self) -> int { 30 } } - - diff --git a/src/test/auxiliary/trait_inheritance_overloading_xc.rs b/src/test/auxiliary/trait_inheritance_overloading_xc.rs index 1b480ff17b3..1fb0db25b31 100644 --- a/src/test/auxiliary/trait_inheritance_overloading_xc.rs +++ b/src/test/auxiliary/trait_inheritance_overloading_xc.rs @@ -38,4 +38,3 @@ impl Eq for MyInt { impl MyNum for MyInt; fn mi(v: int) -> MyInt { MyInt { val: v } } - diff --git a/src/test/auxiliary/xc_private_method_lib.rs b/src/test/auxiliary/xc_private_method_lib.rs index f9fda2b0810..05325c3b935 100644 --- a/src/test/auxiliary/xc_private_method_lib.rs +++ b/src/test/auxiliary/xc_private_method_lib.rs @@ -7,4 +7,3 @@ pub struct Foo { impl Foo { fn new() -> Foo { Foo { x: 1 } } } - diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index 3833c884652..6cda0a1945a 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -104,7 +104,7 @@ fn main() { ~[~"", ~"10000", ~"4"] } else { copy args - }; + }; debug!("%?", args); run(args); diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index c4044d45f36..a8fb29a47e2 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -101,7 +101,7 @@ fn main() { ~[~"", ~"10000", ~"4"] } else { copy args - }; + }; debug!("%?", args); run(args); diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index a1ab7384d62..853b057277d 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -72,7 +72,7 @@ fn main() { ~[~"", ~"10", ~"100"] } else { copy args - }; + }; let num_tasks = uint::from_str(args[1]).get(); let msg_per_task = uint::from_str(args[2]).get(); diff --git a/src/test/bench/msgsend-ring-pipes.rs b/src/test/bench/msgsend-ring-pipes.rs index 14e955dd7bd..1288ac29078 100644 --- a/src/test/bench/msgsend-ring-pipes.rs +++ b/src/test/bench/msgsend-ring-pipes.rs @@ -65,7 +65,7 @@ fn main() { ~[~"", ~"100", ~"1000"] } else { copy args - }; + }; let num_tasks = uint::from_str(args[1]).get(); let msg_per_task = uint::from_str(args[2]).get(); diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs index 8e819cc4aba..2cf0fbfc397 100644 --- a/src/test/bench/msgsend-ring-rw-arcs.rs +++ b/src/test/bench/msgsend-ring-rw-arcs.rs @@ -73,7 +73,7 @@ fn main() { ~[~"", ~"10", ~"100"] } else { copy args - }; + }; let num_tasks = uint::from_str(args[1]).get(); let msg_per_task = uint::from_str(args[2]).get(); diff --git a/src/test/bench/pingpong.rs b/src/test/bench/pingpong.rs index 4a6e90f4116..09e663325ed 100644 --- a/src/test/bench/pingpong.rs +++ b/src/test/bench/pingpong.rs @@ -11,7 +11,7 @@ // Compare bounded and unbounded protocol performance. // xfail-pretty - + extern mod std; use core::cell::Cell; diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 9dad24646de..5d893d4ec07 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -218,4 +218,3 @@ fn main() { rendezvous(nn, ~[Blue, Red, Yellow, Red, Yellow, Blue, Red, Yellow, Red, Blue]); } - diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index 21f38245ca3..cb32e0e496e 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -92,4 +92,3 @@ fn main() { let n: i32 = FromStr::from_str(os::args()[1]).get(); println(fmt!("Pfannkuchen(%d) = %d", n as int, fannkuch_redux(n) as int)); } - diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index 5ece9810206..d6a0f4b8b25 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -201,4 +201,3 @@ fn main() { fputc('\n' as c_int, stdout); } } - diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 4cd7b58ce12..d1f3dbf22ce 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -222,4 +222,3 @@ fn main() { io::println(from_child[ii].recv()); } } - diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 224885a3f79..1791af67ed0 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -252,7 +252,7 @@ fn generate_frequencies(frequencies: &mut Table, mut input: &[u8], frame: i32) { let mut code = Code(0); - + // Pull first frame. for (frame as uint).times { code = code.push_char(input[0]); @@ -313,4 +313,3 @@ fn main() { print_occurrences(frequencies, occurrence); } } - diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index e62cb8ea849..7d2b25792ec 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -57,4 +57,3 @@ fn main() { } } } - diff --git a/src/test/bench/shootout-pidigits.rs b/src/test/bench/shootout-pidigits.rs index 38e87358ee2..cb7fa969be7 100644 --- a/src/test/bench/shootout-pidigits.rs +++ b/src/test/bench/shootout-pidigits.rs @@ -175,4 +175,3 @@ fn main() { let n: u32 = FromStr::from_str(os::args()[1]).get(); pidigits(n); } - diff --git a/src/test/bench/shootout-reverse-complement.rs b/src/test/bench/shootout-reverse-complement.rs index 72c01c8d55c..a9cb3c7636a 100644 --- a/src/test/bench/shootout-reverse-complement.rs +++ b/src/test/bench/shootout-reverse-complement.rs @@ -152,4 +152,3 @@ fn main() { fwrite(transmute(out.unsafe_ref(0)), 1, pos as size_t, stdout); } } - diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 9221da8b557..8afddd3a31e 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -274,4 +274,3 @@ fn main() { sudoku.solve(); sudoku.write(io::stdout()); } - diff --git a/src/test/compile-fail/alt-tag-nullary.rs b/src/test/compile-fail/alt-tag-nullary.rs index c74ee3d852a..2b0c3dbf8e8 100644 --- a/src/test/compile-fail/alt-tag-nullary.rs +++ b/src/test/compile-fail/alt-tag-nullary.rs @@ -14,4 +14,3 @@ enum a { A, } enum b { B, } fn main() { let x: a = A; match x { B => { } } } - diff --git a/src/test/compile-fail/alt-tag-unary.rs b/src/test/compile-fail/alt-tag-unary.rs index e01b9a045e5..a129ff19ac6 100644 --- a/src/test/compile-fail/alt-tag-unary.rs +++ b/src/test/compile-fail/alt-tag-unary.rs @@ -14,4 +14,3 @@ enum a { A(int), } enum b { B(int), } fn main() { let x: a = A(0); match x { B(y) => { } } } - diff --git a/src/test/compile-fail/auto-ref-borrowck-failure.rs b/src/test/compile-fail/auto-ref-borrowck-failure.rs index 90b9b44cfbe..894b71357b7 100644 --- a/src/test/compile-fail/auto-ref-borrowck-failure.rs +++ b/src/test/compile-fail/auto-ref-borrowck-failure.rs @@ -28,4 +28,3 @@ fn main() { let x = Foo { x: 3 }; x.printme(); //~ ERROR illegal borrow } - diff --git a/src/test/compile-fail/bogus-tag.rs b/src/test/compile-fail/bogus-tag.rs index 12e8ba56532..89ad7b4245a 100644 --- a/src/test/compile-fail/bogus-tag.rs +++ b/src/test/compile-fail/bogus-tag.rs @@ -21,4 +21,3 @@ fn main() { hsl(h, s, l) => { debug!("hsl"); } } } - diff --git a/src/test/compile-fail/borrowck-assign-comp-idx.rs b/src/test/compile-fail/borrowck-assign-comp-idx.rs index 25b56abb5ba..a284cd5b4a7 100644 --- a/src/test/compile-fail/borrowck-assign-comp-idx.rs +++ b/src/test/compile-fail/borrowck-assign-comp-idx.rs @@ -45,4 +45,3 @@ fn c() { fn main() { } - diff --git a/src/test/compile-fail/borrowck-assign-comp.rs b/src/test/compile-fail/borrowck-assign-comp.rs index 283f04a283f..eb832fe738d 100644 --- a/src/test/compile-fail/borrowck-assign-comp.rs +++ b/src/test/compile-fail/borrowck-assign-comp.rs @@ -42,4 +42,3 @@ fn d() { fn main() { } - diff --git a/src/test/compile-fail/borrowck-call-method-from-mut-aliasable.rs b/src/test/compile-fail/borrowck-call-method-from-mut-aliasable.rs index 2c68429baec..f2c6ae98819 100644 --- a/src/test/compile-fail/borrowck-call-method-from-mut-aliasable.rs +++ b/src/test/compile-fail/borrowck-call-method-from-mut-aliasable.rs @@ -38,4 +38,3 @@ fn c(x: &const Foo) { fn main() { } - diff --git a/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs index a2ba5ad4891..1c2bd8dc8e1 100644 --- a/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs +++ b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs @@ -30,6 +30,6 @@ use core::either::{Either, Left, Right}; let y: &Either = &x; let z: &mut Either = &mut x; //~ ERROR conflicts with prior loan *z = *y; - } + } fn main() {} diff --git a/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs b/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs index a4ad7e69b33..21bb7434f8d 100644 --- a/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs +++ b/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Point { +struct Point { x: int, y: int, } @@ -56,4 +56,3 @@ fn c() { fn main() { } - diff --git a/src/test/compile-fail/borrowck-loan-rcvr.rs b/src/test/compile-fail/borrowck-loan-rcvr.rs index 4473574926a..36007abf05e 100644 --- a/src/test/compile-fail/borrowck-loan-rcvr.rs +++ b/src/test/compile-fail/borrowck-loan-rcvr.rs @@ -63,4 +63,3 @@ fn c() { fn main() { } - diff --git a/src/test/compile-fail/borrowck-mut-boxed-vec.rs b/src/test/compile-fail/borrowck-mut-boxed-vec.rs index d4c0b5a1e9b..e8ed362176f 100644 --- a/src/test/compile-fail/borrowck-mut-boxed-vec.rs +++ b/src/test/compile-fail/borrowck-mut-boxed-vec.rs @@ -14,4 +14,3 @@ fn main() { v[1] = 4; } } - diff --git a/src/test/compile-fail/borrowck-ref-into-rvalue.rs b/src/test/compile-fail/borrowck-ref-into-rvalue.rs index 37ee747069c..84acd0df20b 100644 --- a/src/test/compile-fail/borrowck-ref-into-rvalue.rs +++ b/src/test/compile-fail/borrowck-ref-into-rvalue.rs @@ -13,9 +13,8 @@ fn main() { match Some(~"Hello") { //~ ERROR illegal borrow Some(ref m) => { msg = m; - }, + }, None => { fail!() } - } + } io::println(*msg); } - diff --git a/src/test/compile-fail/borrowck-uniq-via-box.rs b/src/test/compile-fail/borrowck-uniq-via-box.rs index e1c0e67ff8d..97414ff5e78 100644 --- a/src/test/compile-fail/borrowck-uniq-via-box.rs +++ b/src/test/compile-fail/borrowck-uniq-via-box.rs @@ -52,4 +52,3 @@ fn box_imm_recs(v: @Outer) { fn main() { } - diff --git a/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs b/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs index 27902100373..805b162f1d3 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs @@ -9,4 +9,3 @@ fn a() { } fn main() {} - diff --git a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs index 05ff85d612c..eef99aafd68 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs @@ -18,4 +18,3 @@ fn b() { } fn main() {} - diff --git a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-2.rs b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-2.rs index e47ad721b0d..f9e6bc1b22e 100644 --- a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-2.rs +++ b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-2.rs @@ -3,4 +3,3 @@ fn main() { let _x = &mut *b; //~ NOTE prior loan as mutable granted here let _y = &mut *b; //~ ERROR loan of dereference of mutable ~ pointer as mutable conflicts with prior loan } - diff --git a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-3.rs b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-3.rs index 015f368ecb0..6c82b25a6a1 100644 --- a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-3.rs +++ b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-3.rs @@ -5,4 +5,3 @@ fn main() { let mut d = /*move*/ a; //~ ERROR moving out of mutable local variable prohibited due to outstanding loan *d += 1; } - diff --git a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail.rs b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail.rs index 36d32fddda1..dc453d98193 100644 --- a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail.rs +++ b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail.rs @@ -4,4 +4,3 @@ fn main() { let mut y = /*move*/ b; //~ ERROR moving out of mutable local variable prohibited *y += 1; } - diff --git a/src/test/compile-fail/borrowck-wg-move-base-2.rs b/src/test/compile-fail/borrowck-wg-move-base-2.rs index ba85616e63f..0ede523daa4 100644 --- a/src/test/compile-fail/borrowck-wg-move-base-2.rs +++ b/src/test/compile-fail/borrowck-wg-move-base-2.rs @@ -7,5 +7,3 @@ fn foo(x: &mut int) { fn main() { } - - diff --git a/src/test/compile-fail/by-move-pattern-binding.rs b/src/test/compile-fail/by-move-pattern-binding.rs index 95091f15ce0..1efed154286 100644 --- a/src/test/compile-fail/by-move-pattern-binding.rs +++ b/src/test/compile-fail/by-move-pattern-binding.rs @@ -20,4 +20,3 @@ fn main() { &Bar(ref identifier) => io::println(*identifier) }; } - diff --git a/src/test/compile-fail/dead-code-ret.rs b/src/test/compile-fail/dead-code-ret.rs index 182a41c1b17..97f6149b162 100644 --- a/src/test/compile-fail/dead-code-ret.rs +++ b/src/test/compile-fail/dead-code-ret.rs @@ -15,4 +15,3 @@ fn f(caller: str) { debug!(caller); } fn main() { return f("main"); debug!("Paul is dead"); } - diff --git a/src/test/compile-fail/does-nothing.rs b/src/test/compile-fail/does-nothing.rs index a360d657957..699baad4d43 100644 --- a/src/test/compile-fail/does-nothing.rs +++ b/src/test/compile-fail/does-nothing.rs @@ -1,3 +1,2 @@ // error-pattern: unresolved name: `this_does_nothing_what_the`. fn main() { debug!("doing"); this_does_nothing_what_the; debug!("boing"); } - diff --git a/src/test/compile-fail/drop-on-non-struct.rs b/src/test/compile-fail/drop-on-non-struct.rs index 4e5b64c8f3d..b2f87686ac6 100644 --- a/src/test/compile-fail/drop-on-non-struct.rs +++ b/src/test/compile-fail/drop-on-non-struct.rs @@ -19,5 +19,3 @@ impl Drop for Foo { //~ ERROR the Drop trait may only be implemented fn main() { } - - diff --git a/src/test/compile-fail/explicit-call-to-dtor.rs b/src/test/compile-fail/explicit-call-to-dtor.rs index 71674186b61..24fedaaabe3 100644 --- a/src/test/compile-fail/explicit-call-to-dtor.rs +++ b/src/test/compile-fail/explicit-call-to-dtor.rs @@ -22,4 +22,3 @@ fn main() { let x = Foo { x: 3 }; x.finalize(); //~ ERROR explicit call to destructor } - diff --git a/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs b/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs index 26b13566f7a..fd49889a3f7 100644 --- a/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs +++ b/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs @@ -31,5 +31,3 @@ impl Bar for Foo { fn main() { let x = Foo { x: 3 }; } - - diff --git a/src/test/compile-fail/float-literal-inference-restrictions.rs b/src/test/compile-fail/float-literal-inference-restrictions.rs index 80aefbbf48f..48dbdd86b11 100644 --- a/src/test/compile-fail/float-literal-inference-restrictions.rs +++ b/src/test/compile-fail/float-literal-inference-restrictions.rs @@ -12,4 +12,3 @@ fn main() { let x: f32 = 1; //~ ERROR mismatched types let y: f32 = 1f; //~ ERROR mismatched types } - diff --git a/src/test/compile-fail/foreign-unsafe-fn-called.rs b/src/test/compile-fail/foreign-unsafe-fn-called.rs index 9122abab713..ed8b8088ee4 100644 --- a/src/test/compile-fail/foreign-unsafe-fn-called.rs +++ b/src/test/compile-fail/foreign-unsafe-fn-called.rs @@ -21,4 +21,3 @@ fn main() { test::free(); //~^ ERROR access to unsafe function requires unsafe function or block } - diff --git a/src/test/compile-fail/foreign-unsafe-fn.rs b/src/test/compile-fail/foreign-unsafe-fn.rs index 32fafe29646..3633267d02c 100644 --- a/src/test/compile-fail/foreign-unsafe-fn.rs +++ b/src/test/compile-fail/foreign-unsafe-fn.rs @@ -21,5 +21,3 @@ fn main() { let x = test::free; //~^ ERROR access to unsafe function requires unsafe function or block } - - diff --git a/src/test/compile-fail/issue-1451.rs b/src/test/compile-fail/issue-1451.rs index acc371076e7..a295e8eb7ed 100644 --- a/src/test/compile-fail/issue-1451.rs +++ b/src/test/compile-fail/issue-1451.rs @@ -30,4 +30,3 @@ fn main() { fooT(T {f: x}); fooT(T {f: bar}); } - diff --git a/src/test/compile-fail/issue-2951.rs b/src/test/compile-fail/issue-2951.rs index 3874d9b13f5..e57d4f09175 100644 --- a/src/test/compile-fail/issue-2951.rs +++ b/src/test/compile-fail/issue-2951.rs @@ -15,5 +15,4 @@ fn foo(x: T, y: U) { } fn main() { - } diff --git a/src/test/compile-fail/issue-3044.rs b/src/test/compile-fail/issue-3044.rs index fcd5b1deee5..635d0aa3df1 100644 --- a/src/test/compile-fail/issue-3044.rs +++ b/src/test/compile-fail/issue-3044.rs @@ -17,4 +17,3 @@ fn main() { // // the first error is, um, non-ideal. } - diff --git a/src/test/compile-fail/issue-3096-2.rs b/src/test/compile-fail/issue-3096-2.rs index da13d450273..eb58cf3e13b 100644 --- a/src/test/compile-fail/issue-3096-2.rs +++ b/src/test/compile-fail/issue-3096-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum bottom { } +enum bottom { } fn main() { let x = ptr::to_unsafe_ptr(&()) as *bottom; diff --git a/src/test/compile-fail/issue-3991.rs b/src/test/compile-fail/issue-3991.rs index d1c9057b880..d3016f893b4 100644 --- a/src/test/compile-fail/issue-3991.rs +++ b/src/test/compile-fail/issue-3991.rs @@ -12,11 +12,11 @@ struct HasNested { mut nest: ~[~[int]], } - + impl HasNested { fn method_push_local(&self) { self.nest[0].push(0); } } - + fn main() {} diff --git a/src/test/compile-fail/issue-4265.rs b/src/test/compile-fail/issue-4265.rs index b6a32f5feba..e76d211deda 100644 --- a/src/test/compile-fail/issue-4265.rs +++ b/src/test/compile-fail/issue-4265.rs @@ -11,12 +11,12 @@ struct Foo { baz: uint } - + impl Foo { fn bar() { Foo { baz: 0 }.bar(); } - + fn bar() { //~ ERROR duplicate definition of value bar } } diff --git a/src/test/compile-fail/issue-4366.rs b/src/test/compile-fail/issue-4366.rs index 7d97932d9af..f4e57171599 100644 --- a/src/test/compile-fail/issue-4366.rs +++ b/src/test/compile-fail/issue-4366.rs @@ -37,4 +37,3 @@ mod m1 { fn main() { foo(); //~ ERROR: unresolved name: `foo` } - diff --git a/src/test/compile-fail/issue-4968.rs b/src/test/compile-fail/issue-4968.rs index fc0c29e9a79..700d8a61c3a 100644 --- a/src/test/compile-fail/issue-4968.rs +++ b/src/test/compile-fail/issue-4968.rs @@ -14,4 +14,3 @@ static A: (int,int) = (4,2); fn main() { match 42 { A => () } //~ ERROR mismatched types: expected `` but found `(int,int)` (expected integral variable but found tuple) } - diff --git a/src/test/compile-fail/kindck-destructor-owned.rs b/src/test/compile-fail/kindck-destructor-owned.rs index e956f95b422..faad36a15d2 100644 --- a/src/test/compile-fail/kindck-destructor-owned.rs +++ b/src/test/compile-fail/kindck-destructor-owned.rs @@ -9,4 +9,3 @@ impl Drop for Foo { //~ ERROR cannot implement a destructor on a struct that is } fn main() { } - diff --git a/src/test/compile-fail/lint-default-methods.rs b/src/test/compile-fail/lint-default-methods.rs index 1350c3e3ad1..89b99fcebca 100644 --- a/src/test/compile-fail/lint-default-methods.rs +++ b/src/test/compile-fail/lint-default-methods.rs @@ -5,4 +5,3 @@ trait Foo { //~ ERROR default methods are experimental } fn main() {} - diff --git a/src/test/compile-fail/lint-type-limits.rs b/src/test/compile-fail/lint-type-limits.rs index e45ef38e97a..2eb794fd1c2 100644 --- a/src/test/compile-fail/lint-type-limits.rs +++ b/src/test/compile-fail/lint-type-limits.rs @@ -32,4 +32,3 @@ fn qux() { i += 1; } } - diff --git a/src/test/compile-fail/liveness-if-no-else.rs b/src/test/compile-fail/liveness-if-no-else.rs index e37ee5bd4d4..22b1b5edbac 100644 --- a/src/test/compile-fail/liveness-if-no-else.rs +++ b/src/test/compile-fail/liveness-if-no-else.rs @@ -11,6 +11,6 @@ fn foo(x: int) { debug!(x); } fn main() { - let x: int; if 1 > 2 { x = 10; } - foo(x); //~ ERROR use of possibly uninitialized variable: `x` + let x: int; if 1 > 2 { x = 10; } + foo(x); //~ ERROR use of possibly uninitialized variable: `x` } diff --git a/src/test/compile-fail/liveness-return.rs b/src/test/compile-fail/liveness-return.rs index 12f7aa434cc..6558bc57968 100644 --- a/src/test/compile-fail/liveness-return.rs +++ b/src/test/compile-fail/liveness-return.rs @@ -9,8 +9,8 @@ // except according to those terms. fn f() -> int { - let x: int; - return x; //~ ERROR use of possibly uninitialized variable: `x` + let x: int; + return x; //~ ERROR use of possibly uninitialized variable: `x` } fn main() { f(); } diff --git a/src/test/compile-fail/liveness-uninit-after-item.rs b/src/test/compile-fail/liveness-uninit-after-item.rs index b3ab0053888..a828b1d6b9f 100644 --- a/src/test/compile-fail/liveness-uninit-after-item.rs +++ b/src/test/compile-fail/liveness-uninit-after-item.rs @@ -13,4 +13,3 @@ fn main() { fn baz(_x: int) { } baz(bar); //~ ERROR use of possibly uninitialized variable: `bar` } - diff --git a/src/test/compile-fail/liveness-uninit.rs b/src/test/compile-fail/liveness-uninit.rs index 8797132fd50..a360f8e85a6 100644 --- a/src/test/compile-fail/liveness-uninit.rs +++ b/src/test/compile-fail/liveness-uninit.rs @@ -11,6 +11,6 @@ fn foo(x: int) { debug!(x); } fn main() { - let x: int; - foo(x); //~ ERROR use of possibly uninitialized variable: `x` + let x: int; + foo(x); //~ ERROR use of possibly uninitialized variable: `x` } diff --git a/src/test/compile-fail/macro-with-seps-err-msg.rs b/src/test/compile-fail/macro-with-seps-err-msg.rs index 74c040238ac..95250e36b86 100644 --- a/src/test/compile-fail/macro-with-seps-err-msg.rs +++ b/src/test/compile-fail/macro-with-seps-err-msg.rs @@ -13,5 +13,3 @@ fn main() { globnar::brotz!(); } - - diff --git a/src/test/compile-fail/missing-derivable-attr.rs b/src/test/compile-fail/missing-derivable-attr.rs index 67cf67bfa5a..eb27d51061f 100644 --- a/src/test/compile-fail/missing-derivable-attr.rs +++ b/src/test/compile-fail/missing-derivable-attr.rs @@ -24,4 +24,3 @@ impl MyEq for A; //~ ERROR missing method fn main() { } - diff --git a/src/test/compile-fail/missing-return.rs b/src/test/compile-fail/missing-return.rs index c0007d2bee8..1dc817cc6e6 100644 --- a/src/test/compile-fail/missing-return.rs +++ b/src/test/compile-fail/missing-return.rs @@ -13,4 +13,3 @@ fn f() -> int { } fn main() { f(); } - diff --git a/src/test/compile-fail/moves-based-on-type-block-bad.rs b/src/test/compile-fail/moves-based-on-type-block-bad.rs index 020dadfc96c..67eb06ab424 100644 --- a/src/test/compile-fail/moves-based-on-type-block-bad.rs +++ b/src/test/compile-fail/moves-based-on-type-block-bad.rs @@ -24,4 +24,3 @@ fn main() { } } } - diff --git a/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs b/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs index 57829e72674..6dce011ddc8 100644 --- a/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs +++ b/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs @@ -5,4 +5,3 @@ fn main() { } io::println(x); //~ ERROR use of moved value } - diff --git a/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs b/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs index bee9596df72..2b9291ce328 100644 --- a/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs +++ b/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs @@ -29,4 +29,3 @@ fn consume(v: ~List) -> int { } fn main() {} - diff --git a/src/test/compile-fail/no-capture-arc.rs b/src/test/compile-fail/no-capture-arc.rs index da75dfd0106..2c8c98ad5d6 100644 --- a/src/test/compile-fail/no-capture-arc.rs +++ b/src/test/compile-fail/no-capture-arc.rs @@ -16,7 +16,7 @@ use std::arc; fn main() { let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let arc_v = arc::ARC(v); - + do task::spawn() { let v = *arc::get(&arc_v); assert!(v[3] == 4); diff --git a/src/test/compile-fail/noexporttypeexe.rs b/src/test/compile-fail/noexporttypeexe.rs index 8d9796c7c41..95428568e4c 100644 --- a/src/test/compile-fail/noexporttypeexe.rs +++ b/src/test/compile-fail/noexporttypeexe.rs @@ -20,4 +20,3 @@ fn main() { let x: int = noexporttypelib::foo(); //~^ ERROR expected `int` but found `core::option::Option` } - diff --git a/src/test/compile-fail/non-exhaustive-match-nested.rs b/src/test/compile-fail/non-exhaustive-match-nested.rs index 4d1db362376..34fe6b0f678 100644 --- a/src/test/compile-fail/non-exhaustive-match-nested.rs +++ b/src/test/compile-fail/non-exhaustive-match-nested.rs @@ -20,4 +20,3 @@ fn main() { b => { fail!(~"goodbye"); } } } - diff --git a/src/test/compile-fail/once-fn-subtyping.rs b/src/test/compile-fail/once-fn-subtyping.rs index 00009c706e3..178c04dfc79 100644 --- a/src/test/compile-fail/once-fn-subtyping.rs +++ b/src/test/compile-fail/once-fn-subtyping.rs @@ -14,4 +14,3 @@ fn main() { let h: &fn() = ||(); let i: &once fn() = h; // ok } - diff --git a/src/test/compile-fail/private-impl-method.rs b/src/test/compile-fail/private-impl-method.rs index 74bdcdc7f82..a6728f82ec3 100644 --- a/src/test/compile-fail/private-impl-method.rs +++ b/src/test/compile-fail/private-impl-method.rs @@ -22,4 +22,3 @@ fn main() { let s = a::Foo { x: 1 }; s.foo(); //~ ERROR method `foo` is private } - diff --git a/src/test/compile-fail/private-item-simple.rs b/src/test/compile-fail/private-item-simple.rs index e8038df188b..8776739db2d 100644 --- a/src/test/compile-fail/private-item-simple.rs +++ b/src/test/compile-fail/private-item-simple.rs @@ -15,4 +15,3 @@ mod a { fn main() { a::f(); //~ ERROR unresolved name } - diff --git a/src/test/compile-fail/private-method-inherited.rs b/src/test/compile-fail/private-method-inherited.rs index 7b64623e16c..bc27027e886 100644 --- a/src/test/compile-fail/private-method-inherited.rs +++ b/src/test/compile-fail/private-method-inherited.rs @@ -12,4 +12,3 @@ fn main() { let x = a::Foo; x.f(); //~ ERROR method `f` is private } - diff --git a/src/test/compile-fail/private-struct-field-ctor.rs b/src/test/compile-fail/private-struct-field-ctor.rs index 43e7427dd74..7ab28d72965 100644 --- a/src/test/compile-fail/private-struct-field-ctor.rs +++ b/src/test/compile-fail/private-struct-field-ctor.rs @@ -17,4 +17,3 @@ mod a { fn main() { let s = a::Foo { x: 1 }; //~ ERROR field `x` is private } - diff --git a/src/test/compile-fail/private-struct-field-pattern.rs b/src/test/compile-fail/private-struct-field-pattern.rs index 864c9bd98d7..6f524a8eaa4 100644 --- a/src/test/compile-fail/private-struct-field-pattern.rs +++ b/src/test/compile-fail/private-struct-field-pattern.rs @@ -25,4 +25,3 @@ fn main() { Foo { x: _ } => {} //~ ERROR field `x` is private } } - diff --git a/src/test/compile-fail/qquote-1.rs b/src/test/compile-fail/qquote-1.rs index eda207f711d..4710d9dee45 100644 --- a/src/test/compile-fail/qquote-1.rs +++ b/src/test/compile-fail/qquote-1.rs @@ -65,4 +65,3 @@ fn main() { fn check_pp(expr: T, f: &fn(pprust::ps, T), expect: str) { fail!(); } - diff --git a/src/test/compile-fail/qquote-2.rs b/src/test/compile-fail/qquote-2.rs index c6690534008..d3773256105 100644 --- a/src/test/compile-fail/qquote-2.rs +++ b/src/test/compile-fail/qquote-2.rs @@ -60,4 +60,3 @@ fn main() { fn check_pp(expr: T, f: &fn(pprust::ps, T), expect: str) { fail!(); } - diff --git a/src/test/compile-fail/refutable-pattern-in-fn-arg.rs b/src/test/compile-fail/refutable-pattern-in-fn-arg.rs index 5e157c1bd7b..957925709e1 100644 --- a/src/test/compile-fail/refutable-pattern-in-fn-arg.rs +++ b/src/test/compile-fail/refutable-pattern-in-fn-arg.rs @@ -12,4 +12,3 @@ fn main() { let f = |3: int| io::println("hello"); //~ ERROR refutable pattern f(4); } - diff --git a/src/test/compile-fail/regions-addr-of-self.rs b/src/test/compile-fail/regions-addr-of-self.rs index 732d946bf9e..f96ef639e75 100644 --- a/src/test/compile-fail/regions-addr-of-self.rs +++ b/src/test/compile-fail/regions-addr-of-self.rs @@ -35,4 +35,3 @@ fn main() { d.chase_cat(); debug!("cats_chased: %u", d.cats_chased); } - diff --git a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs index a8b7ae1b9c8..6ee0216655e 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs @@ -24,4 +24,3 @@ fn foo(p: @point) -> &int { } fn main() {} - diff --git a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs index bf8f227b573..602f5dc6983 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs @@ -15,8 +15,8 @@ fn foo(cond: &fn() -> bool, box: &fn() -> @int) { loop { let x = box(); - // Here we complain because the resulting region - // of this borrow is the fn body as a whole. + // Here we complain because the resulting region + // of this borrow is the fn body as a whole. y = borrow(x); //~ ERROR illegal borrow: cannot root managed value long enough assert!(*x == *y); diff --git a/src/test/compile-fail/regions-ret.rs b/src/test/compile-fail/regions-ret.rs index be7b28f6ef4..cf7cb175bb8 100644 --- a/src/test/compile-fail/regions-ret.rs +++ b/src/test/compile-fail/regions-ret.rs @@ -14,4 +14,3 @@ fn f<'a>(_x : &'a int) -> &'a int { fn main() { } - diff --git a/src/test/compile-fail/repeat-to-run-dtor-twice.rs b/src/test/compile-fail/repeat-to-run-dtor-twice.rs index 18bdb564441..e1e1e2313f4 100644 --- a/src/test/compile-fail/repeat-to-run-dtor-twice.rs +++ b/src/test/compile-fail/repeat-to-run-dtor-twice.rs @@ -26,4 +26,3 @@ fn main() { let a = Foo { x: 3 }; let _ = [ a, ..5 ]; //~ ERROR copying a value of non-copyable type } - diff --git a/src/test/compile-fail/static-method-privacy.rs b/src/test/compile-fail/static-method-privacy.rs index 50df4f04971..0fd82b5ace3 100644 --- a/src/test/compile-fail/static-method-privacy.rs +++ b/src/test/compile-fail/static-method-privacy.rs @@ -8,4 +8,3 @@ mod a { fn main() { let _ = a::S::new(); //~ ERROR function `new` is private } - diff --git a/src/test/compile-fail/static-region-bound.rs b/src/test/compile-fail/static-region-bound.rs index 500a5b0c8bc..ada3aebb2f4 100644 --- a/src/test/compile-fail/static-region-bound.rs +++ b/src/test/compile-fail/static-region-bound.rs @@ -6,4 +6,3 @@ fn main() { let x = &3; f(x); //~ ERROR instantiating a type parameter with an incompatible type } - diff --git a/src/test/compile-fail/struct-like-enum-nonexhaustive.rs b/src/test/compile-fail/struct-like-enum-nonexhaustive.rs index 52a61628c35..91709e2ea7d 100644 --- a/src/test/compile-fail/struct-like-enum-nonexhaustive.rs +++ b/src/test/compile-fail/struct-like-enum-nonexhaustive.rs @@ -20,5 +20,3 @@ fn main() { B { x: None } => {} } } - - diff --git a/src/test/compile-fail/super-at-top-level.rs b/src/test/compile-fail/super-at-top-level.rs index 21b9e5292b1..f1064a62905 100644 --- a/src/test/compile-fail/super-at-top-level.rs +++ b/src/test/compile-fail/super-at-top-level.rs @@ -2,6 +2,4 @@ use super::f; //~ ERROR unresolved name //~^ ERROR failed to resolve import fn main() { - } - diff --git a/src/test/compile-fail/trait-impl-method-mismatch.rs b/src/test/compile-fail/trait-impl-method-mismatch.rs index 7f4c227d2d0..54fa62f7977 100644 --- a/src/test/compile-fail/trait-impl-method-mismatch.rs +++ b/src/test/compile-fail/trait-impl-method-mismatch.rs @@ -19,7 +19,3 @@ impl Mumbo for uint { } fn main() {} - - - - diff --git a/src/test/compile-fail/trait-inheritance-missing-requirement.rs b/src/test/compile-fail/trait-inheritance-missing-requirement.rs index a341c242611..5968c296e13 100644 --- a/src/test/compile-fail/trait-inheritance-missing-requirement.rs +++ b/src/test/compile-fail/trait-inheritance-missing-requirement.rs @@ -30,4 +30,3 @@ impl Bar for A { fn main() { } - diff --git a/src/test/compile-fail/tuple-struct-nonexhaustive.rs b/src/test/compile-fail/tuple-struct-nonexhaustive.rs index 7cfdab2e96d..de28a06abab 100644 --- a/src/test/compile-fail/tuple-struct-nonexhaustive.rs +++ b/src/test/compile-fail/tuple-struct-nonexhaustive.rs @@ -17,5 +17,3 @@ fn main() { Foo(2, b) => io::println(fmt!("%d", b)) } } - - diff --git a/src/test/compile-fail/tutorial-suffix-inference-test.rs b/src/test/compile-fail/tutorial-suffix-inference-test.rs index c68af84b95b..d92aa8d640a 100644 --- a/src/test/compile-fail/tutorial-suffix-inference-test.rs +++ b/src/test/compile-fail/tutorial-suffix-inference-test.rs @@ -22,11 +22,11 @@ fn main() { //~^ ERROR mismatched types: expected `u16` but found `i32` let a = 3i; - + fn identity_i(n: int) -> int { n } identity_i(a); // ok - identity_u16(a); + identity_u16(a); //~^ ERROR mismatched types: expected `u16` but found `int` } diff --git a/src/test/compile-fail/unique-object-noncopyable.rs b/src/test/compile-fail/unique-object-noncopyable.rs index edc8a47822d..95945b0b5ba 100644 --- a/src/test/compile-fail/unique-object-noncopyable.rs +++ b/src/test/compile-fail/unique-object-noncopyable.rs @@ -31,4 +31,3 @@ fn main() { let y: ~Foo = x as ~Foo; let _z = copy y; //~ ERROR copying a value of non-copyable type } - diff --git a/src/test/compile-fail/use-after-move-based-on-type.rs b/src/test/compile-fail/use-after-move-based-on-type.rs index 6c268c5e13c..3d176bb339d 100644 --- a/src/test/compile-fail/use-after-move-based-on-type.rs +++ b/src/test/compile-fail/use-after-move-based-on-type.rs @@ -13,4 +13,3 @@ fn main() { let _y = x; io::println(x); //~ ERROR use of moved value } - diff --git a/src/test/compile-fail/use-after-move-self-based-on-type.rs b/src/test/compile-fail/use-after-move-self-based-on-type.rs index b0a2bc8ec12..627b8924b67 100644 --- a/src/test/compile-fail/use-after-move-self-based-on-type.rs +++ b/src/test/compile-fail/use-after-move-self-based-on-type.rs @@ -19,4 +19,3 @@ fn main() { let x = S { x: 1 }; io::println(x.foo().to_str()); } - diff --git a/src/test/compile-fail/use-after-move-self.rs b/src/test/compile-fail/use-after-move-self.rs index 3eded9fd4f3..11f37df4541 100644 --- a/src/test/compile-fail/use-after-move-self.rs +++ b/src/test/compile-fail/use-after-move-self.rs @@ -15,4 +15,3 @@ fn main() { let x = S { x: ~1 }; io::println(x.foo().to_str()); } - diff --git a/src/test/compile-fail/view-items-at-top.rs b/src/test/compile-fail/view-items-at-top.rs index a637836320d..023be703cca 100644 --- a/src/test/compile-fail/view-items-at-top.rs +++ b/src/test/compile-fail/view-items-at-top.rs @@ -19,4 +19,3 @@ use std::net; //~ ERROR view items must be declared at the top fn main() { } - diff --git a/src/test/compile-fail/while-type-error.rs b/src/test/compile-fail/while-type-error.rs index f9d3dce7508..ecab746373a 100644 --- a/src/test/compile-fail/while-type-error.rs +++ b/src/test/compile-fail/while-type-error.rs @@ -11,4 +11,3 @@ // error-pattern: mismatched types fn main() { while main { } } - diff --git a/src/test/compile-fail/xc-private-method.rs b/src/test/compile-fail/xc-private-method.rs index d194820df94..e8777a0a9f2 100644 --- a/src/test/compile-fail/xc-private-method.rs +++ b/src/test/compile-fail/xc-private-method.rs @@ -6,4 +6,3 @@ extern mod xc_private_method_lib; fn main() { let _ = xc_private_method_lib::Foo::new(); //~ ERROR function `new` is private } - diff --git a/src/test/pretty/doc-comments.rs b/src/test/pretty/doc-comments.rs index a866afd2405..45e242c0ca0 100644 --- a/src/test/pretty/doc-comments.rs +++ b/src/test/pretty/doc-comments.rs @@ -22,7 +22,7 @@ fn b() { ////////////////////////////////// // some single-line non-doc comment preceded by a separator -////////////////////////////////// +////////////////////////////////// /// some single-line outer-docs preceded by a separator /// (and trailing whitespaces) fn c() { } diff --git a/src/test/run-fail/assert-as-macro.rs b/src/test/run-fail/assert-as-macro.rs index 07813b91e57..f715e21f781 100644 --- a/src/test/run-fail/assert-as-macro.rs +++ b/src/test/run-fail/assert-as-macro.rs @@ -3,4 +3,3 @@ fn main() { assert!(1 == 2); } - diff --git a/src/test/run-fail/borrowck-wg-fail-3.rs b/src/test/run-fail/borrowck-wg-fail-3.rs index ad4c7942121..b239bfc3b31 100644 --- a/src/test/run-fail/borrowck-wg-fail-3.rs +++ b/src/test/run-fail/borrowck-wg-fail-3.rs @@ -5,4 +5,3 @@ fn main() { let y: &mut int = x; *x = 5; } - diff --git a/src/test/run-fail/borrowck-wg-fail.rs b/src/test/run-fail/borrowck-wg-fail.rs index d393832c6e8..93e7f9275b6 100644 --- a/src/test/run-fail/borrowck-wg-fail.rs +++ b/src/test/run-fail/borrowck-wg-fail.rs @@ -10,4 +10,3 @@ fn main() { let x = @mut 3; f(x, x); } - diff --git a/src/test/run-fail/unwind-resource-fail3.rs b/src/test/run-fail/unwind-resource-fail3.rs index d3ba5737b71..bfbad0b5aea 100644 --- a/src/test/run-fail/unwind-resource-fail3.rs +++ b/src/test/run-fail/unwind-resource-fail3.rs @@ -14,7 +14,7 @@ struct faily_box { i: @int } // What happens to the box pointer owned by this class? - + fn faily_box(i: @int) -> faily_box { faily_box { i: i } } #[unsafe_destructor] diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index 9bfe29a5e8e..284195f3f04 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -85,4 +85,3 @@ fn check_pp(cx: fake_ext_ctxt, assert!(s == expect); } } - diff --git a/src/test/run-pass-fulldeps/quote-tokens.rs b/src/test/run-pass-fulldeps/quote-tokens.rs index ccee163eafe..3ec54955229 100644 --- a/src/test/run-pass-fulldeps/quote-tokens.rs +++ b/src/test/run-pass-fulldeps/quote-tokens.rs @@ -27,4 +27,3 @@ fn syntax_extension(ext_cx: @ext_ctxt) { fn main() { } - diff --git a/src/test/run-pass/anon-trait-static-method.rs b/src/test/run-pass/anon-trait-static-method.rs index 8e11786786f..91bbbf5c0a0 100644 --- a/src/test/run-pass/anon-trait-static-method.rs +++ b/src/test/run-pass/anon-trait-static-method.rs @@ -22,4 +22,3 @@ pub fn main() { let x = Foo::new(); io::println(x.x.to_str()); } - diff --git a/src/test/run-pass/anon_trait_static_method_exe.rs b/src/test/run-pass/anon_trait_static_method_exe.rs index 5d8b7983688..1baeca00083 100644 --- a/src/test/run-pass/anon_trait_static_method_exe.rs +++ b/src/test/run-pass/anon_trait_static_method_exe.rs @@ -18,6 +18,3 @@ pub fn main() { let x = Foo::new(); io::println(x.x.to_str()); } - - - diff --git a/src/test/run-pass/auto-ref-newtype.rs b/src/test/run-pass/auto-ref-newtype.rs index bac6d1aa740..a9fca0ccb15 100644 --- a/src/test/run-pass/auto-ref-newtype.rs +++ b/src/test/run-pass/auto-ref-newtype.rs @@ -21,4 +21,3 @@ pub fn main() { let m = Foo(3); assert!(m.len() == 3); } - diff --git a/src/test/run-pass/auto-ref.rs b/src/test/run-pass/auto-ref.rs index f7c0f513a9d..ee250b97219 100644 --- a/src/test/run-pass/auto-ref.rs +++ b/src/test/run-pass/auto-ref.rs @@ -26,4 +26,3 @@ pub fn main() { let x = Foo { x: 3 }; x.printme(); } - diff --git a/src/test/run-pass/autoderef-and-borrow-method-receiver.rs b/src/test/run-pass/autoderef-and-borrow-method-receiver.rs index 883cffa792b..2bc6df47030 100644 --- a/src/test/run-pass/autoderef-and-borrow-method-receiver.rs +++ b/src/test/run-pass/autoderef-and-borrow-method-receiver.rs @@ -22,4 +22,3 @@ fn g(x: &mut Foo) { pub fn main() { } - diff --git a/src/test/run-pass/bare-static-string.rs b/src/test/run-pass/bare-static-string.rs index d8015f0b92c..6208a9c3cc3 100644 --- a/src/test/run-pass/bare-static-string.rs +++ b/src/test/run-pass/bare-static-string.rs @@ -12,4 +12,3 @@ pub fn main() { let x: &'static str = "foo"; io::println(x); } - diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs index e7624c9e3b9..e755a34f058 100644 --- a/src/test/run-pass/binops.rs +++ b/src/test/run-pass/binops.rs @@ -104,7 +104,7 @@ fn p(x: int, y: int) -> p { fn test_class() { let mut q = p(1, 2); let mut r = p(1, 2); - + unsafe { error!("q = %x, r = %x", (::core::cast::transmute::<*p, uint>(&q)), diff --git a/src/test/run-pass/block-arg-in-parentheses.rs b/src/test/run-pass/block-arg-in-parentheses.rs index ce0b85f414b..ad53bd22754 100644 --- a/src/test/run-pass/block-arg-in-parentheses.rs +++ b/src/test/run-pass/block-arg-in-parentheses.rs @@ -33,4 +33,3 @@ pub fn main() { assert!(w_paren2(~[0, 1, 2, 3]) == -4); assert!(w_ret(~[0, 1, 2, 3]) == -4); } - diff --git a/src/test/run-pass/borrow-by-val-method-receiver.rs b/src/test/run-pass/borrow-by-val-method-receiver.rs index fdb51124f0e..fb4316ca1f5 100644 --- a/src/test/run-pass/borrow-by-val-method-receiver.rs +++ b/src/test/run-pass/borrow-by-val-method-receiver.rs @@ -20,4 +20,3 @@ pub fn main() { let items = ~[ 3, 5, 1, 2, 4 ]; items.foo(); } - diff --git a/src/test/run-pass/borrowck-wg-simple.rs b/src/test/run-pass/borrowck-wg-simple.rs index adf2403ec63..f28b0e4c4ec 100644 --- a/src/test/run-pass/borrowck-wg-simple.rs +++ b/src/test/run-pass/borrowck-wg-simple.rs @@ -6,4 +6,3 @@ pub fn main() { let x = @mut 3; f(x); } - diff --git a/src/test/run-pass/boxed-trait-with-vstore.rs b/src/test/run-pass/boxed-trait-with-vstore.rs index 1aac86238dc..1313a17f81d 100644 --- a/src/test/run-pass/boxed-trait-with-vstore.rs +++ b/src/test/run-pass/boxed-trait-with-vstore.rs @@ -22,4 +22,3 @@ pub fn main() { let x = @3 as @Foo; x.foo(); } - diff --git a/src/test/run-pass/break.rs b/src/test/run-pass/break.rs index b3f524c0ad7..a182dcf2ca0 100644 --- a/src/test/run-pass/break.rs +++ b/src/test/run-pass/break.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - pub fn main() { let mut i = 0; while i < 20 { i += 1; if i == 10 { break; } } @@ -22,8 +20,8 @@ pub fn main() { i = 0; while i < 10 { i += 1; if i % 2 == 0 { loop; } assert!((i % 2 != 0)); } i = 0; - loop { - i += 1; if i % 2 == 0 { loop; } assert!((i % 2 != 0)); + loop { + i += 1; if i % 2 == 0 { loop; } assert!((i % 2 != 0)); if i >= 10 { break; } } for vec::each(~[1, 2, 3, 4, 5, 6]) |x| { diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs index 68bc567cf51..76f4e3b68f7 100644 --- a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs +++ b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs @@ -24,4 +24,3 @@ pub fn main() { let nyan : @ToStr = @cat(0u, 2, ~"nyan") as @ToStr; print_out(nyan, ~"nyan"); } - diff --git a/src/test/run-pass/class-impl-parameterized-trait.rs b/src/test/run-pass/class-impl-parameterized-trait.rs index 53ae0021a91..04784b5c515 100644 --- a/src/test/run-pass/class-impl-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-parameterized-trait.rs @@ -48,7 +48,7 @@ class cat : map { } fn size() -> uint { self.meows as uint } - fn insert(+k: int, +v: bool) -> bool { + fn insert(+k: int, +v: bool) -> bool { if v { self.meows += k; } else { self.meows -= k; }; true } diff --git a/src/test/run-pass/cleanup-copy-mode.rs b/src/test/run-pass/cleanup-copy-mode.rs index 41f76b1b4f2..b334f32f344 100644 --- a/src/test/run-pass/cleanup-copy-mode.rs +++ b/src/test/run-pass/cleanup-copy-mode.rs @@ -16,4 +16,3 @@ pub fn main() { adder(@2, failer()); () }))); } - diff --git a/src/test/run-pass/clone-with-exterior.rs b/src/test/run-pass/clone-with-exterior.rs index 57c4f91142d..ae2983b1594 100644 --- a/src/test/run-pass/clone-with-exterior.rs +++ b/src/test/run-pass/clone-with-exterior.rs @@ -18,7 +18,7 @@ struct Pair { pub fn main() { let z = ~Pair { a : 10, b : 12}; - + let f: ~fn() = || { assert!((z.a == 10)); assert!((z.b == 12)); diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs index 609bfe7a4cb..73fdb219c19 100644 --- a/src/test/run-pass/conditional-compile.rs +++ b/src/test/run-pass/conditional-compile.rs @@ -27,7 +27,7 @@ mod rustrt { // module was translated pub fn bogus(); } - + #[abi = "cdecl"] pub extern {} } diff --git a/src/test/run-pass/const-enum-vec-index.rs b/src/test/run-pass/const-enum-vec-index.rs index 01bab077832..4c81eaae1d8 100644 --- a/src/test/run-pass/const-enum-vec-index.rs +++ b/src/test/run-pass/const-enum-vec-index.rs @@ -14,7 +14,7 @@ static C0: E = C[0]; static C1: E = C[1]; pub fn main() { - match C0 { + match C0 { V0 => (), _ => fail!() } diff --git a/src/test/run-pass/const-enum-vec-ptr.rs b/src/test/run-pass/const-enum-vec-ptr.rs index 8615356965e..95c4ed836c7 100644 --- a/src/test/run-pass/const-enum-vec-ptr.rs +++ b/src/test/run-pass/const-enum-vec-ptr.rs @@ -16,7 +16,7 @@ pub fn main() { V1(n) => assert!(n == 0xDEADBEE), _ => fail!() } - match C[2] { + match C[2] { V0 => (), _ => fail!() } diff --git a/src/test/run-pass/const-enum-vector.rs b/src/test/run-pass/const-enum-vector.rs index 7ae2c5a2fee..3dc5b918f7f 100644 --- a/src/test/run-pass/const-enum-vector.rs +++ b/src/test/run-pass/const-enum-vector.rs @@ -16,7 +16,7 @@ pub fn main() { V1(n) => assert!(n == 0xDEADBEE), _ => fail!() } - match C[2] { + match C[2] { V0 => (), _ => fail!() } diff --git a/src/test/run-pass/const-expr-in-fixed-length-vec.rs b/src/test/run-pass/const-expr-in-fixed-length-vec.rs index c593fd39aaa..48b41d04633 100644 --- a/src/test/run-pass/const-expr-in-fixed-length-vec.rs +++ b/src/test/run-pass/const-expr-in-fixed-length-vec.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Check that constant expressions can be used for declaring the +// Check that constant expressions can be used for declaring the // type of a fixed length vector. pub fn main() { diff --git a/src/test/run-pass/const-expr-in-vec-repeat.rs b/src/test/run-pass/const-expr-in-vec-repeat.rs index be54c6eb7be..f10cef520ad 100644 --- a/src/test/run-pass/const-expr-in-vec-repeat.rs +++ b/src/test/run-pass/const-expr-in-vec-repeat.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Check that constant expressions can be used in vec repeat syntax. +// Check that constant expressions can be used in vec repeat syntax. pub fn main() { diff --git a/src/test/run-pass/const-tuple-struct.rs b/src/test/run-pass/const-tuple-struct.rs index a68e12b7b10..828c20912a1 100644 --- a/src/test/run-pass/const-tuple-struct.rs +++ b/src/test/run-pass/const-tuple-struct.rs @@ -20,4 +20,3 @@ pub fn main() { } } } - diff --git a/src/test/run-pass/const-unit-struct.rs b/src/test/run-pass/const-unit-struct.rs index b4acde098ba..7e6d9f0bee9 100644 --- a/src/test/run-pass/const-unit-struct.rs +++ b/src/test/run-pass/const-unit-struct.rs @@ -17,4 +17,3 @@ pub fn main() { Foo => {} } } - diff --git a/src/test/run-pass/const-vec-syntax.rs b/src/test/run-pass/const-vec-syntax.rs index c3e882ac04f..625f6ec30cc 100644 --- a/src/test/run-pass/const-vec-syntax.rs +++ b/src/test/run-pass/const-vec-syntax.rs @@ -14,4 +14,3 @@ pub fn main() { let v = [ 1, 2, 3 ]; f(v); } - diff --git a/src/test/run-pass/consts-in-patterns.rs b/src/test/run-pass/consts-in-patterns.rs index 408c0e612f4..c0520cf737f 100644 --- a/src/test/run-pass/consts-in-patterns.rs +++ b/src/test/run-pass/consts-in-patterns.rs @@ -20,4 +20,3 @@ pub fn main() { }; assert!(y == 2); } - diff --git a/src/test/run-pass/cycle-collection.rs b/src/test/run-pass/cycle-collection.rs index 0512b8a1267..0e9be022113 100644 --- a/src/test/run-pass/cycle-collection.rs +++ b/src/test/run-pass/cycle-collection.rs @@ -21,4 +21,3 @@ fn f() { pub fn main() { f(); } - diff --git a/src/test/run-pass/default-method-simple.rs b/src/test/run-pass/default-method-simple.rs index 62b29d4e4eb..3f44f3f1ef8 100644 --- a/src/test/run-pass/default-method-simple.rs +++ b/src/test/run-pass/default-method-simple.rs @@ -32,4 +32,3 @@ pub fn main() { let a = A { x: 1 }; a.f(); } - diff --git a/src/test/run-pass/deriving-clone-enum.rs b/src/test/run-pass/deriving-clone-enum.rs index 6caceeb2d70..969e1fb5dd6 100644 --- a/src/test/run-pass/deriving-clone-enum.rs +++ b/src/test/run-pass/deriving-clone-enum.rs @@ -16,4 +16,3 @@ enum E { } pub fn main() {} - diff --git a/src/test/run-pass/deriving-clone-generic-enum.rs b/src/test/run-pass/deriving-clone-generic-enum.rs index a868db2425c..23841017e93 100644 --- a/src/test/run-pass/deriving-clone-generic-enum.rs +++ b/src/test/run-pass/deriving-clone-generic-enum.rs @@ -6,4 +6,3 @@ enum E { } fn main() {} - diff --git a/src/test/run-pass/deriving-clone-generic-struct.rs b/src/test/run-pass/deriving-clone-generic-struct.rs index b157cd321cf..0a7a5a3aa75 100644 --- a/src/test/run-pass/deriving-clone-generic-struct.rs +++ b/src/test/run-pass/deriving-clone-generic-struct.rs @@ -16,4 +16,3 @@ struct S { } pub fn main() {} - diff --git a/src/test/run-pass/deriving-clone-generic-tuple-struct.rs b/src/test/run-pass/deriving-clone-generic-tuple-struct.rs index aeaa9ed726d..d6a69e8e6ac 100644 --- a/src/test/run-pass/deriving-clone-generic-tuple-struct.rs +++ b/src/test/run-pass/deriving-clone-generic-tuple-struct.rs @@ -2,4 +2,3 @@ struct S(T, ()); fn main() {} - diff --git a/src/test/run-pass/deriving-clone-tuple-struct.rs b/src/test/run-pass/deriving-clone-tuple-struct.rs index c534883f600..1e5c8c80f8c 100644 --- a/src/test/run-pass/deriving-clone-tuple-struct.rs +++ b/src/test/run-pass/deriving-clone-tuple-struct.rs @@ -12,4 +12,3 @@ struct S((), ()); pub fn main() {} - diff --git a/src/test/run-pass/deriving-via-extension-c-enum.rs b/src/test/run-pass/deriving-via-extension-c-enum.rs index 67893ae9c1e..81c4ce013f2 100644 --- a/src/test/run-pass/deriving-via-extension-c-enum.rs +++ b/src/test/run-pass/deriving-via-extension-c-enum.rs @@ -23,4 +23,3 @@ pub fn main() { assert!(a.eq(&b)); assert!(!a.ne(&b)); } - diff --git a/src/test/run-pass/deriving-via-extension-enum.rs b/src/test/run-pass/deriving-via-extension-enum.rs index 7481bae508b..fac0d402a38 100644 --- a/src/test/run-pass/deriving-via-extension-enum.rs +++ b/src/test/run-pass/deriving-via-extension-enum.rs @@ -22,4 +22,3 @@ pub fn main() { assert!(a.eq(&b)); assert!(!a.ne(&b)); } - diff --git a/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs b/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs index 5ceb8c48750..b08117b71fa 100644 --- a/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs +++ b/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs @@ -25,4 +25,3 @@ enum A { } pub fn main(){} - diff --git a/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs b/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs index 9f18cb6ac58..8369d12ecdd 100644 --- a/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs +++ b/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs @@ -18,5 +18,3 @@ struct Foo { } pub fn main() {} - - diff --git a/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs b/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs index 712767efacf..4ef8fb6b5d9 100644 --- a/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs +++ b/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs @@ -9,4 +9,3 @@ pub fn main() { assert!(x == x); assert!(!(x != x)); } - diff --git a/src/test/run-pass/deriving-via-extension-struct.rs b/src/test/run-pass/deriving-via-extension-struct.rs index 1e004d1a8c0..c0e7ee36b16 100644 --- a/src/test/run-pass/deriving-via-extension-struct.rs +++ b/src/test/run-pass/deriving-via-extension-struct.rs @@ -23,4 +23,3 @@ pub fn main() { assert!(a.eq(&b)); assert!(!a.ne(&b)); } - diff --git a/src/test/run-pass/deriving-via-extension-type-params.rs b/src/test/run-pass/deriving-via-extension-type-params.rs index f310643f943..85a89c62989 100644 --- a/src/test/run-pass/deriving-via-extension-type-params.rs +++ b/src/test/run-pass/deriving-via-extension-type-params.rs @@ -26,4 +26,3 @@ pub fn main() { assert!(a.eq(&b)); assert!(!a.ne(&b)); } - diff --git a/src/test/run-pass/drop-trait-generic.rs b/src/test/run-pass/drop-trait-generic.rs index 21b85084117..65c3faac2b3 100644 --- a/src/test/run-pass/drop-trait-generic.rs +++ b/src/test/run-pass/drop-trait-generic.rs @@ -22,4 +22,3 @@ impl ::core::ops::Drop for S { pub fn main() { let x = S { x: 1 }; } - diff --git a/src/test/run-pass/drop-trait.rs b/src/test/run-pass/drop-trait.rs index 3eddda376a8..b516c6f6de4 100644 --- a/src/test/run-pass/drop-trait.rs +++ b/src/test/run-pass/drop-trait.rs @@ -21,4 +21,3 @@ impl Drop for Foo { pub fn main() { let x: Foo = Foo { x: 3 }; } - diff --git a/src/test/run-pass/enum-discrim-range-overflow.rs b/src/test/run-pass/enum-discrim-range-overflow.rs index a6806fba142..37e457d547b 100644 --- a/src/test/run-pass/enum-discrim-range-overflow.rs +++ b/src/test/run-pass/enum-discrim-range-overflow.rs @@ -9,23 +9,23 @@ // except according to those terms. pub enum E64 { - H64 = 0x7FFF_FFFF_FFFF_FFFF, - L64 = 0x8000_0000_0000_0000 + H64 = 0x7FFF_FFFF_FFFF_FFFF, + L64 = 0x8000_0000_0000_0000 } pub enum E32 { - H32 = 0x7FFF_FFFF, - L32 = 0x8000_0000 + H32 = 0x7FFF_FFFF, + L32 = 0x8000_0000 } pub fn f(e64: E64, e32: E32) -> (bool,bool) { - (match e64 { - H64 => true, - L64 => false - }, - match e32 { - H32 => true, - L32 => false - }) + (match e64 { + H64 => true, + L64 => false + }, + match e32 { + H32 => true, + L32 => false + }) } pub fn main() { } diff --git a/src/test/run-pass/enum-disr-val-pretty.rs b/src/test/run-pass/enum-disr-val-pretty.rs index 39a807789ec..2c61351cf44 100644 --- a/src/test/run-pass/enum-disr-val-pretty.rs +++ b/src/test/run-pass/enum-disr-val-pretty.rs @@ -23,4 +23,3 @@ fn test_color(color: color, val: int, name: ~str) { assert!(color as int == val); assert!(color as float == val as float); } - diff --git a/src/test/run-pass/enum-export-inheritance.rs b/src/test/run-pass/enum-export-inheritance.rs index c3beebdb8ae..49823155043 100644 --- a/src/test/run-pass/enum-export-inheritance.rs +++ b/src/test/run-pass/enum-export-inheritance.rs @@ -19,4 +19,3 @@ mod a { pub fn main() { let x = a::Bar; } - diff --git a/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs b/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs index b5cf15f3b38..4764dbb9417 100644 --- a/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs +++ b/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs @@ -17,8 +17,8 @@ enum List { Nil, Cons(X, @List) } pub fn main() { match Cons(10, @Nil) { - Cons(10, _) => {} - Nil => {} - _ => fail!() + Cons(10, _) => {} + Nil => {} + _ => fail!() } } diff --git a/src/test/run-pass/explicit-self-generic.rs b/src/test/run-pass/explicit-self-generic.rs index 1a2a8cab303..ac19592accf 100644 --- a/src/test/run-pass/explicit-self-generic.rs +++ b/src/test/run-pass/explicit-self-generic.rs @@ -40,4 +40,3 @@ pub fn main() { let mut m = ~linear_map::<(),()>(); assert!(m.len() == 0); } - diff --git a/src/test/run-pass/explicit-self-objects-box.rs b/src/test/run-pass/explicit-self-objects-box.rs index 105aad03083..12a1780e029 100644 --- a/src/test/run-pass/explicit-self-objects-box.rs +++ b/src/test/run-pass/explicit-self-objects-box.rs @@ -30,5 +30,3 @@ pub fn main() { y.f(); y.f(); } - - diff --git a/src/test/run-pass/explicit-self-objects-simple.rs b/src/test/run-pass/explicit-self-objects-simple.rs index de2926b0e7e..814365a8354 100644 --- a/src/test/run-pass/explicit-self-objects-simple.rs +++ b/src/test/run-pass/explicit-self-objects-simple.rs @@ -27,5 +27,3 @@ pub fn main() { let y = x as @Foo; y.f(); } - - diff --git a/src/test/run-pass/explicit-self-objects-uniq.rs b/src/test/run-pass/explicit-self-objects-uniq.rs index e99a6bbedc0..dadf53fb9bc 100644 --- a/src/test/run-pass/explicit-self-objects-uniq.rs +++ b/src/test/run-pass/explicit-self-objects-uniq.rs @@ -27,5 +27,3 @@ pub fn main() { let y = x as ~Foo; y.f(); } - - diff --git a/src/test/run-pass/explicit_self_xcrate_exe.rs b/src/test/run-pass/explicit_self_xcrate_exe.rs index e217e6ebd41..6f6520e8040 100644 --- a/src/test/run-pass/explicit_self_xcrate_exe.rs +++ b/src/test/run-pass/explicit_self_xcrate_exe.rs @@ -18,4 +18,3 @@ pub fn main() { let x = Bar { x: ~"hello" }; x.f(); } - diff --git a/src/test/run-pass/expr-repeat-vstore.rs b/src/test/run-pass/expr-repeat-vstore.rs index 972b2763b1b..e48abc57534 100644 --- a/src/test/run-pass/expr-repeat-vstore.rs +++ b/src/test/run-pass/expr-repeat-vstore.rs @@ -20,4 +20,3 @@ fn main() { println((copy v[3]).to_str()); println((copy v[4]).to_str()); } - diff --git a/src/test/run-pass/extern-mod-abi.rs b/src/test/run-pass/extern-mod-abi.rs index 7eada51b7c7..84fd1b40bf7 100644 --- a/src/test/run-pass/extern-mod-abi.rs +++ b/src/test/run-pass/extern-mod-abi.rs @@ -13,4 +13,3 @@ extern "C" { } pub fn main() {} - diff --git a/src/test/run-pass/extern-mod-ordering-exe.rs b/src/test/run-pass/extern-mod-ordering-exe.rs index b60302277b3..5836245ff78 100644 --- a/src/test/run-pass/extern-mod-ordering-exe.rs +++ b/src/test/run-pass/extern-mod-ordering-exe.rs @@ -8,4 +8,3 @@ use extern_mod_ordering_lib::extern_mod_ordering_lib; fn main() { extern_mod_ordering_lib::f(); } - diff --git a/src/test/run-pass/extern-mod-syntax.rs b/src/test/run-pass/extern-mod-syntax.rs index b6b2e004263..c98b5ebc238 100644 --- a/src/test/run-pass/extern-mod-syntax.rs +++ b/src/test/run-pass/extern-mod-syntax.rs @@ -16,4 +16,3 @@ use std::json::Object; pub fn main() { io::println("Hello world!"); } - diff --git a/src/test/run-pass/extern-pass-TwoU16s.rs b/src/test/run-pass/extern-pass-TwoU16s.rs index f0343c4d2a2..ec65cbb5670 100644 --- a/src/test/run-pass/extern-pass-TwoU16s.rs +++ b/src/test/run-pass/extern-pass-TwoU16s.rs @@ -29,4 +29,3 @@ pub fn main() { assert!(x == y); } } - diff --git a/src/test/run-pass/extern-pass-TwoU32s.rs b/src/test/run-pass/extern-pass-TwoU32s.rs index 16d14a96cfe..6ac5967c54f 100644 --- a/src/test/run-pass/extern-pass-TwoU32s.rs +++ b/src/test/run-pass/extern-pass-TwoU32s.rs @@ -27,4 +27,3 @@ pub fn main() { assert!(x == y); } } - diff --git a/src/test/run-pass/extern-pass-TwoU64s-ref.rs b/src/test/run-pass/extern-pass-TwoU64s-ref.rs index 56d3f8ebbff..2b18dba90f7 100644 --- a/src/test/run-pass/extern-pass-TwoU64s-ref.rs +++ b/src/test/run-pass/extern-pass-TwoU64s-ref.rs @@ -26,4 +26,3 @@ pub fn main() { assert!(x == y); } } - diff --git a/src/test/run-pass/extern-pass-TwoU64s.rs b/src/test/run-pass/extern-pass-TwoU64s.rs index 24dd3db8aca..3a1f4a51238 100644 --- a/src/test/run-pass/extern-pass-TwoU64s.rs +++ b/src/test/run-pass/extern-pass-TwoU64s.rs @@ -31,4 +31,3 @@ pub fn main() { assert!(x == y); } } - diff --git a/src/test/run-pass/extern-pass-TwoU8s.rs b/src/test/run-pass/extern-pass-TwoU8s.rs index 213e9a68a7f..7d08b436908 100644 --- a/src/test/run-pass/extern-pass-TwoU8s.rs +++ b/src/test/run-pass/extern-pass-TwoU8s.rs @@ -29,4 +29,3 @@ pub fn main() { assert!(x == y); } } - diff --git a/src/test/run-pass/extern-pass-char.rs b/src/test/run-pass/extern-pass-char.rs index f4fa6bde392..645396e5a98 100644 --- a/src/test/run-pass/extern-pass-char.rs +++ b/src/test/run-pass/extern-pass-char.rs @@ -19,4 +19,3 @@ pub fn main() { assert!(22_u8 == rust_dbg_extern_identity_u8(22_u8)); } } - diff --git a/src/test/run-pass/extern-pass-double.rs b/src/test/run-pass/extern-pass-double.rs index 4e16acb4ad5..3a6dd26a9dc 100644 --- a/src/test/run-pass/extern-pass-double.rs +++ b/src/test/run-pass/extern-pass-double.rs @@ -17,4 +17,3 @@ pub fn main() { assert!(22.0_f64 == rust_dbg_extern_identity_double(22.0_f64)); } } - diff --git a/src/test/run-pass/extern-pass-u32.rs b/src/test/run-pass/extern-pass-u32.rs index 14d05f82177..19c4d6e1539 100644 --- a/src/test/run-pass/extern-pass-u32.rs +++ b/src/test/run-pass/extern-pass-u32.rs @@ -19,4 +19,3 @@ pub fn main() { assert!(22_u32 == rust_dbg_extern_identity_u32(22_u32)); } } - diff --git a/src/test/run-pass/extern-pass-u64.rs b/src/test/run-pass/extern-pass-u64.rs index 2b5a03a4d71..cce66999922 100644 --- a/src/test/run-pass/extern-pass-u64.rs +++ b/src/test/run-pass/extern-pass-u64.rs @@ -19,4 +19,3 @@ pub fn main() { assert!(22_u64 == rust_dbg_extern_identity_u64(22_u64)); } } - diff --git a/src/test/run-pass/extern-pub.rs b/src/test/run-pass/extern-pub.rs index 9bfeec8c7d6..f9b0ccbb548 100644 --- a/src/test/run-pass/extern-pub.rs +++ b/src/test/run-pass/extern-pub.rs @@ -6,5 +6,3 @@ extern { pub fn main() { } - - diff --git a/src/test/run-pass/fat-arrow-alt.rs b/src/test/run-pass/fat-arrow-alt.rs index 4b8b552bfae..f6b49960fad 100644 --- a/src/test/run-pass/fat-arrow-alt.rs +++ b/src/test/run-pass/fat-arrow-alt.rs @@ -23,4 +23,3 @@ pub fn main() { blue => { 3 } }); } - diff --git a/src/test/run-pass/fixed_length_copy.rs b/src/test/run-pass/fixed_length_copy.rs index 5daa525d9b1..7ee3f5173b0 100644 --- a/src/test/run-pass/fixed_length_copy.rs +++ b/src/test/run-pass/fixed_length_copy.rs @@ -10,7 +10,7 @@ // error on implicit copies to check fixed length vectors -// are implicitly copyable +// are implicitly copyable #[deny(implicit_copies)] pub fn main() { let arr = [1,2,3]; diff --git a/src/test/run-pass/float-literal-inference.rs b/src/test/run-pass/float-literal-inference.rs index 2b59d7bfcee..a5246eef0b0 100644 --- a/src/test/run-pass/float-literal-inference.rs +++ b/src/test/run-pass/float-literal-inference.rs @@ -20,4 +20,3 @@ pub fn main() { let z = S { z: 1.0 }; io::println(z.z.to_str()); } - diff --git a/src/test/run-pass/fn-pattern-expected-type-2.rs b/src/test/run-pass/fn-pattern-expected-type-2.rs index f9bf9b5915e..501bd81d558 100644 --- a/src/test/run-pass/fn-pattern-expected-type-2.rs +++ b/src/test/run-pass/fn-pattern-expected-type-2.rs @@ -15,4 +15,3 @@ pub fn main() { io::println(x.to_str()); } } - diff --git a/src/test/run-pass/fn-pattern-expected-type.rs b/src/test/run-pass/fn-pattern-expected-type.rs index dc3f33a1991..f3949a0f43b 100644 --- a/src/test/run-pass/fn-pattern-expected-type.rs +++ b/src/test/run-pass/fn-pattern-expected-type.rs @@ -15,4 +15,3 @@ pub fn main() { }; f((1, 2)); } - diff --git a/src/test/run-pass/foreign-mod-unused-const.rs b/src/test/run-pass/foreign-mod-unused-const.rs index 430da7a3f60..4909e9d7e56 100644 --- a/src/test/run-pass/foreign-mod-unused-const.rs +++ b/src/test/run-pass/foreign-mod-unused-const.rs @@ -17,4 +17,3 @@ mod foo { pub fn main() { } - diff --git a/src/test/run-pass/functional-struct-update.rs b/src/test/run-pass/functional-struct-update.rs index f1db6db417a..297b5e78a92 100644 --- a/src/test/run-pass/functional-struct-update.rs +++ b/src/test/run-pass/functional-struct-update.rs @@ -18,4 +18,3 @@ pub fn main() { let c = Foo { x: 4, .. a}; io::println(fmt!("%?", c)); } - diff --git a/src/test/run-pass/generic-ivec-leak.rs b/src/test/run-pass/generic-ivec-leak.rs index 8d9b0fa6ddb..ac6e3e1a69a 100644 --- a/src/test/run-pass/generic-ivec-leak.rs +++ b/src/test/run-pass/generic-ivec-leak.rs @@ -11,4 +11,3 @@ enum wrapper { wrapped(T), } pub fn main() { let w = wrapped(~[1, 2, 3, 4, 5]); } - diff --git a/src/test/run-pass/generic-ivec.rs b/src/test/run-pass/generic-ivec.rs index 031821d9909..2a288c8abbf 100644 --- a/src/test/run-pass/generic-ivec.rs +++ b/src/test/run-pass/generic-ivec.rs @@ -10,4 +10,3 @@ fn f(v: @T) { } pub fn main() { f(@~[1, 2, 3, 4, 5]); } - diff --git a/src/test/run-pass/generic-newtype-struct.rs b/src/test/run-pass/generic-newtype-struct.rs index 7c7d73eda10..cf4279d67b8 100644 --- a/src/test/run-pass/generic-newtype-struct.rs +++ b/src/test/run-pass/generic-newtype-struct.rs @@ -4,4 +4,3 @@ pub fn main() { let s = S(2i); io::println(s.to_str()); } - diff --git a/src/test/run-pass/generic-object.rs b/src/test/run-pass/generic-object.rs index ebfc362c72c..54ae2c58e42 100644 --- a/src/test/run-pass/generic-object.rs +++ b/src/test/run-pass/generic-object.rs @@ -27,4 +27,3 @@ pub fn main() { let y = x as @Foo; assert!(y.get() == 1); } - diff --git a/src/test/run-pass/global-scope.rs b/src/test/run-pass/global-scope.rs index 3dd912dea9a..9b292a325c0 100644 --- a/src/test/run-pass/global-scope.rs +++ b/src/test/run-pass/global-scope.rs @@ -18,4 +18,3 @@ pub mod foo { } pub fn main() { return foo::g(); } - diff --git a/src/test/run-pass/impl-privacy-xc-1.rs b/src/test/run-pass/impl-privacy-xc-1.rs index df001c7ab21..19d3caf818d 100644 --- a/src/test/run-pass/impl-privacy-xc-1.rs +++ b/src/test/run-pass/impl-privacy-xc-1.rs @@ -7,4 +7,3 @@ pub fn main() { let fish = impl_privacy_xc_1::Fish { x: 1 }; fish.swim(); } - diff --git a/src/test/run-pass/impl-privacy-xc-2.rs b/src/test/run-pass/impl-privacy-xc-2.rs index 69bd31ab766..74d9a34e161 100644 --- a/src/test/run-pass/impl-privacy-xc-2.rs +++ b/src/test/run-pass/impl-privacy-xc-2.rs @@ -8,4 +8,3 @@ pub fn main() { let fish2 = impl_privacy_xc_2::Fish { x: 2 }; io::println(if fish1.eq(&fish2) { "yes" } else { "no " }); } - diff --git a/src/test/run-pass/infinite-loops.rs b/src/test/run-pass/infinite-loops.rs index 611a4b9ccab..b2ed6d95c20 100644 --- a/src/test/run-pass/infinite-loops.rs +++ b/src/test/run-pass/infinite-loops.rs @@ -21,9 +21,9 @@ fn loopy(n: int) { loop { } } -pub fn main() { +pub fn main() { // Commenting this out, as this will hang forever otherwise. // Even after seeing the comment above, I'm not sure what the // intention of this test is. - // do spawn { loopy(5) }; + // do spawn { loopy(5) }; } diff --git a/src/test/run-pass/instantiable.rs b/src/test/run-pass/instantiable.rs index c140a66ffe4..2173bae85e1 100644 --- a/src/test/run-pass/instantiable.rs +++ b/src/test/run-pass/instantiable.rs @@ -18,4 +18,3 @@ struct X { x: uint, nxt: *foo } pub fn main() { let x = foo(X {x: 0, nxt: ptr::null()}); } - diff --git a/src/test/run-pass/int-conversion-coherence.rs b/src/test/run-pass/int-conversion-coherence.rs index 235fab107e7..ef2a84da219 100644 --- a/src/test/run-pass/int-conversion-coherence.rs +++ b/src/test/run-pass/int-conversion-coherence.rs @@ -23,4 +23,3 @@ impl foo of plus for int { fn plus() -> int { self + 10 } } pub fn main() { assert!(10.plus() == 20); } - diff --git a/src/test/run-pass/intrinsics-integer.rs b/src/test/run-pass/intrinsics-integer.rs index b96ea8cbb7b..1a0d97a5c5b 100644 --- a/src/test/run-pass/intrinsics-integer.rs +++ b/src/test/run-pass/intrinsics-integer.rs @@ -89,7 +89,7 @@ pub fn main() { assert!((cttz16(-1i16) == 0i16)); assert!((cttz32(-1i32) == 0i32)); assert!((cttz64(-1i64) == 0i64)); - + assert!((cttz8(0i8) == 8i8)); assert!((cttz16(0i16) == 16i16)); assert!((cttz32(0i32) == 32i32)); diff --git a/src/test/run-pass/intrinsics-math.rs b/src/test/run-pass/intrinsics-math.rs index 60e32a56ee5..6f9179bc89d 100644 --- a/src/test/run-pass/intrinsics-math.rs +++ b/src/test/run-pass/intrinsics-math.rs @@ -83,7 +83,7 @@ pub fn main() { assert!((log2f32(8f32).fuzzy_eq(&3f32))); assert!((log2f64(f64::consts::e).fuzzy_eq(&f64::consts::log2_e))); - + assert!((fmaf32(1.0f32, 2.0f32, 5.0f32).fuzzy_eq(&7.0f32))); assert!((fmaf64(0.0f64, -2.0f64, f64::consts::e).fuzzy_eq(&f64::consts::e))); @@ -97,7 +97,7 @@ pub fn main() { // undefined reference to llvm.ceil.f32/64 //assert!((ceilf32(-2.3f32) == -2.0f32)); //assert!((ceilf64(3.8f64) == 4.0f64)); - + // Causes linker error // undefined reference to llvm.trunc.f32/64 //assert!((truncf32(0.1f32) == 0.0f32)); diff --git a/src/test/run-pass/issue-1516.rs b/src/test/run-pass/issue-1516.rs index 33be716cc5f..fe3feeb3dbf 100644 --- a/src/test/run-pass/issue-1516.rs +++ b/src/test/run-pass/issue-1516.rs @@ -10,4 +10,3 @@ // xfail-test pub fn main() { let early_error: @fn(str) -> ! = {|msg| fail!() }; } - diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index 8a553784c5e..5b320ddc06b 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -15,7 +15,7 @@ // notes on this test case: // On Thu, Apr 18, 2013 at 6:30 PM, John Clements wrote: // the "issue-2185.rs" test was xfailed with a ref to #2263. Issue #2263 is now fixed, so I tried it again, and after adding some &self parameters, I got this error: -// +// // Running /usr/local/bin/rustc: // issue-2185.rs:24:0: 26:1 error: conflicting implementations for a trait // issue-2185.rs:24 impl iterable for @fn(&fn(uint)) { @@ -25,7 +25,7 @@ // issue-2185.rs:20 impl iterable for @fn(&fn(A)) { // issue-2185.rs:21 fn iter(&self, blk: &fn(A)) { self(blk); } // issue-2185.rs:22 } -// +// // … so it looks like it's just not possible to implement both the generic iterable and iterable for the type iterable. Is it okay if I just remove this test? // // but Niko responded: diff --git a/src/test/run-pass/issue-2216.rs b/src/test/run-pass/issue-2216.rs index 98965cb6d91..c3a2a4c0b7e 100644 --- a/src/test/run-pass/issue-2216.rs +++ b/src/test/run-pass/issue-2216.rs @@ -10,7 +10,7 @@ pub fn main() { let mut x = 0; - + 'foo: loop { 'bar: loop { 'quux: loop { diff --git a/src/test/run-pass/issue-2526-a.rs b/src/test/run-pass/issue-2526-a.rs index c91b5dd303c..39ce74947e9 100644 --- a/src/test/run-pass/issue-2526-a.rs +++ b/src/test/run-pass/issue-2526-a.rs @@ -15,4 +15,3 @@ extern mod issue_2526; use issue_2526::*; pub fn main() {} - diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs index 7125e89287c..319146d0a81 100644 --- a/src/test/run-pass/issue-2734.rs +++ b/src/test/run-pass/issue-2734.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait hax { } -impl hax for A { } +trait hax { } +impl hax for A { } fn perform_hax(x: @T) -> @hax { @x as @hax diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index ef7fd691577..77cc6b3e1b5 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -37,7 +37,7 @@ impl to_str::ToStr for square { closed_lift => { ~"L" } open_lift => { ~"O" } earth => { ~"." } - empty => { ~" " } + empty => { ~" " } } } } diff --git a/src/test/run-pass/issue-3176.rs b/src/test/run-pass/issue-3176.rs index 03b1c127c55..55d62a5bf8e 100644 --- a/src/test/run-pass/issue-3176.rs +++ b/src/test/run-pass/issue-3176.rs @@ -20,7 +20,7 @@ pub fn main() { p2.recv(); error!("sibling fails"); fail!(); - } + } let (p3,c3) = comm::stream(); c.send(c3); c2.send(()); @@ -28,7 +28,7 @@ pub fn main() { let (p, c) = comm::stream(); (p, p3).select(); c.send(()); - }; + }; error!("parent tries"); assert!(!p.recv().try_send(())); error!("all done!"); diff --git a/src/test/run-pass/issue-3250.rs b/src/test/run-pass/issue-3250.rs index a563544b5c7..0a93b89a94d 100644 --- a/src/test/run-pass/issue-3250.rs +++ b/src/test/run-pass/issue-3250.rs @@ -2,6 +2,4 @@ type t = (uint, uint); - - pub fn main() { } diff --git a/src/test/run-pass/issue-3429.rs b/src/test/run-pass/issue-3429.rs index 67877795cc0..7bfb928e86d 100644 --- a/src/test/run-pass/issue-3429.rs +++ b/src/test/run-pass/issue-3429.rs @@ -13,4 +13,3 @@ pub fn main() { let y: @fn() -> int = || x; let z = y(); } - diff --git a/src/test/run-pass/issue-3461.rs b/src/test/run-pass/issue-3461.rs index 4c4144f28e8..dae35d7237b 100644 --- a/src/test/run-pass/issue-3461.rs +++ b/src/test/run-pass/issue-3461.rs @@ -12,6 +12,6 @@ pub fn main() { fn foo() { } - + let bar: ~fn() = ~foo; } diff --git a/src/test/run-pass/issue-3556.rs b/src/test/run-pass/issue-3556.rs index 703dcd54f0a..ff2fa80102b 100644 --- a/src/test/run-pass/issue-3556.rs +++ b/src/test/run-pass/issue-3556.rs @@ -10,7 +10,7 @@ extern mod std; use core::io::WriterUtil; - + enum Token { Text(@~str), ETag(@~[~str], @~str), @@ -19,7 +19,7 @@ enum Token { IncompleteSection(@~[~str], bool, @~str, bool), Partial(@~str, @~str, @~str), } - + fn check_strs(actual: &str, expected: &str) -> bool { if actual != expected @@ -29,12 +29,12 @@ fn check_strs(actual: &str, expected: &str) -> bool } return true; } - + pub fn main() { // assert!(check_strs(fmt!("%?", Text(@~"foo")), "Text(@~\"foo\")")); // assert!(check_strs(fmt!("%?", ETag(@~[~"foo"], @~"bar")), "ETag(@~[ ~\"foo\" ], @~\"bar\")")); - + let t = Text(@~"foo"); let u = Section(@~[~"alpha"], true, @~[t], @~"foo", @~"foo", @~"foo", @~"foo", @~"foo"); let v = fmt!("%?", u); // this is the line that causes the seg fault diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index 9b7ab67c1a3..96925a97a10 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -62,7 +62,7 @@ impl Drop for AsciiArt { // It's common to define a constructor sort of function to create struct instances. // If there is a canonical constructor it is typically named the same as the type. -// Other constructor sort of functions are typically named from_foo, from_bar, etc. +// Other constructor sort of functions are typically named from_foo, from_bar, etc. fn AsciiArt(width: uint, height: uint, fill: char) -> AsciiArt { // Use an anonymous function to build a vector of vectors containing @@ -72,7 +72,7 @@ fn AsciiArt(width: uint, height: uint, fill: char) -> AsciiArt { for height.times { - let mut line = ~[]; + let mut line = ~[]; vec::grow_set(&mut line, width-1, &'.', '.'); push(line); } @@ -208,4 +208,3 @@ pub fn main() { test_add_pt(); test_shapes(); } - diff --git a/src/test/run-pass/issue-3609.rs b/src/test/run-pass/issue-3609.rs index fc6ceb4130f..6c26ac3f65e 100644 --- a/src/test/run-pass/issue-3609.rs +++ b/src/test/run-pass/issue-3609.rs @@ -24,4 +24,3 @@ fn foo(name: ~str, samples_chan: Chan) { } pub fn main() {} - diff --git a/src/test/run-pass/issue-3860.rs b/src/test/run-pass/issue-3860.rs index 46aa7187c9a..778b2b72b13 100644 --- a/src/test/run-pass/issue-3860.rs +++ b/src/test/run-pass/issue-3860.rs @@ -19,6 +19,6 @@ pub impl Foo { pub fn main() { let mut x = @mut Foo { x: 3 }; // Neither of the next two lines should cause an error - let _ = x.stuff(); + let _ = x.stuff(); x.stuff(); } diff --git a/src/test/run-pass/issue-3895.rs b/src/test/run-pass/issue-3895.rs index d3820c1e547..388e09ddb3e 100644 --- a/src/test/run-pass/issue-3895.rs +++ b/src/test/run-pass/issue-3895.rs @@ -11,7 +11,7 @@ // xfail-test pub fn main() { enum State { BadChar, BadSyntax } - + match BadChar { _ if true => BadChar, BadChar | BadSyntax => fail!() , diff --git a/src/test/run-pass/issue-3979-2.rs b/src/test/run-pass/issue-3979-2.rs index c485590f4aa..a04e3510802 100644 --- a/src/test/run-pass/issue-3979-2.rs +++ b/src/test/run-pass/issue-3979-2.rs @@ -24,4 +24,3 @@ trait C: B { } pub fn main() {} - diff --git a/src/test/run-pass/issue-4241.rs b/src/test/run-pass/issue-4241.rs index 18bc471afab..e5905e7a5be 100644 --- a/src/test/run-pass/issue-4241.rs +++ b/src/test/run-pass/issue-4241.rs @@ -55,7 +55,7 @@ priv fn parse_list(len: uint, io: @io::Reader) -> Result { priv fn chop(s: ~str) -> ~str { s.slice(0, s.len() - 1).to_owned() } - + priv fn parse_bulk(io: @io::Reader) -> Result { match int::from_str(chop(io.read_line())) { None => fail!(), diff --git a/src/test/run-pass/issue-4875.rs b/src/test/run-pass/issue-4875.rs index 51c23e76808..81947791881 100644 --- a/src/test/run-pass/issue-4875.rs +++ b/src/test/run-pass/issue-4875.rs @@ -19,4 +19,3 @@ fn foo(Foo{_}: Foo) { pub fn main() { } - diff --git a/src/test/run-pass/issue-868.rs b/src/test/run-pass/issue-868.rs index 16e8fa18c2a..2a82f559d54 100644 --- a/src/test/run-pass/issue-868.rs +++ b/src/test/run-pass/issue-868.rs @@ -22,4 +22,3 @@ pub fn main() { let _ = f(||{}); let _ = (||{}); } - diff --git a/src/test/run-pass/issue_3136_b.rs b/src/test/run-pass/issue_3136_b.rs index c5b6b6b220c..b1d28a1eb67 100644 --- a/src/test/run-pass/issue_3136_b.rs +++ b/src/test/run-pass/issue_3136_b.rs @@ -13,4 +13,3 @@ extern mod issue_3136_a; pub fn main() {} - diff --git a/src/test/run-pass/ivec-add.rs b/src/test/run-pass/ivec-add.rs index 1b9e818421e..bd58ae65651 100644 --- a/src/test/run-pass/ivec-add.rs +++ b/src/test/run-pass/ivec-add.rs @@ -21,4 +21,3 @@ pub fn main() { assert!((d[0] == 1)); assert!((d[1] == 1)); } - diff --git a/src/test/run-pass/ivec-pass-by-value.rs b/src/test/run-pass/ivec-pass-by-value.rs index 756f38196fd..3a3b5746b9d 100644 --- a/src/test/run-pass/ivec-pass-by-value.rs +++ b/src/test/run-pass/ivec-pass-by-value.rs @@ -10,4 +10,3 @@ fn f(a: ~[int]) { } pub fn main() { f(~[1, 2, 3, 4, 5]); } - diff --git a/src/test/run-pass/labeled-break.rs b/src/test/run-pass/labeled-break.rs index 06ca401a136..32cd7f0c7f8 100644 --- a/src/test/run-pass/labeled-break.rs +++ b/src/test/run-pass/labeled-break.rs @@ -18,4 +18,3 @@ pub fn main() { } } } - diff --git a/src/test/run-pass/let-assignability.rs b/src/test/run-pass/let-assignability.rs index 51fa84613ca..0afc3ee87e0 100644 --- a/src/test/run-pass/let-assignability.rs +++ b/src/test/run-pass/let-assignability.rs @@ -17,4 +17,3 @@ fn f() { pub fn main() { f(); } - diff --git a/src/test/run-pass/liveness-assign-imm-local-after-loop.rs b/src/test/run-pass/liveness-assign-imm-local-after-loop.rs index f352a2b5273..5d59c4c1471 100644 --- a/src/test/run-pass/liveness-assign-imm-local-after-loop.rs +++ b/src/test/run-pass/liveness-assign-imm-local-after-loop.rs @@ -16,5 +16,5 @@ fn test(cond: bool) { } pub fn main() { - // note: don't call test()... :) + // note: don't call test()... :) } diff --git a/src/test/run-pass/log-linearized.rs b/src/test/run-pass/log-linearized.rs index 919c53e0330..0f388489000 100644 --- a/src/test/run-pass/log-linearized.rs +++ b/src/test/run-pass/log-linearized.rs @@ -32,4 +32,3 @@ fn f() { pub fn main() { f::(); } - diff --git a/src/test/run-pass/max-min-classes.rs b/src/test/run-pass/max-min-classes.rs index 58dcb24edf9..d986d7e676a 100644 --- a/src/test/run-pass/max-min-classes.rs +++ b/src/test/run-pass/max-min-classes.rs @@ -37,4 +37,3 @@ pub fn main() { let foo = Foo(3, 20); io::println(fmt!("%d %d", foo.sum(), foo.product())); } - diff --git a/src/test/run-pass/module-qualified-struct-destructure.rs b/src/test/run-pass/module-qualified-struct-destructure.rs index 6fb6d21f13f..87c854d32be 100644 --- a/src/test/run-pass/module-qualified-struct-destructure.rs +++ b/src/test/run-pass/module-qualified-struct-destructure.rs @@ -19,4 +19,3 @@ pub fn main() { let x = m::S { x: 1, y: 2 }; let m::S { x: a, y: b } = x; } - diff --git a/src/test/run-pass/move-self.rs b/src/test/run-pass/move-self.rs index d8464695728..4ed1faf65b6 100644 --- a/src/test/run-pass/move-self.rs +++ b/src/test/run-pass/move-self.rs @@ -16,4 +16,3 @@ pub fn main() { let x = S { x: ~"Hello!" }; x.foo(); } - diff --git a/src/test/run-pass/moves-based-on-type-capture-clause.rs b/src/test/run-pass/moves-based-on-type-capture-clause.rs index 2f427ca48aa..26d4773d961 100644 --- a/src/test/run-pass/moves-based-on-type-capture-clause.rs +++ b/src/test/run-pass/moves-based-on-type-capture-clause.rs @@ -4,4 +4,3 @@ pub fn main() { io::println(x); } } - diff --git a/src/test/run-pass/multiple-trait-bounds.rs b/src/test/run-pass/multiple-trait-bounds.rs index 3c6559b9c0d..cdfa93d3094 100644 --- a/src/test/run-pass/multiple-trait-bounds.rs +++ b/src/test/run-pass/multiple-trait-bounds.rs @@ -4,4 +4,3 @@ fn f(_: T) { pub fn main() { f(3); } - diff --git a/src/test/run-pass/mut-vstore-expr.rs b/src/test/run-pass/mut-vstore-expr.rs index 0ababc43c3f..fa6dde5b3ef 100644 --- a/src/test/run-pass/mut-vstore-expr.rs +++ b/src/test/run-pass/mut-vstore-expr.rs @@ -11,4 +11,3 @@ pub fn main() { let x: &mut [int] = &mut [ 1, 2, 3 ]; } - diff --git a/src/test/run-pass/nested-class.rs b/src/test/run-pass/nested-class.rs index 44348223b60..83820f87d50 100644 --- a/src/test/run-pass/nested-class.rs +++ b/src/test/run-pass/nested-class.rs @@ -9,14 +9,13 @@ // except according to those terms. pub fn main() { - - struct b { - i: int, - } + struct b { + i: int, + } - pub impl b { - fn do_stuff(&self) -> int { return 37; } - } + pub impl b { + fn do_stuff(&self) -> int { return 37; } + } fn b(i:int) -> b { b { @@ -24,10 +23,9 @@ pub fn main() { } } - // fn b(x:int) -> int { fail!(); } + // fn b(x:int) -> int { fail!(); } - let z = b(42); - assert!((z.i == 42)); - assert!((z.do_stuff() == 37)); - + let z = b(42); + assert!((z.i == 42)); + assert!((z.do_stuff() == 37)); } diff --git a/src/test/run-pass/new-impl-syntax.rs b/src/test/run-pass/new-impl-syntax.rs index 12b41fc9148..2603353f0cf 100644 --- a/src/test/run-pass/new-impl-syntax.rs +++ b/src/test/run-pass/new-impl-syntax.rs @@ -23,4 +23,3 @@ pub fn main() { io::println(Thingy { x: 1, y: 2 }.to_str()); io::println(PolymorphicThingy { x: Thingy { x: 1, y: 2 } }.to_str()); } - diff --git a/src/test/run-pass/new-import-syntax.rs b/src/test/run-pass/new-import-syntax.rs index 267f365c713..1390ae5f7eb 100644 --- a/src/test/run-pass/new-import-syntax.rs +++ b/src/test/run-pass/new-import-syntax.rs @@ -13,4 +13,3 @@ use core::io::println; pub fn main() { println("Hello world!"); } - diff --git a/src/test/run-pass/new-style-constants.rs b/src/test/run-pass/new-style-constants.rs index 9a319ea6a5c..6fe4a88d071 100644 --- a/src/test/run-pass/new-style-constants.rs +++ b/src/test/run-pass/new-style-constants.rs @@ -15,4 +15,3 @@ static FOO: int = 3; pub fn main() { println(fmt!("%d", FOO)); } - diff --git a/src/test/run-pass/new-style-fixed-length-vec.rs b/src/test/run-pass/new-style-fixed-length-vec.rs index 5d37a42af42..6eea23f6b2b 100644 --- a/src/test/run-pass/new-style-fixed-length-vec.rs +++ b/src/test/run-pass/new-style-fixed-length-vec.rs @@ -15,6 +15,3 @@ static FOO: [int, ..3] = [1, 2, 3]; pub fn main() { println(fmt!("%d %d %d", FOO[0], FOO[1], FOO[2])); } - - - diff --git a/src/test/run-pass/new-vstore-mut-box-syntax.rs b/src/test/run-pass/new-vstore-mut-box-syntax.rs index 971e870d1f8..63569c71982 100644 --- a/src/test/run-pass/new-vstore-mut-box-syntax.rs +++ b/src/test/run-pass/new-vstore-mut-box-syntax.rs @@ -12,4 +12,3 @@ pub fn main() { let x: @mut [int] = @mut [ 1, 2, 3 ]; } - diff --git a/src/test/run-pass/newtype-struct-with-dtor.rs b/src/test/run-pass/newtype-struct-with-dtor.rs index b33bfa0388a..eb3b74553b7 100644 --- a/src/test/run-pass/newtype-struct-with-dtor.rs +++ b/src/test/run-pass/newtype-struct-with-dtor.rs @@ -13,5 +13,3 @@ impl Drop for Fd { pub fn main() { } - - diff --git a/src/test/run-pass/newtype-struct-xc-2.rs b/src/test/run-pass/newtype-struct-xc-2.rs index 1fca01f7373..cedf1d42c3d 100644 --- a/src/test/run-pass/newtype-struct-xc-2.rs +++ b/src/test/run-pass/newtype-struct-xc-2.rs @@ -11,4 +11,3 @@ fn f() -> Au { pub fn main() { let _ = f(); } - diff --git a/src/test/run-pass/newtype-struct-xc.rs b/src/test/run-pass/newtype-struct-xc.rs index 49ce618e37b..2280b335f3f 100644 --- a/src/test/run-pass/newtype-struct-xc.rs +++ b/src/test/run-pass/newtype-struct-xc.rs @@ -6,4 +6,3 @@ extern mod newtype_struct_xc; pub fn main() { let _ = newtype_struct_xc::Au(2); } - diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index 0c4d297403c..206381bcef7 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -20,7 +20,7 @@ use core::{option, cast}; enum E { Thing(int, T), Nothing((), ((), ()), [i8, ..0]) } impl E { - fn is_none(&self) -> bool { + fn is_none(&self) -> bool { match *self { Thing(*) => false, Nothing(*) => true diff --git a/src/test/run-pass/one-tuple.rs b/src/test/run-pass/one-tuple.rs index 2efa0b98b6a..eb32e7cda1a 100644 --- a/src/test/run-pass/one-tuple.rs +++ b/src/test/run-pass/one-tuple.rs @@ -21,4 +21,3 @@ pub fn main() { let (y,) = x; assert!(y == 'd'); } - diff --git a/src/test/run-pass/pattern-in-closure.rs b/src/test/run-pass/pattern-in-closure.rs index 7194fca519b..08c749235c2 100644 --- a/src/test/run-pass/pattern-in-closure.rs +++ b/src/test/run-pass/pattern-in-closure.rs @@ -19,4 +19,3 @@ pub fn main() { f((2, 3)); g(Foo { x: 1, y: 2 }); } - diff --git a/src/test/run-pass/pipe-detect-term.rs b/src/test/run-pass/pipe-detect-term.rs index bd0ffa64590..55e43075204 100644 --- a/src/test/run-pass/pipe-detect-term.rs +++ b/src/test/run-pass/pipe-detect-term.rs @@ -29,7 +29,7 @@ proto! oneshot ( pub fn main() { let iotask = &uv::global_loop::get(); - + let (chan, port) = oneshot::init(); let port = Cell(port); do spawn { @@ -48,7 +48,7 @@ pub fn main() { fn failtest() { let (c, p) = oneshot::init(); - do task::spawn_with(c) |_c| { + do task::spawn_with(c) |_c| { fail!(); } diff --git a/src/test/run-pass/pipe-pingpong-bounded.rs b/src/test/run-pass/pipe-pingpong-bounded.rs index 6d82663d195..69d87804b42 100644 --- a/src/test/run-pass/pipe-pingpong-bounded.rs +++ b/src/test/run-pass/pipe-pingpong-bounded.rs @@ -99,7 +99,7 @@ mod test { let pong(_chan) = recv(chan); error!("Received pong"); } - + pub fn server(+chan: ::pingpong::server::ping) { use pingpong::server; diff --git a/src/test/run-pass/pipe-pingpong-proto.rs b/src/test/run-pass/pipe-pingpong-proto.rs index 65a5672941f..d1198f3611d 100644 --- a/src/test/run-pass/pipe-pingpong-proto.rs +++ b/src/test/run-pass/pipe-pingpong-proto.rs @@ -37,7 +37,7 @@ mod test { let pong(_chan) = recv(chan); error!(~"Received pong"); } - + pub fn server(+chan: ::pingpong::server::ping) { use pingpong::server; diff --git a/src/test/run-pass/pipe-select.rs b/src/test/run-pass/pipe-select.rs index 12d60c9d6ab..8782f6f6ebd 100644 --- a/src/test/run-pass/pipe-select.rs +++ b/src/test/run-pass/pipe-select.rs @@ -55,8 +55,8 @@ pub fn main() { use stream::client::*; let iotask = &uv::global_loop::get(); - - let c = spawn_service(stream::init, |p| { + + let c = spawn_service(stream::init, |p| { error!("waiting for pipes"); let stream::send(x, p) = recv(p); error!("got pipes"); @@ -86,7 +86,7 @@ pub fn main() { let (_c2, p2) = oneshot::init(); let c = send(c, (p1, p2)); - + sleep(iotask, 100); signal(c1); diff --git a/src/test/run-pass/pipe-sleep.rs b/src/test/run-pass/pipe-sleep.rs index 86ffc96e89a..da49a4303a6 100644 --- a/src/test/run-pass/pipe-sleep.rs +++ b/src/test/run-pass/pipe-sleep.rs @@ -55,6 +55,6 @@ pub fn main() { let iotask = &uv::global_loop::get(); sleep(iotask, 500); - + signal(c); } diff --git a/src/test/run-pass/pub-use-xcrate.rs b/src/test/run-pass/pub-use-xcrate.rs index 03004e5e475..74ae81e63e2 100644 --- a/src/test/run-pass/pub-use-xcrate.rs +++ b/src/test/run-pass/pub-use-xcrate.rs @@ -21,4 +21,3 @@ pub fn main() { name: 0 }; } - diff --git a/src/test/run-pass/pub_use_mods_xcrate_exe.rs b/src/test/run-pass/pub_use_mods_xcrate_exe.rs index 1d60cab3a82..953a99e1fd5 100644 --- a/src/test/run-pass/pub_use_mods_xcrate_exe.rs +++ b/src/test/run-pass/pub_use_mods_xcrate_exe.rs @@ -15,4 +15,3 @@ extern mod pub_use_mods_xcrate; use pub_use_mods_xcrate::a::c; pub fn main(){} - diff --git a/src/test/run-pass/reexport-star.rs b/src/test/run-pass/reexport-star.rs index 3b9fe688d4d..3cc250b1707 100644 --- a/src/test/run-pass/reexport-star.rs +++ b/src/test/run-pass/reexport-star.rs @@ -25,4 +25,3 @@ pub fn main() { b::f(); b::g(); } - diff --git a/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs b/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs index 1fb9c126e74..7efe62236f3 100644 --- a/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs +++ b/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs @@ -26,4 +26,3 @@ fn get_x<'r>(x: &'r Character) -> &'r int { pub fn main() { } - diff --git a/src/test/run-pass/regions-addr-of-ret.rs b/src/test/run-pass/regions-addr-of-ret.rs index a9c65d01295..9e19618f332 100644 --- a/src/test/run-pass/regions-addr-of-ret.rs +++ b/src/test/run-pass/regions-addr-of-ret.rs @@ -16,4 +16,3 @@ pub fn main() { let three = &3; error!(fmt!("%d", *f(three))); } - diff --git a/src/test/run-pass/regions-fn-subtyping-2.rs b/src/test/run-pass/regions-fn-subtyping-2.rs index a660b9c9ee2..ef8d9970c2b 100644 --- a/src/test/run-pass/regions-fn-subtyping-2.rs +++ b/src/test/run-pass/regions-fn-subtyping-2.rs @@ -19,10 +19,8 @@ fn has_same_region(f: &fn<'a>(x: &'a int, g: &fn(y: &'a int))) { wants_same_region(f); } -fn wants_same_region(_f: &fn<'b>(x: &'b int, g: &fn(y: &'b int))) { +fn wants_same_region(_f: &fn<'b>(x: &'b int, g: &fn(y: &'b int))) { } pub fn main() { } - - diff --git a/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs b/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs index ee2682ff4ab..39da08de6df 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs @@ -13,15 +13,15 @@ pub fn main() { for uint::range(0, 3) |i| { // ensure that the borrow in this alt - // does not inferfere with the swap - // below. note that it would it you - // naively borrowed &x for the lifetime - // of the variable x, as we once did + // does not inferfere with the swap + // below. note that it would it you + // naively borrowed &x for the lifetime + // of the variable x, as we once did match i { - i => { - let y = &x; - assert!(i < *y); - } + i => { + let y = &x; + assert!(i < *y); + } } let mut y = 4; y <-> x; diff --git a/src/test/run-pass/regions-infer-borrow-scope-view.rs b/src/test/run-pass/regions-infer-borrow-scope-view.rs index 9358ea8a777..8f7452f2d06 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-view.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-view.rs @@ -16,4 +16,3 @@ pub fn main() { let y = view(x); assert!((v[0] == x[0]) && (v[0] == y[0])); } - diff --git a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs index 08c54c790b1..73535f52043 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs @@ -15,6 +15,6 @@ pub fn main() { loop { let y = borrow(x); assert!(*x == *y); - break; + break; } } diff --git a/src/test/run-pass/regions-infer-borrow-scope.rs b/src/test/run-pass/regions-infer-borrow-scope.rs index e06a2fea1c1..61b9000aea3 100644 --- a/src/test/run-pass/regions-infer-borrow-scope.rs +++ b/src/test/run-pass/regions-infer-borrow-scope.rs @@ -19,4 +19,3 @@ pub fn main() { let xc = x_coord(p); assert!(*xc == 3); } - diff --git a/src/test/run-pass/regions-mock-trans-impls.rs b/src/test/run-pass/regions-mock-trans-impls.rs index e9163505748..d54aae7bb63 100644 --- a/src/test/run-pass/regions-mock-trans-impls.rs +++ b/src/test/run-pass/regions-mock-trans-impls.rs @@ -52,4 +52,3 @@ pub fn main() { let mut ccx = Ccx { x: 0 }; f(&mut ccx); } - diff --git a/src/test/run-pass/regions-mock-trans.rs b/src/test/run-pass/regions-mock-trans.rs index c46e41ab0eb..0ea6f852a89 100644 --- a/src/test/run-pass/regions-mock-trans.rs +++ b/src/test/run-pass/regions-mock-trans.rs @@ -52,4 +52,3 @@ pub fn main() { let ccx = Ccx { x: 0 }; f(&ccx); } - diff --git a/src/test/run-pass/regions-self-impls.rs b/src/test/run-pass/regions-self-impls.rs index 2f4eefe5243..c43fd0db566 100644 --- a/src/test/run-pass/regions-self-impls.rs +++ b/src/test/run-pass/regions-self-impls.rs @@ -25,4 +25,3 @@ pub fn main() { debug!(*clam.get_chowder()); clam.get_chowder(); } - diff --git a/src/test/run-pass/regions-self-in-enums.rs b/src/test/run-pass/regions-self-in-enums.rs index 78045e5e5d4..5f8b9ee3332 100644 --- a/src/test/run-pass/regions-self-in-enums.rs +++ b/src/test/run-pass/regions-self-in-enums.rs @@ -21,4 +21,3 @@ pub fn main() { } debug!(*z); } - diff --git a/src/test/run-pass/regions-simple.rs b/src/test/run-pass/regions-simple.rs index f7a50e6b114..436fede4dc1 100644 --- a/src/test/run-pass/regions-simple.rs +++ b/src/test/run-pass/regions-simple.rs @@ -14,5 +14,3 @@ pub fn main() { *y = 5; debug!(*y); } - - diff --git a/src/test/run-pass/repeated-vector-syntax.rs b/src/test/run-pass/repeated-vector-syntax.rs index a22384a6b53..f3d6c1640d8 100644 --- a/src/test/run-pass/repeated-vector-syntax.rs +++ b/src/test/run-pass/repeated-vector-syntax.rs @@ -21,4 +21,3 @@ pub fn main() { error!("%?", x); error!("%?", y); } - diff --git a/src/test/run-pass/resource-cycle.rs b/src/test/run-pass/resource-cycle.rs index fdb8c2a496c..f498553834a 100644 --- a/src/test/run-pass/resource-cycle.rs +++ b/src/test/run-pass/resource-cycle.rs @@ -57,7 +57,7 @@ pub fn main() { debug!("r = %x", cast::transmute::<*r, uint>(&rs)); rs } }); - + debug!("x1 = %x, x1.r = %x", cast::transmute::<@mut t, uint>(x1), cast::transmute::<*r, uint>(&x1.r)); @@ -70,7 +70,7 @@ pub fn main() { rs } }); - + debug!("x2 = %x, x2.r = %x", cast::transmute::<@mut t, uint>(x2), cast::transmute::<*r, uint>(&(x2.r))); diff --git a/src/test/run-pass/resource-cycle3.rs b/src/test/run-pass/resource-cycle3.rs index 0d699a6e49b..ef713724778 100644 --- a/src/test/run-pass/resource-cycle3.rs +++ b/src/test/run-pass/resource-cycle3.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// same as resource-cycle2, but be sure to give r multiple fields... +// same as resource-cycle2, but be sure to give r multiple fields... // Don't leak the unique pointers @@ -50,7 +50,7 @@ struct Node { r: R } -pub fn main() { +pub fn main() { unsafe { let i1 = ~0xA; let i1p = cast::transmute_copy(&i1); diff --git a/src/test/run-pass/self-type-param.rs b/src/test/run-pass/self-type-param.rs index 0af19796804..d90ec51bedf 100644 --- a/src/test/run-pass/self-type-param.rs +++ b/src/test/run-pass/self-type-param.rs @@ -13,4 +13,3 @@ impl MyTrait for S { } pub fn main() {} - diff --git a/src/test/run-pass/static-methods-in-traits.rs b/src/test/run-pass/static-methods-in-traits.rs index d171434aa48..42d0f02d642 100644 --- a/src/test/run-pass/static-methods-in-traits.rs +++ b/src/test/run-pass/static-methods-in-traits.rs @@ -9,27 +9,26 @@ // except according to those terms. mod a { - pub trait Foo { - pub fn foo() -> Self; - } + pub trait Foo { + pub fn foo() -> Self; + } - impl Foo for int { - pub fn foo() -> int { - 3 - } - } - - impl Foo for uint { - pub fn foo() -> uint { - 5u - } - } + impl Foo for int { + pub fn foo() -> int { + 3 + } + } + + impl Foo for uint { + pub fn foo() -> uint { + 5u + } + } } pub fn main() { - let x: int = a::Foo::foo(); - let y: uint = a::Foo::foo(); - assert!(x == 3); - assert!(y == 5); + let x: int = a::Foo::foo(); + let y: uint = a::Foo::foo(); + assert!(x == 3); + assert!(y == 5); } - diff --git a/src/test/run-pass/struct-deref.rs b/src/test/run-pass/struct-deref.rs index f71bc06a1cf..a52a2851689 100644 --- a/src/test/run-pass/struct-deref.rs +++ b/src/test/run-pass/struct-deref.rs @@ -14,4 +14,3 @@ pub fn main() { let x: Foo = Foo(2); assert!(*x == 2); } - diff --git a/src/test/run-pass/struct-field-assignability.rs b/src/test/run-pass/struct-field-assignability.rs index 1e13c7b86bf..0aca1a3d05f 100644 --- a/src/test/run-pass/struct-field-assignability.rs +++ b/src/test/run-pass/struct-field-assignability.rs @@ -6,4 +6,3 @@ pub fn main() { let f = Foo { x: @3 }; assert!(*f.x == 3); } - diff --git a/src/test/run-pass/struct-like-variant-construct.rs b/src/test/run-pass/struct-like-variant-construct.rs index 0d14d90c1f1..bc2dce680c9 100644 --- a/src/test/run-pass/struct-like-variant-construct.rs +++ b/src/test/run-pass/struct-like-variant-construct.rs @@ -22,4 +22,3 @@ enum Foo { pub fn main() { let x = Bar { a: 2, b: 3 }; } - diff --git a/src/test/run-pass/struct-like-variant-match.rs b/src/test/run-pass/struct-like-variant-match.rs index 3158d2836dd..64a75ddab22 100644 --- a/src/test/run-pass/struct-like-variant-match.rs +++ b/src/test/run-pass/struct-like-variant-match.rs @@ -38,4 +38,3 @@ pub fn main() { let y = Baz { x: 1.0, y: 2.0 }; f(&y); } - diff --git a/src/test/run-pass/struct-pattern-matching.rs b/src/test/run-pass/struct-pattern-matching.rs index 1d7bcb2585f..1bda2d2412d 100644 --- a/src/test/run-pass/struct-pattern-matching.rs +++ b/src/test/run-pass/struct-pattern-matching.rs @@ -19,6 +19,3 @@ pub fn main() { Foo { x: x, y: y } => io::println(fmt!("yes, %d, %d", x, y)) } } - - - diff --git a/src/test/run-pass/super.rs b/src/test/run-pass/super.rs index 2fe0696b2f2..b5eb6e85045 100644 --- a/src/test/run-pass/super.rs +++ b/src/test/run-pass/super.rs @@ -9,4 +9,3 @@ pub mod a { pub fn main() { } - diff --git a/src/test/run-pass/tag-disr-val-shape.rs b/src/test/run-pass/tag-disr-val-shape.rs index 50ab17fdeea..dd78dff0d6e 100644 --- a/src/test/run-pass/tag-disr-val-shape.rs +++ b/src/test/run-pass/tag-disr-val-shape.rs @@ -23,4 +23,3 @@ pub fn main() { assert!(~"green" == fmt!("%?", green)); assert!(~"white" == fmt!("%?", white)); } - diff --git a/src/test/run-pass/tag-variant-disr-val.rs b/src/test/run-pass/tag-variant-disr-val.rs index 0806f1ea92a..d4eadd366de 100644 --- a/src/test/run-pass/tag-variant-disr-val.rs +++ b/src/test/run-pass/tag-variant-disr-val.rs @@ -69,5 +69,3 @@ fn get_color_if(color: color) -> ~str { else if color == orange {~"orange"} else {~"unknown"} } - - diff --git a/src/test/run-pass/threads.rs b/src/test/run-pass/threads.rs index f736ded3db2..288a23b855b 100644 --- a/src/test/run-pass/threads.rs +++ b/src/test/run-pass/threads.rs @@ -19,4 +19,3 @@ pub fn main() { } fn child(&&x: int) { debug!(x); } - diff --git a/src/test/run-pass/trait-composition-trivial.rs b/src/test/run-pass/trait-composition-trivial.rs index 328c0b6888c..de130bf1b41 100644 --- a/src/test/run-pass/trait-composition-trivial.rs +++ b/src/test/run-pass/trait-composition-trivial.rs @@ -17,5 +17,3 @@ trait Bar : Foo { } pub fn main() {} - - diff --git a/src/test/run-pass/trait-inheritance-auto-xc-2.rs b/src/test/run-pass/trait-inheritance-auto-xc-2.rs index 446dd4b3d8e..996f55d4019 100644 --- a/src/test/run-pass/trait-inheritance-auto-xc-2.rs +++ b/src/test/run-pass/trait-inheritance-auto-xc-2.rs @@ -30,4 +30,3 @@ pub fn main() { let a = &A { x: 3 }; f(a); } - diff --git a/src/test/run-pass/trait-inheritance-auto-xc.rs b/src/test/run-pass/trait-inheritance-auto-xc.rs index 03287809a9b..3af8d606bf4 100644 --- a/src/test/run-pass/trait-inheritance-auto-xc.rs +++ b/src/test/run-pass/trait-inheritance-auto-xc.rs @@ -31,4 +31,3 @@ pub fn main() { let a = &A { x: 3 }; f(a); } - diff --git a/src/test/run-pass/trait-inheritance-auto.rs b/src/test/run-pass/trait-inheritance-auto.rs index b74064591d3..fb97dd5e774 100644 --- a/src/test/run-pass/trait-inheritance-auto.rs +++ b/src/test/run-pass/trait-inheritance-auto.rs @@ -34,4 +34,3 @@ pub fn main() { let a = &A { x: 3 }; f(a); } - diff --git a/src/test/run-pass/trait-inheritance-call-bound-inherited.rs b/src/test/run-pass/trait-inheritance-call-bound-inherited.rs index 26b96f93326..805c9655d81 100644 --- a/src/test/run-pass/trait-inheritance-call-bound-inherited.rs +++ b/src/test/run-pass/trait-inheritance-call-bound-inherited.rs @@ -25,4 +25,3 @@ pub fn main() { let a = &A { x: 3 }; assert!(gg(a) == 10); } - diff --git a/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs b/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs index 5e612bbca64..0b35fd90bbd 100644 --- a/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs +++ b/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs @@ -28,4 +28,3 @@ pub fn main() { let a = &A { x: 3 }; assert!(gg(a) == 10); } - diff --git a/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs b/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs index 6efd854e01b..df9cc4fb8b6 100644 --- a/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs +++ b/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs @@ -38,4 +38,3 @@ pub fn main() { assert!(afoo.f() == 10); assert!(abar.g() == 20); } - diff --git a/src/test/run-pass/trait-inheritance-cast.rs b/src/test/run-pass/trait-inheritance-cast.rs index 02382797797..75c121e10b0 100644 --- a/src/test/run-pass/trait-inheritance-cast.rs +++ b/src/test/run-pass/trait-inheritance-cast.rs @@ -40,4 +40,3 @@ pub fn main() { assert!(abar.g() == 20); assert!(abar.f() == 10); } - diff --git a/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs b/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs index 3c1bf2035aa..976c9a02439 100644 --- a/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs +++ b/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs @@ -27,4 +27,3 @@ pub fn main() { let a = &aux::A { x: 3 }; assert!(a.g() == 10); } - diff --git a/src/test/run-pass/trait-inheritance-cross-trait-call.rs b/src/test/run-pass/trait-inheritance-cross-trait-call.rs index 997f13d0e5e..20dac16b492 100644 --- a/src/test/run-pass/trait-inheritance-cross-trait-call.rs +++ b/src/test/run-pass/trait-inheritance-cross-trait-call.rs @@ -24,4 +24,3 @@ pub fn main() { let a = &A { x: 3 }; assert!(a.g() == 10); } - diff --git a/src/test/run-pass/trait-inheritance-overloading-simple.rs b/src/test/run-pass/trait-inheritance-overloading-simple.rs index 711571e8c64..3a1c3716df4 100644 --- a/src/test/run-pass/trait-inheritance-overloading-simple.rs +++ b/src/test/run-pass/trait-inheritance-overloading-simple.rs @@ -32,4 +32,3 @@ pub fn main() { assert!(x != y); assert!(x == z); } - diff --git a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs index 9f745db7638..d89852e2b05 100644 --- a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs +++ b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs @@ -27,4 +27,3 @@ pub fn main() { assert!(b == mi(-2)); assert!(c == mi(15)); } - diff --git a/src/test/run-pass/trait-inheritance-overloading.rs b/src/test/run-pass/trait-inheritance-overloading.rs index 5b68aff269e..e58ec24f1b7 100644 --- a/src/test/run-pass/trait-inheritance-overloading.rs +++ b/src/test/run-pass/trait-inheritance-overloading.rs @@ -46,4 +46,3 @@ pub fn main() { assert!(b == mi(-2)); assert!(c == mi(15)); } - diff --git a/src/test/run-pass/trait-inheritance-self.rs b/src/test/run-pass/trait-inheritance-self.rs index 02ed518ff65..5eb87b7a96b 100644 --- a/src/test/run-pass/trait-inheritance-self.rs +++ b/src/test/run-pass/trait-inheritance-self.rs @@ -26,4 +26,3 @@ pub fn main() { let s = S { x: 1 }; s.g(); } - diff --git a/src/test/run-pass/trait-inheritance-simple.rs b/src/test/run-pass/trait-inheritance-simple.rs index 779dfb65944..2da1f02779e 100644 --- a/src/test/run-pass/trait-inheritance-simple.rs +++ b/src/test/run-pass/trait-inheritance-simple.rs @@ -29,4 +29,3 @@ pub fn main() { assert!(ff(a) == 10); assert!(gg(a) == 20); } - diff --git a/src/test/run-pass/trait-inheritance-subst.rs b/src/test/run-pass/trait-inheritance-subst.rs index 22efdabec83..479f293a396 100644 --- a/src/test/run-pass/trait-inheritance-subst.rs +++ b/src/test/run-pass/trait-inheritance-subst.rs @@ -33,4 +33,3 @@ pub fn main() { let z = f(x, y); assert!(z.val == 8) } - diff --git a/src/test/run-pass/trait-inheritance-subst2.rs b/src/test/run-pass/trait-inheritance-subst2.rs index 4f3b808f8eb..5d1741a45f3 100644 --- a/src/test/run-pass/trait-inheritance-subst2.rs +++ b/src/test/run-pass/trait-inheritance-subst2.rs @@ -43,4 +43,3 @@ pub fn main() { let z = f(x, y); assert!(z.val == 13); } - diff --git a/src/test/run-pass/trait-inheritance2.rs b/src/test/run-pass/trait-inheritance2.rs index 5d6913d4146..adb7ab018d6 100644 --- a/src/test/run-pass/trait-inheritance2.rs +++ b/src/test/run-pass/trait-inheritance2.rs @@ -31,4 +31,3 @@ pub fn main() { let a = &A { x: 3 }; f(a); } - diff --git a/src/test/run-pass/trait-region-pointer-simple.rs b/src/test/run-pass/trait-region-pointer-simple.rs index 285b0e65daf..a2742828a1b 100644 --- a/src/test/run-pass/trait-region-pointer-simple.rs +++ b/src/test/run-pass/trait-region-pointer-simple.rs @@ -28,4 +28,3 @@ pub fn main() { let b = (&a) as &Foo; assert!(b.f() == 3); } - diff --git a/src/test/run-pass/trait-static-method-overwriting.rs b/src/test/run-pass/trait-static-method-overwriting.rs index a8a579422a3..86ebc5356eb 100644 --- a/src/test/run-pass/trait-static-method-overwriting.rs +++ b/src/test/run-pass/trait-static-method-overwriting.rs @@ -21,7 +21,7 @@ mod base { impl ::base::HasNew for Foo { fn new() -> Foo { - unsafe { io::println("Foo"); } + unsafe { io::println("Foo"); } Foo { dummy: () } } } @@ -32,7 +32,7 @@ mod base { impl ::base::HasNew for Bar { fn new() -> Bar { - unsafe { io::println("Bar"); } + unsafe { io::println("Bar"); } Bar { dummy: () } } } @@ -40,5 +40,5 @@ mod base { pub fn main() { let f: base::Foo = base::HasNew::new::(); - let b: base::Bar = base::HasNew::new::(); + let b: base::Bar = base::HasNew::new::(); } diff --git a/src/test/run-pass/traits.rs b/src/test/run-pass/traits.rs index c4ec15ff273..ba3e8e082b3 100644 --- a/src/test/run-pass/traits.rs +++ b/src/test/run-pass/traits.rs @@ -53,4 +53,3 @@ impl Ord for int { self == (*a) } } - diff --git a/src/test/run-pass/tuple-struct-construct.rs b/src/test/run-pass/tuple-struct-construct.rs index ea410093c4b..c5ea3e14d39 100644 --- a/src/test/run-pass/tuple-struct-construct.rs +++ b/src/test/run-pass/tuple-struct-construct.rs @@ -14,4 +14,3 @@ pub fn main() { let x = Foo(1, 2); io::println(fmt!("%?", x)); } - diff --git a/src/test/run-pass/tuple-struct-destructuring.rs b/src/test/run-pass/tuple-struct-destructuring.rs index 7e6b9570def..1cb944da040 100644 --- a/src/test/run-pass/tuple-struct-destructuring.rs +++ b/src/test/run-pass/tuple-struct-destructuring.rs @@ -17,4 +17,3 @@ pub fn main() { assert!(y == 1); assert!(z == 2); } - diff --git a/src/test/run-pass/tuple-struct-matching.rs b/src/test/run-pass/tuple-struct-matching.rs index 405616f9b1f..e3cbd1201c1 100644 --- a/src/test/run-pass/tuple-struct-matching.rs +++ b/src/test/run-pass/tuple-struct-matching.rs @@ -20,4 +20,3 @@ pub fn main() { } } } - diff --git a/src/test/run-pass/tuple-struct-trivial.rs b/src/test/run-pass/tuple-struct-trivial.rs index 8ddc04a186f..c6c32cf49c6 100644 --- a/src/test/run-pass/tuple-struct-trivial.rs +++ b/src/test/run-pass/tuple-struct-trivial.rs @@ -14,4 +14,3 @@ struct Foo(int, int, int); pub fn main() { } - diff --git a/src/test/run-pass/typeclasses-eq-example-static.rs b/src/test/run-pass/typeclasses-eq-example-static.rs index 9c5f8c3218a..c14dd0471f9 100644 --- a/src/test/run-pass/typeclasses-eq-example-static.rs +++ b/src/test/run-pass/typeclasses-eq-example-static.rs @@ -38,7 +38,7 @@ impl Equal for ColorTree { fn isEq(a: ColorTree, b: ColorTree) -> bool { match (a, b) { (leaf(x), leaf(y)) => { Equal::isEq(x, y) } - (branch(l1, r1), branch(l2, r2)) => { + (branch(l1, r1), branch(l2, r2)) => { Equal::isEq(*l1, *l2) && Equal::isEq(*r1, *r2) } _ => { false } diff --git a/src/test/run-pass/typeclasses-eq-example.rs b/src/test/run-pass/typeclasses-eq-example.rs index 51c19cef50a..18a68bc1c34 100644 --- a/src/test/run-pass/typeclasses-eq-example.rs +++ b/src/test/run-pass/typeclasses-eq-example.rs @@ -37,7 +37,7 @@ impl Equal for ColorTree { fn isEq(&self, a: ColorTree) -> bool { match (*self, a) { (leaf(x), leaf(y)) => { x.isEq(y) } - (branch(l1, r1), branch(l2, r2)) => { + (branch(l1, r1), branch(l2, r2)) => { (*l1).isEq(*l2) && (*r1).isEq(*r2) } _ => { false } diff --git a/src/test/run-pass/unique-object.rs b/src/test/run-pass/unique-object.rs index 1cf4cf09b81..5e0954969ef 100644 --- a/src/test/run-pass/unique-object.rs +++ b/src/test/run-pass/unique-object.rs @@ -27,4 +27,3 @@ pub fn main() { let y = x as ~Foo; assert!(y.f() == 10); } - diff --git a/src/test/run-pass/unit-like-struct.rs b/src/test/run-pass/unit-like-struct.rs index 837bfa50b8e..1b81015b029 100644 --- a/src/test/run-pass/unit-like-struct.rs +++ b/src/test/run-pass/unit-like-struct.rs @@ -16,4 +16,3 @@ pub fn main() { Foo => { io::println("hi"); } } } - diff --git a/src/test/run-pass/unsafe-pointer-assignability.rs b/src/test/run-pass/unsafe-pointer-assignability.rs index 05c9cd8a574..f19558fbb1d 100644 --- a/src/test/run-pass/unsafe-pointer-assignability.rs +++ b/src/test/run-pass/unsafe-pointer-assignability.rs @@ -17,6 +17,3 @@ fn f(x: *int) { pub fn main() { f(&3); } - - - diff --git a/src/test/run-pass/vec-fixed-length.rs b/src/test/run-pass/vec-fixed-length.rs index 5ce1b04dbe9..2c4add63e8b 100644 --- a/src/test/run-pass/vec-fixed-length.rs +++ b/src/test/run-pass/vec-fixed-length.rs @@ -12,4 +12,3 @@ pub fn main() { let x: [int, ..4] = [1, 2, 3, 4]; io::println(fmt!("%d", x[0])); } - -- cgit 1.4.1-3-g733a5