From 6a0720b439a4692f55d3b9951e74d452a7aef802 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 7 Aug 2012 18:10:06 -0700 Subject: [PATCH] Convert impls to new syntax --- src/compiletest/errors.rs | 2 - src/compiletest/header.rs | 1 - src/compiletest/procsrv.rs | 2 +- src/libcore/arc.rs | 5 +- src/libcore/at_vec.rs | 4 +- src/libcore/comm.rs | 4 +- src/libcore/core.rs | 24 +------- src/libcore/dlist.rs | 12 ++-- src/libcore/dvec.rs | 11 ++-- src/libcore/f32.rs | 2 +- src/libcore/f64.rs | 2 +- src/libcore/float.rs | 2 +- src/libcore/future.rs | 2 +- src/libcore/int-template.rs | 10 ++-- src/libcore/io.rs | 18 +++--- src/libcore/iter-trait.rs | 6 +- src/libcore/iter-trait/dlist.rs | 3 - src/libcore/iter-trait/dvec.rs | 2 - src/libcore/option.rs | 4 +- src/libcore/pipes.rs | 17 +++--- src/libcore/ptr.rs | 2 +- src/libcore/rand.rs | 6 +- src/libcore/result.rs | 8 +-- src/libcore/run.rs | 3 +- src/libcore/send_map.rs | 20 +++---- src/libcore/str.rs | 6 +- src/libcore/sync.rs | 14 ++--- src/libcore/sys.rs | 2 +- src/libcore/task.rs | 11 +--- src/libcore/to_bytes.rs | 8 +-- src/libcore/to_str.rs | 38 ++++++------ src/libcore/tuple.rs | 8 +-- src/libcore/uint-template.rs | 10 ++-- src/libcore/vec.rs | 22 +++---- src/libstd/base64.rs | 10 ++-- src/libstd/bitv.rs | 2 +- src/libstd/cmp.rs | 6 +- src/libstd/deque.rs | 4 +- src/libstd/ebml.rs | 14 ++--- src/libstd/json.rs | 59 +++++++++---------- src/libstd/map.rs | 9 ++- src/libstd/net_ip.rs | 3 +- src/libstd/net_tcp.rs | 13 ++-- src/libstd/net_url.rs | 6 +- src/libstd/par.rs | 2 - src/libstd/prettyprint.rs | 2 +- src/libstd/serialization.rs | 4 +- src/libstd/sha1.rs | 2 +- src/libstd/smallintmap.rs | 6 +- src/libstd/tempfile.rs | 1 - src/libstd/time.rs | 6 +- src/libstd/uv_global_loop.rs | 2 +- src/libstd/uv_iotask.rs | 2 +- src/libsyntax/ast.rs | 8 +-- src/libsyntax/ast_map.rs | 1 - src/libsyntax/ast_util.rs | 2 +- src/libsyntax/codemap.rs | 2 +- src/libsyntax/diagnostic.rs | 4 +- src/libsyntax/ext/auto_serialize.rs | 2 +- src/libsyntax/ext/base.rs | 4 +- src/libsyntax/ext/pipes.rs | 4 +- src/libsyntax/ext/pipes/ast_builder.rs | 4 +- src/libsyntax/ext/pipes/check.rs | 6 +- src/libsyntax/ext/pipes/liveness.rs | 3 - src/libsyntax/ext/pipes/parse_proto.rs | 2 +- src/libsyntax/ext/pipes/pipec.rs | 26 ++++---- src/libsyntax/ext/pipes/proto.rs | 14 ++--- src/libsyntax/ext/qquote.rs | 14 ++--- src/libsyntax/ext/simplext.rs | 2 +- src/libsyntax/ext/tt/earley_parser.rs | 2 +- src/libsyntax/ext/tt/macro_rules.rs | 2 +- src/libsyntax/fold.rs | 4 +- src/libsyntax/parse.rs | 4 +- src/libsyntax/parse/attr.rs | 2 +- src/libsyntax/parse/comments.rs | 3 +- src/libsyntax/parse/common.rs | 2 +- src/libsyntax/parse/lexer.rs | 4 +- src/libsyntax/parse/parser.rs | 8 +-- src/libsyntax/print/pp.rs | 4 +- src/libsyntax/print/pprust.rs | 2 +- src/libsyntax/util/interner.rs | 4 +- src/rustc/driver/driver.rs | 2 +- src/rustc/driver/rustc.rs | 1 - src/rustc/driver/session.rs | 2 +- src/rustc/front/test.rs | 2 +- src/rustc/metadata/creader.rs | 2 +- src/rustc/metadata/csearch.rs | 2 +- src/rustc/metadata/decoder.rs | 3 +- src/rustc/metadata/filesearch.rs | 2 +- src/rustc/middle/astencode.rs | 42 ++++++------- src/rustc/middle/borrowck.rs | 4 +- src/rustc/middle/borrowck/check_loans.rs | 6 +- src/rustc/middle/borrowck/gather_loans.rs | 5 +- src/rustc/middle/borrowck/loan.rs | 4 +- src/rustc/middle/borrowck/preserve.rs | 6 +- src/rustc/middle/check_const.rs | 2 +- src/rustc/middle/kind.rs | 3 +- src/rustc/middle/lint.rs | 2 +- src/rustc/middle/liveness.rs | 10 ++-- src/rustc/middle/mem_categorization.rs | 6 +- src/rustc/middle/region.rs | 4 +- src/rustc/middle/resolve3.rs | 2 +- src/rustc/middle/trans/alt.rs | 2 +- src/rustc/middle/trans/base.rs | 8 +-- src/rustc/middle/trans/closure.rs | 1 - src/rustc/middle/trans/common.rs | 11 ++-- src/rustc/middle/trans/reflect.rs | 2 +- src/rustc/middle/trans/shape.rs | 3 +- src/rustc/middle/trans/tvec.rs | 2 +- src/rustc/middle/ty.rs | 16 ++--- src/rustc/middle/typeck.rs | 4 +- src/rustc/middle/typeck/check.rs | 10 ++-- src/rustc/middle/typeck/check/alt.rs | 2 - src/rustc/middle/typeck/check/demand.rs | 2 +- src/rustc/middle/typeck/check/method.rs | 3 +- src/rustc/middle/typeck/check/regionck.rs | 2 +- src/rustc/middle/typeck/check/vtable.rs | 3 +- src/rustc/middle/typeck/check/writeback.rs | 2 +- src/rustc/middle/typeck/coherence.rs | 4 +- src/rustc/middle/typeck/collect.rs | 4 +- src/rustc/middle/typeck/infer.rs | 47 ++++++++------- src/rustc/middle/typeck/rscope.rs | 8 +-- src/rustdoc/astsrv.rs | 2 +- src/rustdoc/demo.rs | 2 +- src/rustdoc/doc.rs | 22 +++---- src/rustdoc/markdown_pass.rs | 1 - src/rustdoc/markdown_writer.rs | 2 +- src/test/auxiliary/ambig_impl_2_lib.rs | 2 +- src/test/auxiliary/cci_impl_lib.rs | 2 +- src/test/auxiliary/cci_nested_lib.rs | 2 +- .../crate-method-reexport-grrrrrrr2.rs | 8 +-- src/test/auxiliary/issue-2380.rs | 2 +- src/test/auxiliary/issue-2414-a.rs | 2 +- src/test/auxiliary/issue-2414-b.rs | 2 - src/test/auxiliary/issue-2526.rs | 2 +- src/test/auxiliary/issue_2242_a.rs | 2 +- src/test/auxiliary/issue_2242_b.rs | 2 +- src/test/auxiliary/issue_2242_c.rs | 2 +- src/test/auxiliary/static-methods-crate.rs | 4 +- src/test/bench/core-std.rs | 2 +- src/test/bench/core-vec-append.rs | 2 +- src/test/bench/msgsend-pipes-shared.rs | 1 - src/test/bench/msgsend-ring.rs | 1 - src/test/bench/shootout-chameneos-redux.rs | 2 - src/test/bench/shootout-k-nucleotide-pipes.rs | 2 - src/test/bench/shootout-k-nucleotide.rs | 2 - src/test/bench/shootout-mandelbrot.rs | 2 +- src/test/bench/std-smallintmap.rs | 2 +- src/test/bench/sudoku.rs | 2 +- .../bench/task-perf-word-count-generic.rs | 7 +-- src/test/compile-fail/ambig_impl_2_exe.rs | 5 +- src/test/compile-fail/ambig_impl_unify.rs | 8 +-- .../compile-fail/bad-method-typaram-kind.rs | 2 +- src/test/compile-fail/borrowck-loan-rcvr.rs | 2 +- .../compile-fail/infinite-instantiation.rs | 4 +- src/test/compile-fail/issue-2063.rs | 2 +- src/test/compile-fail/issue-2149.rs | 2 +- src/test/compile-fail/issue-2330.rs | 2 +- src/test/compile-fail/issue-2590.rs | 2 +- src/test/compile-fail/issue-2766-a.rs | 2 +- src/test/compile-fail/issue-3021-d.rs | 2 +- src/test/compile-fail/issue-3021.rs | 2 +- .../kindck-owned-trait-contains.rs | 2 +- .../compile-fail/kindck-owned-trait-scoped.rs | 2 +- .../compile-fail/pure-modifies-aliased.rs | 2 +- src/test/compile-fail/qquote-1.rs | 2 +- src/test/compile-fail/qquote-2.rs | 2 +- .../regions-escape-via-trait-or-not.rs | 2 +- .../regions-infer-paramd-indirect.rs | 2 +- .../regions-infer-paramd-method.rs | 4 +- src/test/compile-fail/regions-trait-1.rs | 2 +- src/test/compile-fail/regions-trait-2.rs | 2 +- src/test/compile-fail/selftype-astparam.rs | 2 +- src/test/compile-fail/seq-args.rs | 4 +- src/test/compile-fail/staticness-mismatch.rs | 2 +- src/test/compile-fail/tps-invariant-trait.rs | 2 +- .../trait-impl-different-num-params.rs | 2 +- src/test/compile-fail/trait-test-2.rs | 4 +- src/test/compile-fail/trait-test.rs | 2 +- src/test/run-fail/issue-2156.rs | 2 +- src/test/run-fail/unwind-box-trait.rs | 2 +- src/test/run-fail/zip-different-lengths.rs | 2 +- src/test/run-pass-fulldeps/qquote.rs | 2 +- src/test/run-pass/assignability-trait.rs | 4 +- src/test/run-pass/auto_serialize.rs | 3 - src/test/run-pass/autoderef-method-newtype.rs | 2 +- .../run-pass/autoderef-method-priority.rs | 4 +- .../autoderef-method-twice-but-not-thrice.rs | 2 +- src/test/run-pass/autoderef-method-twice.rs | 2 +- src/test/run-pass/autoderef-method.rs | 2 +- .../run-pass/borrowck-newtype-issue-2573.rs | 2 +- src/test/run-pass/cci_capture_clause.rs | 1 - src/test/run-pass/cci_impl_exe.rs | 1 - src/test/run-pass/class-separate-impl.rs | 2 +- .../crate-method-reexport-grrrrrrr.rs | 1 - src/test/run-pass/dvec-test.rs | 2 +- src/test/run-pass/impl-variance.rs | 2 +- src/test/run-pass/issue-2185.rs | 4 +- src/test/run-pass/issue-2445-b.rs | 2 +- src/test/run-pass/issue-2445.rs | 2 +- src/test/run-pass/issue-2734.rs | 2 +- src/test/run-pass/issue-2735.rs | 2 +- src/test/run-pass/issue-2904.rs | 4 +- src/test/run-pass/issue-2935.rs | 2 +- .../run-pass/kindck-owned-trait-contains-1.rs | 2 +- src/test/run-pass/method-attributes.rs | 2 +- .../module-polymorphism4-files/trait.rs | 2 +- src/test/run-pass/module-polymorphism4.rs | 2 - src/test/run-pass/monad.rs | 4 +- .../run-pass/monomorphize-trait-in-fn-at.rs | 2 +- src/test/run-pass/rcvr-borrowed-to-region.rs | 2 +- src/test/run-pass/rcvr-borrowed-to-slice.rs | 2 +- src/test/run-pass/reflect-visit-data.rs | 9 ++- src/test/run-pass/regions-self-impls.rs | 2 +- src/test/run-pass/regions-trait.rs | 2 +- src/test/run-pass/static-impl.rs | 9 ++- src/test/run-pass/static-method-test.rs | 8 +-- src/test/run-pass/trait-bounds.rs | 4 +- src/test/run-pass/trait-cast.rs | 6 +- src/test/run-pass/trait-generic.rs | 8 +-- src/test/run-pass/trait-to-str.rs | 4 +- src/test/run-pass/use-trait-before-def.rs | 2 +- 222 files changed, 503 insertions(+), 617 deletions(-) diff --git a/src/compiletest/errors.rs b/src/compiletest/errors.rs index 53599a9ad0e..931a678d529 100644 --- a/src/compiletest/errors.rs +++ b/src/compiletest/errors.rs @@ -1,5 +1,3 @@ -import io::reader_util; - import common::config; export load_errors; diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index bf58e809692..180dd75ed6a 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -1,6 +1,5 @@ import option; import str; -import io::reader_util; import common::config; diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index ba4249999a4..a37741c2996 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -1,5 +1,5 @@ import run::spawn_process; -import io::{writer_util, reader_util}; +import io::writer_util; import libc::{c_int, pid_t}; import pipes::chan; diff --git a/src/libcore/arc.rs b/src/libcore/arc.rs index c84db57bd39..ab16750b8da 100644 --- a/src/libcore/arc.rs +++ b/src/libcore/arc.rs @@ -3,8 +3,6 @@ * share immutable data between tasks. */ -import sys::methods; - export arc, get, clone; export exclusive, methods; @@ -96,7 +94,7 @@ fn exclusive(-data: T) -> exclusive { } } -impl methods for exclusive { +impl exclusive { /// Duplicate an exclusive ARC. See arc::clone. fn clone() -> exclusive { unsafe { @@ -142,7 +140,6 @@ unsafe fn with(f: fn(x: &mut T) -> U) -> U { #[cfg(test)] mod tests { import comm::*; - import future::extensions; #[test] fn manually_share_arc() { diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 90a68df211a..74f3c59acae 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -123,7 +123,7 @@ fn vec_reserve_shared_actual(++t: *sys::type_desc, } } -impl extensions of vec_concat for @[T] { +impl @[T]: vec_concat { #[inline(always)] pure fn +(rhs: &[const T]) -> @[T] { append(self, rhs) @@ -131,7 +131,7 @@ impl extensions of vec_concat for @[T] { } #[cfg(notest)] -impl extensions of add<&[const T],@[T]> for @[T] { +impl @[T]: add<&[const T],@[T]> { #[inline(always)] pure fn add(rhs: &[const T]) -> @[T] { append(self, rhs) diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index 794bdc90885..4fcdad60146 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -70,7 +70,7 @@ fn port() -> port { port_t(@port_ptr(rustrt::new_port(sys::size_of::() as size_t))) } -impl methods for port { +impl port { fn chan() -> chan { chan(self) } fn send(+v: T) { self.chan().send(v) } @@ -79,7 +79,7 @@ fn peek() -> bool { peek(self) } } -impl methods for chan { +impl chan { fn chan() -> chan { self } fn send(+v: T) { send(self, v) } diff --git a/src/libcore/core.rs b/src/libcore/core.rs index 448f800f566..3f442318476 100644 --- a/src/libcore/core.rs +++ b/src/libcore/core.rs @@ -5,31 +5,13 @@ import option::{some, none}; import option = option::option; import path = path::path; -import tuple::{extensions, tuple_ops, extended_tuple_ops}; -import str::{extensions, str_slice, unique_str}; -import vec::extensions; +import tuple::{tuple_ops, extended_tuple_ops}; +import str::{str_slice, unique_str}; import vec::{const_vector, copyable_vector, immutable_vector}; import vec::{immutable_copyable_vector, iter_trait_extensions, vec_concat}; import iter::{base_iter, extended_iter, copyable_iter, times, timesi}; -import option::extensions; -import option_iter::extensions; -import ptr::{extensions, ptr}; -import rand::extensions; -import result::extensions; -import int::{num, times, timesi}; -import i8::{num, times, timesi}; -import i16::{num, times, timesi}; -import i32::{num, times, timesi}; -import i64::{num, times, timesi}; -import uint::{num, times, timesi}; -import u8::{num, times, timesi}; -import u16::{num, times, timesi}; -import u32::{num, times, timesi}; -import u64::{num, times, timesi}; -import float::num; -import f32::num; -import f64::num; import num::num; +import ptr::ptr; export path, option, some, none, unreachable; export extensions; diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 0d96e029fb7..c3d8def4751 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -4,8 +4,6 @@ * Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate. */ -import dlist_iter::extensions; - export dlist, dlist_node; export new_dlist, from_elem, from_vec, extensions; @@ -24,7 +22,7 @@ enum dlist = @{ mut tl: dlist_link, }; -impl private_methods for dlist_node { +priv impl dlist_node { pure fn assert_links() { match self.next { some(neighbour) => match neighbour.prev { @@ -47,7 +45,7 @@ impl private_methods for dlist_node { } } -impl extensions for dlist_node { +impl dlist_node { /// Get the next node in the list, if there is one. pure fn next_link() -> option> { self.assert_links(); @@ -109,7 +107,7 @@ fn concat(lists: dlist>) -> dlist { result } -impl private_methods for dlist { +priv impl dlist { pure fn new_link(-data: T) -> dlist_link { some(dlist_node(@{data: data, mut linked: true, mut prev: none, mut next: none})) @@ -184,7 +182,7 @@ fn insert_right(neighbour: dlist_node, nobe: dlist_link) { } } -impl extensions for dlist { +impl dlist { /// Get the size of the list. O(1). pure fn len() -> uint { self.size } /// Returns true if the list is empty. O(1). @@ -413,7 +411,7 @@ fn assert_consistent() { } } -impl extensions for dlist { +impl dlist { /// Remove data from the head of the list. O(1). fn pop() -> option { self.pop_n().map (|nobe| nobe.data) } /// Remove data from the tail of the list. O(1). diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index a05df4e608a..0d3748e187a 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -5,9 +5,8 @@ // // Note that recursive use is not permitted. -import dvec_iter::extensions; import unsafe::reinterpret_cast; -import ptr::{null, extensions}; +import ptr::null; export dvec; export from_elem; @@ -75,7 +74,7 @@ fn unwrap(-d: dvec) -> ~[mut A] { return v; } -impl private_methods for dvec { +priv impl dvec { pure fn check_not_borrowed() { unsafe { let data: *() = unsafe::reinterpret_cast(self.data); @@ -107,7 +106,7 @@ fn give_back(-data: ~[mut A]) { // In theory, most everything should work with any A, but in practice // almost nothing works without the copy bound due to limitations // around closures. -impl extensions for dvec { +impl dvec { /// Reserves space for N elements fn reserve(count: uint) { vec::reserve(self.data, count) @@ -188,7 +187,7 @@ fn reverse() { } } -impl extensions for dvec { +impl dvec { /** * Append all elements of a vector to the end of the list * @@ -311,7 +310,7 @@ fn reachi(f: fn(uint, A) -> bool) { } } -impl extensions of index for dvec { +impl dvec: index { pure fn index(&&idx: uint) -> A { self.get_elt(idx) } diff --git a/src/libcore/f32.rs b/src/libcore/f32.rs index c9852eb67b6..575c1d40c42 100644 --- a/src/libcore/f32.rs +++ b/src/libcore/f32.rs @@ -167,7 +167,7 @@ mod consts { return ln(n) / consts::ln_2; } -impl num of num::num for f32 { +impl f32: num::num { pure fn add(&&other: f32) -> f32 { return self + other; } pure fn sub(&&other: f32) -> f32 { return self - other; } pure fn mul(&&other: f32) -> f32 { return self * other; } diff --git a/src/libcore/f64.rs b/src/libcore/f64.rs index 550ed568be4..bc2c6faa69d 100644 --- a/src/libcore/f64.rs +++ b/src/libcore/f64.rs @@ -194,7 +194,7 @@ mod consts { return ln(n) / consts::ln_2; } -impl num of num::num for f64 { +impl f64: num::num { pure fn add(&&other: f64) -> f64 { return self + other; } pure fn sub(&&other: f64) -> f64 { return self - other; } pure fn mul(&&other: f64) -> f64 { return self * other; } diff --git a/src/libcore/float.rs b/src/libcore/float.rs index 4269ef41f4d..c41853b4e15 100644 --- a/src/libcore/float.rs +++ b/src/libcore/float.rs @@ -409,7 +409,7 @@ fn pow_with_uint(base: uint, pow: uint) -> float { pure fn cos(x: float) -> float { f64::cos(x as f64) as float } pure fn tan(x: float) -> float { f64::tan(x as f64) as float } -impl num of num::num for float { +impl float: num::num { pure fn add(&&other: float) -> float { return self + other; } pure fn sub(&&other: float) -> float { return self - other; } pure fn mul(&&other: float) -> float { return self * other; } diff --git a/src/libcore/future.rs b/src/libcore/future.rs index 8b7b51eef58..361f41ba21b 100644 --- a/src/libcore/future.rs +++ b/src/libcore/future.rs @@ -32,7 +32,7 @@ enum future = { }; /// Methods on the `future` type -impl extensions for future { +impl future { fn get() -> A { //! Get the value of the future diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index 897f4030a47..ac5d83a778b 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -62,20 +62,20 @@ fn range(lo: T, hi: T, it: fn(T) -> bool) { if is_negative(i) { -i } else { i } } -impl ord of ord for T { +impl T: ord { pure fn lt(&&other: T) -> bool { return self < other; } } -impl eq of eq for T { +impl T: eq { pure fn eq(&&other: T) -> bool { return self == other; } } -impl num of num::num for T { +impl T: num::num { pure fn add(&&other: T) -> T { return self + other; } pure fn sub(&&other: T) -> T { return self - other; } pure fn mul(&&other: T) -> T { return self * other; } @@ -87,7 +87,7 @@ impl num of num::num for T { pure fn from_int(n: int) -> T { return n as T; } } -impl times of iter::times for T { +impl T: iter::times { #[inline(always)] #[doc = "A convenience form for basic iteration. Given a variable `x` \ of any numeric type, the expression `for x.times { /* anything */ }` \ @@ -107,7 +107,7 @@ fn times(it: fn() -> bool) { } } -impl timesi of iter::timesi for T { +impl T: iter::timesi { #[inline(always)] /// Like `times`, but provides an index fn timesi(it: fn(uint) -> bool) { diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 2946700f832..571fc8587ef 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -6,7 +6,7 @@ import result::result; -import dvec::{dvec, extensions}; +import dvec::dvec; import libc::{c_int, c_long, c_uint, c_void, size_t, ssize_t}; import libc::consts::os::posix88::*; import libc::consts::os::extra::*; @@ -42,7 +42,7 @@ trait reader { // Generic utility functions defined on readers -impl reader_util for reader { +impl reader { fn read_bytes(len: uint) -> ~[u8] { let mut buf = ~[mut]; vec::reserve(buf, len); @@ -203,7 +203,7 @@ fn convert_whence(whence: seek_style) -> i32 { }; } -impl of reader for *libc::FILE { +impl *libc::FILE: reader { fn read(buf: &[mut u8], len: uint) -> uint { do vec::as_buf(buf) |buf_p, buf_len| { assert buf_len <= len; @@ -227,7 +227,7 @@ fn seek(offset: int, whence: seek_style) { // A forwarding impl of reader that also holds on to a resource for the // duration of its lifetime. // FIXME there really should be a better way to do this // #2004 -impl of reader for {base: T, cleanup: C} { +impl {base: T, cleanup: C}: reader { fn read(buf: &[mut u8], len: uint) -> uint { self.base.read(buf, len) } fn read_byte() -> int { self.base.read_byte() } fn unread_byte(byte: int) { self.base.unread_byte(byte); } @@ -273,7 +273,7 @@ fn file_reader(path: ~str) -> result { type byte_buf = {buf: ~[const u8], mut pos: uint, len: uint}; -impl of reader for byte_buf { +impl byte_buf: reader { fn read(buf: &[mut u8], len: uint) -> uint { let count = uint::min(len, self.len - self.pos); @@ -343,7 +343,7 @@ trait writer { fn get_type() -> writer_type; } -impl of writer for {base: T, cleanup: C} { +impl {base: T, cleanup: C}: writer { fn write(bs: &[const u8]) { self.base.write(bs); } fn seek(off: int, style: seek_style) { self.base.seek(off, style); } fn tell() -> uint { self.base.tell() } @@ -351,7 +351,7 @@ fn flush() -> int { self.base.flush() } fn get_type() -> writer_type { file } } -impl of writer for *libc::FILE { +impl *libc::FILE: writer { fn write(v: &[const u8]) { do vec::as_const_buf(v) |vbuf, len| { let nout = libc::fwrite(vbuf as *c_void, len as size_t, @@ -384,7 +384,7 @@ fn FILE_writer(f: *libc::FILE, cleanup: bool) -> writer { } } -impl of writer for fd_t { +impl fd_t: writer { fn write(v: &[const u8]) { let mut count = 0u; do vec::as_const_buf(v) |vbuf, len| { @@ -658,7 +658,7 @@ fn stderr() -> writer { fd_writer(libc::STDERR_FILENO as c_int, false) } type mem_buffer = @{buf: dvec, mut pos: uint}; -impl of writer for mem_buffer { +impl mem_buffer: writer { fn write(v: &[const u8]) { // Fast path. let vlen = vec::len(v); diff --git a/src/libcore/iter-trait.rs b/src/libcore/iter-trait.rs index a7ba67ec1bd..d448292b1aa 100644 --- a/src/libcore/iter-trait.rs +++ b/src/libcore/iter-trait.rs @@ -5,12 +5,12 @@ import inst::{IMPL_T, EACH, SIZE_HINT}; export extensions; -impl extensions of iter::base_iter for IMPL_T { +impl IMPL_T: iter::base_iter { fn each(blk: fn(A) -> bool) { EACH(self, blk) } fn size_hint() -> option { SIZE_HINT(self) } } -impl extensions of iter::extended_iter for IMPL_T { +impl IMPL_T: iter::extended_iter { fn eachi(blk: fn(uint, A) -> bool) { iter::eachi(self, blk) } fn all(blk: fn(A) -> bool) -> bool { iter::all(self, blk) } fn any(blk: fn(A) -> bool) -> bool { iter::any(self, blk) } @@ -24,7 +24,7 @@ fn position(f: fn(A) -> bool) -> option { } } -impl extensions of iter::copyable_iter for IMPL_T { +impl IMPL_T: iter::copyable_iter { fn filter_to_vec(pred: fn(A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } diff --git a/src/libcore/iter-trait/dlist.rs b/src/libcore/iter-trait/dlist.rs index a94ed6a54dc..9d8d147ffd7 100644 --- a/src/libcore/iter-trait/dlist.rs +++ b/src/libcore/iter-trait/dlist.rs @@ -8,8 +8,6 @@ * node is forbidden. */ pure fn EACH(self: IMPL_T, f: fn(A) -> bool) { - import dlist::extensions; - let mut link = self.peek_n(); while option::is_some(link) { let nobe = option::get(link); @@ -31,6 +29,5 @@ } fn SIZE_HINT(self: IMPL_T) -> option { - import dlist::extensions; some(self.len()) } diff --git a/src/libcore/iter-trait/dvec.rs b/src/libcore/iter-trait/dvec.rs index efab0b70b57..d40eead14ff 100644 --- a/src/libcore/iter-trait/dvec.rs +++ b/src/libcore/iter-trait/dvec.rs @@ -6,11 +6,9 @@ * Attempts to access this dvec during iteration will fail. */ fn EACH(self: IMPL_T, f: fn(A) -> bool) { - import dvec::extensions; self.swap(|v| { vec::each(v, f); v }) } fn SIZE_HINT(self: IMPL_T) -> option { - import dvec::extensions; some(self.len()) } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index d64b89c2f04..325f4cf70c5 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -136,7 +136,7 @@ fn swap_unwrap(opt: &mut option) -> T { unwrap(opt) } -impl extensions for option { +impl option { /** * Update an optional value by optionally running its content through a * function that returns an option. @@ -155,7 +155,7 @@ impl extensions for option { pure fn map(f: fn(T) -> U) -> option { map(self, f) } } -impl extensions for option { +impl option { /** * Gets the value out of an option * diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 8a2dc361b3e..042d107b990 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -61,7 +61,6 @@ import unsafe::{forget, reinterpret_cast, transmute}; import either::{either, left, right}; import option::unwrap; -import arc::methods; // Things used by code generated by the pipe compiler. export entangle, get_buffer, drop_buffer; @@ -167,7 +166,7 @@ trait has_buffer { fn set_buffer(b: *libc::c_void); } -impl methods of has_buffer for packet { +impl packet: has_buffer { fn set_buffer(b: *libc::c_void) { self.header.buffer = b; } @@ -475,7 +474,7 @@ fn try_recv(-p: recv_packet_buffered) } } -impl peek for recv_packet_buffered { +impl recv_packet_buffered { pure fn peek() -> bool { peek(self) } @@ -637,7 +636,7 @@ trait selectable { pure fn header() -> *packet_header; } -impl of selectable for *packet_header { +impl *packet_header: selectable { pure fn header() -> *packet_header { self } } @@ -923,7 +922,7 @@ fn stream() -> (chan, port) { (chan_({ mut endp: some(c) }), port_({ mut endp: some(s) })) } -impl chan of channel for chan { +impl chan: channel { fn send(+x: T) { let mut endp = none; endp <-> self.endp; @@ -944,7 +943,7 @@ fn try_send(+x: T) -> bool { } } -impl port of recv for port { +impl port: recv { fn recv() -> T { let mut endp = none; endp <-> self.endp; @@ -1037,7 +1036,7 @@ fn recv() -> T { } } -impl of selectable for port { +impl port: selectable { pure fn header() -> *packet_header unchecked { match self.endp { some(endp) => endp.header(), @@ -1049,7 +1048,7 @@ impl of selectable for port { /// A channel that can be shared between many senders. type shared_chan = arc::exclusive>; -impl chan of channel for shared_chan { +impl shared_chan: channel { fn send(+x: T) { let mut xx = some(x); do self.with |chan| { @@ -1083,7 +1082,7 @@ trait select2 { } impl, Right: selectable recv> - of select2 for (Left, Right) { + (Left, Right): select2 { fn select() -> either { match self { diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index d63e1b755c0..61990b745ad 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -156,7 +156,7 @@ trait ptr { } /// Extension methods for pointers -impl extensions of ptr for *T { +impl *T: ptr { /// Returns true if the pointer is equal to the null pointer. pure fn is_null() -> bool { is_null(self) } diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 82a88e6718f..2bf983c373e 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -24,7 +24,7 @@ trait rng { type weighted = { weight: uint, item: T }; /// Extension methods for random number generators -impl extensions for rng { +impl rng { /// Return a random int fn gen_int() -> int { @@ -248,7 +248,7 @@ fn shuffle_mut(&&values: ~[mut T]) { drop { rustrt::rand_free(self.c); } } -impl of rng for @rand_res { +impl @rand_res: rng { fn next() -> u32 { return rustrt::rand_next((*self).c); } } @@ -279,7 +279,7 @@ fn seeded_rng(seed: ~[u8]) -> rng { mut w: u32 }; -impl of rng for xorshift_state { +impl xorshift_state: rng { fn next() -> u32 { let x = self.x; let mut t = x ^ (x << 11); diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 417841f3323..42a4b671a39 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -180,7 +180,7 @@ fn map_err(res: result, op: fn(E) -> F) } } -impl extensions for result { +impl result { fn is_ok() -> bool { is_ok(self) } fn is_err() -> bool { is_err(self) } @@ -200,7 +200,7 @@ fn iter_err(f: fn(E)) { } } -impl extensions for result { +impl result { fn get() -> T { get(self) } fn map_err(op: fn(E) -> F) -> result { @@ -211,7 +211,7 @@ fn map_err(op: fn(E) -> F) -> result { } } -impl extensions for result { +impl result { fn get_err() -> E { get_err(self) } fn map(op: fn(T) -> U) -> result { @@ -222,7 +222,7 @@ fn map(op: fn(T) -> U) -> result { } } -impl extensions for result { +impl result { fn chain(op: fn(T) -> result) -> result { chain(self, op) } diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 92e89d8a7c8..7b550f832b7 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -1,7 +1,6 @@ //! Process spawning import option::{some, none}; import libc::{pid_t, c_void, c_int}; -import io::reader_util; export program; export run_program; @@ -228,7 +227,7 @@ fn destroy_repr(r: prog_repr) { drop { destroy_repr(self.r); } } - impl of program for prog_res { + impl prog_res: program { fn get_id() -> pid_t { return self.r.pid; } fn input() -> io::writer { io::fd_writer(self.r.in_fd, false) } fn output() -> io::reader { io::FILE_reader(self.r.out_file, false) } diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs index e865bac41ed..f49cee1ba07 100644 --- a/src/libcore/send_map.rs +++ b/src/libcore/send_map.rs @@ -64,7 +64,7 @@ unsafe fn borrow(&&k: K) -> &K { unsafe::reinterpret_cast(p) } - impl private_methods for &const linear_map { + priv impl &const linear_map { #[inline(always)] pure fn to_bucket(h: uint) -> uint { // FIXME(#3041) borrow a more sophisticated technique here from @@ -126,7 +126,7 @@ impl private_methods for &const linear_map { } } - impl private_methods for &mut linear_map { + priv impl &mut linear_map { /// Expands the capacity of the array and re-inserts each /// of the existing buckets. fn expand() { @@ -175,7 +175,7 @@ fn insert_internal(hash: uint, +k: K, +v: V) -> bool { } } - impl public_methods for &mut linear_map { + impl &mut linear_map { fn insert(+k: K, +v: V) -> bool { if self.size >= self.resize_at { // n.b.: We could also do this after searching, so @@ -230,13 +230,13 @@ fn remove(k: &K) -> bool { } } - impl private_methods for &linear_map { + priv impl &linear_map { fn search(hash: uint, op: fn(x: &option>) -> bool) { let _ = self.bucket_sequence(hash, |i| op(&self.buckets[i])); } } - impl public_methods for &const linear_map { + impl &const linear_map { fn len() -> uint { self.size } @@ -253,7 +253,7 @@ fn contains_key(k: &K) -> bool { } } - impl public_methods for &const linear_map { + impl &const linear_map { fn find(k: &K) -> option { match self.bucket_for_key(self.buckets, k) { found_entry(idx) => { @@ -280,7 +280,7 @@ fn [](k: &K) -> V { } } - impl imm_methods for &linear_map { + impl &linear_map { /* FIXME --- #2979 must be fixed to typecheck this fn find_ptr(k: K) -> option<&V> { @@ -309,17 +309,17 @@ fn each_value_ref(blk: fn(v: &V) -> bool) { } } - impl public_methods for &linear_map { + impl &linear_map { fn each(blk: fn(+K,+V) -> bool) { self.each_ref(|k,v| blk(copy *k, copy *v)); } } - impl public_methods for &linear_map { + impl &linear_map { fn each_key(blk: fn(+K) -> bool) { self.each_key_ref(|k| blk(copy *k)); } } - impl public_methods for &linear_map { + impl &linear_map { fn each_value(blk: fn(+V) -> bool) { self.each_value_ref(|v| blk(copy *v)); } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 4a13c1d9354..62fb03e9263 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -1901,7 +1901,7 @@ trait unique_str { } /// Extension methods for strings -impl extensions of unique_str for ~str { +impl ~str: unique_str { /// Returns a string with leading and trailing whitespace removed #[inline] fn trim() -> ~str { trim(self) } @@ -1920,7 +1920,7 @@ fn trim_right() -> ~str { trim_right(self) } } #[cfg(notest)] -impl extensions of add<&str,~str> for ~str { +impl ~str: add<&str,~str> { #[inline(always)] pure fn add(rhs: &str) -> ~str { append(self, rhs) @@ -1956,7 +1956,7 @@ trait str_slice { } /// Extension methods for strings -impl extensions/& of str_slice for &str { +impl &str: str_slice { /** * Return true if a predicate matches all characters or if the string * contains no characters diff --git a/src/libcore/sync.rs b/src/libcore/sync.rs index 909d4d4dc1b..6def915b6d8 100644 --- a/src/libcore/sync.rs +++ b/src/libcore/sync.rs @@ -32,7 +32,7 @@ enum sem = exclusive<{ blocked: Q, }>; -impl sem for &sem { +impl &sem { fn acquire() { let mut waiter_nobe = none; unsafe { @@ -72,14 +72,14 @@ fn release() { } } // FIXME(#3154) move both copies of this into sem, and unify the 2 structs -impl sem_access for &sem<()> { +impl &sem<()> { fn access(blk: fn() -> U) -> U { self.acquire(); let _x = sem_release(self); blk() } } -impl sem_access for &sem { +impl &sem { fn access(blk: fn() -> U) -> U { self.acquire(); let _x = sem_and_signal_release(self); @@ -102,7 +102,7 @@ struct sem_and_signal_release { /// A mechanism for atomic-unlock-and-deschedule blocking and signalling. enum condvar = &sem; -impl condvar for condvar { +impl condvar { /// Atomically drop the associated lock, and block until a signal is sent. fn wait() { let (signal_end, wait_end) = pipes::stream(); @@ -158,7 +158,7 @@ fn broadcast() -> uint { } } -impl sem_and_signal for &sem { +impl &sem { fn access_cond(blk: fn(condvar) -> U) -> U { do self.access { blk(condvar(self)) } } @@ -179,7 +179,7 @@ fn new_semaphore(count: int) -> semaphore { blocked: () }))) } -impl semaphore for &semaphore { +impl &semaphore { /// Create a new handle to the semaphore. fn clone() -> semaphore { semaphore(sem((***self).clone())) } @@ -218,7 +218,7 @@ fn new_mutex() -> mutex { blocked: { head: block_head, tail: block_tail } }))) } -impl mutex for &mutex { +impl &mutex { /// Create a new handle to the mutex. fn clone() -> mutex { mutex(sem((***self).clone())) } diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 879865a988a..3fd1718cd37 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -106,7 +106,7 @@ enum type_desc = { drop { rustrt::rust_destroy_little_lock(self.l); } } -impl methods for little_lock { +impl little_lock { unsafe fn lock(f: fn() -> T) -> T { class unlock { let l: rust_little_lock; diff --git a/src/libcore/task.rs b/src/libcore/task.rs index 282f692d2d6..f80dd309c7b 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -24,9 +24,6 @@ */ import result::result; -import dvec::extensions; -import dvec_iter::extensions; -import arc::methods; export task; export task_result; @@ -209,7 +206,7 @@ fn task() -> task_builder { }) } -impl private_methods for task_builder { +priv impl task_builder { fn consume() -> task_builder { if self.consumed { fail ~"Cannot copy a task_builder"; // Fake move mode on self @@ -219,7 +216,7 @@ fn consume() -> task_builder { } } -impl task_builder for task_builder { +impl task_builder { /** * Decouple the child task's failure from the parent's. If either fails, * the other will not be killed. @@ -1246,7 +1243,7 @@ fn new_task_in_new_sched(opts: sched_opts) -> *rust_task { type local_data_key = fn@(+@T); trait local_data { } -impl of local_data for @T { } +impl @T: local_data { } // We use dvec because it's the best data structure in core. If TLS is used // heavily in future, this could be made more efficient with a proper map. @@ -1955,7 +1952,6 @@ fn test_platform_thread() { #[ignore(cfg(windows))] #[should_fail] fn test_unkillable() { - import comm::methods; let po = comm::port(); let ch = po.chan(); @@ -1992,7 +1988,6 @@ fn test_unkillable() { #[ignore(cfg(windows))] #[should_fail] fn test_unkillable_nested() { - import comm::methods; let po = comm::port(); let ch = po.chan(); diff --git a/src/libcore/to_bytes.rs b/src/libcore/to_bytes.rs index 3e463653a43..45e502e4b0c 100644 --- a/src/libcore/to_bytes.rs +++ b/src/libcore/to_bytes.rs @@ -2,18 +2,18 @@ trait to_bytes { fn to_bytes() -> ~[u8]; } -impl of to_bytes for ~[u8] { +impl ~[u8]: to_bytes { fn to_bytes() -> ~[u8] { copy self } } -impl of to_bytes for @~[u8] { +impl @~[u8]: to_bytes { fn to_bytes() -> ~[u8] { copy *self } } -impl of to_bytes for ~str { +impl ~str: to_bytes { fn to_bytes() -> ~[u8] { str::bytes(self) } } -impl of to_bytes for @(~str) { +impl @(~str): to_bytes { fn to_bytes() -> ~[u8] { str::bytes(*self) } } diff --git a/src/libcore/to_str.rs b/src/libcore/to_str.rs index 76b0694d3d8..01f55a24bde 100644 --- a/src/libcore/to_str.rs +++ b/src/libcore/to_str.rs @@ -1,62 +1,62 @@ trait to_str { fn to_str() -> ~str; } -impl of to_str for int { +impl int: to_str { fn to_str() -> ~str { int::str(self) } } -impl of to_str for i8 { +impl i8: to_str { fn to_str() -> ~str { i8::str(self) } } -impl of to_str for i16 { +impl i16: to_str { fn to_str() -> ~str { i16::str(self) } } -impl of to_str for i32 { +impl i32: to_str { fn to_str() -> ~str { i32::str(self) } } -impl of to_str for i64 { +impl i64: to_str { fn to_str() -> ~str { i64::str(self) } } -impl of to_str for uint { +impl uint: to_str { fn to_str() -> ~str { uint::str(self) } } -impl of to_str for u8 { +impl u8: to_str { fn to_str() -> ~str { u8::str(self) } } -impl of to_str for u16 { +impl u16: to_str { fn to_str() -> ~str { u16::str(self) } } -impl of to_str for u32 { +impl u32: to_str { fn to_str() -> ~str { u32::str(self) } } -impl of to_str for u64 { +impl u64: to_str { fn to_str() -> ~str { u64::str(self) } } -impl of to_str for float { +impl float: to_str { fn to_str() -> ~str { float::to_str(self, 4u) } } -impl of to_str for bool { +impl bool: to_str { fn to_str() -> ~str { bool::to_str(self) } } -impl of to_str for () { +impl (): to_str { fn to_str() -> ~str { ~"()" } } -impl of to_str for ~str { +impl ~str: to_str { fn to_str() -> ~str { self } } -impl of to_str for (A, B) { +impl (A, B): to_str { fn to_str() -> ~str { let (a, b) = self; ~"(" + a.to_str() + ~", " + b.to_str() + ~")" } } -impl of to_str for (A, B, C){ +impl (A, B, C): to_str { fn to_str() -> ~str { let (a, b, c) = self; ~"(" + a.to_str() + ~", " + b.to_str() + ~", " + c.to_str() + ~")" } } -impl of to_str for ~[A] { +impl ~[A]: to_str { fn to_str() -> ~str { let mut acc = ~"[", first = true; for vec::each(self) |elt| { @@ -69,10 +69,10 @@ fn to_str() -> ~str { } } -impl of to_str for @A { +impl @A: to_str { fn to_str() -> ~str { ~"@" + (*self).to_str() } } -impl of to_str for ~A { +impl ~A: to_str { fn to_str() -> ~str { ~"~" + (*self).to_str() } } diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index a92ca63dd8b..42990eaf4ba 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -6,7 +6,7 @@ trait tuple_ops { pure fn swap() -> (U, T); } -impl extensions of tuple_ops for (T, U) { +impl (T, U): tuple_ops { /// Return the first element of self pure fn first() -> T { @@ -33,8 +33,7 @@ trait extended_tuple_ops { fn map(f: fn(A, B) -> C) -> ~[C]; } -impl extensions of extended_tuple_ops - for (&[A], &[B]) { +impl (&[A], &[B]): extended_tuple_ops { fn zip() -> ~[(A, B)] { let (a, b) = self; @@ -47,8 +46,7 @@ fn map(f: fn(A, B) -> C) -> ~[C] { } } -impl extensions of extended_tuple_ops - for (~[A], ~[B]) { +impl (~[A], ~[B]): extended_tuple_ops { fn zip() -> ~[(A, B)] { let (a, b) = self; diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index a0feaf3ed9d..3178e6ab75d 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -56,19 +56,19 @@ max_value ^ i } -impl ord of ord for T { +impl T: ord { pure fn lt(&&other: T) -> bool { return self < other; } } -impl eq of eq for T { +impl T: eq { pure fn eq(&&other: T) -> bool { return self == other; } } -impl num of num::num for T { +impl T: num::num { pure fn add(&&other: T) -> T { return self + other; } pure fn sub(&&other: T) -> T { return self - other; } pure fn mul(&&other: T) -> T { return self * other; } @@ -80,7 +80,7 @@ impl num of num::num for T { pure fn from_int(n: int) -> T { return n as T; } } -impl times of iter::times for T { +impl T: iter::times { #[inline(always)] #[doc = "A convenience form for basic iteration. Given a variable `x` \ of any numeric type, the expression `for x.times { /* anything */ }` \ @@ -96,7 +96,7 @@ fn times(it: fn() -> bool) { } } -impl timesi of iter::timesi for T { +impl T: iter::timesi { #[inline(always)] /// Like `times`, but with an index, `eachi`-style. fn timesi(it: fn(uint) -> bool) { diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 54b78f2a482..c104bdbc17a 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1287,7 +1287,7 @@ trait vec_concat { pure fn +(rhs: &[const T]) -> self; } -impl extensions of vec_concat for ~[T] { +impl ~[T]: vec_concat { #[inline(always)] pure fn +(rhs: &[const T]) -> ~[T] { append(self, rhs) @@ -1295,21 +1295,21 @@ impl extensions of vec_concat for ~[T] { } #[cfg(notest)] -impl extensions of add<&[const T],~[T]> for ~[T] { +impl ~[T]: add<&[const T],~[T]> { #[inline(always)] pure fn add(rhs: &[const T]) -> ~[T] { append(self, rhs) } } -impl extensions of vec_concat for ~[mut T] { +impl ~[mut T]: vec_concat { #[inline(always)] pure fn +(rhs: &[const T]) -> ~[mut T] { append_mut(self, rhs) } } -impl extensions of add<&[const T],~[mut T]> for ~[mut T] { +impl ~[mut T]: add<&[const T],~[mut T]> { #[inline(always)] pure fn add(rhs: &[const T]) -> ~[mut T] { append_mut(self, rhs) @@ -1323,7 +1323,7 @@ trait const_vector { } /// Extension methods for vectors -impl extensions/& of const_vector for &[const T] { +impl &[const T]: const_vector { /// Returns true if a vector contains no elements #[inline] pure fn is_empty() -> bool { is_empty(self) } @@ -1344,7 +1344,7 @@ trait copyable_vector { } /// Extension methods for vectors -impl extensions/& of copyable_vector for &[const T] { +impl &[const T]: copyable_vector { /// Returns the first element of a vector #[inline] pure fn head() -> T { head(self) } @@ -1381,7 +1381,7 @@ trait immutable_vector { } /// Extension methods for vectors -impl extensions/& of immutable_vector for &[T] { +impl &[T]: immutable_vector { /// Reduce a vector from right to left #[inline] pure fn foldr(z: U, p: fn(T, U) -> U) -> U { foldr(self, z, p) } @@ -1496,7 +1496,7 @@ trait immutable_copyable_vector { } /// Extension methods for vectors -impl extensions/& of immutable_copyable_vector for &[T] { +impl &[T]: immutable_copyable_vector { /** * Construct a new vector from the elements of a vector for which some * predicate holds. @@ -1741,12 +1741,12 @@ fn memmove(dst: &[mut u8], src: &[const u8], count: uint) { // This cannot be used with iter-trait.rs because of the region pointer // required in the slice. -impl extensions/& of iter::base_iter for &[A] { +impl &[A]: iter::base_iter { fn each(blk: fn(A) -> bool) { each(self, blk) } fn size_hint() -> option { some(len(self)) } } -impl extensions/& of iter::extended_iter for &[A] { +impl &[A]: iter::extended_iter { fn eachi(blk: fn(uint, A) -> bool) { iter::eachi(self, blk) } fn all(blk: fn(A) -> bool) -> bool { iter::all(self, blk) } fn any(blk: fn(A) -> bool) -> bool { iter::any(self, blk) } @@ -1766,7 +1766,7 @@ trait iter_trait_extensions { fn max() -> A; } -impl extensions/& of iter_trait_extensions for &[A] { +impl &[A]: iter_trait_extensions { fn filter_to_vec(pred: fn(A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index a51ac7658a6..2b9a1dccb36 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -1,10 +1,10 @@ -import io::{reader, reader_util}; +import io::reader; trait to_base64 { fn to_base64() -> ~str; } -impl of to_base64 for ~[u8] { +impl ~[u8]: to_base64 { fn to_base64() -> ~str { let chars = str::chars( ~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" @@ -52,7 +52,7 @@ fn to_base64() -> ~str { } } -impl of to_base64 for ~str { +impl ~str: to_base64 { fn to_base64() -> ~str { str::bytes(self).to_base64() } @@ -62,7 +62,7 @@ trait from_base64 { fn from_base64() -> ~[u8]; } -impl of from_base64 for ~[u8] { +impl ~[u8]: from_base64 { fn from_base64() -> ~[u8] { if self.len() % 4u != 0u { fail ~"invalid base64 length"; } @@ -124,7 +124,7 @@ fn from_base64() -> ~[u8] { } } -impl of from_base64 for ~str { +impl ~str: from_base64 { fn from_base64() -> ~[u8] { str::bytes(self).from_base64() } diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index b0189139f42..3b5d08d0c40 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -421,7 +421,7 @@ fn ones(f: fn(uint) -> bool) { pure fn right(_w0: uint, w1: uint) -> uint { return w1; } -impl extensions of ops::index for bitv { +impl bitv: ops::index { pure fn index(&&i: uint) -> bool { self.get(i) } diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index cc2c9dae3d6..937f8869177 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -6,19 +6,19 @@ trait fuzzy_eq { pure fn fuzzy_eq(&&other: self) -> bool; } -impl fuzzy_eq of fuzzy_eq for float { +impl float: fuzzy_eq { pure fn fuzzy_eq(&&other: float) -> bool { return float::abs(self - other) < fuzzy_epsilon; } } -impl fuzzy_eq of fuzzy_eq for f32 { +impl f32: fuzzy_eq { pure fn fuzzy_eq(&&other: f32) -> bool { return f32::abs(self - other) < (fuzzy_epsilon as f32); } } -impl fuzzy_eq of fuzzy_eq for f64 { +impl f64: fuzzy_eq { pure fn fuzzy_eq(&&other: f64) -> bool { return f64::abs(self - other) < (fuzzy_epsilon as f64); } diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index c7d0d1e5be8..8bb7ae64825 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -1,7 +1,7 @@ //! A deque. Untested as of yet. Likely buggy import option::{some, none}; -import dvec::{dvec, extensions}; +import dvec::dvec; trait t { fn size() -> uint; @@ -49,7 +49,7 @@ fn get(elts: dvec>, i: uint) -> T { mut hi: uint, elts: dvec>}; - impl of t for repr { + impl repr: t { fn size() -> uint { return self.nelts; } fn add_front(t: T) { let oldlo: uint = self.lo; diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index f5396395b93..8f0e54a10c5 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -46,13 +46,13 @@ trait get_doc { fn [](tag: uint) -> doc; } -impl extensions of get_doc for doc { +impl doc: get_doc { fn [](tag: uint) -> doc { get_doc(self, tag) } } -impl extensions of ops::index for doc { +impl doc: ops::index { pure fn index(&&tag: uint) -> doc { unchecked { get_doc(self, tag) @@ -214,7 +214,7 @@ fn writer(w: io::writer) -> writer { } // FIXME (#2741): Provide a function to write the standard ebml header. -impl writer for writer { +impl writer { fn start_tag(tag_id: uint) { debug!{"Start tag %u", tag_id}; @@ -339,7 +339,7 @@ trait serializer_priv { fn _emit_label(label: ~str); } -impl serializer of serializer_priv for ebml::writer { +impl ebml::writer: serializer_priv { // used internally to emit things like the vector length and so on fn _emit_tagged_uint(t: ebml_serializer_tag, v: uint) { assert v <= 0xFFFF_FFFF_u; @@ -357,7 +357,7 @@ fn _emit_label(label: ~str) { } } -impl serializer of serialization::serializer for ebml::writer { +impl ebml::writer: serialization::serializer { fn emit_nil() {} fn emit_uint(v: uint) { self.wr_tagged_u64(es_uint as uint, v as u64); } @@ -424,7 +424,7 @@ fn ebml_deserializer(d: ebml::doc) -> ebml_deserializer { ebml_deserializer_({mut parent: d, mut pos: d.start}) } -impl deserializer_priv for ebml_deserializer { +priv impl ebml_deserializer { fn _check_label(lbl: ~str) { if self.pos < self.parent.end { let {tag: r_tag, doc: r_doc} = @@ -479,7 +479,7 @@ fn _next_uint(exp_tag: ebml_serializer_tag) -> uint { } } -impl deserializer of serialization::deserializer for ebml_deserializer { +impl ebml_deserializer: serialization::deserializer { fn read_nil() -> () { () } fn read_u64() -> u64 { ebml::doc_as_u64(self.next_doc(es_u64)) } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 882c6147b24..2ddfc041f95 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -5,11 +5,10 @@ import result::{result, ok, err}; import io; -import io::{reader_util, writer_util}; +import io::writer_util; import map; import map::hashmap; import map::map; -import core::vec::extensions; export json; export error; @@ -120,7 +119,7 @@ enum parser { parser_(parser_) } -impl parser for parser { +impl parser { fn eof() -> bool { self.ch == -1 as char } fn bump() { @@ -503,83 +502,83 @@ fn eq(value0: json, value1: json) -> bool { trait to_json { fn to_json() -> json; } -impl of to_json for json { +impl json: to_json { fn to_json() -> json { self } } -impl of to_json for @json { +impl @json: to_json { fn to_json() -> json { *self } } -impl of to_json for int { +impl int: to_json { fn to_json() -> json { num(self as float) } } -impl of to_json for i8 { +impl i8: to_json { fn to_json() -> json { num(self as float) } } -impl of to_json for i16 { +impl i16: to_json { fn to_json() -> json { num(self as float) } } -impl of to_json for i32 { +impl i32: to_json { fn to_json() -> json { num(self as float) } } -impl of to_json for i64 { +impl i64: to_json { fn to_json() -> json { num(self as float) } } -impl of to_json for uint { +impl uint: to_json { fn to_json() -> json { num(self as float) } } -impl of to_json for u8 { +impl u8: to_json { fn to_json() -> json { num(self as float) } } -impl of to_json for u16 { +impl u16: to_json { fn to_json() -> json { num(self as float) } } -impl of to_json for u32 { +impl u32: to_json { fn to_json() -> json { num(self as float) } } -impl of to_json for u64 { +impl u64: to_json { fn to_json() -> json { num(self as float) } } -impl of to_json for float { +impl float: to_json { fn to_json() -> json { num(self) } } -impl of to_json for f32 { +impl f32: to_json { fn to_json() -> json { num(self as float) } } -impl of to_json for f64 { +impl f64: to_json { fn to_json() -> json { num(self as float) } } -impl of to_json for () { +impl (): to_json { fn to_json() -> json { null } } -impl of to_json for bool { +impl bool: to_json { fn to_json() -> json { boolean(self) } } -impl of to_json for ~str { +impl ~str: to_json { fn to_json() -> json { string(@copy self) } } -impl of to_json for @~str { +impl @~str: to_json { fn to_json() -> json { string(self) } } -impl of to_json for (A, B) { +impl (A, B): to_json { fn to_json() -> json { match self { (a, b) => { @@ -589,8 +588,8 @@ fn to_json() -> json { } } -impl - of to_json for (A, B, C) { +impl (A, B, C): to_json { + fn to_json() -> json { match self { (a, b, c) => { @@ -600,11 +599,11 @@ fn to_json() -> json { } } -impl of to_json for ~[A] { +impl ~[A]: to_json { fn to_json() -> json { list(@self.map(|elt| elt.to_json())) } } -impl of to_json for hashmap<~str, A> { +impl hashmap<~str, A>: to_json { fn to_json() -> json { let d = map::str_hash(); for self.each() |key, value| { @@ -614,7 +613,7 @@ fn to_json() -> json { } } -impl of to_json for option { +impl option: to_json { fn to_json() -> json { match self { none => null, @@ -623,11 +622,11 @@ fn to_json() -> json { } } -impl of to_str::to_str for json { +impl json: to_str::to_str { fn to_str() -> ~str { to_str(self) } } -impl of to_str::to_str for error { +impl error: to_str::to_str { fn to_str() -> ~str { fmt!{"%u:%u: %s", self.line, self.col, *self.msg} } diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 695f40fc387..944e9c93e19 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -2,7 +2,6 @@ #[warn(deprecated_mode)]; -import chained::hashmap; import io::writer_util; import to_str::to_str; export hashmap, hashfn, eqfn, set, map, chained, hashmap, str_hash; @@ -127,7 +126,7 @@ enum search_result { found_after(@entry, @entry) } - impl private_methods for t { + priv impl t { fn search_rem(k: &K, h: uint, idx: uint, e_root: @entry) -> search_result { let mut e0 = e_root; @@ -207,7 +206,7 @@ fn each_entry(blk: fn(@entry) -> bool) { } } - impl hashmap of map for t { + impl t: map { fn size() -> uint { self.count } fn contains_key(+k: K) -> bool { @@ -328,7 +327,7 @@ fn each_value_ref(blk: fn(value: &V) -> bool) { } } - impl hashmap of to_str for t { + impl t: to_str { fn to_writer(wr: io::writer) { if self.count == 0u { wr.write_str(~"{}"); @@ -354,7 +353,7 @@ fn to_str() -> ~str { } } - impl hashmap of ops::index for t { + impl t: ops::index { pure fn index(&&k: K) -> V { unchecked { self.get(k) diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 00c489c1daa..5e25a91d901 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -4,7 +4,6 @@ import uint; import iotask = uv::iotask::iotask; import interact = uv::iotask::interact; -import comm::methods; import sockaddr_in = uv::ll::sockaddr_in; import sockaddr_in6 = uv::ll::sockaddr_in6; @@ -147,7 +146,7 @@ trait as_unsafe_u32 { unsafe fn as_u32() -> u32; } - impl x of as_unsafe_u32 for ipv4_rep { + impl ipv4_rep: as_unsafe_u32 { // this is pretty dastardly, i know unsafe fn as_u32() -> u32 { *((ptr::addr_of(self)) as *u32) diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 4e25a42985a..c32186fdd3c 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -3,15 +3,12 @@ import ip = net_ip; import uv::iotask; import uv::iotask::iotask; -import comm::methods; import future_spawn = future::spawn; -import future::extensions; // FIXME #1935 // should be able to, but can't atm, replace w/ result::{result, extensions}; import result::*; import libc::size_t; -import str::extensions; -import io::{reader, reader_util, writer}; +import io::{reader, writer}; // tcp interfaces export tcp_socket; @@ -726,7 +723,7 @@ fn socket_buf(-sock: tcp_socket) -> tcp_socket_buf { } /// Convenience methods extending `net::tcp::tcp_socket` -impl tcp_socket for tcp_socket { +impl tcp_socket { fn read_start() -> result::result>, tcp_err_data> { read_start(self) @@ -755,7 +752,7 @@ fn write_future(raw_write_data: ~[u8]) } /// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket` -impl tcp_socket_buf of io::reader for @tcp_socket_buf { +impl @tcp_socket_buf: io::reader { fn read(buf: &[mut u8], len: uint) -> uint { // Loop until our buffer has enough data in it for us to read from. while self.data.buf.len() < len { @@ -808,7 +805,7 @@ fn tell() -> uint { } /// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket` -impl tcp_socket_buf of io::writer for @tcp_socket_buf { +impl @tcp_socket_buf: io::writer { fn write(data: &[const u8]) unsafe { let socket_data_ptr = ptr::addr_of(*((*(self.data)).sock).socket_data); @@ -1067,7 +1064,7 @@ trait to_tcp_err { fn to_tcp_err() -> tcp_err_data; } -impl of to_tcp_err for uv::ll::uv_err_data { +impl uv::ll::uv_err_data: to_tcp_err { fn to_tcp_err() -> tcp_err_data { { err_name: self.err_name, err_msg: self.err_msg } } diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index b8c1b318841..e6428c19d10 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -2,8 +2,8 @@ import map; import map::{hashmap, str_hash}; -import io::{reader, reader_util}; -import dvec::{dvec, extensions}; +import io::reader; +import dvec::dvec; export url, userinfo, query; export from_str, to_str; @@ -673,7 +673,7 @@ fn to_str(url: url) -> ~str { fragment]); } -impl of to_str::to_str for url { +impl url: to_str::to_str { fn to_str() -> ~str { to_str(self) } diff --git a/src/libstd/par.rs b/src/libstd/par.rs index 65aa077ef87..c604ae7b9d6 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -3,8 +3,6 @@ import comm::send; import comm::recv; import future_spawn = future::spawn; -import future::extensions; -import core::vec::extensions; export map, mapi, alli, any, mapi_factory; diff --git a/src/libstd/prettyprint.rs b/src/libstd/prettyprint.rs index 6122474c06d..a33ad7ca65d 100644 --- a/src/libstd/prettyprint.rs +++ b/src/libstd/prettyprint.rs @@ -2,7 +2,7 @@ import io::writer_util; import serialization::serializer; -impl of serializer for writer { +impl writer: serializer { fn emit_nil() { self.write_str(~"()") } diff --git a/src/libstd/serialization.rs b/src/libstd/serialization.rs index ce9b73af471..c27081a457b 100644 --- a/src/libstd/serialization.rs +++ b/src/libstd/serialization.rs @@ -105,7 +105,7 @@ trait serializer_helpers { fn emit_from_vec(v: ~[T], f: fn(T)); } -impl serializer_helpers of serializer_helpers for S { +impl S: serializer_helpers { fn emit_from_vec(v: ~[T], f: fn(T)) { emit_from_vec(self, v, f) } @@ -115,7 +115,7 @@ trait deserializer_helpers { fn read_to_vec(f: fn() -> T) -> ~[T]; } -impl deserializer_helpers of deserializer_helpers for D { +impl D: deserializer_helpers { fn read_to_vec(f: fn() -> T) -> ~[T] { read_to_vec(self, f) } diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index 14410eed636..dc07a6bc3f0 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -217,7 +217,7 @@ fn pad_msg(st: sha1state) { process_msg_block(st); } - impl of sha1 for sha1state { + impl sha1state: sha1 { fn reset() { // FIXME: Should be typestate precondition (#2345) assert (vec::len(self.h) == digest_buf_len); diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index de9af5d44f4..4248cec854f 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -4,7 +4,7 @@ */ import core::option; import core::option::{some, none}; -import dvec::{dvec, extensions}; +import dvec::dvec; import map::map; // FIXME (#2347): Should not be @; there's a bug somewhere in rustc that @@ -63,7 +63,7 @@ fn contains_key(self: smallintmap, key: uint) -> bool { } /// Implements the map::map interface for smallintmap -impl of map::map for smallintmap { +impl smallintmap: map::map { fn size() -> uint { let mut sz = 0u; for self.v.each |item| { @@ -134,7 +134,7 @@ fn each_value_ref(blk: fn(value: &V) -> bool) { } } -impl extensions of ops::index for smallintmap { +impl smallintmap: ops::index { pure fn index(&&key: uint) -> V { unchecked { get(self, key) diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index 1ebfe695519..a4e68c78bba 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -3,7 +3,6 @@ import core::option; import option::{none, some}; import rand; -import core::rand::extensions; fn mkdtemp(prefix: ~str, suffix: ~str) -> option<~str> { let r = rand::rng(); diff --git a/src/libstd/time.rs b/src/libstd/time.rs index b654b0f1d4f..ee8ca6c28da 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -1,6 +1,6 @@ import libc::{c_char, c_int, c_long, size_t, time_t}; -import io::{reader, reader_util}; -import result::{result, ok, err, extensions}; +import io::reader; +import result::{result, ok, err}; export timespec, @@ -730,7 +730,7 @@ fn parse_type(ch: char, tm: tm) -> ~str { buf } -impl tm for tm { +impl tm { /// Convert time to the seconds from January 1, 1970 fn to_timespec() -> timespec { let mut sec = 0i64; diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index b2ae1de6e4a..149bc077eb3 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -7,7 +7,7 @@ import get_gl = get; import iotask::{iotask, spawn_iotask}; import priv::{chan_from_global_ptr, weaken_task}; -import comm::{port, chan, methods, select2, listen}; +import comm::{port, chan, select2, listen}; import task::task_builder; import either::{left, right}; diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index 80d1053570e..324a90553c7 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -12,7 +12,7 @@ import libc::c_void; import ptr::addr_of; -import comm::{port, chan, methods, listen}; +import comm::{port, chan, listen}; import task::task_builder; import ll = uv_ll; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index ee1e12b87b7..c33b3e9b6ec 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -827,20 +827,20 @@ trait path_concat { } // Remove after snapshot! -impl methods of path_concat for ident { +impl ident: path_concat { pure fn +(&&id: ident) -> @path { simple_path(self, empty_span()) + id } } -impl methods of ops::add for ident { +impl ident: ops::add { pure fn add(&&id: ident) -> @path { simple_path(self, empty_span()) + id } } // Remove after snapshot! -impl methods of path_concat for @path { +impl @path: path_concat { pure fn +(&&id: ident) -> @path { @{ idents: vec::append_one(self.idents, id) @@ -849,7 +849,7 @@ impl methods of path_concat for @path { } } -impl methods of ops::add for @path { +impl @path: ops::add { pure fn add(&&id: ident) -> @path { @{ idents: vec::append_one(self.idents, id) diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index dfb87b7efbb..241a212c2ac 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -3,7 +3,6 @@ import ast::*; import print::pprust; import ast_util::path_to_ident; -import ast_util::inlined_item_methods; import diagnostic::span_handler; enum path_elt { path_mod(ident), path_name(ident) } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 6ff0bed8e10..6ea6ecb1ba3 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -368,7 +368,7 @@ trait inlined_item_utils { fn accept(e: E, v: visit::vt); } -impl inlined_item_methods of inlined_item_utils for inlined_item { +impl inlined_item: inlined_item_utils { fn ident() -> ident { match self { ii_item(i) => /* FIXME (#2543) */ copy i.ident, diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index e725eaaa724..0d8566ae42c 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -1,4 +1,4 @@ -import dvec::{dvec, extensions}; +import dvec::dvec; export filename; export filemap; diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index bd5b37ab698..c71422d198f 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -46,7 +46,7 @@ trait handler { cm: codemap::codemap }; -impl codemap_span_handler of span_handler for codemap_t { +impl codemap_t: span_handler { fn span_fatal(sp: span, msg: ~str) -> ! { self.handler.emit(some((self.cm, sp)), msg, fatal); fail; @@ -72,7 +72,7 @@ fn handler() -> handler { } } -impl codemap_handler of handler for handler_t { +impl handler_t: handler { fn fatal(msg: ~str) -> ! { self.emit(none, msg, fatal); fail; diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs index 934a295dfb5..c93dccda034 100644 --- a/src/libsyntax/ext/auto_serialize.rs +++ b/src/libsyntax/ext/auto_serialize.rs @@ -150,7 +150,7 @@ fn ty_fn(span: span, fn at(span: span, expr: @ast::expr) -> @ast::expr; } -impl helpers of ext_ctxt_helpers for ext_ctxt { +impl ext_ctxt: ext_ctxt_helpers { fn helper_path(base_path: @ast::path, helper_name: ~str) -> @ast::path { let head = vec::init(base_path.idents); diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 0f163e73c81..484932b539e 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -144,7 +144,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, cfg: ast::crate_cfg, mut backtrace: expn_info, mut mod_path: ~[ast::ident]}; - impl of ext_ctxt for ctxt_repr { + impl ctxt_repr: ext_ctxt { fn codemap() -> codemap { self.parse_sess.cm } fn parse_sess() -> parse::parse_sess { self.parse_sess } fn cfg() -> ast::crate_cfg { self.cfg } @@ -277,7 +277,7 @@ fn get_mac_body(cx: ext_ctxt, sp: span, args: ast::mac_body) fn tt_args_to_original_flavor(cx: ext_ctxt, sp: span, arg: ~[ast::token_tree]) -> ast::mac_arg { import ast::{matcher, matcher_, match_tok, match_seq, match_nonterminal}; - import parse::lexer::{new_tt_reader, tt_reader_as_reader, reader}; + import parse::lexer::{new_tt_reader, reader}; import tt::earley_parser::{parse_or_else, matched_seq, matched_nonterminal}; diff --git a/src/libsyntax/ext/pipes.rs b/src/libsyntax/ext/pipes.rs index 08562c4490f..b9ff13c9578 100644 --- a/src/libsyntax/ext/pipes.rs +++ b/src/libsyntax/ext/pipes.rs @@ -36,15 +36,13 @@ import codemap::span; import ext::base::ext_ctxt; import ast::tt_delim; -import parse::lexer::{new_tt_reader, reader, tt_reader_as_reader}; +import parse::lexer::{new_tt_reader, reader}; import parse::parser::{parser, SOURCE_FILE}; import parse::common::parser_common; import pipes::parse_proto::proto_parser; -import pipes::pipec::compile; import pipes::proto::{visit, protocol}; -import pipes::check::proto_check; fn expand_proto(cx: ext_ctxt, _sp: span, id: ast::ident, tt: ~[ast::token_tree]) -> base::mac_result diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index 716fe62a61f..d2ef304a1f0 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -36,7 +36,7 @@ trait append_types { fn add_tys(+tys: ~[@ast::ty]) -> @ast::path; } -impl methods of append_types for @ast::path { +impl @ast::path: append_types { fn add_ty(ty: @ast::ty) -> @ast::path { @{types: vec::append_one(self.types, ty) with *self} @@ -89,7 +89,7 @@ fn item_ty_poly(name: ident, fn ty_option(ty: @ast::ty) -> @ast::ty; } -impl ast_builder of ext_ctxt_ast_builder for ext_ctxt { +impl ext_ctxt: ext_ctxt_ast_builder { fn ty_option(ty: @ast::ty) -> @ast::ty { self.ty_path_ast_builder(path(@~"option", self.empty_span()) .add_ty(ty)) diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs index 8595a991e24..e286b4f76be 100644 --- a/src/libsyntax/ext/pipes/check.rs +++ b/src/libsyntax/ext/pipes/check.rs @@ -19,16 +19,14 @@ */ -import dvec::extensions; - import ext::base::ext_ctxt; import ast::{ident}; -import proto::{state, protocol, next_state, methods}; +import proto::{state, protocol, next_state}; import ast_builder::empty_span; -impl proto_check of proto::visitor<(), (), ()> for ext_ctxt { +impl ext_ctxt: proto::visitor<(), (), ()> { fn visit_proto(_proto: protocol, _states: &[()]) { } diff --git a/src/libsyntax/ext/pipes/liveness.rs b/src/libsyntax/ext/pipes/liveness.rs index 87179accefa..17e569552a7 100644 --- a/src/libsyntax/ext/pipes/liveness.rs +++ b/src/libsyntax/ext/pipes/liveness.rs @@ -27,11 +27,8 @@ */ -import dvec::extensions; - import std::bitv::{bitv}; -import proto::methods; import ast_builder::empty_span; fn analyze(proto: protocol, _cx: ext_ctxt) { diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs index aa553d8ae53..84180ff3797 100644 --- a/src/libsyntax/ext/pipes/parse_proto.rs +++ b/src/libsyntax/ext/pipes/parse_proto.rs @@ -11,7 +11,7 @@ trait proto_parser { fn parse_state(proto: protocol); } -impl proto_parser of proto_parser for parser { +impl parser: proto_parser { fn parse_proto(id: ident) -> protocol { let proto = protocol(id, self.span); diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index b4db8a6a72a..a835cbb27a4 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -3,9 +3,6 @@ import to_str::to_str; import dvec::dvec; -import dvec::extensions; - -import tuple::extensions; import ast::ident; import util::interner; @@ -15,11 +12,8 @@ import parse; import parse::*; import proto::*; -import ast::methods; import ast_builder::append_types; -import ast_builder::ast_builder; -import ast_builder::methods; import ast_builder::path; // Transitional reexports so qquote can find the paths it is looking for @@ -44,7 +38,7 @@ trait gen_init { fn compile(cx: ext_ctxt) -> @ast::item; } -impl compile of gen_send for message { +impl message: gen_send { fn gen_send(cx: ext_ctxt, try: bool) -> @ast::item { debug!{"pipec: gen_send"}; match self { @@ -199,7 +193,7 @@ fn to_ty(cx: ext_ctxt) -> @ast::ty { } } -impl compile of to_type_decls for state { +impl state: to_type_decls { fn to_type_decls(cx: ext_ctxt) -> ~[@ast::item] { debug!{"pipec: to_type_decls"}; // This compiles into two different type declarations. Say the @@ -283,7 +277,7 @@ fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> ~[@ast::item] { } } -impl compile of gen_init for protocol { +impl protocol: gen_init { fn gen_init(cx: ext_ctxt) -> @ast::item { let ext_cx = cx; @@ -425,37 +419,37 @@ trait to_source { fn to_source() -> ~str; } -impl of to_source for @ast::item { +impl @ast::item: to_source { fn to_source() -> ~str { item_to_str(self) } } -impl of to_source for ~[@ast::item] { +impl ~[@ast::item]: to_source { fn to_source() -> ~str { str::connect(self.map(|i| i.to_source()), ~"\n\n") } } -impl of to_source for @ast::ty { +impl @ast::ty: to_source { fn to_source() -> ~str { ty_to_str(self) } } -impl of to_source for ~[@ast::ty] { +impl ~[@ast::ty]: to_source { fn to_source() -> ~str { str::connect(self.map(|i| i.to_source()), ~", ") } } -impl of to_source for ~[ast::ty_param] { +impl ~[ast::ty_param]: to_source { fn to_source() -> ~str { pprust::typarams_to_str(self) } } -impl of to_source for @ast::expr { +impl @ast::expr: to_source { fn to_source() -> ~str { pprust::expr_to_str(self) } @@ -467,7 +461,7 @@ trait ext_ctxt_parse_utils { fn parse_stmt(s: ~str) -> @ast::stmt; } -impl parse_utils of ext_ctxt_parse_utils for ext_ctxt { +impl ext_ctxt: ext_ctxt_parse_utils { fn parse_item(s: ~str) -> @ast::item { let res = parse::parse_item_from_source_str( ~"***protocol expansion***", diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 5769125225e..8409135db6b 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -1,15 +1,15 @@ import to_str::to_str; -import dvec::{dvec, extensions}; +import dvec::dvec; import ast::{ident}; -import ast_builder::{path, methods, ast_builder, append_types}; +import ast_builder::{path, append_types}; enum direction { send, recv } -impl of to_str for direction { +impl direction: to_str { fn to_str() -> ~str { match self { send => ~"send", @@ -18,7 +18,7 @@ fn to_str() -> ~str { } } -impl methods for direction { +impl direction { fn reverse() -> direction { match self { send => recv, @@ -34,7 +34,7 @@ enum message { message(ident, span, ~[@ast::ty], state, next_state) } -impl methods for message { +impl message { fn name() -> ident { match self { message(id, _, _, _, _) => id @@ -67,7 +67,7 @@ enum state { }), } -impl methods for state { +impl state { fn add_message(name: ident, span: span, +data: ~[@ast::ty], next: next_state) { self.messages.push(message(name, span, data, self, @@ -161,7 +161,7 @@ fn is_bounded() -> bool { } } -impl methods for protocol { +impl protocol { fn add_state(name: ident, dir: direction) -> state { self.add_state_poly(name, dir, ~[]) } diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs index 8d219ec4395..c5af28bc0b3 100644 --- a/src/libsyntax/ext/qquote.rs +++ b/src/libsyntax/ext/qquote.rs @@ -2,7 +2,7 @@ mac_aq, mac_var}; import parse::parser; import parse::parser::parse_from_source_str; -import dvec::{dvec, extensions}; +import dvec::dvec; import fold::*; import visit::*; @@ -34,7 +34,7 @@ trait qq_helper { fn get_fold_fn() -> ~str; } -impl of qq_helper for @ast::crate { +impl @ast::crate: qq_helper { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt) {visit_crate(*self, cx, v);} fn extract_mac() -> option {fail} @@ -44,7 +44,7 @@ fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { } fn get_fold_fn() -> ~str {~"fold_crate"} } -impl of qq_helper for @ast::expr { +impl @ast::expr: qq_helper { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt) {visit_expr(self, cx, v);} fn extract_mac() -> option { @@ -59,7 +59,7 @@ fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { } fn get_fold_fn() -> ~str {~"fold_expr"} } -impl of qq_helper for @ast::ty { +impl @ast::ty: qq_helper { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt) {visit_ty(self, cx, v);} fn extract_mac() -> option { @@ -74,7 +74,7 @@ fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { } fn get_fold_fn() -> ~str {~"fold_ty"} } -impl of qq_helper for @ast::item { +impl @ast::item: qq_helper { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt) {visit_item(self, cx, v);} fn extract_mac() -> option {fail} @@ -84,7 +84,7 @@ fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { } fn get_fold_fn() -> ~str {~"fold_item"} } -impl of qq_helper for @ast::stmt { +impl @ast::stmt: qq_helper { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt) {visit_stmt(self, cx, v);} fn extract_mac() -> option {fail} @@ -94,7 +94,7 @@ fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { } fn get_fold_fn() -> ~str {~"fold_stmt"} } -impl of qq_helper for @ast::pat { +impl @ast::pat: qq_helper { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt) {visit_pat(self, cx, v);} fn extract_mac() -> option {fail} diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs index 426fea346b9..98289152d33 100644 --- a/src/libsyntax/ext/simplext.rs +++ b/src/libsyntax/ext/simplext.rs @@ -1,6 +1,6 @@ import codemap::span; import std::map::{hashmap, str_hash, box_str_hash}; -import dvec::{dvec, extensions}; +import dvec::dvec; import base::*; diff --git a/src/libsyntax/ext/tt/earley_parser.rs b/src/libsyntax/ext/tt/earley_parser.rs index d84eb3ec488..a0717591b49 100644 --- a/src/libsyntax/ext/tt/earley_parser.rs +++ b/src/libsyntax/ext/tt/earley_parser.rs @@ -7,7 +7,7 @@ //import parse::common::parser_common; import parse::common::*; //resolve bug? import parse::parse_sess; -import dvec::{dvec, extensions}; +import dvec::dvec; import ast::{matcher, match_tok, match_seq, match_nonterminal, ident}; import ast_util::mk_sp; import std::map::{hashmap, box_str_hash}; diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index a870928d50b..557b11c5d95 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -2,7 +2,7 @@ import codemap::span; import ast::{ident, matcher_, matcher, match_tok, match_nonterminal, match_seq, tt_delim}; -import parse::lexer::{new_tt_reader, tt_reader_as_reader, reader}; +import parse::lexer::{new_tt_reader, reader}; import parse::token::{FAT_ARROW, SEMI, LBRACE, RBRACE, nt_matchers, nt_tt}; import parse::parser::{parser, SOURCE_FILE}; import earley_parser::{parse, parse_or_else, success, failure, named_match, diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 5954d70739e..48d0bf12845 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -652,7 +652,7 @@ fn default_ast_fold() -> ast_fold_precursor { new_span: noop_span}; } -impl of ast_fold for ast_fold_precursor { +impl ast_fold_precursor: ast_fold { /* naturally, a macro to write these would be nice */ fn fold_crate(c: crate) -> crate { let (n, s) = self.fold_crate(c.node, c.span, self as ast_fold); @@ -763,7 +763,7 @@ fn new_span(span: span) -> span { } } -impl extensions for ast_fold { +impl ast_fold { fn fold_attributes(attrs: ~[attribute]) -> ~[attribute] { attrs.map(|x| fold_attribute_(x, self)) } diff --git a/src/libsyntax/parse.rs b/src/libsyntax/parse.rs index 0a6df808530..6936eeed8f9 100644 --- a/src/libsyntax/parse.rs +++ b/src/libsyntax/parse.rs @@ -1,5 +1,4 @@ //! The main parser interface -import dvec::extensions; export parse_sess; export new_parse_sess, new_parse_sess_special_handler; @@ -19,8 +18,7 @@ import ast::node_id; import util::interner; import diagnostic::{span_handler, mk_span_handler, mk_handler, emitter}; -import lexer::{reader, string_reader, string_reader_as_reader}; -import lexer::{tt_reader_as_reader}; +import lexer::{reader, string_reader}; type parse_sess = @{ cm: codemap::codemap, diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index aefa7264bf6..a93d25ced00 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -23,7 +23,7 @@ fn parse_inner_attrs_and_next() -> fn parse_optional_meta() -> ~[@ast::meta_item]; } -impl parser_attr of parser_attr for parser { +impl parser: parser_attr { fn parse_outer_attrs_or_ext(first_item_attrs: ~[ast::attribute]) -> attr_or_ext diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index 7c24f8b1245..d3c17b81298 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -1,8 +1,7 @@ -import io::reader_util; import io::println;//XXXXXXXXxxx import util::interner; import lexer::{string_reader, bump, is_eof, nextch, - is_whitespace, get_str_from, string_reader_as_reader, reader}; + is_whitespace, get_str_from, reader}; export cmnt; export lit; diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 445e4c20eed..4038578d3f8 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -59,7 +59,7 @@ fn parse_seq(bra: token::token, ket: token::token, sep: seq_sep, f: fn(parser) -> T) -> spanned<~[T]>; } -impl parser_common of parser_common for parser { +impl parser: parser_common { fn unexpected_last(t: token::token) -> ! { self.span_fatal( copy self.last_span, diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index e9bfbc753f7..69dde491bdf 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -68,7 +68,7 @@ fn dup_string_reader(&&r: string_reader) -> string_reader { mut peek_tok: r.peek_tok, mut peek_span: r.peek_span} } -impl string_reader_as_reader of reader for string_reader { +impl string_reader: reader { fn is_eof() -> bool { is_eof(self) } fn next_token() -> {tok: token::token, sp: span} { let ret_val = {tok: self.peek_tok, sp: self.peek_span}; @@ -86,7 +86,7 @@ fn peek() -> {tok: token::token, sp: span} { fn dup() -> reader { dup_string_reader(self) as reader } } -impl tt_reader_as_reader of reader for tt_reader { +impl tt_reader: reader { fn is_eof() -> bool { self.cur_tok == token::EOF } fn next_token() -> {tok: token::token, sp: span} { /* weird resolve bug: if the following `if`, or any of its diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c8a333bb6e1..a572290a6f1 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -8,12 +8,12 @@ import codemap::{span,fss_none}; import util::interner; import ast_util::{spanned, respan, mk_sp, ident_to_path, operator_prec}; -import lexer::{reader, tt_reader_as_reader}; +import lexer::reader; import prec::{as_prec, token_to_binop}; import attr::parser_attr; import common::{seq_sep_trailing_disallowed, seq_sep_trailing_allowed, seq_sep_none, token_to_str}; -import dvec::{dvec, extensions}; +import dvec::dvec; import vec::{push}; import ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute, bind_by_ref, bind_by_implicit_ref, bind_by_value, @@ -2424,9 +2424,6 @@ fn parse_item_trait() -> item_info { } // Parses four variants (with the region/type params always optional): - // impl /& of to_str for ~[T] { ... } - // impl name/& of to_str for ~[T] { ... } - // impl name/& for ~[T] { ... } // impl ~[T] : to_str { ... } fn parse_item_impl() -> item_info { fn wrap_path(p: parser, pt: @path) -> @ty { @@ -2466,6 +2463,7 @@ fn wrap_path(p: parser, pt: @path) -> @ty { traits = ~[]; } } else { + self.warn(~"old-style named impl?"); let mut ident_old; if self.token == token::BINOP(token::SLASH) { self.parse_region_param(); diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index a8f9cf756a8..5bbf5deb429 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -1,5 +1,5 @@ import io::writer_util; -import dvec::{dvec, extensions}; +import dvec::dvec; /* * This pretty-printer is a direct reimplementation of Philip Karlton's @@ -232,7 +232,7 @@ enum printer { printer_(@printer_) } -impl printer for printer { +impl printer { fn last_token() -> token { self.token[self.right] } // be very careful with this! fn replace_last_token(t: token) { self.token[self.right] = t; } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 4ade7618bcd..7a20dc1d3be 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -7,7 +7,7 @@ import diagnostic; import ast::{required, provided}; import ast_util::{operator_prec}; -import dvec::{dvec, extensions}; +import dvec::dvec; import parse::classify::*; import util::interner; diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index ccc53020155..e003408f3fd 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -3,7 +3,7 @@ // type, and vice versa. import std::map; import std::map::{hashmap, hashfn, eqfn}; -import dvec::{dvec, extensions}; +import dvec::dvec; type hash_interner = {map: hashmap, @@ -25,7 +25,7 @@ trait interner { fn len() -> uint; } -impl of interner for hash_interner { +impl hash_interner: interner { fn intern(val: T) -> uint { match self.map.find(val) { some(idx) => return idx, diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index 2f6bd86592f..779739f8103 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -10,7 +10,7 @@ import back::link; import result::{ok, err}; import std::getopts; -import io::{reader_util, writer_util}; +import io::writer_util; import getopts::{optopt, optmulti, optflag, optflagopt, opt_present}; import back::{x86, x86_64}; import std::map::hashmap; diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index dbbe48f84b2..d737e41f816 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -18,7 +18,6 @@ import syntax::diagnostic; import rustc::driver::session; import rustc::middle::lint; -import io::reader_util; fn version(argv0: ~str) { let mut vers = ~"unknown version"; diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index 712c7d2cc41..172f940e2f1 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -110,7 +110,7 @@ enum session { session_(@session_) } -impl session for session { +impl session { fn span_fatal(sp: span, msg: ~str) -> ! { self.span_diagnostic.span_fatal(sp, msg) } diff --git a/src/rustc/front/test.rs b/src/rustc/front/test.rs index 9c54f6fa981..2f892c9ba9d 100644 --- a/src/rustc/front/test.rs +++ b/src/rustc/front/test.rs @@ -9,7 +9,7 @@ import driver::session; import session::session; import syntax::attr; -import dvec::{dvec, extensions}; +import dvec::dvec; export modify_for_testing; diff --git a/src/rustc/metadata/creader.rs b/src/rustc/metadata/creader.rs index 5b72a6caa6c..13c85d02b73 100644 --- a/src/rustc/metadata/creader.rs +++ b/src/rustc/metadata/creader.rs @@ -9,7 +9,7 @@ import syntax::print::pprust; import filesearch::filesearch; import common::*; -import dvec::{dvec, extensions}; +import dvec::dvec; export read_crates; diff --git a/src/rustc/metadata/csearch.rs b/src/rustc/metadata/csearch.rs index 203b527b21f..985cdd9c2d1 100644 --- a/src/rustc/metadata/csearch.rs +++ b/src/rustc/metadata/csearch.rs @@ -10,7 +10,7 @@ import syntax::diagnostic::expect; import common::*; import std::map::hashmap; -import dvec::{dvec, extensions}; +import dvec::dvec; export class_dtor; export get_symbol; diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index d9567fd1b70..7dcbae048dd 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -2,7 +2,7 @@ import std::{ebml, map}; import std::map::{hashmap, str_hash}; -import dvec::{dvec, extensions}; +import dvec::dvec; import io::writer_util; import syntax::{ast, ast_util}; import syntax::attr; @@ -13,7 +13,6 @@ import syntax::print::pprust; import cmd=cstore::crate_metadata; import util::ppaux::ty_to_str; -import ebml::deserializer; import syntax::diagnostic::span_handler; import common::*; diff --git a/src/rustc/metadata/filesearch.rs b/src/rustc/metadata/filesearch.rs index 54aef6e858f..eb8b2ffec63 100644 --- a/src/rustc/metadata/filesearch.rs +++ b/src/rustc/metadata/filesearch.rs @@ -36,7 +36,7 @@ fn mk_filesearch(maybe_sysroot: option, type filesearch_impl = {sysroot: path, addl_lib_search_paths: ~[path], target_triple: ~str}; - impl of filesearch for filesearch_impl { + impl filesearch_impl: filesearch { fn sysroot() -> path { self.sysroot } fn lib_search_paths() -> ~[path] { let mut paths = self.addl_lib_search_paths; diff --git a/src/rustc/middle/astencode.rs b/src/rustc/middle/astencode.rs index cf0b586e51e..d1ccc72ac00 100644 --- a/src/rustc/middle/astencode.rs +++ b/src/rustc/middle/astencode.rs @@ -1,19 +1,14 @@ import util::ppaux::ty_to_str; -import dvec::extensions; import syntax::ast; import syntax::fold; import syntax::fold::*; import syntax::visit; import syntax::ast_map; import syntax::ast_util; -import syntax::ast_util::inlined_item_methods; import syntax::codemap::span; import std::ebml; import std::ebml::writer; -import std::ebml::serializer; -import std::ebml::deserializer; -import std::ebml::extensions; import std::ebml::get_doc; import std::map::hashmap; import std::serialization::serializer; @@ -21,7 +16,6 @@ import std::serialization::serializer_helpers; import std::serialization::deserializer_helpers; import std::prettyprint::serializer; -import std::smallintmap::map; import middle::{ty, typeck}; import middle::typeck::{method_origin, method_map_entry, serialize_method_map_entry, @@ -155,7 +149,7 @@ fn reserve_id_range(sess: session, return {min: to_id_min, max: to_id_min}; } -impl translation_routines for extended_decode_ctxt { +impl extended_decode_ctxt { fn tr_id(id: ast::node_id) -> ast::node_id { // from_id_range should be non-empty assert !ast_util::empty(self.from_id_range); @@ -173,7 +167,7 @@ fn tr_span(_span: span) -> span { } } -impl of tr for ast::def_id { +impl ast::def_id: tr { fn tr(xcx: extended_decode_ctxt) -> ast::def_id { xcx.tr_def_id(self) } @@ -182,7 +176,7 @@ fn tr_intern(xcx: extended_decode_ctxt) -> ast::def_id { } } -impl of tr for span { +impl span: tr { fn tr(xcx: extended_decode_ctxt) -> span { xcx.tr_span(self) } @@ -192,7 +186,7 @@ trait def_id_serializer_helpers { fn emit_def_id(did: ast::def_id); } -impl serializer_helpers of def_id_serializer_helpers for S { +impl S: def_id_serializer_helpers { fn emit_def_id(did: ast::def_id) { ast::serialize_def_id(self, did) } @@ -202,8 +196,7 @@ trait def_id_deserializer_helpers { fn read_def_id(xcx: extended_decode_ctxt) -> ast::def_id; } -impl deserializer_helpers of def_id_deserializer_helpers - for D { +impl D: def_id_deserializer_helpers { fn read_def_id(xcx: extended_decode_ctxt) -> ast::def_id { let did = ast::deserialize_def_id(self); @@ -350,7 +343,7 @@ fn decode_def(xcx: extended_decode_ctxt, doc: ebml::doc) -> ast::def { def.tr(xcx) } -impl of tr for ast::def { +impl ast::def: tr { fn tr(xcx: extended_decode_ctxt) -> ast::def { match self { ast::def_fn(did, p) => { ast::def_fn(did.tr(xcx), p) } @@ -396,14 +389,14 @@ trait ebml_deserializer_helper { fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry; } -impl helper of ebml_deserializer_helper for ebml::ebml_deserializer { +impl ebml::ebml_deserializer: ebml_deserializer_helper { fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry { let fv = deserialize_freevar_entry(self); fv.tr(xcx) } } -impl of tr for freevar_entry { +impl freevar_entry: tr { fn tr(xcx: extended_decode_ctxt) -> freevar_entry { {def: self.def.tr(xcx), span: self.span.tr(xcx)} } @@ -416,14 +409,14 @@ trait read_method_map_entry_helper { fn read_method_map_entry(xcx: extended_decode_ctxt) -> method_map_entry; } -impl helper of read_method_map_entry_helper for ebml::ebml_deserializer { +impl ebml::ebml_deserializer: read_method_map_entry_helper { fn read_method_map_entry(xcx: extended_decode_ctxt) -> method_map_entry { let mme = deserialize_method_map_entry(self); {derefs: mme.derefs, origin: mme.origin.tr(xcx)} } } -impl of tr for method_origin { +impl method_origin: tr { fn tr(xcx: extended_decode_ctxt) -> method_origin { match self { typeck::method_static(did) => { @@ -502,7 +495,7 @@ trait vtable_deserialization_helpers { fn read_vtable_origin(xcx: extended_decode_ctxt) -> typeck::vtable_origin; } -impl helpers of vtable_deserialization_helpers for ebml::ebml_deserializer { +impl ebml::ebml_deserializer: vtable_deserialization_helpers { fn read_vtable_res(xcx: extended_decode_ctxt) -> typeck::vtable_res { @self.read_to_vec(|| self.read_vtable_origin(xcx) ) } @@ -558,7 +551,7 @@ trait get_ty_str_ctxt { fn ty_str_ctxt() -> @tyencode::ctxt; } -impl helpers of get_ty_str_ctxt for @e::encode_ctxt { +impl @e::encode_ctxt: get_ty_str_ctxt { fn ty_str_ctxt() -> @tyencode::ctxt { @{diag: self.tcx.sess.diagnostic(), ds: e::def_to_str, @@ -575,7 +568,7 @@ trait ebml_writer_helpers { fn emit_tpbt(ecx: @e::encode_ctxt, tpbt: ty::ty_param_bounds_and_ty); } -impl helpers of ebml_writer_helpers for ebml::writer { +impl ebml::writer: ebml_writer_helpers { fn emit_ty(ecx: @e::encode_ctxt, ty: ty::t) { e::write_type(ecx, self, ty) } @@ -612,7 +605,7 @@ trait write_tag_and_id { fn id(id: ast::node_id); } -impl writer of write_tag_and_id for ebml::writer { +impl ebml::writer: write_tag_and_id { fn tag(tag_id: c::astencode_tag, f: fn()) { do self.wr_tag(tag_id as uint) { f() } } @@ -771,7 +764,7 @@ trait doc_decoder_helpers { fn opt_child(tag: c::astencode_tag) -> option; } -impl decoder of doc_decoder_helpers for ebml::doc { +impl ebml::doc: doc_decoder_helpers { fn as_int() -> int { ebml::doc_as_u64(self) as int } fn opt_child(tag: c::astencode_tag) -> option { ebml::maybe_get_doc(self, tag as uint) @@ -786,8 +779,7 @@ fn read_ty_param_bounds_and_ty(xcx: extended_decode_ctxt) -> ty::ty_param_bounds_and_ty; } -impl decoder of ebml_deserializer_decoder_helpers - for ebml::ebml_deserializer { +impl ebml::ebml_deserializer: ebml_deserializer_decoder_helpers { fn read_ty(xcx: extended_decode_ctxt) -> ty::t { // Note: regions types embed local node ids. In principle, we @@ -922,7 +914,7 @@ trait fake_ext_ctxt { type fake_session = (); #[cfg(test)] -impl of fake_ext_ctxt for fake_session { +impl fake_session: fake_ext_ctxt { fn cfg() -> ast::crate_cfg { ~[] } fn parse_sess() -> parse::parse_sess { parse::new_parse_sess(none) } } diff --git a/src/rustc/middle/borrowck.rs b/src/rustc/middle/borrowck.rs index b00a8c31ef0..61caf4a2509 100644 --- a/src/rustc/middle/borrowck.rs +++ b/src/rustc/middle/borrowck.rs @@ -224,12 +224,12 @@ import std::map::{int_hash, hashmap, set}; import std::list; import std::list::{list, cons, nil}; -import result::{result, ok, err, extensions}; +import result::{result, ok, err}; import syntax::print::pprust; import util::common::indenter; import ty::to_str; import driver::session::session; -import dvec::{dvec, extensions}; +import dvec::dvec; import mem_categorization::*; export check_crate, root_map, mutbl_map; diff --git a/src/rustc/middle/borrowck/check_loans.rs b/src/rustc/middle/borrowck/check_loans.rs index d0ec0518458..4c596a34354 100644 --- a/src/rustc/middle/borrowck/check_loans.rs +++ b/src/rustc/middle/borrowck/check_loans.rs @@ -7,7 +7,7 @@ // 3. assignments do not affect things loaned out as immutable // 4. moves to dnot affect things loaned out in any way -import dvec::{dvec, extensions}; +import dvec::dvec; export check_loans; @@ -59,7 +59,7 @@ enum assignment_type { at_mutbl_ref, } -impl methods for assignment_type { +impl assignment_type { fn checked_by_liveness() -> bool { // the liveness pass guarantees that immutable local variables // are only assigned once; but it doesn't consider &mut @@ -78,7 +78,7 @@ fn ing_form(desc: ~str) -> ~str { } } -impl methods for check_loan_ctxt { +impl check_loan_ctxt { fn tcx() -> ty::ctxt { self.bccx.tcx } fn purity(scope_id: ast::node_id) -> option { diff --git a/src/rustc/middle/borrowck/gather_loans.rs b/src/rustc/middle/borrowck/gather_loans.rs index ee09584bb9f..bcf36b4cb1a 100644 --- a/src/rustc/middle/borrowck/gather_loans.rs +++ b/src/rustc/middle/borrowck/gather_loans.rs @@ -7,8 +7,7 @@ // sure that all of these loans are honored. import mem_categorization::{opt_deref_kind}; -import loan::public_methods; -import preserve::{public_methods, preserve_condition, pc_ok, pc_if_pure}; +import preserve::{preserve_condition, pc_ok, pc_if_pure}; import ty::ty_region; export gather_loans; @@ -243,7 +242,7 @@ fn req_loans_in_expr(ex: @ast::expr, self.root_ub = old_root_ub; } -impl methods for gather_loan_ctxt { +impl gather_loan_ctxt { fn tcx() -> ty::ctxt { self.bccx.tcx } // guarantees that addr_of(cmt) will be valid for the duration of diff --git a/src/rustc/middle/borrowck/loan.rs b/src/rustc/middle/borrowck/loan.rs index 9411545754f..ea917ec60d2 100644 --- a/src/rustc/middle/borrowck/loan.rs +++ b/src/rustc/middle/borrowck/loan.rs @@ -5,7 +5,7 @@ export public_methods; import result::{result, ok, err}; -impl public_methods for borrowck_ctxt { +impl borrowck_ctxt { fn loan(cmt: cmt, scope_region: ty::region, mutbl: ast::mutability) -> bckres<@dvec> { @@ -33,7 +33,7 @@ enum loan_ctxt { loan_ctxt_(@loan_ctxt_) } -impl loan_methods for loan_ctxt { +impl loan_ctxt { fn tcx() -> ty::ctxt { self.bccx.tcx } fn ok_with_loan_of(cmt: cmt, diff --git a/src/rustc/middle/borrowck/preserve.rs b/src/rustc/middle/borrowck/preserve.rs index 7993a972517..964a54bcad4 100644 --- a/src/rustc/middle/borrowck/preserve.rs +++ b/src/rustc/middle/borrowck/preserve.rs @@ -10,7 +10,7 @@ enum preserve_condition { pc_if_pure(bckerr) } -impl public_methods for preserve_condition { +impl preserve_condition { // combines two preservation conditions such that if either of // them requires purity, the result requires purity fn combine(pc: preserve_condition) -> preserve_condition { @@ -21,7 +21,7 @@ fn combine(pc: preserve_condition) -> preserve_condition { } } -impl public_methods for borrowck_ctxt { +impl borrowck_ctxt { fn preserve(cmt: cmt, scope_region: ty::region, item_ub: ast::node_id, @@ -54,7 +54,7 @@ enum preserve_ctxt = { }; -impl private_methods for &preserve_ctxt { +priv impl &preserve_ctxt { fn tcx() -> ty::ctxt { self.bccx.tcx } fn preserve(cmt: cmt) -> bckres { diff --git a/src/rustc/middle/check_const.rs b/src/rustc/middle/check_const.rs index 9ea88317176..67e5d9cd6a1 100644 --- a/src/rustc/middle/check_const.rs +++ b/src/rustc/middle/check_const.rs @@ -2,7 +2,7 @@ import syntax::{visit, ast_util, ast_map}; import driver::session::session; import std::map::hashmap; -import dvec::{dvec, extensions}; +import dvec::dvec; fn check_crate(sess: session, crate: @crate, ast_map: ast_map::map, def_map: resolve3::DefMap, diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index 408b0ef6916..61d9938e388 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -1,13 +1,12 @@ import syntax::{visit, ast_util}; import syntax::ast::*; import syntax::codemap::span; -import ty::{kind, kind_copyable, kind_noncopyable, kind_const, operators}; +import ty::{kind, kind_copyable, kind_noncopyable, kind_const}; import driver::session::session; import std::map::hashmap; import util::ppaux::{ty_to_str, tys_to_str}; import syntax::print::pprust::expr_to_str; import freevars::freevar_entry; -import dvec::extensions; import lint::{non_implicitly_copyable_typarams,implicit_copies}; // Kind analysis pass. diff --git a/src/rustc/middle/lint.rs b/src/rustc/middle/lint.rs index 77998a0c8cf..8afcab79444 100644 --- a/src/rustc/middle/lint.rs +++ b/src/rustc/middle/lint.rs @@ -205,7 +205,7 @@ enum ctxt { ctxt_(ctxt_) } -impl methods for ctxt { +impl ctxt { fn get_level(lint: lint) -> level { get_lint_level(self.curr, lint) } diff --git a/src/rustc/middle/liveness.rs b/src/rustc/middle/liveness.rs index b6fc75cfb05..4c4bf98626b 100644 --- a/src/rustc/middle/liveness.rs +++ b/src/rustc/middle/liveness.rs @@ -100,7 +100,7 @@ * - `self_var`: a variable representing 'self' */ -import dvec::{dvec, extensions}; +import dvec::dvec; import std::map::{hashmap, int_hash, str_hash, box_str_hash}; import syntax::{visit, ast_util}; import syntax::print::pprust::{expr_to_str}; @@ -152,11 +152,11 @@ fn check_crate(tcx: ty::ctxt, return last_use_map; } -impl of to_str::to_str for live_node { +impl live_node: to_str::to_str { fn to_str() -> ~str { fmt!{"ln(%u)", *self} } } -impl of to_str::to_str for variable { +impl variable: to_str::to_str { fn to_str() -> ~str { fmt!{"v(%u)", *self} } } @@ -182,7 +182,7 @@ fn to_str() -> ~str { fmt!{"v(%u)", *self} } // variable must not be assigned if there is some successor // assignment. And so forth. -impl methods for live_node { +impl live_node { pure fn is_valid() -> bool { *self != uint::max_value } } @@ -1477,7 +1477,7 @@ enum read_kind { moved_variable } -impl check_methods for @liveness { +impl @liveness { fn check_fields(sp: span, entry_ln: live_node) { for self.ir.field_map.each |nm, var| { match (*self).live_on_entry(entry_ln, var) { diff --git a/src/rustc/middle/mem_categorization.rs b/src/rustc/middle/mem_categorization.rs index 9d6629d8edc..d600f63246a 100644 --- a/src/rustc/middle/mem_categorization.rs +++ b/src/rustc/middle/mem_categorization.rs @@ -209,12 +209,12 @@ trait ast_node { fn span() -> span; } -impl of ast_node for @ast::expr { +impl @ast::expr: ast_node { fn id() -> ast::node_id { self.id } fn span() -> span { self.span } } -impl of ast_node for @ast::pat { +impl @ast::pat: ast_node { fn id() -> ast::node_id { self.id } fn span() -> span { self.span } } @@ -223,7 +223,7 @@ trait get_type_for_node { fn ty(node: N) -> ty::t; } -impl methods of get_type_for_node for ty::ctxt { +impl ty::ctxt: get_type_for_node { fn ty(node: N) -> ty::t { ty::node_id_to_type(self, node.id()) } diff --git a/src/rustc/middle/region.rs b/src/rustc/middle/region.rs index 3dc7d1b9df8..a9117ae8bcb 100644 --- a/src/rustc/middle/region.rs +++ b/src/rustc/middle/region.rs @@ -14,7 +14,7 @@ import syntax::print::pprust; import syntax::ast_util::new_def_hash; import syntax::ast_map; -import dvec::{dvec, extensions}; +import dvec::dvec; import metadata::csearch; import std::list; @@ -365,7 +365,7 @@ enum determine_rp_ctxt { determine_rp_ctxt_(@determine_rp_ctxt_) } -impl methods for determine_rp_ctxt { +impl determine_rp_ctxt { fn add_rp(id: ast::node_id) { assert id != 0; if self.region_paramd_items.insert(id, ()) { diff --git a/src/rustc/middle/resolve3.rs b/src/rustc/middle/resolve3.rs index 15c01c64657..f30ab29b9b0 100644 --- a/src/rustc/middle/resolve3.rs +++ b/src/rustc/middle/resolve3.rs @@ -52,7 +52,7 @@ import syntax::visit::{visit_mod, visit_ty, vt}; import box::ptr_eq; -import dvec::{dvec, extensions}; +import dvec::dvec; import option::{get, is_some}; import str::{connect, split_str}; import vec::pop; diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 6e3034f26ef..1e2a9f42291 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -13,7 +13,7 @@ import middle::resolve3::DefMap; import back::abi; import std::map::hashmap; -import dvec::{dvec, extensions}; +import dvec::dvec; import common::*; diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index fb671a277a8..354b368897a 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -22,7 +22,7 @@ import syntax::attr; import back::{link, abi, upcall}; import syntax::{ast, ast_util, codemap, ast_map}; -import ast_util::{inlined_item_methods, local_def, path_to_ident}; +import ast_util::{local_def, path_to_ident}; import syntax::visit; import syntax::codemap::span; import syntax::print::pprust::{expr_to_str, stmt_to_str, path_to_str}; @@ -98,7 +98,7 @@ trait get_insn_ctxt { fn insn_ctxt(s: ~str) -> icx_popper; } -impl ccx_icx of get_insn_ctxt for @crate_ctxt { +impl @crate_ctxt: get_insn_ctxt { fn insn_ctxt(s: ~str) -> icx_popper { debug!{"new insn_ctxt: %s", s}; if self.sess.count_llvm_insns() { @@ -108,13 +108,13 @@ fn insn_ctxt(s: ~str) -> icx_popper { } } -impl bcx_icx of get_insn_ctxt for block { +impl block: get_insn_ctxt { fn insn_ctxt(s: ~str) -> icx_popper { self.ccx().insn_ctxt(s) } } -impl fcx_icx of get_insn_ctxt for fn_ctxt { +impl fn_ctxt: get_insn_ctxt { fn insn_ctxt(s: ~str) -> icx_popper { self.ccx.insn_ctxt(s) } diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index d5af4e181a7..20a9ab752e0 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -18,7 +18,6 @@ import syntax::ast_map::{path, path_mod, path_name}; import driver::session::session; import std::map::hashmap; -import dvec::extensions; // ___Good to know (tm)__________________________________________________ // diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index 20573eff4cc..1d8c4686c55 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -355,19 +355,22 @@ trait get_node_info { fn info() -> option; } -impl node_info of get_node_info for @ast::expr { +impl @ast::expr: get_node_info { fn info() -> option { some({id: self.id, span: self.span}) } } -impl node_info of get_node_info for ast::blk { +impl ast::blk: get_node_info { fn info() -> option { some({id: self.node.id, span: self.span}) } } -impl node_info of get_node_info for option<@ast::expr> { +// XXX: Work around a trait parsing bug. remove after snapshot +type optional_boxed_ast_expr = option<@ast::expr>; + +impl optional_boxed_ast_expr: get_node_info { fn info() -> option { self.chain(|s| s.info()) } @@ -471,7 +474,7 @@ fn block_parent(cx: block) -> block { // Accessors -impl bcx_cxs for block { +impl block { pure fn ccx() -> @crate_ctxt { self.fcx.ccx } pure fn tcx() -> ty::ctxt { self.fcx.ccx.tcx } pure fn sess() -> session { self.fcx.ccx.sess } diff --git a/src/rustc/middle/trans/reflect.rs b/src/rustc/middle/trans/reflect.rs index fbcb01ff68e..939a50e8b71 100644 --- a/src/rustc/middle/trans/reflect.rs +++ b/src/rustc/middle/trans/reflect.rs @@ -18,7 +18,7 @@ enum reflector = { mut bcx: block }; -impl methods for reflector { +impl reflector { fn c_uint(u: uint) -> ValueRef { C_uint(self.bcx.ccx(), u) diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index 2d57b71e683..32687733554 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -15,8 +15,7 @@ import syntax::util::interner; import util::ppaux::ty_to_str; import syntax::codemap::span; -import dvec::{dvec, extensions}; -import vec::extensions; +import dvec::dvec; import std::map::hashmap; import option::is_some; diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index 94c48ace749..5c4fe468686 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -5,7 +5,7 @@ import base::{call_memmove, INIT, copy_val, load_if_immediate, get_tydesc, sub_block, do_spill_noroot, - dest, bcx_icx, non_gc_box_cast, move_val, lval_owned}; + dest, non_gc_box_cast, move_val, lval_owned}; import syntax::codemap::span; import shape::llsize_of; import build::*; diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index 5af0cc4f435..8cc87932b03 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -485,17 +485,17 @@ trait vid { pure fn to_str() -> ~str; } -impl of vid for tv_vid { +impl tv_vid: vid { pure fn to_uint() -> uint { *self } pure fn to_str() -> ~str { fmt!{"", self.to_uint()} } } -impl of vid for tvi_vid { +impl tvi_vid: vid { pure fn to_uint() -> uint { *self } pure fn to_str() -> ~str { fmt!{"", self.to_uint()} } } -impl of vid for region_vid { +impl region_vid: vid { pure fn to_uint() -> uint { *self } pure fn to_str() -> ~str { fmt!{"", self.to_uint()} } } @@ -504,7 +504,7 @@ trait purity_to_str { pure fn to_str() -> ~str; } -impl of purity_to_str for purity { +impl purity: purity_to_str { pure fn to_str() -> ~str { purity_to_str(self) } @@ -1469,7 +1469,7 @@ fn remove_copyable(k: kind) -> kind { k - kind_(KIND_MASK_COPY) } -impl operators for kind { +impl kind { fn &(other: kind) -> kind { lower_kind(self, other) } @@ -1483,7 +1483,7 @@ fn -(other: kind) -> kind { } } -impl operators of ops::bitand for kind { +impl kind: ops::bitand { pure fn bitand(other: kind) -> kind { unchecked { lower_kind(self, other) @@ -1491,7 +1491,7 @@ impl operators of ops::bitand for kind { } } -impl operators of ops::bitor for kind { +impl kind: ops::bitor { pure fn bitor(other: kind) -> kind { unchecked { raise_kind(self, other) @@ -1499,7 +1499,7 @@ impl operators of ops::bitor for kind { } } -impl operators of ops::sub for kind { +impl kind: ops::sub { pure fn sub(other: kind) -> kind { unchecked { kind_(*self & !*other) diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index aa9942ee108..690322ec4db 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -38,7 +38,7 @@ */ -import result::{result, extensions}; +import result::result; import syntax::{ast, ast_util, ast_map}; import ast::spanned; import ast::{required, provided}; @@ -54,9 +54,7 @@ import middle::ty; import middle::ty::{arg, field, node_type_table, mk_nil, ty_param_bounds_and_ty, lookup_public_fields}; -import middle::typeck::infer::methods; import std::smallintmap; -import std::smallintmap::map; import std::map; import std::map::{hashmap, int_hash}; import std::serialization::{serialize_uint, deserialize_uint}; diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 8a7ba85d141..fa1fb000234 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -68,13 +68,11 @@ import astconv::{ast_conv, ast_path_to_ty, ast_ty_to_ty}; import astconv::{ast_region_to_region}; -import collect::{methods}; // ccx.to_ty() import middle::ty::{tv_vid, vid}; import regionmanip::{replace_bound_regions_in_fn_ty}; import rscope::{anon_rscope, binding_rscope, empty_rscope, in_anon_rscope}; import rscope::{in_binding_rscope, region_scope, type_rscope}; import syntax::ast::ty_i; -import typeck::infer::{unify_methods}; // infcx.set() import typeck::infer::{resolve_type, force_tvar}; import std::map::str_hash; @@ -149,7 +147,7 @@ trait get_and_find_region { fn find(br: ty::bound_region) -> option; } -impl methods of get_and_find_region for isr_alist { +impl isr_alist: get_and_find_region { fn get(br: ty::bound_region) -> ty::region { option::get(self.find(br)) } @@ -504,7 +502,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) { } } -impl of ast_conv for @fn_ctxt { +impl @fn_ctxt: ast_conv { fn tcx() -> ty::ctxt { self.ccx.tcx } fn ccx() -> @crate_ctxt { self.ccx } @@ -517,7 +515,7 @@ fn ty_infer(_span: span) -> ty::t { } } -impl of region_scope for @fn_ctxt { +impl @fn_ctxt: region_scope { fn anon_region() -> result { result::ok(self.infcx.next_region_var_nb()) } @@ -534,7 +532,7 @@ fn named_region(id: ast::ident) -> result { } } -impl methods for @fn_ctxt { +impl @fn_ctxt { fn tag() -> ~str { fmt!{"%x", ptr::addr_of(*self) as uint} } fn block_region() -> result { result::ok(ty::re_scope(self.region_lb)) diff --git a/src/rustc/middle/typeck/check/alt.rs b/src/rustc/middle/typeck/check/alt.rs index cb25cb5382f..99afc9e19fe 100644 --- a/src/rustc/middle/typeck/check/alt.rs +++ b/src/rustc/middle/typeck/check/alt.rs @@ -1,5 +1,3 @@ -import middle::typeck::infer::methods; // next_ty_var, - // resolve_type_vars_if_possible import syntax::print::pprust; fn check_alt(fcx: @fn_ctxt, diff --git a/src/rustc/middle/typeck/check/demand.rs b/src/rustc/middle/typeck/check/demand.rs index 17f171bdf90..cdb2a930608 100644 --- a/src/rustc/middle/typeck/check/demand.rs +++ b/src/rustc/middle/typeck/check/demand.rs @@ -1,4 +1,4 @@ -import check::{fn_ctxt, methods}; +import check::fn_ctxt; // Requires that the two types unify, and prints an error message if they // don't. diff --git a/src/rustc/middle/typeck/check/method.rs b/src/rustc/middle/typeck/check/method.rs index 38307485e85..6ff3c768b1c 100644 --- a/src/rustc/middle/typeck/check/method.rs +++ b/src/rustc/middle/typeck/check/method.rs @@ -3,14 +3,13 @@ import coherence::get_base_type_def_id; import middle::resolve3::{Impl, MethodInfo}; import middle::ty::{mk_box, mk_rptr, mk_uniq}; -import middle::typeck::infer::methods; // next_ty_vars import syntax::ast::{def_id, sty_static, sty_box, sty_by_ref, sty_region, sty_uniq}; import syntax::ast::{sty_value}; import syntax::ast_map; import syntax::ast_map::node_id_to_str; import syntax::ast_util::{dummy_sp, new_def_hash}; -import dvec::{dvec, extensions}; +import dvec::dvec; type candidate = { self_ty: ty::t, // type of a in a.b() diff --git a/src/rustc/middle/typeck/check/regionck.rs b/src/rustc/middle/typeck/check/regionck.rs index 506ed5902e8..34a0bfc41a5 100644 --- a/src/rustc/middle/typeck/check/regionck.rs +++ b/src/rustc/middle/typeck/check/regionck.rs @@ -27,7 +27,7 @@ enum rcx { rcx_({fcx: @fn_ctxt, mut errors_reported: uint}) } type rvt = visit::vt<@rcx>; -impl methods for @rcx { +impl @rcx { /// Try to resolve the type for the given node. /// /// Note one important point: we do not attempt to resolve *region diff --git a/src/rustc/middle/typeck/check/vtable.rs b/src/rustc/middle/typeck/check/vtable.rs index ec8e89ef2ad..3632ad33e0e 100644 --- a/src/rustc/middle/typeck/check/vtable.rs +++ b/src/rustc/middle/typeck/check/vtable.rs @@ -1,7 +1,6 @@ -import check::{fn_ctxt, impl_self_ty, methods}; +import check::{fn_ctxt, impl_self_ty}; import infer::{resolve_type, resolve_all, force_all, fixup_err_to_str}; import ast_util::new_def_hash; -import dvec::extensions; fn has_trait_bounds(tps: ~[ty::param_bounds]) -> bool { vec::any(tps, |bs| { diff --git a/src/rustc/middle/typeck/check/writeback.rs b/src/rustc/middle/typeck/check/writeback.rs index fc5a3763615..9e336ca5ea0 100644 --- a/src/rustc/middle/typeck/check/writeback.rs +++ b/src/rustc/middle/typeck/check/writeback.rs @@ -2,7 +2,7 @@ // unresolved type variables and replaces "ty_var" types with their // substitutions. -import check::{fn_ctxt, lookup_local, methods}; +import check::{fn_ctxt, lookup_local}; import infer::{resolve_type, resolve_all, force_all}; export resolve_type_vars_in_fn; export resolve_type_vars_in_expr; diff --git a/src/rustc/middle/typeck/coherence.rs b/src/rustc/middle/typeck/coherence.rs index c732f16dc80..d84b7ad69c0 100644 --- a/src/rustc/middle/typeck/coherence.rs +++ b/src/rustc/middle/typeck/coherence.rs @@ -30,8 +30,8 @@ import syntax::visit::{visit_mod}; import util::ppaux::ty_to_str; -import dvec::{dvec, extensions}; -import result::{extensions, ok}; +import dvec::dvec; +import result::ok; import std::map::{hashmap, int_hash}; import uint::range; import vec::{len, push}; diff --git a/src/rustc/middle/typeck/collect.rs b/src/rustc/middle/typeck/collect.rs index c404103b77e..02ca13aee2e 100644 --- a/src/rustc/middle/typeck/collect.rs +++ b/src/rustc/middle/typeck/collect.rs @@ -68,7 +68,7 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) { })); } -impl methods for @crate_ctxt { +impl @crate_ctxt { fn to_ty( rs: RS, ast_ty: @ast::ty) -> ty::t { @@ -76,7 +76,7 @@ fn to_ty( } } -impl of ast_conv for @crate_ctxt { +impl @crate_ctxt: ast_conv { fn tcx() -> ty::ctxt { self.tcx } fn ccx() -> @crate_ctxt { self } diff --git a/src/rustc/middle/typeck/infer.rs b/src/rustc/middle/typeck/infer.rs index b4c28b19354..9f62b8c7eb2 100644 --- a/src/rustc/middle/typeck/infer.rs +++ b/src/rustc/middle/typeck/infer.rs @@ -166,7 +166,6 @@ fn bar() { import std::smallintmap; import std::smallintmap::smallintmap; -import std::smallintmap::map; import std::map::hashmap; import middle::ty; import middle::ty::{tv_vid, tvi_vid, region_vid, vid, @@ -174,14 +173,14 @@ fn bar() { import syntax::{ast, ast_util}; import syntax::ast::{ret_style, purity}; import util::ppaux::{ty_to_str, mt_to_str}; -import result::{result, extensions, ok, err, map_vec, map_vec2, iter_vec2}; +import result::{result, ok, err, map_vec, map_vec2, iter_vec2}; import ty::{mk_fn, type_is_bot}; import check::regionmanip::{replace_bound_regions_in_fn_ty}; import driver::session::session; import util::common::{indent, indenter}; import ast::{unsafe_fn, impure_fn, pure_fn, extern_fn}; import ast::{m_const, m_imm, m_mutbl}; -import dvec::{dvec, extensions}; +import dvec::dvec; export infer_ctxt; export new_infer_ctxt; @@ -441,7 +440,7 @@ fn then(f: fn() -> result) -> result; } -impl methods of then for ures { +impl ures: then { fn then(f: fn() -> result) -> result { self.chain(|_i| f()) @@ -453,7 +452,7 @@ trait cres_helpers { fn compare(t: T, f: fn() -> ty::type_err) -> cres; } -impl methods of cres_helpers for cres { +impl cres: cres_helpers { fn to_ures() -> ures { match self { ok(_v) => ok(()), @@ -476,25 +475,25 @@ trait to_str { fn to_str(cx: infer_ctxt) -> ~str; } -impl of to_str for ty::t { +impl ty::t: to_str { fn to_str(cx: infer_ctxt) -> ~str { ty_to_str(cx.tcx, self) } } -impl of to_str for ty::mt { +impl ty::mt: to_str { fn to_str(cx: infer_ctxt) -> ~str { mt_to_str(cx.tcx, self) } } -impl of to_str for ty::region { +impl ty::region: to_str { fn to_str(cx: infer_ctxt) -> ~str { util::ppaux::region_to_str(cx.tcx, self) } } -impl of to_str for bound { +impl bound: to_str { fn to_str(cx: infer_ctxt) -> ~str { match self { some(v) => v.to_str(cx), @@ -503,7 +502,7 @@ fn to_str(cx: infer_ctxt) -> ~str { } } -impl of to_str for bounds { +impl bounds: to_str { fn to_str(cx: infer_ctxt) -> ~str { fmt!{"{%s <: %s}", self.lb.to_str(cx), @@ -511,7 +510,7 @@ fn to_str(cx: infer_ctxt) -> ~str { } } -impl of to_str for int_ty_set { +impl int_ty_set: to_str { fn to_str(_cx: infer_ctxt) -> ~str { match self { int_ty_set(v) => uint::to_str(v, 10u) @@ -519,7 +518,7 @@ fn to_str(_cx: infer_ctxt) -> ~str { } } -impl of to_str for var_value { +impl var_value: to_str { fn to_str(cx: infer_ctxt) -> ~str { match self { redirect(vid) => fmt!{"redirect(%s)", vid.to_str()}, @@ -535,7 +534,7 @@ trait st { fn glb(infcx: infer_ctxt, b: self) -> cres; } -impl of st for ty::t { +impl ty::t: st { fn sub(infcx: infer_ctxt, &&b: ty::t) -> ures { sub(infcx).tys(self, b).to_ures() } @@ -549,7 +548,7 @@ fn glb(infcx: infer_ctxt, &&b: ty::t) -> cres { } } -impl of st for ty::region { +impl ty::region: st { fn sub(infcx: infer_ctxt, &&b: ty::region) -> ures { sub(infcx).regions(self, b).chain(|_r| ok(())) } @@ -576,7 +575,7 @@ fn rollback_to( } } -impl transaction_methods for infer_ctxt { +impl infer_ctxt { /// Execute `f` and commit the bindings if successful fn commit(f: fn() -> result) -> result { @@ -625,7 +624,7 @@ fn probe(f: fn() -> result) -> result { } } -impl methods for infer_ctxt { +impl infer_ctxt { fn next_ty_var_id() -> tv_vid { let id = *self.ty_var_counter; *self.ty_var_counter += 1u; @@ -695,7 +694,7 @@ fn resolve_region_if_possible(oldr: ty::region) -> ty::region { } } -impl unify_methods for infer_ctxt { +impl infer_ctxt { fn set( vb: vals_and_bindings, vid: V, @@ -1123,7 +1122,7 @@ fn resolver(infcx: infer_ctxt, modes: uint) -> resolve_state { mut v_seen: ~[]}) } -impl methods for resolve_state { +impl resolve_state { fn should(mode: uint) -> bool { (self.modes & mode) == mode } @@ -1347,7 +1346,7 @@ fn resolve_ty_var_integral(vid: tvi_vid) -> ty::t { // A. But this upper-bound might be stricter than what is truly // needed. -impl assignment for infer_ctxt { +impl infer_ctxt { fn assign_tys(anmnt: assignment, a: ty::t, b: ty::t) -> ures { fn select(fst: option, snd: option) -> option { @@ -1878,7 +1877,7 @@ fn super_tys( } } -impl of combine for sub { +impl sub: combine { fn infcx() -> infer_ctxt { *self } fn tag() -> ~str { ~"sub" } @@ -2057,7 +2056,7 @@ fn self_tys(a: option, b: option) -> cres> { } } -impl of combine for lub { +impl lub: combine { fn infcx() -> infer_ctxt { *self } fn tag() -> ~str { ~"lub" } @@ -2237,7 +2236,7 @@ fn self_tys(a: option, b: option) -> cres> { } } -impl of combine for glb { +impl glb: combine { fn infcx() -> infer_ctxt { *self } fn tag() -> ~str { ~"glb" } @@ -2448,7 +2447,7 @@ trait lattice_ops { fn ty_bot(t: ty::t) -> cres; } -impl of lattice_ops for lub { +impl lub: lattice_ops { fn bnd(b: bounds) -> option { b.ub } fn with_bnd(b: bounds, t: T) -> bounds { {ub: some(t) with b} @@ -2458,7 +2457,7 @@ fn ty_bot(t: ty::t) -> cres { } } -impl of lattice_ops for glb { +impl glb: lattice_ops { fn bnd(b: bounds) -> option { b.lb } fn with_bnd(b: bounds, t: T) -> bounds { {lb: some(t) with b} diff --git a/src/rustc/middle/typeck/rscope.rs b/src/rustc/middle/typeck/rscope.rs index 812354f97a2..9d1fb7d20f8 100644 --- a/src/rustc/middle/typeck/rscope.rs +++ b/src/rustc/middle/typeck/rscope.rs @@ -6,7 +6,7 @@ trait region_scope { } enum empty_rscope { empty_rscope } -impl of region_scope for empty_rscope { +impl empty_rscope: region_scope { fn anon_region() -> result { result::ok(ty::re_static) } @@ -17,7 +17,7 @@ fn named_region(id: ast::ident) -> result { } enum type_rscope = bool; -impl of region_scope for type_rscope { +impl type_rscope: region_scope { fn anon_region() -> result { if *self { result::ok(ty::re_bound(ty::br_self)) @@ -42,7 +42,7 @@ fn in_anon_rscope(self: RS, r: ty::region) -> @anon_rscope { @anon_rscope({anon: r, base: self as region_scope}) } -impl of region_scope for @anon_rscope { +impl @anon_rscope: region_scope { fn anon_region() -> result { result::ok(self.anon) } @@ -57,7 +57,7 @@ fn in_binding_rscope(self: RS) let base = self as region_scope; @binding_rscope({base: base}) } -impl of region_scope for @binding_rscope { +impl @binding_rscope: region_scope { fn anon_region() -> result { result::ok(ty::re_bound(ty::br_anon)) } diff --git a/src/rustdoc/astsrv.rs b/src/rustdoc/astsrv.rs index 655587b165d..52746f66425 100644 --- a/src/rustdoc/astsrv.rs +++ b/src/rustdoc/astsrv.rs @@ -144,7 +144,7 @@ fn build_error_handlers( inner: diagnostic::handler, }; - impl of diagnostic::handler for diagnostic_handler { + impl diagnostic_handler: diagnostic::handler { fn fatal(msg: ~str) -> ! { self.inner.fatal(msg) } fn err(msg: ~str) { self.inner.err(msg) } fn bump_err_count() { diff --git a/src/rustdoc/demo.rs b/src/rustdoc/demo.rs index 0a46d7e7195..9fb37977231 100644 --- a/src/rustdoc/demo.rs +++ b/src/rustdoc/demo.rs @@ -176,7 +176,7 @@ trait the_shunned_house { } /// Whatever -impl of the_shunned_house for omnomnomy { +impl omnomnomy: the_shunned_house { fn dingy_house(_unkempt_yard: int) { } diff --git a/src/rustdoc/doc.rs b/src/rustdoc/doc.rs index 6fb1faa4483..2ab27340791 100644 --- a/src/rustdoc/doc.rs +++ b/src/rustdoc/doc.rs @@ -138,7 +138,7 @@ enum moddoc { link: ~str }; -impl util for doc { +impl doc { fn cratedoc() -> cratedoc { option::get(vec::foldl(none, self.pages, |_m, page| { match page { @@ -154,7 +154,7 @@ fn cratemod() -> moddoc { } /// Some helper methods on moddoc, mostly for testing -impl util for moddoc { +impl moddoc { fn mods() -> ~[moddoc] { do vec::filter_map(self.items) |itemtag| { @@ -240,7 +240,7 @@ trait page_utils { fn types() -> ~[tydoc]; } -impl util of page_utils for ~[page] { +impl ~[page]: page_utils { fn mods() -> ~[moddoc] { do vec::filter_map(self) |page| { @@ -319,7 +319,7 @@ trait item { pure fn item() -> itemdoc; } -impl of item for itemtag { +impl itemtag: item { pure fn item() -> itemdoc { match self { doc::modtag(doc) => doc.item, @@ -334,27 +334,27 @@ impl of item for itemtag { } } -impl of item for simpleitemdoc { +impl simpleitemdoc: item { pure fn item() -> itemdoc { self.item } } -impl of item for moddoc { +impl moddoc: item { pure fn item() -> itemdoc { self.item } } -impl of item for nmoddoc { +impl nmoddoc: item { pure fn item() -> itemdoc { self.item } } -impl of item for enumdoc { +impl enumdoc: item { pure fn item() -> itemdoc { self.item } } -impl of item for traitdoc { +impl traitdoc: item { pure fn item() -> itemdoc { self.item } } -impl of item for impldoc { +impl impldoc: item { pure fn item() -> itemdoc { self.item } } @@ -367,7 +367,7 @@ trait item_utils { pure fn sections() -> ~[section]; } -impl util of item_utils for A { +impl A: item_utils { pure fn id() -> ast_id { self.item().id } diff --git a/src/rustdoc/markdown_pass.rs b/src/rustdoc/markdown_pass.rs index dbba57960c0..6ddd8f29b65 100644 --- a/src/rustdoc/markdown_pass.rs +++ b/src/rustdoc/markdown_pass.rs @@ -2,7 +2,6 @@ import doc::item_utils; import markdown_writer::writer; -import markdown_writer::writer_util; import markdown_writer::writer_utils; import markdown_writer::writer_factory; diff --git a/src/rustdoc/markdown_writer.rs b/src/rustdoc/markdown_writer.rs index a3b40a1caaa..139ea0f36f5 100644 --- a/src/rustdoc/markdown_writer.rs +++ b/src/rustdoc/markdown_writer.rs @@ -23,7 +23,7 @@ trait writer_utils { fn write_done(); } -impl writer_util of writer_utils for writer { +impl writer: writer_utils { fn write_str(str: ~str) { self(write(str)); } diff --git a/src/test/auxiliary/ambig_impl_2_lib.rs b/src/test/auxiliary/ambig_impl_2_lib.rs index bf838a9d22c..eed27b58aa8 100644 --- a/src/test/auxiliary/ambig_impl_2_lib.rs +++ b/src/test/auxiliary/ambig_impl_2_lib.rs @@ -1,4 +1,4 @@ trait me { fn me() -> uint; } -impl methods1 of me for uint { fn me() -> uint { self } } +impl uint: me { fn me() -> uint { self } } diff --git a/src/test/auxiliary/cci_impl_lib.rs b/src/test/auxiliary/cci_impl_lib.rs index af5fa814c6a..1f0f2574ba3 100644 --- a/src/test/auxiliary/cci_impl_lib.rs +++ b/src/test/auxiliary/cci_impl_lib.rs @@ -4,7 +4,7 @@ trait uint_helpers { fn to(v: uint, f: fn(uint)); } -impl helpers of uint_helpers for uint { +impl uint: uint_helpers { #[inline] fn to(v: uint, f: fn(uint)) { let mut i = self; diff --git a/src/test/auxiliary/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs index 31ee535fcab..38bc20f637b 100644 --- a/src/test/auxiliary/cci_nested_lib.rs +++ b/src/test/auxiliary/cci_nested_lib.rs @@ -1,4 +1,4 @@ -import dvec::{dvec,extensions}; +import dvec::dvec; type entry = {key: A, value: B}; type alist = { eq_fn: fn@(A,A) -> bool, data: dvec> }; diff --git a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs index 3a7f3844019..bd3f6303857 100644 --- a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs +++ b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs @@ -3,7 +3,6 @@ export rust; import name_pool::add; -import name_pool::methods; mod name_pool { @@ -13,7 +12,7 @@ trait add { fn add(s: ~str); } - impl methods of add for name_pool { + impl name_pool: add { fn add(s: ~str) { } } @@ -22,9 +21,10 @@ fn add(s: ~str) { mod rust { import name_pool::add; + // FIXME #3155: this is a hack + import name_pool::__extensions__; export add; export rt; - export methods; export cx; type rt = @(); @@ -33,7 +33,7 @@ trait cx { fn cx(); } - impl methods of cx for rt { + impl rt: cx { fn cx() { } } diff --git a/src/test/auxiliary/issue-2380.rs b/src/test/auxiliary/issue-2380.rs index 6749998c612..eb38c48158c 100644 --- a/src/test/auxiliary/issue-2380.rs +++ b/src/test/auxiliary/issue-2380.rs @@ -4,7 +4,7 @@ trait i { } fn f() -> i { - impl of i for () { } + impl (): i { } () as i:: } diff --git a/src/test/auxiliary/issue-2414-a.rs b/src/test/auxiliary/issue-2414-a.rs index 5eb25c4f44f..805d1625681 100644 --- a/src/test/auxiliary/issue-2414-a.rs +++ b/src/test/auxiliary/issue-2414-a.rs @@ -7,7 +7,7 @@ trait foo { fn foo(); } -impl t2 of foo for ~str { +impl ~str: foo { fn foo() {} } diff --git a/src/test/auxiliary/issue-2414-b.rs b/src/test/auxiliary/issue-2414-b.rs index b5a27c6fabc..2b2db4cda5d 100644 --- a/src/test/auxiliary/issue-2414-b.rs +++ b/src/test/auxiliary/issue-2414-b.rs @@ -5,5 +5,3 @@ use a; -import a::t2; -export t2; diff --git a/src/test/auxiliary/issue-2526.rs b/src/test/auxiliary/issue-2526.rs index 9504ec576c4..f8b374dcf85 100644 --- a/src/test/auxiliary/issue-2526.rs +++ b/src/test/auxiliary/issue-2526.rs @@ -31,6 +31,6 @@ fn init() -> arc_destruct unsafe { type context = arc_destruct; -impl context for context { +impl context { fn socket() { } } diff --git a/src/test/auxiliary/issue_2242_a.rs b/src/test/auxiliary/issue_2242_a.rs index 36a7daae9dc..c00f27cd511 100644 --- a/src/test/auxiliary/issue_2242_a.rs +++ b/src/test/auxiliary/issue_2242_a.rs @@ -5,6 +5,6 @@ trait to_str { fn to_str() -> ~str; } -impl of to_str for ~str { +impl ~str: to_str { fn to_str() -> ~str { self } } diff --git a/src/test/auxiliary/issue_2242_b.rs b/src/test/auxiliary/issue_2242_b.rs index 51a955c8590..a676066acf3 100644 --- a/src/test/auxiliary/issue_2242_b.rs +++ b/src/test/auxiliary/issue_2242_b.rs @@ -4,6 +4,6 @@ use a; import a::to_str; -impl of to_str for int { +impl int: to_str { fn to_str() -> ~str { fmt!{"%?", self} } } diff --git a/src/test/auxiliary/issue_2242_c.rs b/src/test/auxiliary/issue_2242_c.rs index 3a6fc87173b..35c82ff7c01 100644 --- a/src/test/auxiliary/issue_2242_c.rs +++ b/src/test/auxiliary/issue_2242_c.rs @@ -5,6 +5,6 @@ import a::to_str; -impl of to_str for bool { +impl bool: to_str { fn to_str() -> ~str { fmt!{"%b", self} } } diff --git a/src/test/auxiliary/static-methods-crate.rs b/src/test/auxiliary/static-methods-crate.rs index 56cc7f9aca3..3312a15f49e 100644 --- a/src/test/auxiliary/static-methods-crate.rs +++ b/src/test/auxiliary/static-methods-crate.rs @@ -9,13 +9,13 @@ trait read { static fn readMaybe(s: ~str) -> option; } -impl of read for int { +impl int: read { static fn readMaybe(s: ~str) -> option { int::from_str(s) } } -impl of read for bool { +impl bool: read { static fn readMaybe(s: ~str) -> option { match s { ~"true" => some(true), diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index dd92b28c41c..c6a11eca75b 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -6,7 +6,7 @@ import std::map; import std::map::{map, hashmap}; -import io::{reader, reader_util}; +import io::reader; fn main(argv: ~[~str]) { #macro[ diff --git a/src/test/bench/core-vec-append.rs b/src/test/bench/core-vec-append.rs index d950abb99be..59923a77a38 100644 --- a/src/test/bench/core-vec-append.rs +++ b/src/test/bench/core-vec-append.rs @@ -1,7 +1,7 @@ // A raw test of vector appending performance. use std; -import dvec::{dvec, extensions}; +import dvec::dvec; import io::writer_util; fn collect_raw(num: uint) -> ~[uint] { diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index c2129aa5fda..0d7bd2185eb 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -14,7 +14,6 @@ import io::writer; import io::writer_util; -import arc::methods; import pipes::{port, chan, shared_chan}; macro_rules! move_out { diff --git a/src/test/bench/msgsend-ring.rs b/src/test/bench/msgsend-ring.rs index 6722423a08e..e3c51ec8d43 100644 --- a/src/test/bench/msgsend-ring.rs +++ b/src/test/bench/msgsend-ring.rs @@ -6,7 +6,6 @@ import comm::*; import future::future; -import future::extensions; use std; import std::time; diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index fd367181df4..17f2129ed80 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -1,7 +1,5 @@ // chameneos -import io::reader_util; - use std; import std::map; import std::map::hashmap; diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 7aed4749eed..d0234022a85 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -2,8 +2,6 @@ // multi tasking k-nucleotide -import io::reader_util; - use std; import std::map; import std::map::hashmap; diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 6eeb50d52f5..e5bd37c1968 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -2,8 +2,6 @@ // multi tasking k-nucleotide -import io::reader_util; - use std; import std::map; import std::map::hashmap; diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index 93a1d60ff7f..3ff45e6f713 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -90,7 +90,7 @@ fn chanmb(i: uint, size: uint, ch: comm::chan) -> () type devnull = {dn: int}; -impl of io::writer for devnull { +impl devnull: io::writer { fn write(_b: &[const u8]) {} fn seek(_i: int, _s: io::seek_style) {} fn tell() -> uint {0_u} diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index f5e4ab2e8fa..e166688e457 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -2,7 +2,7 @@ use std; import std::smallintmap; -import std::smallintmap::{smallintmap, map}; +import std::smallintmap::smallintmap; import io::writer_util; fn append_sequential(min: uint, max: uint, map: smallintmap) { diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index fc22b99f59c..4f100f0581f 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -1,7 +1,7 @@ use std; import std::bitv; -import io::{writer_util, reader_util}; +import io::writer_util; // Computes a single solution to a given 9x9 sudoku // diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs index 2281939b57a..086aba0ac40 100644 --- a/src/test/bench/task-perf-word-count-generic.rs +++ b/src/test/bench/task-perf-word-count-generic.rs @@ -20,7 +20,7 @@ import std::map::hashmap; import vec; import io; -import io::{reader_util, writer_util}; +import io::writer_util; import std::time; import u64; @@ -31,7 +31,6 @@ import comm::port; import comm::recv; import comm::send; -import comm::methods; macro_rules! move_out { { $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } } @@ -53,7 +52,7 @@ fn mk_hash() -> map::hashmap { map::hashmap(hashfn, hasheq) } -impl of hash_key for ~str { +impl ~str: hash_key { pure fn hash() -> uint { str::hash(&self) } pure fn eq(&&x: ~str) -> bool { self == x } } @@ -74,7 +73,7 @@ fn join(t: joinable_task) { t.recv() } -impl of word_reader for io::reader { +impl io::reader: word_reader { fn read_word() -> option<~str> { read_word(self) } } diff --git a/src/test/compile-fail/ambig_impl_2_exe.rs b/src/test/compile-fail/ambig_impl_2_exe.rs index fe603738440..51c19db4a94 100644 --- a/src/test/compile-fail/ambig_impl_2_exe.rs +++ b/src/test/compile-fail/ambig_impl_2_exe.rs @@ -1,11 +1,10 @@ // xfail-fast aux-build // aux-build:ambig_impl_2_lib.rs use ambig_impl_2_lib; -import ambig_impl_2_lib::methods1; import ambig_impl_2_lib::me; trait me { fn me() -> uint; } -impl methods2 of me for uint { fn me() -> uint { self } } //~ NOTE is `methods2::me` +impl uint: me { fn me() -> uint { self } } //~ NOTE is `__extensions__::me` fn main() { 1u.me(); } //~ ERROR multiple applicable methods in scope -//~^ NOTE is `ambig_impl_2_lib::methods1::me` +//~^ NOTE is `ambig_impl_2_lib::__extensions__::me` diff --git a/src/test/compile-fail/ambig_impl_unify.rs b/src/test/compile-fail/ambig_impl_unify.rs index f6994536a99..fc78da19aab 100644 --- a/src/test/compile-fail/ambig_impl_unify.rs +++ b/src/test/compile-fail/ambig_impl_unify.rs @@ -2,12 +2,12 @@ trait foo { fn foo() -> int; } -impl methods of foo for ~[uint] { - fn foo() -> int {1} //~ NOTE candidate #1 is `methods::foo` +impl ~[uint]: foo { + fn foo() -> int {1} //~ NOTE candidate #1 is `__extensions__::foo` } -impl methods of foo for ~[int] { - fn foo() -> int {2} //~ NOTE candidate #2 is `methods::foo` +impl ~[int]: foo { + fn foo() -> int {2} //~ NOTE candidate #2 is `__extensions__::foo` } fn main() { diff --git a/src/test/compile-fail/bad-method-typaram-kind.rs b/src/test/compile-fail/bad-method-typaram-kind.rs index 18f160ce8e4..1da4ec8a626 100644 --- a/src/test/compile-fail/bad-method-typaram-kind.rs +++ b/src/test/compile-fail/bad-method-typaram-kind.rs @@ -6,7 +6,7 @@ trait bar { fn bar(); } -impl methods of bar for uint { +impl uint: bar { fn bar() { } } diff --git a/src/test/compile-fail/borrowck-loan-rcvr.rs b/src/test/compile-fail/borrowck-loan-rcvr.rs index 77cec9c869c..6972905a8cc 100644 --- a/src/test/compile-fail/borrowck-loan-rcvr.rs +++ b/src/test/compile-fail/borrowck-loan-rcvr.rs @@ -6,7 +6,7 @@ trait methods { pure fn purem(); } -impl foo of methods for point { +impl point: methods { fn impurem() { } diff --git a/src/test/compile-fail/infinite-instantiation.rs b/src/test/compile-fail/infinite-instantiation.rs index 7d019461b48..a8ffc30eeb2 100644 --- a/src/test/compile-fail/infinite-instantiation.rs +++ b/src/test/compile-fail/infinite-instantiation.rs @@ -5,13 +5,13 @@ trait to_opt { fn to_option() -> option; } -impl of to_opt for uint { +impl uint: to_opt { fn to_option() -> option { some(self) } } -impl of to_opt for option { +impl option: to_opt { fn to_option() -> option> { some(self) } diff --git a/src/test/compile-fail/issue-2063.rs b/src/test/compile-fail/issue-2063.rs index d2d8744e479..ac2f757502f 100644 --- a/src/test/compile-fail/issue-2063.rs +++ b/src/test/compile-fail/issue-2063.rs @@ -10,7 +10,7 @@ trait to_str_2 { // I use an impl here because it will cause // the compiler to attempt autoderef and then // try to resolve the method. -impl methods of to_str_2 for t { +impl t: to_str_2 { fn to_str() -> ~str { ~"t" } } diff --git a/src/test/compile-fail/issue-2149.rs b/src/test/compile-fail/issue-2149.rs index 344d151ae2b..3917e73a9ae 100644 --- a/src/test/compile-fail/issue-2149.rs +++ b/src/test/compile-fail/issue-2149.rs @@ -2,7 +2,7 @@ trait vec_monad { fn bind(f: fn(A) -> ~[B]); } -impl monad of vec_monad for ~[A] { +impl ~[A]: vec_monad { fn bind(f: fn(A) -> ~[B]) { let mut r = fail; for self.each |elt| { r += f(elt); } diff --git a/src/test/compile-fail/issue-2330.rs b/src/test/compile-fail/issue-2330.rs index 8ae1cdbe18a..aee379cac70 100644 --- a/src/test/compile-fail/issue-2330.rs +++ b/src/test/compile-fail/issue-2330.rs @@ -5,7 +5,7 @@ trait channel { } // `chan` is not a trait, it's an enum -impl of chan for int { //~ ERROR can only implement trait types +impl int: chan { //~ ERROR can only implement trait types fn send(v: int) { fail } } diff --git a/src/test/compile-fail/issue-2590.rs b/src/test/compile-fail/issue-2590.rs index 132ce4757e0..ef66cfc3da6 100644 --- a/src/test/compile-fail/issue-2590.rs +++ b/src/test/compile-fail/issue-2590.rs @@ -8,7 +8,7 @@ trait parse { fn parse() -> ~[mut int]; } -impl parser of parse for parser { +impl parser: parse { fn parse() -> ~[mut int] { dvec::unwrap(self.tokens) //~ ERROR illegal move from self } diff --git a/src/test/compile-fail/issue-2766-a.rs b/src/test/compile-fail/issue-2766-a.rs index ce24b4a6a52..facbcee4cc8 100644 --- a/src/test/compile-fail/issue-2766-a.rs +++ b/src/test/compile-fail/issue-2766-a.rs @@ -1,7 +1,7 @@ mod stream { enum stream { send(T, server::stream), } mod server { - impl recv for stream { + impl stream { fn recv() -> extern fn(+stream) -> stream::stream { // resolve really should report just one error here. // Change the test case when it changes. diff --git a/src/test/compile-fail/issue-3021-d.rs b/src/test/compile-fail/issue-3021-d.rs index 82aeb1c8da2..d0e0a288839 100644 --- a/src/test/compile-fail/issue-3021-d.rs +++ b/src/test/compile-fail/issue-3021-d.rs @@ -18,7 +18,7 @@ fn mk_result(st : sipstate) -> u64 { return v0 ^ v1; } - impl of siphash for sipstate { + impl sipstate: siphash { fn reset() { self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture //~^ ERROR unresolved name: k0 diff --git a/src/test/compile-fail/issue-3021.rs b/src/test/compile-fail/issue-3021.rs index 89fe96b7302..656e2094e62 100644 --- a/src/test/compile-fail/issue-3021.rs +++ b/src/test/compile-fail/issue-3021.rs @@ -10,7 +10,7 @@ fn siphash(k0 : u64) -> siphash { }; - impl of siphash for sipstate { + impl sipstate: siphash { fn reset() { self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture //~^ ERROR unresolved name: k0 diff --git a/src/test/compile-fail/kindck-owned-trait-contains.rs b/src/test/compile-fail/kindck-owned-trait-contains.rs index 00d5f8e9901..8a7de8160fb 100644 --- a/src/test/compile-fail/kindck-owned-trait-contains.rs +++ b/src/test/compile-fail/kindck-owned-trait-contains.rs @@ -1,6 +1,6 @@ trait repeat { fn get() -> A; } -impl of repeat for @A { +impl @A: repeat { fn get() -> A { *self } } diff --git a/src/test/compile-fail/kindck-owned-trait-scoped.rs b/src/test/compile-fail/kindck-owned-trait-scoped.rs index 888e75a4f32..80a0e3bc0d5 100644 --- a/src/test/compile-fail/kindck-owned-trait-scoped.rs +++ b/src/test/compile-fail/kindck-owned-trait-scoped.rs @@ -5,7 +5,7 @@ trait foo { fn foo(i: &self/int) -> int; } -impl of foo for T { +impl T: foo { fn foo(i: &self/int) -> int {*i} } diff --git a/src/test/compile-fail/pure-modifies-aliased.rs b/src/test/compile-fail/pure-modifies-aliased.rs index 20cb1fa6b6b..4a5d879a32d 100644 --- a/src/test/compile-fail/pure-modifies-aliased.rs +++ b/src/test/compile-fail/pure-modifies-aliased.rs @@ -12,7 +12,7 @@ trait modify_in_box_rec { pure fn modify_in_box_rec(sum: @{mut f: int}); } -impl foo of modify_in_box_rec for int { +impl int: modify_in_box_rec { pure fn modify_in_box_rec(sum: @{mut f: int}) { sum.f = self; //~ ERROR assigning to mutable field prohibited in pure context } diff --git a/src/test/compile-fail/qquote-1.rs b/src/test/compile-fail/qquote-1.rs index a1211e1b09f..eb6a52ce64c 100644 --- a/src/test/compile-fail/qquote-1.rs +++ b/src/test/compile-fail/qquote-1.rs @@ -24,7 +24,7 @@ trait fake_ext_ctxt { type fake_session = {opts: @fake_options, parse_sess: parse::parse_sess}; -impl of fake_ext_ctxt for fake_session { +impl fake_session: fake_ext_ctxt { fn session() -> fake_session {self} } diff --git a/src/test/compile-fail/qquote-2.rs b/src/test/compile-fail/qquote-2.rs index 6469e046229..8e9edb54613 100644 --- a/src/test/compile-fail/qquote-2.rs +++ b/src/test/compile-fail/qquote-2.rs @@ -24,7 +24,7 @@ trait fake_ext_ctxt { type fake_session = {opts: @fake_options, parse_sess: parser::parse_sess}; -impl of fake_ext_ctxt for fake_session { +impl fake_session: fake_ext_ctxt { fn session() -> fake_session {self} } diff --git a/src/test/compile-fail/regions-escape-via-trait-or-not.rs b/src/test/compile-fail/regions-escape-via-trait-or-not.rs index ef5f3463e8e..140dbc9e1b3 100644 --- a/src/test/compile-fail/regions-escape-via-trait-or-not.rs +++ b/src/test/compile-fail/regions-escape-via-trait-or-not.rs @@ -2,7 +2,7 @@ trait deref { fn get() -> int; } -impl of deref for &int { +impl &int: deref { fn get() -> int { *self } diff --git a/src/test/compile-fail/regions-infer-paramd-indirect.rs b/src/test/compile-fail/regions-infer-paramd-indirect.rs index 9a2329f849e..5c5dd8537ca 100644 --- a/src/test/compile-fail/regions-infer-paramd-indirect.rs +++ b/src/test/compile-fail/regions-infer-paramd-indirect.rs @@ -10,7 +10,7 @@ trait set_f { fn set_f_bad(b: @b); } -impl methods of set_f for c { +impl c: set_f { fn set_f_ok(b: @b/&self) { self.f = b; } diff --git a/src/test/compile-fail/regions-infer-paramd-method.rs b/src/test/compile-fail/regions-infer-paramd-method.rs index ea62d72cd66..73b834c2624 100644 --- a/src/test/compile-fail/regions-infer-paramd-method.rs +++ b/src/test/compile-fail/regions-infer-paramd-method.rs @@ -13,7 +13,7 @@ trait set_foo_foo { fn set_foo(f: foo); } -impl methods of set_foo_foo for with_foo { +impl with_foo: set_foo_foo { fn set_foo(f: foo) { self.f = f; //~ ERROR mismatched types: expected `foo/&self` but found `foo/&` } @@ -31,7 +31,7 @@ trait set_foo_bar { fn set_foo(f: bar); } -impl methods of set_foo_bar for with_bar { +impl with_bar: set_foo_bar { fn set_foo(f: bar) { self.f = f; } diff --git a/src/test/compile-fail/regions-trait-1.rs b/src/test/compile-fail/regions-trait-1.rs index 71081ac37fb..4932712aa0a 100644 --- a/src/test/compile-fail/regions-trait-1.rs +++ b/src/test/compile-fail/regions-trait-1.rs @@ -7,7 +7,7 @@ trait get_ctxt { type has_ctxt = { c: &ctxt }; -impl of get_ctxt for has_ctxt { +impl has_ctxt: get_ctxt { // Here an error occurs because we used `&self` but // the definition used `&`: diff --git a/src/test/compile-fail/regions-trait-2.rs b/src/test/compile-fail/regions-trait-2.rs index 98b9797df62..a34a903e3ba 100644 --- a/src/test/compile-fail/regions-trait-2.rs +++ b/src/test/compile-fail/regions-trait-2.rs @@ -6,7 +6,7 @@ trait get_ctxt { type has_ctxt = { c: &ctxt }; -impl of get_ctxt for has_ctxt { +impl has_ctxt: get_ctxt { fn get_ctxt() -> &self/ctxt { self.c } } diff --git a/src/test/compile-fail/selftype-astparam.rs b/src/test/compile-fail/selftype-astparam.rs index 25dd29300e5..9324ada075e 100644 --- a/src/test/compile-fail/selftype-astparam.rs +++ b/src/test/compile-fail/selftype-astparam.rs @@ -2,7 +2,7 @@ trait add { fn plus(++x: self) -> self; } -impl of add for int { +impl int: add { fn plus(++x: int) -> int { self + x } } diff --git a/src/test/compile-fail/seq-args.rs b/src/test/compile-fail/seq-args.rs index 4d9eadf65ed..c416e3de206 100644 --- a/src/test/compile-fail/seq-args.rs +++ b/src/test/compile-fail/seq-args.rs @@ -2,10 +2,10 @@ fn main() { trait seq { } -impl of seq for ~[T] { //~ ERROR wrong number of type arguments +impl ~[T]: seq { //~ ERROR wrong number of type arguments /* ... */ } -impl of seq for u32 { +impl u32: seq { /* Treat the integer as a sequence of bits */ } diff --git a/src/test/compile-fail/staticness-mismatch.rs b/src/test/compile-fail/staticness-mismatch.rs index 1e23f588843..51c7a819860 100644 --- a/src/test/compile-fail/staticness-mismatch.rs +++ b/src/test/compile-fail/staticness-mismatch.rs @@ -3,7 +3,7 @@ trait foo { static fn bar(); } -impl of foo for int { +impl int: foo { fn bar() {} //~ ERROR self type does not match the trait method's } diff --git a/src/test/compile-fail/tps-invariant-trait.rs b/src/test/compile-fail/tps-invariant-trait.rs index 93ad8a72ac3..88039f234b5 100644 --- a/src/test/compile-fail/tps-invariant-trait.rs +++ b/src/test/compile-fail/tps-invariant-trait.rs @@ -7,7 +7,7 @@ enum box_impl = { mut f: T }; -impl of box_trait for box_impl { +impl box_impl: box_trait { fn get() -> T { return self.f; } fn set(t: T) { self.f = t; } } diff --git a/src/test/compile-fail/trait-impl-different-num-params.rs b/src/test/compile-fail/trait-impl-different-num-params.rs index 0ac42fe52eb..8cf572d27ab 100644 --- a/src/test/compile-fail/trait-impl-different-num-params.rs +++ b/src/test/compile-fail/trait-impl-different-num-params.rs @@ -1,7 +1,7 @@ trait foo { fn bar(x: uint) -> self; } -impl of foo for int { +impl int: foo { fn bar() -> int { //~^ ERROR method `bar` has 0 parameters but the trait has 1 self diff --git a/src/test/compile-fail/trait-test-2.rs b/src/test/compile-fail/trait-test-2.rs index f822aa15380..664a7b7995d 100644 --- a/src/test/compile-fail/trait-test-2.rs +++ b/src/test/compile-fail/trait-test-2.rs @@ -1,6 +1,6 @@ trait bar { fn dup() -> self; fn blah(); } -impl of bar for int { fn dup() -> int { self } fn blah() {} } -impl of bar for uint { fn dup() -> uint { self } fn blah() {} } +impl int: bar { fn dup() -> int { self } fn blah() {} } +impl uint: bar { fn dup() -> uint { self } fn blah() {} } fn main() { 10.dup::(); //~ ERROR does not take type parameters diff --git a/src/test/compile-fail/trait-test.rs b/src/test/compile-fail/trait-test.rs index 3084c0f4e57..e76910a321c 100644 --- a/src/test/compile-fail/trait-test.rs +++ b/src/test/compile-fail/trait-test.rs @@ -1,5 +1,5 @@ trait foo { fn foo(); } -impl of int for uint { fn foo() {} } //~ ERROR trait +impl uint: int { fn foo() {} } //~ ERROR trait fn main() {} diff --git a/src/test/run-fail/issue-2156.rs b/src/test/run-fail/issue-2156.rs index d18c7de3d34..f0ef08b6558 100644 --- a/src/test/run-fail/issue-2156.rs +++ b/src/test/run-fail/issue-2156.rs @@ -1,7 +1,7 @@ // error-pattern:explicit failure // Don't double free the string use std; -import io::{reader, reader_util}; +import io::reader; fn main() { do io::with_str_reader(~"") |rdr| { diff --git a/src/test/run-fail/unwind-box-trait.rs b/src/test/run-fail/unwind-box-trait.rs index f56cc13273b..524c0c3dcaa 100644 --- a/src/test/run-fail/unwind-box-trait.rs +++ b/src/test/run-fail/unwind-box-trait.rs @@ -8,7 +8,7 @@ trait i { fn foo(); } -impl of i for ~int { +impl ~int: i { fn foo() { } } diff --git a/src/test/run-fail/zip-different-lengths.rs b/src/test/run-fail/zip-different-lengths.rs index 9e7cf14959f..6cff0afec08 100644 --- a/src/test/run-fail/zip-different-lengths.rs +++ b/src/test/run-fail/zip-different-lengths.rs @@ -4,7 +4,7 @@ use std; import uint; import u8; -import vec::{extensions, same_length, zip}; +import vec::{same_length, zip}; fn enum_chars(start: u8, end: u8) -> ~[char] { assert start < end; diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index bdf1cb63f99..d531c5ca647 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -18,7 +18,7 @@ trait fake_ext_ctxt { type fake_session = (); -impl of fake_ext_ctxt for fake_session { +impl fake_session: fake_ext_ctxt { fn cfg() -> ast::crate_cfg { ~[] } fn parse_sess() -> parse::parse_sess { parse::new_parse_sess(none) } } diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index b5a3fd8af61..3f53525a5ba 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -6,13 +6,13 @@ trait iterable { fn iterate(blk: fn(A) -> bool); } -impl vec of iterable for &[A] { +impl &[A]: iterable { fn iterate(f: fn(A) -> bool) { vec::each(self, f); } } -impl vec of iterable for ~[A] { +impl ~[A]: iterable { fn iterate(f: fn(A) -> bool) { vec::each(self, f); } diff --git a/src/test/run-pass/auto_serialize.rs b/src/test/run-pass/auto_serialize.rs index 46e743cde6c..25ade45e2d6 100644 --- a/src/test/run-pass/auto_serialize.rs +++ b/src/test/run-pass/auto_serialize.rs @@ -5,9 +5,6 @@ import std::ebml; import io::writer; -import std::prettyprint::serializer; -import std::ebml::serializer; -import std::ebml::deserializer; import std::serialization::{serialize_uint, deserialize_uint}; fn test_ser_and_deser(a1: A, diff --git a/src/test/run-pass/autoderef-method-newtype.rs b/src/test/run-pass/autoderef-method-newtype.rs index 3d67a5fd1f5..8dd60004b6c 100644 --- a/src/test/run-pass/autoderef-method-newtype.rs +++ b/src/test/run-pass/autoderef-method-newtype.rs @@ -2,7 +2,7 @@ trait double { fn double() -> uint; } -impl methods of double for uint { +impl uint: double { fn double() -> uint { self * 2u } } diff --git a/src/test/run-pass/autoderef-method-priority.rs b/src/test/run-pass/autoderef-method-priority.rs index 23f2a5e6b49..e44a210a57c 100644 --- a/src/test/run-pass/autoderef-method-priority.rs +++ b/src/test/run-pass/autoderef-method-priority.rs @@ -2,11 +2,11 @@ trait double { fn double() -> uint; } -impl methods of double for uint { +impl uint: double { fn double() -> uint { self } } -impl methods of double for @uint { +impl @uint: double { fn double() -> uint { *self * 2u } } diff --git a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs index 45f8ffde6d8..979d656cd2d 100644 --- a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs +++ b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs @@ -2,7 +2,7 @@ trait double { fn double() -> uint; } -impl methods of double for @@uint { +impl @@uint: double { fn double() -> uint { **self * 2u } } diff --git a/src/test/run-pass/autoderef-method-twice.rs b/src/test/run-pass/autoderef-method-twice.rs index 899769352d6..661fd839430 100644 --- a/src/test/run-pass/autoderef-method-twice.rs +++ b/src/test/run-pass/autoderef-method-twice.rs @@ -2,7 +2,7 @@ trait double { fn double() -> uint; } -impl methods of double for uint { +impl uint: double { fn double() -> uint { self * 2u } } diff --git a/src/test/run-pass/autoderef-method.rs b/src/test/run-pass/autoderef-method.rs index 5b66ce718f4..34045444bcc 100644 --- a/src/test/run-pass/autoderef-method.rs +++ b/src/test/run-pass/autoderef-method.rs @@ -2,7 +2,7 @@ trait double { fn double() -> uint; } -impl methods of double for uint { +impl uint: double { fn double() -> uint { self * 2u } } diff --git a/src/test/run-pass/borrowck-newtype-issue-2573.rs b/src/test/run-pass/borrowck-newtype-issue-2573.rs index 108613f54a2..1dd4bb9e31a 100644 --- a/src/test/run-pass/borrowck-newtype-issue-2573.rs +++ b/src/test/run-pass/borrowck-newtype-issue-2573.rs @@ -6,7 +6,7 @@ trait frob { fn frob(); } -impl quuux of frob for foo { +impl foo: frob { fn frob() { really_impure(self.bar); } diff --git a/src/test/run-pass/cci_capture_clause.rs b/src/test/run-pass/cci_capture_clause.rs index fd46766c58e..1abde0084c2 100644 --- a/src/test/run-pass/cci_capture_clause.rs +++ b/src/test/run-pass/cci_capture_clause.rs @@ -7,7 +7,6 @@ use cci_capture_clause; import comm::recv; -import comm::methods; fn main() { cci_capture_clause::foo(()).recv() diff --git a/src/test/run-pass/cci_impl_exe.rs b/src/test/run-pass/cci_impl_exe.rs index 55bb9a8ad35..fab76a02569 100644 --- a/src/test/run-pass/cci_impl_exe.rs +++ b/src/test/run-pass/cci_impl_exe.rs @@ -2,7 +2,6 @@ // aux-build:cci_impl_lib.rs use cci_impl_lib; -import cci_impl_lib::helpers; import cci_impl_lib::uint_helpers; fn main() { diff --git a/src/test/run-pass/class-separate-impl.rs b/src/test/run-pass/class-separate-impl.rs index 95f12651b66..9be142647b5 100644 --- a/src/test/run-pass/class-separate-impl.rs +++ b/src/test/run-pass/class-separate-impl.rs @@ -35,7 +35,7 @@ fn eat() -> bool { } } -impl of to_str for cat { +impl cat: to_str { fn to_str() -> ~str { self.name } } diff --git a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs index 37da90be375..849c85c7d18 100644 --- a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs +++ b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs @@ -8,7 +8,6 @@ use crate_method_reexport_grrrrrrr2; fn main() { - import crate_method_reexport_grrrrrrr2::rust::methods; import crate_method_reexport_grrrrrrr2::rust::add; import crate_method_reexport_grrrrrrr2::rust::cx; let x = @(); diff --git a/src/test/run-pass/dvec-test.rs b/src/test/run-pass/dvec-test.rs index 998df76b93f..78b804ecf38 100644 --- a/src/test/run-pass/dvec-test.rs +++ b/src/test/run-pass/dvec-test.rs @@ -1,4 +1,4 @@ -import dvec::{dvec, extensions}; +import dvec::dvec; fn main() { let d = dvec(); diff --git a/src/test/run-pass/impl-variance.rs b/src/test/run-pass/impl-variance.rs index 1a913abbbf0..3ad13779b73 100644 --- a/src/test/run-pass/impl-variance.rs +++ b/src/test/run-pass/impl-variance.rs @@ -2,7 +2,7 @@ trait foo { fn foo() -> uint; } -impl extensions of foo for ~[const T] { +impl ~[const T]: foo { fn foo() -> uint { vec::len(self) } } diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index a5e2d8ba613..35793e85bfd 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -6,11 +6,11 @@ trait iterable { fn iter(blk: fn(A)); } -impl of iterable for fn@(fn(A)) { +impl fn@(fn(A)): iterable { fn iter(blk: fn(A)) { self(blk); } } -impl of iterable for fn@(fn(uint)) { +impl fn@(fn(uint)): iterable { fn iter(blk: fn(&&uint)) { self( |i| blk(i) ) } } diff --git a/src/test/run-pass/issue-2445-b.rs b/src/test/run-pass/issue-2445-b.rs index 4fd6e5e0530..b004eba99c4 100644 --- a/src/test/run-pass/issue-2445-b.rs +++ b/src/test/run-pass/issue-2445-b.rs @@ -6,7 +6,7 @@ fn f1(x: int) { } } -impl i1 for c1 { +impl c1 { fn f2(x: int) { } } diff --git a/src/test/run-pass/issue-2445.rs b/src/test/run-pass/issue-2445.rs index 39a8722e091..461dbfadbac 100644 --- a/src/test/run-pass/issue-2445.rs +++ b/src/test/run-pass/issue-2445.rs @@ -7,7 +7,7 @@ fn f1(x: T) {} } -impl i1 for c1 { +impl c1 { fn f2(x: T) {} } diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs index d466265cf7a..a440d4f05d4 100644 --- a/src/test/run-pass/issue-2734.rs +++ b/src/test/run-pass/issue-2734.rs @@ -1,5 +1,5 @@ trait hax { } -impl of hax for A { } +impl A: hax { } fn perform_hax(x: @T) -> hax { x as hax diff --git a/src/test/run-pass/issue-2735.rs b/src/test/run-pass/issue-2735.rs index 7a5479ac3fa..81fbae57105 100644 --- a/src/test/run-pass/issue-2735.rs +++ b/src/test/run-pass/issue-2735.rs @@ -1,5 +1,5 @@ trait hax { } -impl of hax for A { } +impl A: hax { } 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 de1819f9577..200fe185f9f 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -2,8 +2,6 @@ use std; -import io::reader_util; - enum square { bot, wall, @@ -15,7 +13,7 @@ enum square { empty } -impl of to_str::to_str for square { +impl square: to_str::to_str { fn to_str() -> ~str { match self { bot => { ~"R" } diff --git a/src/test/run-pass/issue-2935.rs b/src/test/run-pass/issue-2935.rs index 36ad03a0df3..855f5caf9a0 100644 --- a/src/test/run-pass/issue-2935.rs +++ b/src/test/run-pass/issue-2935.rs @@ -6,7 +6,7 @@ trait it { fn f(); } -impl of it for t { +impl t: it { fn f() { } } diff --git a/src/test/run-pass/kindck-owned-trait-contains-1.rs b/src/test/run-pass/kindck-owned-trait-contains-1.rs index e69714e5aa7..7de63c20e0c 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs @@ -1,6 +1,6 @@ trait repeat { fn get() -> A; } -impl of repeat for @A { +impl @A: repeat { fn get() -> A { *self } } diff --git a/src/test/run-pass/method-attributes.rs b/src/test/run-pass/method-attributes.rs index b48d3887379..2301b45f7dd 100644 --- a/src/test/run-pass/method-attributes.rs +++ b/src/test/run-pass/method-attributes.rs @@ -9,7 +9,7 @@ trait frobable { } #[int_frobable] -impl frobable of frobable for int { +impl int: frobable { #[frob_attr1] fn frob() { #[frob_attr2]; diff --git a/src/test/run-pass/module-polymorphism4-files/trait.rs b/src/test/run-pass/module-polymorphism4-files/trait.rs index ec68d32ba95..983a4039eeb 100644 --- a/src/test/run-pass/module-polymorphism4-files/trait.rs +++ b/src/test/run-pass/module-polymorphism4-files/trait.rs @@ -2,7 +2,7 @@ trait says { fn says() -> ~str; } -impl talky of says for T { +impl T: says { // 'animal' and 'talk' functions are implemented by the module // instantiating the talky trait. They are 'abstract' diff --git a/src/test/run-pass/module-polymorphism4.rs b/src/test/run-pass/module-polymorphism4.rs index 5c061c4d3b5..0824e5b49bb 100644 --- a/src/test/run-pass/module-polymorphism4.rs +++ b/src/test/run-pass/module-polymorphism4.rs @@ -3,8 +3,6 @@ // xfail-test fn main() { - import cat::trait::talky; - import dog::trait::talky; let cat1 = cat::inst::meowlycat; let cat2 = cat::inst::howlycat; let dog = dog::inst::dog; diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index 59ea633f218..e4ae676bfa8 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -2,7 +2,7 @@ trait vec_monad { fn bind(f: fn(A) -> ~[B]) -> ~[B]; } -impl monad of vec_monad for ~[A] { +impl ~[A]: vec_monad { fn bind(f: fn(A) -> ~[B]) -> ~[B] { let mut r = ~[]; for self.each |elt| { r += f(elt); } @@ -14,7 +14,7 @@ trait option_monad { fn bind(f: fn(A) -> option) -> option; } -impl monad of option_monad for option { +impl option: option_monad { fn bind(f: fn(A) -> option) -> option { match self { some(a) => { f(a) } diff --git a/src/test/run-pass/monomorphize-trait-in-fn-at.rs b/src/test/run-pass/monomorphize-trait-in-fn-at.rs index bc782d44416..364fc28fb16 100644 --- a/src/test/run-pass/monomorphize-trait-in-fn-at.rs +++ b/src/test/run-pass/monomorphize-trait-in-fn-at.rs @@ -10,7 +10,7 @@ trait ty_ops { fn mk() -> uint; } -impl of ty_ops for () { +impl (): ty_ops { fn mk() -> uint { 22u } } diff --git a/src/test/run-pass/rcvr-borrowed-to-region.rs b/src/test/run-pass/rcvr-borrowed-to-region.rs index 5aa8dd01733..cdd79e3c3c2 100644 --- a/src/test/run-pass/rcvr-borrowed-to-region.rs +++ b/src/test/run-pass/rcvr-borrowed-to-region.rs @@ -3,7 +3,7 @@ trait get { } // Note: impl on a slice -impl foo of get for &int { +impl &int: get { fn get() -> int { return *self; } diff --git a/src/test/run-pass/rcvr-borrowed-to-slice.rs b/src/test/run-pass/rcvr-borrowed-to-slice.rs index f770fed1969..2d08d9b6948 100644 --- a/src/test/run-pass/rcvr-borrowed-to-slice.rs +++ b/src/test/run-pass/rcvr-borrowed-to-slice.rs @@ -3,7 +3,7 @@ trait sum { } // Note: impl on a slice -impl foo of sum for &[int] { +impl &[int]: sum { fn sum() -> int { let mut sum = 0; for vec::each(self) |e| { sum += e; } diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index 3b6c7d5962c..de1e27f24f6 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -25,8 +25,7 @@ fn align(size: uint, align: uint) -> uint { enum ptr_visit_adaptor = { inner: V }; -impl ptr_visitor - of ty_visitor for ptr_visit_adaptor { +impl ptr_visit_adaptor: ty_visitor { #[inline(always)] fn bump(sz: uint) { @@ -464,7 +463,7 @@ enum my_visitor = @{ mut vals: ~[~str] }; -impl extra_methods for my_visitor { +impl my_visitor { fn get(f: fn(T)) { unsafe { f(*(self.ptr1 as *T)); @@ -479,14 +478,14 @@ fn visit_inner(inner: *tydesc) -> bool { } } -impl of movable_ptr for my_visitor { +impl my_visitor: movable_ptr { fn move_ptr(adjustment: fn(*c_void) -> *c_void) { self.ptr1 = adjustment(self.ptr1); self.ptr2 = adjustment(self.ptr2); } } -impl of ty_visitor for my_visitor { +impl my_visitor: ty_visitor { fn visit_bot() -> bool { true } fn visit_nil() -> bool { true } diff --git a/src/test/run-pass/regions-self-impls.rs b/src/test/run-pass/regions-self-impls.rs index 40c1ea0e360..7afc85af60f 100644 --- a/src/test/run-pass/regions-self-impls.rs +++ b/src/test/run-pass/regions-self-impls.rs @@ -4,7 +4,7 @@ trait get_chowder { fn get_chowder() -> &self/int; } -impl clam of get_chowder for clam { +impl clam: get_chowder { fn get_chowder() -> &self/int { return self.chowder; } } diff --git a/src/test/run-pass/regions-trait.rs b/src/test/run-pass/regions-trait.rs index 1d264b706ed..4be94ba2446 100644 --- a/src/test/run-pass/regions-trait.rs +++ b/src/test/run-pass/regions-trait.rs @@ -6,7 +6,7 @@ trait get_ctxt { type has_ctxt = { c: &ctxt }; -impl of get_ctxt for has_ctxt { +impl has_ctxt: get_ctxt { fn get_ctxt() -> &self/ctxt { self.c } diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index 580713dab0f..388c000daf0 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -1,16 +1,15 @@ import a::*; -import b::baz; trait plus { fn plus() -> int; } mod a { - impl foo of plus for uint { fn plus() -> int { self as int + 20 } } + impl uint: plus { fn plus() -> int { self as int + 20 } } } mod b { - impl baz of plus for ~str { fn plus() -> int { 200 } } + impl ~str: plus { fn plus() -> int { 200 } } } trait uint_utils { @@ -18,7 +17,7 @@ trait uint_utils { fn multi(f: fn(uint)); } -impl util of uint_utils for uint { +impl uint: uint_utils { fn str() -> ~str { uint::str(self) } fn multi(f: fn(uint)) { let mut c = 0u; @@ -32,7 +31,7 @@ trait vec_utils { fn map_(f: fn(T) -> U) -> ~[U]; } -impl util of vec_utils for ~[T] { +impl ~[T]: vec_utils { fn length_() -> uint { vec::len(self) } fn iter_(f: fn(T)) { for self.each |x| { f(x); } } fn map_(f: fn(T) -> U) -> ~[U] { diff --git a/src/test/run-pass/static-method-test.rs b/src/test/run-pass/static-method-test.rs index 5cfa34ed59b..99c5776a5ac 100644 --- a/src/test/run-pass/static-method-test.rs +++ b/src/test/run-pass/static-method-test.rs @@ -9,13 +9,13 @@ fn andand(x1: T, x2: T) -> T { select(x1, x2, x1) } -impl of bool_like for bool { +impl bool: bool_like { static fn select(&&b: bool, +x1: A, +x2: A) -> A { if b { x1 } else { x2 } } } -impl of bool_like for int { +impl int: bool_like { static fn select(&&b: int, +x1: A, +x2: A) -> A { if b != 0 { x1 } else { x2 } } @@ -28,14 +28,14 @@ trait buildable { } -impl extensions of buildable for @[A] { +impl @[A]: buildable { #[inline(always)] static pure fn build_sized(size: uint, builder: fn(push: pure fn(+A))) -> @[A] { at_vec::build_sized(size, builder) } } -impl extensions of buildable for ~[A] { +impl ~[A]: buildable { #[inline(always)] static pure fn build_sized(size: uint, builder: fn(push: pure fn(+A))) -> ~[A] { diff --git a/src/test/run-pass/trait-bounds.rs b/src/test/run-pass/trait-bounds.rs index 9a2b9114309..19ad551d1e7 100644 --- a/src/test/run-pass/trait-bounds.rs +++ b/src/test/run-pass/trait-bounds.rs @@ -9,11 +9,11 @@ trait connection_factory { type my_connection = (); type my_connection_factory = (); -impl of connection for () { +impl (): connection { fn read() -> int { 43 } } -impl of connection_factory for my_connection_factory { +impl my_connection_factory: connection_factory { fn create() -> my_connection { () } } diff --git a/src/test/run-pass/trait-cast.rs b/src/test/run-pass/trait-cast.rs index dc097c515ca..db15409d7bb 100644 --- a/src/test/run-pass/trait-cast.rs +++ b/src/test/run-pass/trait-cast.rs @@ -11,7 +11,7 @@ trait to_str { fn to_str() -> ~str; } -impl of to_str for option { +impl option: to_str { fn to_str() -> ~str { match self { none => { ~"none" } @@ -20,11 +20,11 @@ fn to_str() -> ~str { } } -impl of to_str for int { +impl int: to_str { fn to_str() -> ~str { int::str(self) } } -impl of to_str for Tree { +impl Tree: to_str { fn to_str() -> ~str { let l = self.left, r = self.right; fmt!{"[%s, %s, %s]", self.val.to_str(), diff --git a/src/test/run-pass/trait-generic.rs b/src/test/run-pass/trait-generic.rs index d6b1aa4ee1f..4019ca72bd6 100644 --- a/src/test/run-pass/trait-generic.rs +++ b/src/test/run-pass/trait-generic.rs @@ -1,20 +1,20 @@ trait to_str { fn to_str() -> ~str; } -impl of to_str for int { +impl int: to_str { fn to_str() -> ~str { int::str(self) } } -impl of to_str for ~str { +impl ~str: to_str { fn to_str() -> ~str { self } } -impl of to_str for () { +impl (): to_str { fn to_str() -> ~str { ~"()" } } trait map { fn map(f: fn(T) -> U) -> ~[U]; } -impl of map for ~[T] { +impl ~[T]: map { fn map(f: fn(T) -> U) -> ~[U] { let mut r = ~[]; for self.each |x| { r += ~[f(x)]; } diff --git a/src/test/run-pass/trait-to-str.rs b/src/test/run-pass/trait-to-str.rs index 29d17cc7c7d..26d15ce790d 100644 --- a/src/test/run-pass/trait-to-str.rs +++ b/src/test/run-pass/trait-to-str.rs @@ -2,11 +2,11 @@ trait to_str { fn to_str() -> ~str; } -impl of to_str for int { +impl int: to_str { fn to_str() -> ~str { int::str(self) } } -impl of to_str for ~[T] { +impl ~[T]: to_str { fn to_str() -> ~str { ~"[" + str::connect(vec::map(self, |e| e.to_str() ), ~", ") + ~"]" } diff --git a/src/test/run-pass/use-trait-before-def.rs b/src/test/run-pass/use-trait-before-def.rs index 6687c61ce45..654b78f05a4 100644 --- a/src/test/run-pass/use-trait-before-def.rs +++ b/src/test/run-pass/use-trait-before-def.rs @@ -1,5 +1,5 @@ // Issue #1761 -impl of foo for int { fn foo() -> int { 10 } } +impl int: foo { fn foo() -> int { 10 } } trait foo { fn foo() -> int; } fn main() {} \ No newline at end of file