1
Fork 0

librustc: Stop parsing impl Type : Trait and fix several declarations that slipped through. r=tjc

This commit is contained in:
Patrick Walton 2013-02-14 21:17:26 -08:00
parent 566bcf2225
commit bb833ca0f0
82 changed files with 327 additions and 424 deletions

View file

@ -71,7 +71,7 @@ pub struct Package {
versions: ~[(~str, ~str)] versions: ~[(~str, ~str)]
} }
pub impl Package : cmp::Ord { pub impl cmp::Ord for Package {
pure fn lt(&self, other: &Package) -> bool { pure fn lt(&self, other: &Package) -> bool {
if (*self).name.lt(&(*other).name) { return true; } if (*self).name.lt(&(*other).name) { return true; }
if (*other).name.lt(&(*self).name) { return false; } if (*other).name.lt(&(*self).name) { return false; }

View file

@ -173,7 +173,7 @@ pub mod traits {
use kinds::Copy; use kinds::Copy;
use ops::Add; use ops::Add;
pub impl<T: Copy> @[T] : Add<&[const T],@[T]> { pub impl<T: Copy> Add<&[const T],@[T]> for @[T] {
#[inline(always)] #[inline(always)]
pure fn add(&self, rhs: & &self/[const T]) -> @[T] { pure fn add(&self, rhs: & &self/[const T]) -> @[T] {
append(*self, (*rhs)) append(*self, (*rhs))

View file

@ -282,7 +282,7 @@ impl num::One for f32 {
static pure fn one() -> f32 { 1.0 } static pure fn one() -> f32 { 1.0 }
} }
pub impl f32: NumCast { pub impl NumCast for f32 {
/** /**
* Cast `n` to an `f32` * Cast `n` to an `f32`
*/ */

View file

@ -297,7 +297,7 @@ impl cmp::Ord for f64 {
pure fn gt(&self, other: &f64) -> bool { (*self) > (*other) } pure fn gt(&self, other: &f64) -> bool { (*self) > (*other) }
} }
pub impl f64: NumCast { pub impl NumCast for f64 {
/** /**
* Cast `n` to an `f64` * Cast `n` to an `f64`
*/ */

View file

@ -415,7 +415,7 @@ impl num::One for float {
static pure fn one() -> float { 1.0 } static pure fn one() -> float { 1.0 }
} }
pub impl float: NumCast { pub impl NumCast for float {
/** /**
* Cast `n` to a `float` * Cast `n` to a `float`
*/ */

View file

@ -17,7 +17,7 @@ mod inst {
pub const bits: uint = ::u16::bits; pub const bits: uint = ::u16::bits;
} }
pub impl i16: NumCast { pub impl NumCast for i16 {
/** /**
* Cast `n` to a `i16` * Cast `n` to a `i16`
*/ */

View file

@ -17,7 +17,7 @@ mod inst {
pub const bits: uint = ::u32::bits; pub const bits: uint = ::u32::bits;
} }
pub impl i32: NumCast { pub impl NumCast for i32 {
/** /**
* Cast `n` to a `i32` * Cast `n` to a `i32`
*/ */

View file

@ -17,7 +17,7 @@ mod inst {
pub const bits: uint = ::u64::bits; pub const bits: uint = ::u64::bits;
} }
pub impl i64: NumCast { pub impl NumCast for i64 {
/** /**
* Cast `n` to a `i64` * Cast `n` to a `i64`
*/ */

View file

@ -17,7 +17,7 @@ mod inst {
pub const bits: uint = ::u8::bits; pub const bits: uint = ::u8::bits;
} }
pub impl i8: NumCast { pub impl NumCast for i8 {
/** /**
* Cast `n` to a `i8` * Cast `n` to a `i8`
*/ */

View file

@ -58,7 +58,7 @@ mod inst {
} }
} }
pub impl int: NumCast { pub impl NumCast for int {
/** /**
* Cast `n` to a `int` * Cast `n` to a `int`
*/ */

View file

@ -19,7 +19,7 @@ mod inst {
pub const bits: uint = 16; pub const bits: uint = 16;
} }
pub impl u16: NumCast { pub impl NumCast for u16 {
/** /**
* Cast `n` to a `u16` * Cast `n` to a `u16`
*/ */

View file

@ -19,7 +19,7 @@ mod inst {
pub const bits: uint = 32; pub const bits: uint = 32;
} }
pub impl u32: NumCast { pub impl NumCast for u32 {
/** /**
* Cast `n` to a `u32` * Cast `n` to a `u32`
*/ */

View file

@ -19,7 +19,7 @@ mod inst {
pub const bits: uint = 64; pub const bits: uint = 64;
} }
pub impl u64: num::NumCast { pub impl NumCast for u64 {
/** /**
* Cast `n` to a `u64` * Cast `n` to a `u64`
*/ */

View file

@ -26,7 +26,7 @@ mod inst {
pub pure fn is_ascii(x: T) -> bool { return 0 as T == x & 128 as T; } pub pure fn is_ascii(x: T) -> bool { return 0 as T == x & 128 as T; }
} }
pub impl u8: NumCast { pub impl NumCast for u8 {
/** /**
* Cast `n` to a `u8` * Cast `n` to a `u8`
*/ */

View file

@ -110,7 +110,7 @@ pub mod inst {
return true; return true;
} }
pub impl uint: iter::Times { pub impl iter::Times for uint {
#[inline(always)] #[inline(always)]
/** /**
* A convenience form for basic iteration. Given a uint `x`, * A convenience form for basic iteration. Given a uint `x`,
@ -209,7 +209,7 @@ pub mod inst {
} }
} }
pub impl uint: NumCast { pub impl NumCast for uint {
/** /**
* Cast `n` to a `uint` * Cast `n` to a `uint`
*/ */

View file

@ -1211,11 +1211,11 @@ pub trait Select2<T: Owned, U: Owned> {
fn select() -> Either<T, U>; fn select() -> Either<T, U>;
} }
impl<T: Owned, U: Owned, impl<T: Owned,
U: Owned,
Left: Selectable GenericPort<T>, Left: Selectable GenericPort<T>,
Right: Selectable GenericPort<U>> Right: Selectable GenericPort<U>>
(Left, Right): Select2<T, U> { Select2<T,U> for (Left, Right) {
fn select() -> Either<T, U> { fn select() -> Either<T, U> {
match self { match self {
(ref lp, ref rp) => match select2i(lp, rp) { (ref lp, ref rp) => match select2i(lp, rp) {

View file

@ -2328,7 +2328,7 @@ pub trait OwnedStr {
fn push_char(&mut self, c: char); fn push_char(&mut self, c: char);
} }
pub impl ~str : OwnedStr { pub impl OwnedStr for ~str {
fn push_str(&mut self, v: &str) { fn push_str(&mut self, v: &str) {
push_str(self, v); push_str(self, v);
} }

View file

@ -170,7 +170,7 @@ impl IterBytes for char {
pub mod x32 { pub mod x32 {
use to_bytes::{Cb, IterBytes}; use to_bytes::{Cb, IterBytes};
pub impl uint: IterBytes { pub impl IterBytes for uint {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as u32).iter_bytes(lsb0, f) (*self as u32).iter_bytes(lsb0, f)
@ -182,7 +182,7 @@ pub mod x32 {
pub mod x64 { pub mod x64 {
use to_bytes::{Cb, IterBytes}; use to_bytes::{Cb, IterBytes};
pub impl uint: IterBytes { pub impl IterBytes for uint {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as u64).iter_bytes(lsb0, f) (*self as u64).iter_bytes(lsb0, f)

View file

@ -175,6 +175,7 @@ pub fn time<T>(do_it: bool, what: ~str, thunk: fn() -> T) -> T {
rv rv
} }
#[deriving_eq]
pub enum compile_upto { pub enum compile_upto {
cu_parse, cu_parse,
cu_expand, cu_expand,
@ -183,13 +184,6 @@ pub enum compile_upto {
cu_everything, cu_everything,
} }
pub impl compile_upto : cmp::Eq {
pure fn eq(&self, other: &compile_upto) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &compile_upto) -> bool { !(*self).eq(other) }
}
pub fn compile_upto(sess: Session, cfg: ast::crate_cfg, pub fn compile_upto(sess: Session, cfg: ast::crate_cfg,
input: input, upto: compile_upto, input: input, upto: compile_upto,
outputs: Option<output_filenames>) outputs: Option<output_filenames>)

View file

@ -29,24 +29,12 @@ use syntax::parse::parse_sess;
use syntax::{ast, codemap}; use syntax::{ast, codemap};
use syntax; use syntax;
#[deriving_eq]
pub enum os { os_win32, os_macos, os_linux, os_android, os_freebsd, } pub enum os { os_win32, os_macos, os_linux, os_android, os_freebsd, }
pub impl os : cmp::Eq { #[deriving_eq]
pure fn eq(&self, other: &os) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &os) -> bool { !(*self).eq(other) }
}
pub enum arch { arch_x86, arch_x86_64, arch_arm, } pub enum arch { arch_x86, arch_x86_64, arch_arm, }
pub impl arch : cmp::Eq {
pure fn eq(&self, other: &arch) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &arch) -> bool { !(*self).eq(other) }
}
pub enum crate_type { bin_crate, lib_crate, unknown_crate, } pub enum crate_type { bin_crate, lib_crate, unknown_crate, }
pub type config = pub type config =
@ -117,6 +105,7 @@ pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
] ]
} }
#[deriving_eq]
pub enum OptLevel { pub enum OptLevel {
No, // -O0 No, // -O0
Less, // -O1 Less, // -O1
@ -124,13 +113,6 @@ pub enum OptLevel {
Aggressive // -O3 Aggressive // -O3
} }
pub impl OptLevel : cmp::Eq {
pure fn eq(&self, other: &OptLevel) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &OptLevel) -> bool { !(*self).eq(other) }
}
pub type options = pub type options =
// The crate config requested for the session, which may be combined // The crate config requested for the session, which may be combined
// with additional crate configurations during the compile process // with additional crate configurations during the compile process

View file

@ -132,6 +132,7 @@ pub enum RealPredicate {
// enum for the LLVM TypeKind type - must stay in sync with the def of // enum for the LLVM TypeKind type - must stay in sync with the def of
// LLVMTypeKind in llvm/include/llvm-c/Core.h // LLVMTypeKind in llvm/include/llvm-c/Core.h
#[deriving_eq]
pub enum TypeKind { pub enum TypeKind {
Void = 0, Void = 0,
Half = 1, Half = 1,
@ -151,46 +152,6 @@ pub enum TypeKind {
X86_MMX = 15 X86_MMX = 15
} }
pub impl TypeKind : cmp::Eq {
pure fn eq(&self, other: &TypeKind) -> bool {
match ((*self), (*other)) {
(Void, Void) => true,
(Half, Half) => true,
(Float, Float) => true,
(Double, Double) => true,
(X86_FP80, X86_FP80) => true,
(FP128, FP128) => true,
(PPC_FP128, PPC_FP128) => true,
(Label, Label) => true,
(Integer, Integer) => true,
(Function, Function) => true,
(Struct, Struct) => true,
(Array, Array) => true,
(Pointer, Pointer) => true,
(Vector, Vector) => true,
(Metadata, Metadata) => true,
(X86_MMX, X86_MMX) => true,
(Void, _) => false,
(Half, _) => false,
(Float, _) => false,
(Double, _) => false,
(X86_FP80, _) => false,
(FP128, _) => false,
(PPC_FP128, _) => false,
(Label, _) => false,
(Integer, _) => false,
(Function, _) => false,
(Struct, _) => false,
(Array, _) => false,
(Pointer, _) => false,
(Vector, _) => false,
(Metadata, _) => false,
(X86_MMX, _) => false,
}
}
pure fn ne(&self, other: &TypeKind) -> bool { !(*self).eq(other) }
}
pub enum AtomicBinOp { pub enum AtomicBinOp {
Xchg = 0, Xchg = 0,
Add = 1, Add = 1,

View file

@ -449,7 +449,7 @@ impl LoanKind {
/// Creates and returns a new root_map /// Creates and returns a new root_map
pub impl root_map_key : to_bytes::IterBytes { pub impl to_bytes::IterBytes for root_map_key {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.id, &self.derefs, lsb0, f); to_bytes::iter_bytes_2(&self.id, &self.derefs, lsb0, f);
} }

View file

@ -281,12 +281,12 @@ pub trait ast_node {
fn span() -> span; fn span() -> span;
} }
pub impl @ast::expr: ast_node { pub impl ast_node for @ast::expr {
fn id() -> ast::node_id { self.id } fn id() -> ast::node_id { self.id }
fn span() -> span { self.span } fn span() -> span { self.span }
} }
pub impl @ast::pat: ast_node { pub impl ast_node for @ast::pat {
fn id() -> ast::node_id { self.id } fn id() -> ast::node_id { self.id }
fn span() -> span { self.span } fn span() -> span { self.span }
} }
@ -295,7 +295,7 @@ pub trait get_type_for_node {
fn ty<N: ast_node>(node: N) -> ty::t; fn ty<N: ast_node>(node: N) -> ty::t;
} }
pub impl ty::ctxt: get_type_for_node { pub impl get_type_for_node for ty::ctxt {
fn ty<N: ast_node>(node: N) -> ty::t { fn ty<N: ast_node>(node: N) -> ty::t {
ty::node_id_to_type(self, node.id()) ty::node_id_to_type(self, node.id())
} }

View file

@ -108,7 +108,7 @@ pub trait get_insn_ctxt {
fn insn_ctxt(s: &str) -> icx_popper; fn insn_ctxt(s: &str) -> icx_popper;
} }
pub impl @crate_ctxt: get_insn_ctxt { pub impl get_insn_ctxt for @crate_ctxt {
fn insn_ctxt(s: &str) -> icx_popper { fn insn_ctxt(s: &str) -> icx_popper {
debug!("new insn_ctxt: %s", s); debug!("new insn_ctxt: %s", s);
if self.sess.count_llvm_insns() { if self.sess.count_llvm_insns() {
@ -118,13 +118,13 @@ pub impl @crate_ctxt: get_insn_ctxt {
} }
} }
pub impl block: get_insn_ctxt { pub impl get_insn_ctxt for block {
fn insn_ctxt(s: &str) -> icx_popper { fn insn_ctxt(s: &str) -> icx_popper {
self.ccx().insn_ctxt(s) self.ccx().insn_ctxt(s)
} }
} }
pub impl fn_ctxt: get_insn_ctxt { pub impl get_insn_ctxt for fn_ctxt {
fn insn_ctxt(s: &str) -> icx_popper { fn insn_ctxt(s: &str) -> icx_popper {
self.ccx.insn_ctxt(s) self.ccx.insn_ctxt(s)
} }

View file

@ -532,13 +532,13 @@ pub trait get_node_info {
fn info() -> Option<node_info>; fn info() -> Option<node_info>;
} }
pub impl @ast::expr: get_node_info { pub impl get_node_info for @ast::expr {
fn info() -> Option<node_info> { fn info() -> Option<node_info> {
Some({id: self.id, span: self.span}) Some({id: self.id, span: self.span})
} }
} }
pub impl ast::blk: get_node_info { pub impl get_node_info for ast::blk {
fn info() -> Option<node_info> { fn info() -> Option<node_info> {
Some({id: self.node.id, span: self.span}) Some({id: self.node.id, span: self.span})
} }
@ -547,7 +547,7 @@ pub impl ast::blk: get_node_info {
// XXX: Work around a trait parsing bug. remove after snapshot // XXX: Work around a trait parsing bug. remove after snapshot
pub type optional_boxed_ast_expr = Option<@ast::expr>; pub type optional_boxed_ast_expr = Option<@ast::expr>;
pub impl optional_boxed_ast_expr: get_node_info { pub impl get_node_info for optional_boxed_ast_expr {
fn info() -> Option<node_info> { fn info() -> Option<node_info> {
self.chain_ref(|s| s.info()) self.chain_ref(|s| s.info())
} }
@ -1280,7 +1280,7 @@ pub struct mono_id_ {
pub type mono_id = @mono_id_; pub type mono_id = @mono_id_;
pub impl mono_param_id : to_bytes::IterBytes { pub impl to_bytes::IterBytes for mono_param_id {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match /*bad*/copy *self { match /*bad*/copy *self {
mono_precise(t, mids) => mono_precise(t, mids) =>
@ -1294,7 +1294,7 @@ pub impl mono_param_id : to_bytes::IterBytes {
} }
} }
pub impl mono_id_ : to_bytes::IterBytes { pub impl to_bytes::IterBytes for mono_id_ {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.def, &self.params, lsb0, f); to_bytes::iter_bytes_2(&self.def, &self.params, lsb0, f);
} }

View file

@ -104,6 +104,7 @@ use core::uint;
use core::vec; use core::vec;
use syntax::parse::token::special_idents; use syntax::parse::token::special_idents;
#[deriving_eq]
pub enum CopyAction { pub enum CopyAction {
INIT, INIT,
DROP_EXISTING DROP_EXISTING
@ -150,14 +151,14 @@ pub impl DatumMode {
} }
} }
pub impl DatumMode: cmp::Eq { pub impl cmp::Eq for DatumMode {
pure fn eq(&self, other: &DatumMode) -> bool { pure fn eq(&self, other: &DatumMode) -> bool {
(*self) as uint == (*other as uint) (*self) as uint == (*other as uint)
} }
pure fn ne(&self, other: &DatumMode) -> bool { !(*self).eq(other) } pure fn ne(&self, other: &DatumMode) -> bool { !(*self).eq(other) }
} }
pub impl DatumMode: to_bytes::IterBytes { pub impl to_bytes::IterBytes for DatumMode {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f) (*self as uint).iter_bytes(lsb0, f)
} }
@ -846,14 +847,3 @@ pub impl DatumBlock {
} }
} }
pub impl CopyAction : cmp::Eq {
pure fn eq(&self, other: &CopyAction) -> bool {
match ((*self), (*other)) {
(INIT, INIT) => true,
(DROP_EXISTING, DROP_EXISTING) => true,
(INIT, _) => false,
(DROP_EXISTING, _) => false,
}
}
pure fn ne(&self, other: &CopyAction) -> bool { !(*self).eq(other) }
}

View file

@ -657,46 +657,46 @@ pub trait Vid {
pure fn to_uint() -> uint; pure fn to_uint() -> uint;
} }
pub impl TyVid: Vid { pub impl Vid for TyVid {
pure fn to_uint() -> uint { *self } pure fn to_uint() -> uint { *self }
} }
pub impl TyVid: ToStr { pub impl ToStr for TyVid {
pure fn to_str(&self) -> ~str { fmt!("<V%u>", self.to_uint()) } pure fn to_str(&self) -> ~str { fmt!("<V%u>", self.to_uint()) }
} }
pub impl IntVid: Vid { pub impl Vid for IntVid {
pure fn to_uint() -> uint { *self } pure fn to_uint() -> uint { *self }
} }
pub impl IntVid: ToStr { pub impl ToStr for IntVid {
pure fn to_str(&self) -> ~str { fmt!("<VI%u>", self.to_uint()) } pure fn to_str(&self) -> ~str { fmt!("<VI%u>", self.to_uint()) }
} }
pub impl FloatVid: Vid { pub impl Vid for FloatVid {
pure fn to_uint() -> uint { *self } pure fn to_uint() -> uint { *self }
} }
pub impl FloatVid: ToStr { pub impl ToStr for FloatVid {
pure fn to_str(&self) -> ~str { fmt!("<VF%u>", self.to_uint()) } pure fn to_str(&self) -> ~str { fmt!("<VF%u>", self.to_uint()) }
} }
pub impl RegionVid: Vid { pub impl Vid for RegionVid {
pure fn to_uint() -> uint { *self } pure fn to_uint() -> uint { *self }
} }
pub impl RegionVid: ToStr { pub impl ToStr for RegionVid {
pure fn to_str(&self) -> ~str { fmt!("%?", self) } pure fn to_str(&self) -> ~str { fmt!("%?", self) }
} }
pub impl FnSig : ToStr { pub impl ToStr for FnSig {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
// grr, without tcx not much we can do. // grr, without tcx not much we can do.
return ~"(...)"; return ~"(...)";
} }
} }
pub impl InferTy: ToStr { pub impl ToStr for InferTy {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
match *self { match *self {
TyVar(ref v) => v.to_str(), TyVar(ref v) => v.to_str(),
@ -706,7 +706,7 @@ pub impl InferTy: ToStr {
} }
} }
pub impl IntVarValue : ToStr { pub impl ToStr for IntVarValue {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
match *self { match *self {
IntType(ref v) => v.to_str(), IntType(ref v) => v.to_str(),
@ -715,25 +715,25 @@ pub impl IntVarValue : ToStr {
} }
} }
pub impl TyVid : to_bytes::IterBytes { pub impl to_bytes::IterBytes for TyVid {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
self.to_uint().iter_bytes(lsb0, f) self.to_uint().iter_bytes(lsb0, f)
} }
} }
pub impl IntVid : to_bytes::IterBytes { pub impl to_bytes::IterBytes for IntVid {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
self.to_uint().iter_bytes(lsb0, f) self.to_uint().iter_bytes(lsb0, f)
} }
} }
pub impl FloatVid : to_bytes::IterBytes { pub impl to_bytes::IterBytes for FloatVid {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
self.to_uint().iter_bytes(lsb0, f) self.to_uint().iter_bytes(lsb0, f)
} }
} }
pub impl RegionVid : to_bytes::IterBytes { pub impl to_bytes::IterBytes for RegionVid {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
self.to_uint().iter_bytes(lsb0, f) self.to_uint().iter_bytes(lsb0, f)
} }

View file

@ -620,7 +620,7 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) {
} }
} }
pub impl FnCtxt: AstConv { pub impl AstConv for FnCtxt {
fn tcx(@mut self) -> ty::ctxt { self.ccx.tcx } fn tcx(@mut self) -> ty::ctxt { self.ccx.tcx }
fn ccx(@mut self) -> @mut CrateCtxt { self.ccx } fn ccx(@mut self) -> @mut CrateCtxt { self.ccx }
@ -654,7 +654,7 @@ pub impl FnCtxt {
} }
} }
pub impl @mut FnCtxt: region_scope { pub impl region_scope for @mut FnCtxt {
pure fn anon_region(span: span) -> Result<ty::Region, ~str> { pure fn anon_region(span: span) -> Result<ty::Region, ~str> {
// XXX: Unsafe to work around purity // XXX: Unsafe to work around purity
unsafe { unsafe {

View file

@ -121,7 +121,7 @@ pub impl @mut CrateCtxt {
} }
} }
pub impl CrateCtxt: AstConv { pub impl AstConv for CrateCtxt {
fn tcx(@mut self) -> ty::ctxt { self.tcx } fn tcx(@mut self) -> ty::ctxt { self.tcx }
fn ccx(@mut self) -> @mut CrateCtxt { self } fn ccx(@mut self) -> @mut CrateCtxt { self }

View file

@ -27,7 +27,7 @@ use std::list;
pub enum Glb = CombineFields; // "greatest lower bound" (common subtype) pub enum Glb = CombineFields; // "greatest lower bound" (common subtype)
pub impl Glb: Combine { pub impl Combine for Glb {
fn infcx() -> @mut InferCtxt { self.infcx } fn infcx() -> @mut InferCtxt { self.infcx }
fn tag() -> ~str { ~"glb" } fn tag() -> ~str { ~"glb" }
fn a_is_expected() -> bool { self.a_is_expected } fn a_is_expected() -> bool { self.a_is_expected }

View file

@ -57,7 +57,7 @@ pub trait LatticeValue {
pub type LatticeOp<T> = &fn(cf: &CombineFields, a: &T, b: &T) -> cres<T>; pub type LatticeOp<T> = &fn(cf: &CombineFields, a: &T, b: &T) -> cres<T>;
pub impl ty::t: LatticeValue { pub impl LatticeValue for ty::t {
static fn sub(cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures { static fn sub(cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures {
Sub(*cf).tys(*a, *b).to_ures() Sub(*cf).tys(*a, *b).to_ures()
} }
@ -301,7 +301,7 @@ pub trait TyLatticeDir {
fn ty_bot(t: ty::t) -> cres<ty::t>; fn ty_bot(t: ty::t) -> cres<ty::t>;
} }
pub impl Lub: LatticeDir { pub impl LatticeDir for Lub {
fn combine_fields() -> CombineFields { *self } fn combine_fields() -> CombineFields { *self }
fn bnd<T:Copy>(b: &Bounds<T>) -> Option<T> { b.ub } fn bnd<T:Copy>(b: &Bounds<T>) -> Option<T> { b.ub }
fn with_bnd<T:Copy>(b: &Bounds<T>, +t: T) -> Bounds<T> { fn with_bnd<T:Copy>(b: &Bounds<T>, +t: T) -> Bounds<T> {
@ -309,13 +309,13 @@ pub impl Lub: LatticeDir {
} }
} }
pub impl Lub: TyLatticeDir { pub impl TyLatticeDir for Lub {
fn ty_bot(t: ty::t) -> cres<ty::t> { fn ty_bot(t: ty::t) -> cres<ty::t> {
Ok(t) Ok(t)
} }
} }
pub impl Glb: LatticeDir { pub impl LatticeDir for Glb {
fn combine_fields() -> CombineFields { *self } fn combine_fields() -> CombineFields { *self }
fn bnd<T:Copy>(b: &Bounds<T>) -> Option<T> { b.lb } fn bnd<T:Copy>(b: &Bounds<T>) -> Option<T> { b.lb }
fn with_bnd<T:Copy>(b: &Bounds<T>, +t: T) -> Bounds<T> { fn with_bnd<T:Copy>(b: &Bounds<T>, +t: T) -> Bounds<T> {
@ -323,7 +323,7 @@ pub impl Glb: LatticeDir {
} }
} }
pub impl Glb: TyLatticeDir { pub impl TyLatticeDir for Glb {
fn ty_bot(_t: ty::t) -> cres<ty::t> { fn ty_bot(_t: ty::t) -> cres<ty::t> {
Ok(ty::mk_bot(self.infcx.tcx)) Ok(ty::mk_bot(self.infcx.tcx))
} }

View file

@ -36,7 +36,7 @@ pub impl Lub {
fn ty_bot(b: ty::t) -> cres<ty::t> { self.bot_ty(b) } // commutative fn ty_bot(b: ty::t) -> cres<ty::t> { self.bot_ty(b) } // commutative
} }
pub impl Lub: Combine { pub impl Combine for Lub {
fn infcx() -> @mut InferCtxt { self.infcx } fn infcx() -> @mut InferCtxt { self.infcx }
fn tag() -> ~str { ~"lub" } fn tag() -> ~str { ~"lub" }
fn a_is_expected() -> bool { self.a_is_expected } fn a_is_expected() -> bool { self.a_is_expected }

View file

@ -32,7 +32,7 @@ pub fn macros() {
pub enum Sub = CombineFields; // "subtype", "subregion" etc pub enum Sub = CombineFields; // "subtype", "subregion" etc
pub impl Sub: Combine { pub impl Combine for Sub {
fn infcx() -> @mut InferCtxt { self.infcx } fn infcx() -> @mut InferCtxt { self.infcx }
fn tag() -> ~str { ~"sub" } fn tag() -> ~str { ~"sub" }
fn a_is_expected() -> bool { self.a_is_expected } fn a_is_expected() -> bool { self.a_is_expected }

View file

@ -28,13 +28,13 @@ pub trait InferStr {
fn inf_str(&self, cx: &InferCtxt) -> ~str; fn inf_str(&self, cx: &InferCtxt) -> ~str;
} }
pub impl ty::t : InferStr { pub impl InferStr for ty::t {
fn inf_str(&self, cx: &InferCtxt) -> ~str { fn inf_str(&self, cx: &InferCtxt) -> ~str {
ty_to_str(cx.tcx, *self) ty_to_str(cx.tcx, *self)
} }
} }
pub impl FnSig : InferStr { pub impl InferStr for FnSig {
fn inf_str(&self, cx: &InferCtxt) -> ~str { fn inf_str(&self, cx: &InferCtxt) -> ~str {
fmt!("(%s) -> %s", fmt!("(%s) -> %s",
str::connect(self.inputs.map(|a| a.ty.inf_str(cx)), ", "), str::connect(self.inputs.map(|a| a.ty.inf_str(cx)), ", "),
@ -42,19 +42,19 @@ pub impl FnSig : InferStr {
} }
} }
pub impl ty::mt : InferStr { pub impl InferStr for ty::mt {
fn inf_str(&self, cx: &InferCtxt) -> ~str { fn inf_str(&self, cx: &InferCtxt) -> ~str {
mt_to_str(cx.tcx, *self) mt_to_str(cx.tcx, *self)
} }
} }
pub impl ty::Region : InferStr { pub impl InferStr for ty::Region {
fn inf_str(&self, _cx: &InferCtxt) -> ~str { fn inf_str(&self, _cx: &InferCtxt) -> ~str {
fmt!("%?", *self) fmt!("%?", *self)
} }
} }
pub impl<V:InferStr> Bound<V> : InferStr { pub impl<V:InferStr> InferStr for Bound<V> {
fn inf_str(&self, cx: &InferCtxt) -> ~str { fn inf_str(&self, cx: &InferCtxt) -> ~str {
match *self { match *self {
Some(ref v) => v.inf_str(cx), Some(ref v) => v.inf_str(cx),
@ -63,7 +63,7 @@ pub impl<V:InferStr> Bound<V> : InferStr {
} }
} }
pub impl<T:InferStr> Bounds<T> : InferStr { pub impl<T:InferStr> InferStr for Bounds<T> {
fn inf_str(&self, cx: &InferCtxt) -> ~str { fn inf_str(&self, cx: &InferCtxt) -> ~str {
fmt!("{%s <: %s}", fmt!("{%s <: %s}",
self.lb.inf_str(cx), self.lb.inf_str(cx),
@ -71,7 +71,7 @@ pub impl<T:InferStr> Bounds<T> : InferStr {
} }
} }
pub impl<V:Vid ToStr, T:InferStr> VarValue<V, T> : InferStr { pub impl<V:Vid ToStr, T:InferStr> InferStr for VarValue<V, T> {
fn inf_str(&self, cx: &InferCtxt) -> ~str { fn inf_str(&self, cx: &InferCtxt) -> ~str {
match *self { match *self {
Redirect(ref vid) => fmt!("Redirect(%s)", vid.to_str()), Redirect(ref vid) => fmt!("Redirect(%s)", vid.to_str()),
@ -81,13 +81,13 @@ pub impl<V:Vid ToStr, T:InferStr> VarValue<V, T> : InferStr {
} }
} }
pub impl IntVarValue : InferStr { pub impl InferStr for IntVarValue {
fn inf_str(&self, _cx: &InferCtxt) -> ~str { fn inf_str(&self, _cx: &InferCtxt) -> ~str {
self.to_str() self.to_str()
} }
} }
pub impl ast::float_ty : InferStr { pub impl InferStr for ast::float_ty {
fn inf_str(&self, _cx: &InferCtxt) -> ~str { fn inf_str(&self, _cx: &InferCtxt) -> ~str {
self.to_str() self.to_str()
} }

View file

@ -237,35 +237,35 @@ pub impl InferCtxt {
// ______________________________________________________________________ // ______________________________________________________________________
pub impl ty::TyVid : UnifyVid<Bounds<ty::t>> { pub impl UnifyVid<Bounds<ty::t>> for ty::TyVid {
static fn appropriate_vals_and_bindings(infcx: &v/mut InferCtxt) static fn appropriate_vals_and_bindings(infcx: &v/mut InferCtxt)
-> &v/mut ValsAndBindings<ty::TyVid, Bounds<ty::t>> { -> &v/mut ValsAndBindings<ty::TyVid, Bounds<ty::t>> {
return &mut infcx.ty_var_bindings; return &mut infcx.ty_var_bindings;
} }
} }
pub impl ty::IntVid : UnifyVid<Option<IntVarValue>> { pub impl UnifyVid<Option<IntVarValue>> for ty::IntVid {
static fn appropriate_vals_and_bindings(infcx: &v/mut InferCtxt) static fn appropriate_vals_and_bindings(infcx: &v/mut InferCtxt)
-> &v/mut ValsAndBindings<ty::IntVid, Option<IntVarValue>> { -> &v/mut ValsAndBindings<ty::IntVid, Option<IntVarValue>> {
return &mut infcx.int_var_bindings; return &mut infcx.int_var_bindings;
} }
} }
pub impl IntVarValue : SimplyUnifiable { pub impl SimplyUnifiable for IntVarValue {
static fn to_type_err(err: expected_found<IntVarValue>) static fn to_type_err(err: expected_found<IntVarValue>)
-> ty::type_err { -> ty::type_err {
return ty::terr_int_mismatch(err); return ty::terr_int_mismatch(err);
} }
} }
pub impl ty::FloatVid : UnifyVid<Option<ast::float_ty>> { pub impl UnifyVid<Option<ast::float_ty>> for ty::FloatVid {
static fn appropriate_vals_and_bindings(infcx: &v/mut InferCtxt) static fn appropriate_vals_and_bindings(infcx: &v/mut InferCtxt)
-> &v/mut ValsAndBindings<ty::FloatVid, Option<ast::float_ty>> { -> &v/mut ValsAndBindings<ty::FloatVid, Option<ast::float_ty>> {
return &mut infcx.float_var_bindings; return &mut infcx.float_var_bindings;
} }
} }
pub impl ast::float_ty : SimplyUnifiable { pub impl SimplyUnifiable for ast::float_ty {
static fn to_type_err(err: expected_found<ast::float_ty>) static fn to_type_err(err: expected_found<ast::float_ty>)
-> ty::type_err { -> ty::type_err {
return ty::terr_float_mismatch(err); return ty::terr_float_mismatch(err);

View file

@ -26,7 +26,7 @@ pub trait region_scope {
} }
pub enum empty_rscope { empty_rscope } pub enum empty_rscope { empty_rscope }
pub impl empty_rscope: region_scope { pub impl region_scope for empty_rscope {
pure fn anon_region(_span: span) -> Result<ty::Region, ~str> { pure fn anon_region(_span: span) -> Result<ty::Region, ~str> {
result::Ok(ty::re_static) result::Ok(ty::re_static)
} }
@ -40,7 +40,7 @@ pub impl empty_rscope: region_scope {
} }
pub enum type_rscope = Option<ty::region_variance>; pub enum type_rscope = Option<ty::region_variance>;
pub impl type_rscope: region_scope { pub impl region_scope for type_rscope {
pure fn anon_region(_span: span) -> Result<ty::Region, ~str> { pure fn anon_region(_span: span) -> Result<ty::Region, ~str> {
match *self { match *self {
Some(_) => result::Ok(ty::re_bound(ty::br_self)), Some(_) => result::Ok(ty::re_bound(ty::br_self)),
@ -73,7 +73,7 @@ pub fn in_anon_rscope<RS: region_scope Copy Durable>(self: RS, r: ty::Region)
-> @anon_rscope { -> @anon_rscope {
@anon_rscope({anon: r, base: self as region_scope}) @anon_rscope({anon: r, base: self as region_scope})
} }
pub impl @anon_rscope: region_scope { pub impl region_scope for @anon_rscope {
pure fn anon_region(_span: span) -> Result<ty::Region, ~str> { pure fn anon_region(_span: span) -> Result<ty::Region, ~str> {
result::Ok(self.anon) result::Ok(self.anon)
} }
@ -96,7 +96,7 @@ pub fn in_binding_rscope<RS: region_scope Copy Durable>(self: RS)
let base = self as region_scope; let base = self as region_scope;
@mut binding_rscope { base: base, anon_bindings: 0 } @mut binding_rscope { base: base, anon_bindings: 0 }
} }
pub impl @mut binding_rscope: region_scope { pub impl region_scope for @mut binding_rscope {
pure fn anon_region(_span: span) -> Result<ty::Region, ~str> { pure fn anon_region(_span: span) -> Result<ty::Region, ~str> {
// XXX: Unsafe to work around purity // XXX: Unsafe to work around purity
unsafe { unsafe {

View file

@ -296,18 +296,12 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
compile_input(sess, cfg, input, &odir, &ofile); compile_input(sess, cfg, input, &odir, &ofile);
} }
#[deriving_eq]
pub enum monitor_msg { pub enum monitor_msg {
fatal, fatal,
done, done,
} }
pub impl monitor_msg : cmp::Eq {
pure fn eq(&self, other: &monitor_msg) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &monitor_msg) -> bool { !(*self).eq(other) }
}
/* /*
This is a sanity check that any failure of the compiler is performed This is a sanity check that any failure of the compiler is performed
through the diagnostic module and reported properly - we shouldn't be calling through the diagnostic module and reported properly - we shouldn't be calling

View file

@ -59,7 +59,7 @@ pub struct Config {
pandoc_cmd: Option<~str> pandoc_cmd: Option<~str>
} }
pub impl Config: Clone { pub impl Clone for Config {
fn clone(&self) -> Config { copy *self } fn clone(&self) -> Config { copy *self }
} }

View file

@ -761,7 +761,7 @@ fn should_write_impl_header() {
#[test] #[test]
fn should_write_impl_header_with_trait() { fn should_write_impl_header_with_trait() {
let markdown = test::render(~"impl int: j { fn a() { } }"); let markdown = test::render(~"impl j for int { fn a() { } }");
assert str::contains(markdown, ~"## Implementation of `j` for `int`"); assert str::contains(markdown, ~"## Implementation of `j` for `int`");
} }

View file

@ -297,7 +297,7 @@ fn fold_impl(
#[test] #[test]
fn should_add_impl_trait_types() { fn should_add_impl_trait_types() {
let doc = test::mk_doc(~"impl int: j { fn a<T>() { } }"); let doc = test::mk_doc(~"impl j for int { fn a<T>() { } }");
assert doc.cratemod().impls()[0].trait_types[0] == ~"j"; assert doc.cratemod().impls()[0].trait_types[0] == ~"j";
} }

View file

@ -258,7 +258,7 @@ pub trait ByteChan {
const CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD]; const CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD];
pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P>: GenericPort<T> { pub impl<T,U:Unflattener<T>,P:BytePort> GenericPort<T> for FlatPort<T, U, P> {
fn recv() -> T { fn recv() -> T {
match self.try_recv() { match self.try_recv() {
Some(val) => val, Some(val) => val,
@ -358,7 +358,7 @@ pub mod flatteners {
bogus: () bogus: ()
} }
pub impl<T: Copy Owned> PodUnflattener<T>: Unflattener<T> { pub impl<T: Copy Owned> Unflattener<T> for PodUnflattener<T> {
fn unflatten(&self, buf: ~[u8]) -> T { fn unflatten(&self, buf: ~[u8]) -> T {
assert size_of::<T>() != 0; assert size_of::<T>() != 0;
assert size_of::<T>() == buf.len(); assert size_of::<T>() == buf.len();
@ -368,7 +368,7 @@ pub mod flatteners {
} }
} }
pub impl<T: Copy Owned> PodFlattener<T>: Flattener<T> { pub impl<T: Copy Owned> Flattener<T> for PodFlattener<T> {
fn flatten(&self, val: T) -> ~[u8] { fn flatten(&self, val: T) -> ~[u8] {
assert size_of::<T>() != 0; assert size_of::<T>() != 0;
let val: *T = ptr::to_unsafe_ptr(&val); let val: *T = ptr::to_unsafe_ptr(&val);
@ -406,36 +406,32 @@ pub mod flatteners {
serialize_value: SerializeValue<T> serialize_value: SerializeValue<T>
} }
pub impl<D: Decoder, T: Decodable<D>> pub impl<D: Decoder, T: Decodable<D>> Unflattener<T>
DeserializingUnflattener<D, T>: Unflattener<T> { for DeserializingUnflattener<D, T> {
fn unflatten(&self, buf: ~[u8]) -> T { fn unflatten(&self, buf: ~[u8]) -> T {
(self.deserialize_buffer)(buf) (self.deserialize_buffer)(buf)
} }
} }
pub impl<S: Encoder, T: Encodable<S>> pub impl<S: Encoder, T: Encodable<S>> Flattener<T>
SerializingFlattener<S, T>: Flattener<T> { for SerializingFlattener<S, T> {
fn flatten(&self, val: T) -> ~[u8] { fn flatten(&self, val: T) -> ~[u8] {
(self.serialize_value)(&val) (self.serialize_value)(&val)
} }
} }
pub impl<D: Decoder, T: Decodable<D>> pub impl<D: Decoder, T: Decodable<D>> DeserializingUnflattener<D, T> {
DeserializingUnflattener<D, T> { static fn new(deserialize_buffer: DeserializeBuffer<T>)
-> DeserializingUnflattener<D, T> {
static fn new(deserialize_buffer: DeserializeBuffer<T>
) -> DeserializingUnflattener<D, T> {
DeserializingUnflattener { DeserializingUnflattener {
deserialize_buffer: deserialize_buffer deserialize_buffer: deserialize_buffer
} }
} }
} }
pub impl<S: Encoder, T: Encodable<S>> pub impl<S: Encoder, T: Encodable<S>> SerializingFlattener<S, T> {
SerializingFlattener<S, T> { static fn new(serialize_value: SerializeValue<T>)
-> SerializingFlattener<S, T> {
static fn new(serialize_value: SerializeValue<T>
) -> SerializingFlattener<S, T> {
SerializingFlattener { SerializingFlattener {
serialize_value: serialize_value serialize_value: serialize_value
} }
@ -523,7 +519,7 @@ pub mod bytepipes {
writer: W writer: W
} }
pub impl<R: Reader> ReaderBytePort<R>: BytePort { pub impl<R: Reader> BytePort for ReaderBytePort<R> {
fn try_recv(&self, count: uint) -> Option<~[u8]> { fn try_recv(&self, count: uint) -> Option<~[u8]> {
let mut left = count; let mut left = count;
let mut bytes = ~[]; let mut bytes = ~[];
@ -545,7 +541,7 @@ pub mod bytepipes {
} }
} }
pub impl<W: Writer> WriterByteChan<W>: ByteChan { pub impl<W: Writer> ByteChan for WriterByteChan<W> {
fn send(&self, val: ~[u8]) { fn send(&self, val: ~[u8]) {
self.writer.write(val); self.writer.write(val);
} }
@ -576,7 +572,7 @@ pub mod bytepipes {
chan: pipes::Chan<~[u8]> chan: pipes::Chan<~[u8]>
} }
pub impl PipeBytePort: BytePort { pub impl BytePort for PipeBytePort {
fn try_recv(&self, count: uint) -> Option<~[u8]> { fn try_recv(&self, count: uint) -> Option<~[u8]> {
if self.buf.len() >= count { if self.buf.len() >= count {
let mut bytes = ::core::util::replace(&mut self.buf, ~[]); let mut bytes = ::core::util::replace(&mut self.buf, ~[]);
@ -608,7 +604,7 @@ pub mod bytepipes {
} }
} }
pub impl PipeByteChan: ByteChan { pub impl ByteChan for PipeByteChan {
fn send(&self, val: ~[u8]) { fn send(&self, val: ~[u8]) {
self.chan.send(val) self.chan.send(val)
} }

View file

@ -82,7 +82,7 @@ pub fn Encoder(wr: io::Writer) -> Encoder {
Encoder { wr: wr } Encoder { wr: wr }
} }
pub impl Encoder: serialize::Encoder { pub impl serialize::Encoder for Encoder {
fn emit_nil(&self) { self.wr.write_str("null") } fn emit_nil(&self) { self.wr.write_str("null") }
fn emit_uint(&self, v: uint) { self.emit_float(v as float); } fn emit_uint(&self, v: uint) { self.emit_float(v as float); }
@ -217,7 +217,7 @@ pub fn PrettyEncoder(wr: io::Writer) -> PrettyEncoder {
PrettyEncoder { wr: wr, indent: 0 } PrettyEncoder { wr: wr, indent: 0 }
} }
pub impl PrettyEncoder: serialize::Encoder { pub impl serialize::Encoder for PrettyEncoder {
fn emit_nil(&self) { self.wr.write_str("null") } fn emit_nil(&self) { self.wr.write_str("null") }
fn emit_uint(&self, v: uint) { self.emit_float(v as float); } fn emit_uint(&self, v: uint) { self.emit_float(v as float); }
@ -323,7 +323,7 @@ pub impl PrettyEncoder: serialize::Encoder {
} }
} }
pub impl<S: serialize::Encoder> Json: serialize::Encodable<S> { pub impl<S: serialize::Encoder> serialize::Encodable<S> for Json {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
match *self { match *self {
Number(v) => v.encode(s), Number(v) => v.encode(s),
@ -768,7 +768,7 @@ priv impl Decoder {
} }
} }
pub impl Decoder: serialize::Decoder { pub impl serialize::Decoder for Decoder {
fn read_nil(&self) -> () { fn read_nil(&self) -> () {
debug!("read_nil"); debug!("read_nil");
match *self.pop() { match *self.pop() {

View file

@ -22,7 +22,7 @@ pub fn Serializer(wr: io::Writer) -> Serializer {
Serializer { wr: wr } Serializer { wr: wr }
} }
pub impl Serializer: serialize::Encoder { pub impl serialize::Encoder for Serializer {
fn emit_nil(&self) { fn emit_nil(&self) {
self.wr.write_str(~"()") self.wr.write_str(~"()")
} }

View file

@ -113,210 +113,210 @@ pub trait Decodable<D: Decoder> {
static fn decode(&self, d: &D) -> Self; static fn decode(&self, d: &D) -> Self;
} }
pub impl<S: Encoder> uint: Encodable<S> { pub impl<S: Encoder> Encodable<S> for uint {
fn encode(&self, s: &S) { s.emit_uint(*self) } fn encode(&self, s: &S) { s.emit_uint(*self) }
} }
pub impl<D: Decoder> uint: Decodable<D> { pub impl<D: Decoder> Decodable<D> for uint {
static fn decode(&self, d: &D) -> uint { static fn decode(&self, d: &D) -> uint {
d.read_uint() d.read_uint()
} }
} }
pub impl<S: Encoder> u8: Encodable<S> { pub impl<S: Encoder> Encodable<S> for u8 {
fn encode(&self, s: &S) { s.emit_u8(*self) } fn encode(&self, s: &S) { s.emit_u8(*self) }
} }
pub impl<D: Decoder> u8: Decodable<D> { pub impl<D: Decoder> Decodable<D> for u8 {
static fn decode(&self, d: &D) -> u8 { static fn decode(&self, d: &D) -> u8 {
d.read_u8() d.read_u8()
} }
} }
pub impl<S: Encoder> u16: Encodable<S> { pub impl<S: Encoder> Encodable<S> for u16 {
fn encode(&self, s: &S) { s.emit_u16(*self) } fn encode(&self, s: &S) { s.emit_u16(*self) }
} }
pub impl<D: Decoder> u16: Decodable<D> { pub impl<D: Decoder> Decodable<D> for u16 {
static fn decode(&self, d: &D) -> u16 { static fn decode(&self, d: &D) -> u16 {
d.read_u16() d.read_u16()
} }
} }
pub impl<S: Encoder> u32: Encodable<S> { pub impl<S: Encoder> Encodable<S> for u32 {
fn encode(&self, s: &S) { s.emit_u32(*self) } fn encode(&self, s: &S) { s.emit_u32(*self) }
} }
pub impl<D: Decoder> u32: Decodable<D> { pub impl<D: Decoder> Decodable<D> for u32 {
static fn decode(&self, d: &D) -> u32 { static fn decode(&self, d: &D) -> u32 {
d.read_u32() d.read_u32()
} }
} }
pub impl<S: Encoder> u64: Encodable<S> { pub impl<S: Encoder> Encodable<S> for u64 {
fn encode(&self, s: &S) { s.emit_u64(*self) } fn encode(&self, s: &S) { s.emit_u64(*self) }
} }
pub impl<D: Decoder> u64: Decodable<D> { pub impl<D: Decoder> Decodable<D> for u64 {
static fn decode(&self, d: &D) -> u64 { static fn decode(&self, d: &D) -> u64 {
d.read_u64() d.read_u64()
} }
} }
pub impl<S: Encoder> int: Encodable<S> { pub impl<S: Encoder> Encodable<S> for int {
fn encode(&self, s: &S) { s.emit_int(*self) } fn encode(&self, s: &S) { s.emit_int(*self) }
} }
pub impl<D: Decoder> int: Decodable<D> { pub impl<D: Decoder> Decodable<D> for int {
static fn decode(&self, d: &D) -> int { static fn decode(&self, d: &D) -> int {
d.read_int() d.read_int()
} }
} }
pub impl<S: Encoder> i8: Encodable<S> { pub impl<S: Encoder> Encodable<S> for i8 {
fn encode(&self, s: &S) { s.emit_i8(*self) } fn encode(&self, s: &S) { s.emit_i8(*self) }
} }
pub impl<D: Decoder> i8: Decodable<D> { pub impl<D: Decoder> Decodable<D> for i8 {
static fn decode(&self, d: &D) -> i8 { static fn decode(&self, d: &D) -> i8 {
d.read_i8() d.read_i8()
} }
} }
pub impl<S: Encoder> i16: Encodable<S> { pub impl<S: Encoder> Encodable<S> for i16 {
fn encode(&self, s: &S) { s.emit_i16(*self) } fn encode(&self, s: &S) { s.emit_i16(*self) }
} }
pub impl<D: Decoder> i16: Decodable<D> { pub impl<D: Decoder> Decodable<D> for i16 {
static fn decode(&self, d: &D) -> i16 { static fn decode(&self, d: &D) -> i16 {
d.read_i16() d.read_i16()
} }
} }
pub impl<S: Encoder> i32: Encodable<S> { pub impl<S: Encoder> Encodable<S> for i32 {
fn encode(&self, s: &S) { s.emit_i32(*self) } fn encode(&self, s: &S) { s.emit_i32(*self) }
} }
pub impl<D: Decoder> i32: Decodable<D> { pub impl<D: Decoder> Decodable<D> for i32 {
static fn decode(&self, d: &D) -> i32 { static fn decode(&self, d: &D) -> i32 {
d.read_i32() d.read_i32()
} }
} }
pub impl<S: Encoder> i64: Encodable<S> { pub impl<S: Encoder> Encodable<S> for i64 {
fn encode(&self, s: &S) { s.emit_i64(*self) } fn encode(&self, s: &S) { s.emit_i64(*self) }
} }
pub impl<D: Decoder> i64: Decodable<D> { pub impl<D: Decoder> Decodable<D> for i64 {
static fn decode(&self, d: &D) -> i64 { static fn decode(&self, d: &D) -> i64 {
d.read_i64() d.read_i64()
} }
} }
pub impl<S: Encoder> &str: Encodable<S> { pub impl<S: Encoder> Encodable<S> for &str {
fn encode(&self, s: &S) { s.emit_borrowed_str(*self) } fn encode(&self, s: &S) { s.emit_borrowed_str(*self) }
} }
pub impl<S: Encoder> ~str: Encodable<S> { pub impl<S: Encoder> Encodable<S> for ~str {
fn encode(&self, s: &S) { s.emit_owned_str(*self) } fn encode(&self, s: &S) { s.emit_owned_str(*self) }
} }
pub impl<D: Decoder> ~str: Decodable<D> { pub impl<D: Decoder> Decodable<D> for ~str {
static fn decode(&self, d: &D) -> ~str { static fn decode(&self, d: &D) -> ~str {
d.read_owned_str() d.read_owned_str()
} }
} }
pub impl<S: Encoder> @str: Encodable<S> { pub impl<S: Encoder> Encodable<S> for @str {
fn encode(&self, s: &S) { s.emit_managed_str(*self) } fn encode(&self, s: &S) { s.emit_managed_str(*self) }
} }
pub impl<D: Decoder> @str: Decodable<D> { pub impl<D: Decoder> Decodable<D> for @str {
static fn decode(&self, d: &D) -> @str { static fn decode(&self, d: &D) -> @str {
d.read_managed_str() d.read_managed_str()
} }
} }
pub impl<S: Encoder> float: Encodable<S> { pub impl<S: Encoder> Encodable<S> for float {
fn encode(&self, s: &S) { s.emit_float(*self) } fn encode(&self, s: &S) { s.emit_float(*self) }
} }
pub impl<D: Decoder> float: Decodable<D> { pub impl<D: Decoder> Decodable<D> for float {
static fn decode(&self, d: &D) -> float { static fn decode(&self, d: &D) -> float {
d.read_float() d.read_float()
} }
} }
pub impl<S: Encoder> f32: Encodable<S> { pub impl<S: Encoder> Encodable<S> for f32 {
fn encode(&self, s: &S) { s.emit_f32(*self) } fn encode(&self, s: &S) { s.emit_f32(*self) }
} }
pub impl<D: Decoder> f32: Decodable<D> { pub impl<D: Decoder> Decodable<D> for f32 {
static fn decode(&self, d: &D) -> f32 { static fn decode(&self, d: &D) -> f32 {
d.read_f32() } d.read_f32() }
} }
pub impl<S: Encoder> f64: Encodable<S> { pub impl<S: Encoder> Encodable<S> for f64 {
fn encode(&self, s: &S) { s.emit_f64(*self) } fn encode(&self, s: &S) { s.emit_f64(*self) }
} }
pub impl<D: Decoder> f64: Decodable<D> { pub impl<D: Decoder> Decodable<D> for f64 {
static fn decode(&self, d: &D) -> f64 { static fn decode(&self, d: &D) -> f64 {
d.read_f64() d.read_f64()
} }
} }
pub impl<S: Encoder> bool: Encodable<S> { pub impl<S: Encoder> Encodable<S> for bool {
fn encode(&self, s: &S) { s.emit_bool(*self) } fn encode(&self, s: &S) { s.emit_bool(*self) }
} }
pub impl<D: Decoder> bool: Decodable<D> { pub impl<D: Decoder> Decodable<D> for bool {
static fn decode(&self, d: &D) -> bool { static fn decode(&self, d: &D) -> bool {
d.read_bool() d.read_bool()
} }
} }
pub impl<S: Encoder> (): Encodable<S> { pub impl<S: Encoder> Encodable<S> for () {
fn encode(&self, s: &S) { s.emit_nil() } fn encode(&self, s: &S) { s.emit_nil() }
} }
pub impl<D: Decoder> (): Decodable<D> { pub impl<D: Decoder> Decodable<D> for () {
static fn decode(&self, d: &D) -> () { static fn decode(&self, d: &D) -> () {
d.read_nil() d.read_nil()
} }
} }
pub impl<S: Encoder, T: Encodable<S>> &T: Encodable<S> { pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for &T {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
s.emit_borrowed(|| (**self).encode(s)) s.emit_borrowed(|| (**self).encode(s))
} }
} }
pub impl<S: Encoder, T: Encodable<S>> ~T: Encodable<S> { pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for ~T {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
s.emit_owned(|| (**self).encode(s)) s.emit_owned(|| (**self).encode(s))
} }
} }
pub impl<D: Decoder, T: Decodable<D>> ~T: Decodable<D> { pub impl<D: Decoder, T: Decodable<D>> Decodable<D> for ~T {
static fn decode(&self, d: &D) -> ~T { static fn decode(&self, d: &D) -> ~T {
d.read_owned(|| ~Decodable::decode(d)) d.read_owned(|| ~Decodable::decode(d))
} }
} }
pub impl<S: Encoder, T: Encodable<S>> @T: Encodable<S> { pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for @T {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
s.emit_managed(|| (**self).encode(s)) s.emit_managed(|| (**self).encode(s))
} }
} }
pub impl<D: Decoder, T: Decodable<D>> @T: Decodable<D> { pub impl<D: Decoder, T: Decodable<D>> Decodable<D> for @T {
static fn decode(&self, d: &D) -> @T { static fn decode(&self, d: &D) -> @T {
d.read_managed(|| @Decodable::decode(d)) d.read_managed(|| @Decodable::decode(d))
} }
} }
pub impl<S: Encoder, T: Encodable<S>> &[T]: Encodable<S> { pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for &[T] {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
do s.emit_borrowed_vec(self.len()) { do s.emit_borrowed_vec(self.len()) {
for self.eachi |i, e| { for self.eachi |i, e| {
@ -326,7 +326,7 @@ pub impl<S: Encoder, T: Encodable<S>> &[T]: Encodable<S> {
} }
} }
pub impl<S: Encoder, T: Encodable<S>> ~[T]: Encodable<S> { pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for ~[T] {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
do s.emit_owned_vec(self.len()) { do s.emit_owned_vec(self.len()) {
for self.eachi |i, e| { for self.eachi |i, e| {
@ -336,7 +336,7 @@ pub impl<S: Encoder, T: Encodable<S>> ~[T]: Encodable<S> {
} }
} }
pub impl<D: Decoder, T: Decodable<D>> ~[T]: Decodable<D> { pub impl<D: Decoder, T: Decodable<D>> Decodable<D> for ~[T] {
static fn decode(&self, d: &D) -> ~[T] { static fn decode(&self, d: &D) -> ~[T] {
do d.read_owned_vec |len| { do d.read_owned_vec |len| {
do vec::from_fn(len) |i| { do vec::from_fn(len) |i| {
@ -346,7 +346,7 @@ pub impl<D: Decoder, T: Decodable<D>> ~[T]: Decodable<D> {
} }
} }
pub impl<S: Encoder, T: Encodable<S>> @[T]: Encodable<S> { pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for @[T] {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
do s.emit_managed_vec(self.len()) { do s.emit_managed_vec(self.len()) {
for self.eachi |i, e| { for self.eachi |i, e| {
@ -356,7 +356,7 @@ pub impl<S: Encoder, T: Encodable<S>> @[T]: Encodable<S> {
} }
} }
pub impl<D: Decoder, T: Decodable<D>> @[T]: Decodable<D> { pub impl<D: Decoder, T: Decodable<D>> Decodable<D> for @[T] {
static fn decode(&self, d: &D) -> @[T] { static fn decode(&self, d: &D) -> @[T] {
do d.read_managed_vec |len| { do d.read_managed_vec |len| {
do at_vec::from_fn(len) |i| { do at_vec::from_fn(len) |i| {
@ -366,7 +366,7 @@ pub impl<D: Decoder, T: Decodable<D>> @[T]: Decodable<D> {
} }
} }
pub impl<S: Encoder, T: Encodable<S>> Option<T>: Encodable<S> { pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for Option<T> {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
do s.emit_enum(~"option") { do s.emit_enum(~"option") {
match *self { match *self {
@ -381,7 +381,7 @@ pub impl<S: Encoder, T: Encodable<S>> Option<T>: Encodable<S> {
} }
} }
pub impl<D: Decoder, T: Decodable<D>> Option<T>: Decodable<D> { pub impl<D: Decoder, T: Decodable<D>> Decodable<D> for Option<T> {
static fn decode(&self, d: &D) -> Option<T> { static fn decode(&self, d: &D) -> Option<T> {
do d.read_enum(~"option") { do d.read_enum(~"option") {
do d.read_enum_variant |i| { do d.read_enum_variant |i| {
@ -396,11 +396,8 @@ pub impl<D: Decoder, T: Decodable<D>> Option<T>: Decodable<D> {
} }
} }
pub impl< pub impl<S: Encoder, T0: Encodable<S>, T1: Encodable<S>> Encodable<S>
S: Encoder, for (T0, T1) {
T0: Encodable<S>,
T1: Encodable<S>
> (T0, T1): Encodable<S> {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
match *self { match *self {
(ref t0, ref t1) => { (ref t0, ref t1) => {
@ -413,11 +410,8 @@ pub impl<
} }
} }
pub impl< pub impl<D: Decoder, T0: Decodable<D>, T1: Decodable<D>> Decodable<D>
D: Decoder, for (T0, T1) {
T0: Decodable<D>,
T1: Decodable<D>
> (T0, T1): Decodable<D> {
static fn decode(&self, d: &D) -> (T0, T1) { static fn decode(&self, d: &D) -> (T0, T1) {
do d.read_tup(2) { do d.read_tup(2) {
( (
@ -433,7 +427,7 @@ pub impl<
T0: Encodable<S>, T0: Encodable<S>,
T1: Encodable<S>, T1: Encodable<S>,
T2: Encodable<S> T2: Encodable<S>
> (T0, T1, T2): Encodable<S> { > Encodable<S> for (T0, T1, T2) {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
match *self { match *self {
(ref t0, ref t1, ref t2) => { (ref t0, ref t1, ref t2) => {
@ -452,7 +446,7 @@ pub impl<
T0: Decodable<D>, T0: Decodable<D>,
T1: Decodable<D>, T1: Decodable<D>,
T2: Decodable<D> T2: Decodable<D>
> (T0, T1, T2): Decodable<D> { > Decodable<D> for (T0, T1, T2) {
static fn decode(&self, d: &D) -> (T0, T1, T2) { static fn decode(&self, d: &D) -> (T0, T1, T2) {
do d.read_tup(3) { do d.read_tup(3) {
( (
@ -470,7 +464,7 @@ pub impl<
T1: Encodable<S>, T1: Encodable<S>,
T2: Encodable<S>, T2: Encodable<S>,
T3: Encodable<S> T3: Encodable<S>
> (T0, T1, T2, T3): Encodable<S> { > Encodable<S> for (T0, T1, T2, T3) {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
match *self { match *self {
(ref t0, ref t1, ref t2, ref t3) => { (ref t0, ref t1, ref t2, ref t3) => {
@ -491,7 +485,7 @@ pub impl<
T1: Decodable<D>, T1: Decodable<D>,
T2: Decodable<D>, T2: Decodable<D>,
T3: Decodable<D> T3: Decodable<D>
> (T0, T1, T2, T3): Decodable<D> { > Decodable<D> for (T0, T1, T2, T3) {
static fn decode(&self, d: &D) -> (T0, T1, T2, T3) { static fn decode(&self, d: &D) -> (T0, T1, T2, T3) {
do d.read_tup(4) { do d.read_tup(4) {
( (
@ -511,7 +505,7 @@ pub impl<
T2: Encodable<S>, T2: Encodable<S>,
T3: Encodable<S>, T3: Encodable<S>,
T4: Encodable<S> T4: Encodable<S>
> (T0, T1, T2, T3, T4): Encodable<S> { > Encodable<S> for (T0, T1, T2, T3, T4) {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
match *self { match *self {
(ref t0, ref t1, ref t2, ref t3, ref t4) => { (ref t0, ref t1, ref t2, ref t3, ref t4) => {
@ -534,7 +528,7 @@ pub impl<
T2: Decodable<D>, T2: Decodable<D>,
T3: Decodable<D>, T3: Decodable<D>,
T4: Decodable<D> T4: Decodable<D>
> (T0, T1, T2, T3, T4): Decodable<D> { > Decodable<D> for (T0, T1, T2, T3, T4) {
static fn decode(&self, d: &D) static fn decode(&self, d: &D)
-> (T0, T1, T2, T3, T4) { -> (T0, T1, T2, T3, T4) {
do d.read_tup(5) { do d.read_tup(5) {
@ -558,7 +552,7 @@ pub trait EncoderHelpers {
fn emit_from_vec<T>(&self, v: &[T], f: fn(v: &T)); fn emit_from_vec<T>(&self, v: &[T], f: fn(v: &T));
} }
pub impl<S: Encoder> S: EncoderHelpers { pub impl<S: Encoder> EncoderHelpers for S {
fn emit_from_vec<T>(&self, v: &[T], f: fn(v: &T)) { fn emit_from_vec<T>(&self, v: &[T], f: fn(v: &T)) {
do self.emit_owned_vec(v.len()) { do self.emit_owned_vec(v.len()) {
for v.eachi |i, e| { for v.eachi |i, e| {
@ -574,7 +568,7 @@ pub trait DecoderHelpers {
fn read_to_vec<T>(&self, f: fn() -> T) -> ~[T]; fn read_to_vec<T>(&self, f: fn() -> T) -> ~[T];
} }
pub impl<D: Decoder> D: DecoderHelpers { pub impl<D: Decoder> DecoderHelpers for D {
fn read_to_vec<T>(&self, f: fn() -> T) -> ~[T] { fn read_to_vec<T>(&self, f: fn() -> T) -> ~[T] {
do self.read_owned_vec |len| { do self.read_owned_vec |len| {
do vec::from_fn(len) |i| { do vec::from_fn(len) |i| {

View file

@ -138,7 +138,7 @@ impl WorkKey {
type WorkMap = LinearMap<WorkKey, ~str>; type WorkMap = LinearMap<WorkKey, ~str>;
pub impl<S: Encoder> WorkMap: Encodable<S> { pub impl<S: Encoder> Encodable<S> for WorkMap {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
let mut d = ~[]; let mut d = ~[];
for self.each |&(k, v)| { for self.each |&(k, v)| {
@ -149,7 +149,7 @@ pub impl<S: Encoder> WorkMap: Encodable<S> {
} }
} }
pub impl<D: Decoder> WorkMap: Decodable<D> { pub impl<D: Decoder> Decodable<D> for WorkMap {
static fn decode(&self, d: &D) -> WorkMap { static fn decode(&self, d: &D) -> WorkMap {
let v : ~[(WorkKey,~str)] = Decodable::decode(d); let v : ~[(WorkKey,~str)] = Decodable::decode(d);
let mut w = LinearMap::new(); let mut w = LinearMap::new();

View file

@ -32,7 +32,7 @@ macro_rules! interner_key (
#[deriving_eq] #[deriving_eq]
pub struct ident { repr: uint } pub struct ident { repr: uint }
pub impl<S: Encoder> ident: Encodable<S> { pub impl<S: Encoder> Encodable<S> for ident {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
let intr = match unsafe { let intr = match unsafe {
task::local_data::local_data_get(interner_key!()) task::local_data::local_data_get(interner_key!())
@ -45,7 +45,7 @@ pub impl<S: Encoder> ident: Encodable<S> {
} }
} }
pub impl<D: Decoder> ident: Decodable<D> { pub impl<D: Decoder> Decodable<D> for ident {
static fn decode(d: &D) -> ident { static fn decode(d: &D) -> ident {
let intr = match unsafe { let intr = match unsafe {
task::local_data::local_data_get(interner_key!()) task::local_data::local_data_get(interner_key!())
@ -58,7 +58,7 @@ pub impl<D: Decoder> ident: Decodable<D> {
} }
} }
pub impl ident: to_bytes::IterBytes { pub impl to_bytes::IterBytes for ident {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
self.repr.iter_bytes(lsb0, f) self.repr.iter_bytes(lsb0, f)
} }
@ -211,7 +211,7 @@ pub enum binding_mode {
bind_infer bind_infer
} }
pub impl binding_mode : to_bytes::IterBytes { pub impl to_bytes::IterBytes for binding_mode {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self { match *self {
bind_by_copy => 0u8.iter_bytes(lsb0, f), bind_by_copy => 0u8.iter_bytes(lsb0, f),
@ -256,7 +256,7 @@ pub enum pat_ {
#[deriving_eq] #[deriving_eq]
pub enum mutability { m_mutbl, m_imm, m_const, } pub enum mutability { m_mutbl, m_imm, m_const, }
pub impl mutability : to_bytes::IterBytes { pub impl to_bytes::IterBytes for mutability {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
@ -269,13 +269,13 @@ pub enum Abi {
RustAbi RustAbi
} }
pub impl Abi : to_bytes::IterBytes { pub impl to_bytes::IterBytes for Abi {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f) (*self as uint).iter_bytes(lsb0, f)
} }
} }
pub impl Abi : ToStr { pub impl ToStr for Abi {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
match *self { match *self {
RustAbi => ~"\"rust\"" RustAbi => ~"\"rust\""
@ -292,13 +292,13 @@ pub enum Sigil {
ManagedSigil ManagedSigil
} }
pub impl Sigil : to_bytes::IterBytes { pub impl to_bytes::IterBytes for Sigil {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f) (*self as uint).iter_bytes(lsb0, f)
} }
} }
pub impl Sigil : ToStr { pub impl ToStr for Sigil {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
match *self { match *self {
BorrowedSigil => ~"&", BorrowedSigil => ~"&",
@ -377,7 +377,7 @@ pub enum inferable<T> {
infer(node_id) infer(node_id)
} }
pub impl<T: to_bytes::IterBytes> inferable<T> : to_bytes::IterBytes { pub impl<T: to_bytes::IterBytes> to_bytes::IterBytes for inferable<T> {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self { match *self {
expl(ref t) => expl(ref t) =>
@ -395,7 +395,7 @@ pub impl<T: to_bytes::IterBytes> inferable<T> : to_bytes::IterBytes {
#[deriving_eq] #[deriving_eq]
pub enum rmode { by_ref, by_val, by_copy } pub enum rmode { by_ref, by_val, by_copy }
pub impl rmode : to_bytes::IterBytes { pub impl to_bytes::IterBytes for rmode {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
@ -736,13 +736,13 @@ pub enum trait_method {
#[deriving_eq] #[deriving_eq]
pub enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, } pub enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, }
pub impl int_ty : ToStr { pub impl ToStr for int_ty {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
::ast_util::int_ty_to_str(*self) ::ast_util::int_ty_to_str(*self)
} }
} }
pub impl int_ty : to_bytes::IterBytes { pub impl to_bytes::IterBytes for int_ty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
@ -753,13 +753,13 @@ pub impl int_ty : to_bytes::IterBytes {
#[deriving_eq] #[deriving_eq]
pub enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, } pub enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
pub impl uint_ty : ToStr { pub impl ToStr for uint_ty {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
::ast_util::uint_ty_to_str(*self) ::ast_util::uint_ty_to_str(*self)
} }
} }
pub impl uint_ty : to_bytes::IterBytes { pub impl to_bytes::IterBytes for uint_ty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
@ -770,13 +770,13 @@ pub impl uint_ty : to_bytes::IterBytes {
#[deriving_eq] #[deriving_eq]
pub enum float_ty { ty_f, ty_f32, ty_f64, } pub enum float_ty { ty_f, ty_f32, ty_f64, }
pub impl float_ty : ToStr { pub impl ToStr for float_ty {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
::ast_util::float_ty_to_str(*self) ::ast_util::float_ty_to_str(*self)
} }
} }
pub impl float_ty : to_bytes::IterBytes { pub impl to_bytes::IterBytes for float_ty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
@ -830,7 +830,7 @@ pub enum Onceness {
Many Many
} }
pub impl Onceness : ToStr { pub impl ToStr for Onceness {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
match *self { match *self {
Once => ~"once", Once => ~"once",
@ -839,7 +839,7 @@ pub impl Onceness : ToStr {
} }
} }
pub impl Onceness : to_bytes::IterBytes { pub impl to_bytes::IterBytes for Onceness {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f); (*self as uint).iter_bytes(lsb0, f);
} }
@ -889,7 +889,7 @@ pub enum ty_ {
ty_infer, ty_infer,
} }
pub impl Ty : to_bytes::IterBytes { pub impl to_bytes::IterBytes for Ty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f); to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f);
} }
@ -925,7 +925,7 @@ pub enum purity {
extern_fn, // declared with "extern fn" extern_fn, // declared with "extern fn"
} }
pub impl purity : ToStr { pub impl ToStr for purity {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
match *self { match *self {
impure_fn => ~"impure", impure_fn => ~"impure",
@ -936,7 +936,7 @@ pub impl purity : ToStr {
} }
} }
pub impl purity : to_bytes::IterBytes { pub impl to_bytes::IterBytes for purity {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
@ -951,7 +951,7 @@ pub enum ret_style {
return_val, // everything else return_val, // everything else
} }
pub impl ret_style : to_bytes::IterBytes { pub impl to_bytes::IterBytes for ret_style {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
@ -1232,7 +1232,7 @@ pub enum item_ {
#[deriving_eq] #[deriving_eq]
pub enum struct_mutability { struct_mutable, struct_immutable } pub enum struct_mutability { struct_mutable, struct_immutable }
pub impl struct_mutability : to_bytes::IterBytes { pub impl to_bytes::IterBytes for struct_mutability {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }

View file

@ -34,7 +34,7 @@ pub enum path_elt {
path_name(ident) path_name(ident)
} }
pub impl path_elt : cmp::Eq { pub impl cmp::Eq for path_elt {
pure fn eq(&self, other: &path_elt) -> bool { pure fn eq(&self, other: &path_elt) -> bool {
match (*self) { match (*self) {
path_mod(e0a) => { path_mod(e0a) => {

View file

@ -198,7 +198,7 @@ pub pure fn is_call_expr(e: @expr) -> bool {
} }
// This makes def_id hashable // This makes def_id hashable
pub impl def_id : to_bytes::IterBytes { pub impl to_bytes::IterBytes for def_id {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.crate, &self.node, lsb0, f); to_bytes::iter_bytes_2(&self.crate, &self.node, lsb0, f);
@ -303,7 +303,7 @@ pub trait inlined_item_utils {
fn accept<E>(&self, e: E, v: visit::vt<E>); fn accept<E>(&self, e: E, v: visit::vt<E>);
} }
pub impl inlined_item: inlined_item_utils { pub impl inlined_item_utils for inlined_item {
fn ident(&self) -> ident { fn ident(&self) -> ident {
match *self { match *self {
ii_item(i) => /* FIXME (#2543) */ copy i.ident, ii_item(i) => /* FIXME (#2543) */ copy i.ident,

View file

@ -46,71 +46,71 @@ pub enum CharPos = uint;
// XXX: Lots of boilerplate in these impls, but so far my attempts to fix // XXX: Lots of boilerplate in these impls, but so far my attempts to fix
// have been unsuccessful // have been unsuccessful
pub impl BytePos: Pos { pub impl Pos for BytePos {
static pure fn from_uint(n: uint) -> BytePos { BytePos(n) } static pure fn from_uint(n: uint) -> BytePos { BytePos(n) }
pure fn to_uint(&self) -> uint { **self } pure fn to_uint(&self) -> uint { **self }
} }
pub impl BytePos: cmp::Eq { pub impl cmp::Eq for BytePos {
pure fn eq(&self, other: &BytePos) -> bool { **self == **other } pure fn eq(&self, other: &BytePos) -> bool { **self == **other }
pure fn ne(&self, other: &BytePos) -> bool { !(*self).eq(other) } pure fn ne(&self, other: &BytePos) -> bool { !(*self).eq(other) }
} }
pub impl BytePos: cmp::Ord { pub impl cmp::Ord for BytePos {
pure fn lt(&self, other: &BytePos) -> bool { **self < **other } pure fn lt(&self, other: &BytePos) -> bool { **self < **other }
pure fn le(&self, other: &BytePos) -> bool { **self <= **other } pure fn le(&self, other: &BytePos) -> bool { **self <= **other }
pure fn ge(&self, other: &BytePos) -> bool { **self >= **other } pure fn ge(&self, other: &BytePos) -> bool { **self >= **other }
pure fn gt(&self, other: &BytePos) -> bool { **self > **other } pure fn gt(&self, other: &BytePos) -> bool { **self > **other }
} }
pub impl BytePos: Add<BytePos, BytePos> { pub impl Add<BytePos, BytePos> for BytePos {
pure fn add(&self, rhs: &BytePos) -> BytePos { pure fn add(&self, rhs: &BytePos) -> BytePos {
BytePos(**self + **rhs) BytePos(**self + **rhs)
} }
} }
pub impl BytePos: Sub<BytePos, BytePos> { pub impl Sub<BytePos, BytePos> for BytePos {
pure fn sub(&self, rhs: &BytePos) -> BytePos { pure fn sub(&self, rhs: &BytePos) -> BytePos {
BytePos(**self - **rhs) BytePos(**self - **rhs)
} }
} }
pub impl BytePos: to_bytes::IterBytes { pub impl to_bytes::IterBytes for BytePos {
pure fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) {
(**self).iter_bytes(lsb0, f) (**self).iter_bytes(lsb0, f)
} }
} }
pub impl CharPos: Pos { pub impl Pos for CharPos {
static pure fn from_uint(n: uint) -> CharPos { CharPos(n) } static pure fn from_uint(n: uint) -> CharPos { CharPos(n) }
pure fn to_uint(&self) -> uint { **self } pure fn to_uint(&self) -> uint { **self }
} }
pub impl CharPos: cmp::Eq { pub impl cmp::Eq for CharPos {
pure fn eq(&self, other: &CharPos) -> bool { **self == **other } pure fn eq(&self, other: &CharPos) -> bool { **self == **other }
pure fn ne(&self, other: &CharPos) -> bool { !(*self).eq(other) } pure fn ne(&self, other: &CharPos) -> bool { !(*self).eq(other) }
} }
pub impl CharPos: cmp::Ord { pub impl cmp::Ord for CharPos {
pure fn lt(&self, other: &CharPos) -> bool { **self < **other } pure fn lt(&self, other: &CharPos) -> bool { **self < **other }
pure fn le(&self, other: &CharPos) -> bool { **self <= **other } pure fn le(&self, other: &CharPos) -> bool { **self <= **other }
pure fn ge(&self, other: &CharPos) -> bool { **self >= **other } pure fn ge(&self, other: &CharPos) -> bool { **self >= **other }
pure fn gt(&self, other: &CharPos) -> bool { **self > **other } pure fn gt(&self, other: &CharPos) -> bool { **self > **other }
} }
pub impl CharPos: to_bytes::IterBytes { pub impl to_bytes::IterBytes for CharPos {
pure fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) {
(**self).iter_bytes(lsb0, f) (**self).iter_bytes(lsb0, f)
} }
} }
pub impl CharPos: Add<CharPos, CharPos> { pub impl Add<CharPos,CharPos> for CharPos {
pure fn add(&self, rhs: &CharPos) -> CharPos { pure fn add(&self, rhs: &CharPos) -> CharPos {
CharPos(**self + **rhs) CharPos(**self + **rhs)
} }
} }
pub impl CharPos: Sub<CharPos, CharPos> { pub impl Sub<CharPos,CharPos> for CharPos {
pure fn sub(&self, rhs: &CharPos) -> CharPos { pure fn sub(&self, rhs: &CharPos) -> CharPos {
CharPos(**self - **rhs) CharPos(**self - **rhs)
} }
@ -133,19 +133,19 @@ pub struct span {
#[deriving_eq] #[deriving_eq]
pub struct spanned<T> { node: T, span: span } pub struct spanned<T> { node: T, span: span }
pub impl span : cmp::Eq { pub impl cmp::Eq for span {
pure fn eq(&self, other: &span) -> bool { pure fn eq(&self, other: &span) -> bool {
return (*self).lo == (*other).lo && (*self).hi == (*other).hi; return (*self).lo == (*other).lo && (*self).hi == (*other).hi;
} }
pure fn ne(&self, other: &span) -> bool { !(*self).eq(other) } pure fn ne(&self, other: &span) -> bool { !(*self).eq(other) }
} }
pub impl<S: Encoder> span: Encodable<S> { pub impl<S: Encoder> Encodable<S> for span {
/* Note #1972 -- spans are encoded but not decoded */ /* Note #1972 -- spans are encoded but not decoded */
fn encode(&self, _s: &S) { } fn encode(&self, _s: &S) { }
} }
pub impl<D: Decoder> span: Decodable<D> { pub impl<D: Decoder> Decodable<D> for span {
static fn decode(_d: &D) -> span { static fn decode(_d: &D) -> span {
dummy_sp() dummy_sp()
} }

View file

@ -54,7 +54,7 @@ pub trait append_types {
fn add_tys(+tys: ~[@ast::Ty]) -> @ast::path; fn add_tys(+tys: ~[@ast::Ty]) -> @ast::path;
} }
pub impl @ast::path: append_types { pub impl append_types for @ast::path {
fn add_ty(ty: @ast::Ty) -> @ast::path { fn add_ty(ty: @ast::Ty) -> @ast::path {
@ast::path { types: vec::append_one(self.types, ty), @ast::path { types: vec::append_one(self.types, ty),
.. *self} .. *self}
@ -112,7 +112,7 @@ pub trait ext_ctxt_ast_builder {
fn strip_bounds(bounds: &[ast::ty_param]) -> ~[ast::ty_param]; fn strip_bounds(bounds: &[ast::ty_param]) -> ~[ast::ty_param];
} }
pub impl ext_ctxt: ext_ctxt_ast_builder { pub impl ext_ctxt_ast_builder for ext_ctxt {
fn ty_option(ty: @ast::Ty) -> @ast::Ty { fn ty_option(ty: @ast::Ty) -> @ast::Ty {
self.ty_path_ast_builder(path_global(~[ self.ty_path_ast_builder(path_global(~[
self.ident_of(~"core"), self.ident_of(~"core"),

View file

@ -37,7 +37,7 @@ use ext::base::ext_ctxt;
use ext::pipes::proto::{state, protocol, next_state}; use ext::pipes::proto::{state, protocol, next_state};
use ext::pipes::proto; use ext::pipes::proto;
pub impl ext_ctxt: proto::visitor<(), (), ()> { pub impl proto::visitor<(), (), ()> for ext_ctxt {
fn visit_proto(_proto: protocol, fn visit_proto(_proto: protocol,
_states: &[()]) { } _states: &[()]) { }

View file

@ -22,7 +22,7 @@ pub trait proto_parser {
fn parse_message(state: state); fn parse_message(state: state);
} }
pub impl parser::Parser: proto_parser { pub impl proto_parser for parser::Parser {
fn parse_proto(id: ~str) -> protocol { fn parse_proto(id: ~str) -> protocol {
let proto = protocol(id, self.span); let proto = protocol(id, self.span);

View file

@ -45,7 +45,7 @@ pub trait gen_init {
fn gen_init_bounded(ext_cx: ext_ctxt) -> @ast::expr; fn gen_init_bounded(ext_cx: ext_ctxt) -> @ast::expr;
} }
pub impl message: gen_send { pub impl gen_send for message {
fn gen_send(cx: ext_ctxt, try: bool) -> @ast::item { fn gen_send(cx: ext_ctxt, try: bool) -> @ast::item {
debug!("pipec: gen_send"); debug!("pipec: gen_send");
match self { match self {
@ -201,7 +201,7 @@ pub impl message: gen_send {
} }
} }
pub impl state: to_type_decls { pub impl to_type_decls for state {
fn to_type_decls(cx: ext_ctxt) -> ~[@ast::item] { fn to_type_decls(cx: ext_ctxt) -> ~[@ast::item] {
debug!("pipec: to_type_decls"); debug!("pipec: to_type_decls");
// This compiles into two different type declarations. Say the // This compiles into two different type declarations. Say the
@ -305,8 +305,7 @@ pub impl state: to_type_decls {
} }
} }
pub impl protocol: gen_init { pub impl gen_init for protocol {
fn gen_init(cx: ext_ctxt) -> @ast::item { fn gen_init(cx: ext_ctxt) -> @ast::item {
let ext_cx = cx; let ext_cx = cx;

View file

@ -21,7 +21,7 @@ use core::to_str::ToStr;
pub enum direction { send, recv } pub enum direction { send, recv }
pub impl direction : cmp::Eq { pub impl cmp::Eq for direction {
pure fn eq(&self, other: &direction) -> bool { pure fn eq(&self, other: &direction) -> bool {
match ((*self), (*other)) { match ((*self), (*other)) {
(send, send) => true, (send, send) => true,
@ -33,7 +33,7 @@ pub impl direction : cmp::Eq {
pure fn ne(&self, other: &direction) -> bool { !(*self).eq(other) } pure fn ne(&self, other: &direction) -> bool { !(*self).eq(other) }
} }
pub impl direction: ToStr { pub impl ToStr for direction {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
match *self { match *self {
send => ~"Send", send => ~"Send",
@ -156,7 +156,6 @@ pub struct protocol_ {
} }
pub impl protocol_ { pub impl protocol_ {
/// Get a state. /// Get a state.
fn get_state(name: ~str) -> state { fn get_state(name: ~str) -> state {
self.states.find(|i| i.name == name).get() self.states.find(|i| i.name == name).get()

View file

@ -692,7 +692,7 @@ pub fn default_ast_fold() -> ast_fold_fns {
new_span: noop_span}; new_span: noop_span};
} }
pub impl ast_fold_fns: ast_fold { pub impl ast_fold for ast_fold_fns {
/* naturally, a macro to write these would be nice */ /* naturally, a macro to write these would be nice */
fn fold_crate(c: crate) -> crate { fn fold_crate(c: crate) -> crate {
let (n, s) = (self.fold_crate)(c.node, c.span, self as ast_fold); let (n, s) = (self.fold_crate)(c.node, c.span, self as ast_fold);

View file

@ -127,7 +127,7 @@ impl reader for StringReader {
fn dup(@mut self) -> reader { dup_string_reader(self) as reader } fn dup(@mut self) -> reader { dup_string_reader(self) as reader }
} }
pub impl TtReader: reader { pub impl reader for TtReader {
fn is_eof(@mut self) -> bool { self.cur_tok == token::EOF } fn is_eof(@mut self) -> bool { self.cur_tok == token::EOF }
fn next_token(@mut self) -> TokenAndSpan { tt_next_token(self) } fn next_token(@mut self) -> TokenAndSpan { tt_next_token(self) }
fn fatal(@mut self, m: ~str) -> ! { fn fatal(@mut self, m: ~str) -> ! {

View file

@ -45,10 +45,11 @@ pub enum ObsoleteSyntax {
ObsoleteMoveInit, ObsoleteMoveInit,
ObsoleteBinaryMove, ObsoleteBinaryMove,
ObsoleteUnsafeBlock, ObsoleteUnsafeBlock,
ObsoleteUnenforcedBound ObsoleteUnenforcedBound,
ObsoleteImplSyntax
} }
pub impl ObsoleteSyntax: to_bytes::IterBytes { pub impl to_bytes::IterBytes for ObsoleteSyntax {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f); (*self as uint).iter_bytes(lsb0, f);
@ -115,6 +116,10 @@ pub impl Parser {
"unenforced type parameter bound", "unenforced type parameter bound",
"use trait bounds on the functions that take the type as \ "use trait bounds on the functions that take the type as \
arguments, not on the types themselves" arguments, not on the types themselves"
),
ObsoleteImplSyntax => (
"colon-separated impl syntax",
"write `impl Trait for Type`"
) )
}; };

View file

@ -74,7 +74,7 @@ use parse::obsolete::{ObsoleteLet, ObsoleteFieldTerminator};
use parse::obsolete::{ObsoleteMoveInit, ObsoleteBinaryMove}; use parse::obsolete::{ObsoleteMoveInit, ObsoleteBinaryMove};
use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith}; use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith};
use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds}; use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds};
use parse::obsolete::{ObsoleteUnsafeBlock}; use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax};
use parse::prec::{as_prec, token_to_binop}; use parse::prec::{as_prec, token_to_binop};
use parse::token::{can_begin_expr, is_ident, is_ident_or_path}; use parse::token::{can_begin_expr, is_ident, is_ident_or_path};
use parse::token::{is_plain_ident, INTERPOLATED, special_idents}; use parse::token::{is_plain_ident, INTERPOLATED, special_idents};
@ -2829,16 +2829,11 @@ pub impl Parser {
// XXX: clownshoes // XXX: clownshoes
let ident = special_idents::clownshoes_extensions; let ident = special_idents::clownshoes_extensions;
// Parse the type. (If this is `impl trait for type`, however, this // Parse the trait.
// actually parses the trait.)
let mut ty = self.parse_ty(false); let mut ty = self.parse_ty(false);
// Parse traits, if necessary. // Parse traits, if necessary.
let opt_trait = if self.token == token::COLON { let opt_trait = if self.eat_keyword(~"for") {
// Old-style trait.
self.bump();
Some(self.parse_trait_ref())
} else if self.eat_keyword(~"for") {
// New-style trait. Reinterpret the type as a trait. // New-style trait. Reinterpret the type as a trait.
let opt_trait_ref = match ty.node { let opt_trait_ref = match ty.node {
ty_path(path, node_id) => { ty_path(path, node_id) => {
@ -2855,6 +2850,9 @@ pub impl Parser {
ty = self.parse_ty(false); ty = self.parse_ty(false);
opt_trait_ref opt_trait_ref
} else if self.eat(token::COLON) {
self.obsolete(copy self.span, ObsoleteImplSyntax);
Some(self.parse_trait_ref())
} else { } else {
None None
}; };

View file

@ -42,7 +42,7 @@ pub trait Interner<T:Eq IterBytes Hash Const Copy> {
fn len() -> uint; fn len() -> uint;
} }
pub impl <T:Eq IterBytes Hash Const Copy> hash_interner<T>: Interner<T> { pub impl<T:Eq IterBytes Hash Const Copy> Interner<T> for hash_interner<T> {
fn intern(val: T) -> uint { fn intern(val: T) -> uint {
match self.map.find(&val) { match self.map.find(&val) {
Some(idx) => return idx, Some(idx) => return idx,

View file

@ -17,7 +17,7 @@ pub mod kitty {
name : ~str, name : ~str,
} }
pub impl cat : ToStr { pub impl ToStr for cat {
pure fn to_str(&self) -> ~str { copy self.name } pure fn to_str(&self) -> ~str { copy self.name }
} }

View file

@ -19,7 +19,7 @@ pub mod name_pool {
fn add(s: ~str); fn add(s: ~str);
} }
pub impl name_pool: add { pub impl add for name_pool {
fn add(s: ~str) { fn add(s: ~str) {
} }
} }
@ -34,7 +34,7 @@ pub mod rust {
fn cx(); fn cx();
} }
pub impl rt: cx { pub impl cx for rt {
fn cx() { fn cx() {
} }
} }

View file

@ -16,7 +16,7 @@ pub mod socket {
sockfd: libc::c_int, sockfd: libc::c_int,
} }
pub impl socket_handle : Drop { pub impl Drop for socket_handle {
fn finalize(&self) { fn finalize(&self) {
/* c::close(self.sockfd); */ /* c::close(self.sockfd); */
} }

View file

@ -15,7 +15,7 @@ pub struct rsrc {
x: i32, x: i32,
} }
pub impl rsrc : Drop { pub impl Drop for rsrc {
fn finalize(&self) { fn finalize(&self) {
foo(self.x); foo(self.x);
} }

View file

@ -17,25 +17,25 @@ pub struct MyInt {
val: int val: int
} }
pub impl MyInt : Add<MyInt, MyInt> { pub impl Add<MyInt, MyInt> for MyInt {
pure fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) } pure fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) }
} }
pub impl MyInt : Sub<MyInt, MyInt> { pub impl Sub<MyInt, MyInt> for MyInt {
pure fn sub(&self, other: &MyInt) -> MyInt { mi(self.val - other.val) } pure fn sub(&self, other: &MyInt) -> MyInt { mi(self.val - other.val) }
} }
pub impl MyInt : Mul<MyInt, MyInt> { pub impl Mul<MyInt, MyInt> for MyInt {
pure fn mul(&self, other: &MyInt) -> MyInt { mi(self.val * other.val) } pure fn mul(&self, other: &MyInt) -> MyInt { mi(self.val * other.val) }
} }
pub impl MyInt : Eq { pub impl Eq for MyInt {
pure fn eq(&self, other: &MyInt) -> bool { self.val == other.val } pure fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
pure fn ne(&self, other: &MyInt) -> bool { !self.eq(other) } pure fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
} }
pub impl MyInt : MyNum; pub impl MyNum for MyInt;
pure fn mi(v: int) -> MyInt { MyInt { val: v } } pure fn mi(v: int) -> MyInt { MyInt { val: v } }

View file

@ -19,7 +19,7 @@ trait Hahaha: Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq //~ ERROR Duplicat
enum Lol = int; enum Lol = int;
pub impl Lol: Hahaha { } pub impl Hahaha for Lol { }
impl Eq for Lol { impl Eq for Lol {
pure fn eq(&self, other: &Lol) -> bool { **self != **other } pure fn eq(&self, other: &Lol) -> bool { **self != **other }

View file

@ -16,7 +16,7 @@ trait BikeMethods {
fn woops(&const self) -> ~str; fn woops(&const self) -> ~str;
} }
pub impl Bike : BikeMethods { pub impl BikeMethods for Bike {
static fn woops(&const self) -> ~str { ~"foo" } static fn woops(&const self) -> ~str { ~"foo" }
//~^ ERROR method `woops` is declared as static in its impl, but not in its trait //~^ ERROR method `woops` is declared as static in its impl, but not in its trait
} }

View file

@ -20,7 +20,7 @@ impl MyEq for int {
pure fn eq(&self, other: &int) -> bool { *self == *other } pure fn eq(&self, other: &int) -> bool { *self == *other }
} }
impl A : MyEq; //~ ERROR missing method impl MyEq for A; //~ ERROR missing method
fn main() { fn main() {
} }

View file

@ -20,6 +20,7 @@ pub mod pipes {
mut payload: Option<T> mut payload: Option<T>
} }
#[deriving_eq]
pub enum state { pub enum state {
empty, empty,
full, full,
@ -27,13 +28,6 @@ pub mod pipes {
terminated terminated
} }
pub impl state : cmp::Eq {
pure fn eq(&self, other: &state) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &state) -> bool { !(*self).eq(other) }
}
pub type packet<T> = { pub type packet<T> = {
mut state: state, mut state: state,
mut blocked_task: Option<task::Task>, mut blocked_task: Option<task::Task>,
@ -161,7 +155,7 @@ pub mod pipes {
mut p: Option<*packet<T>>, mut p: Option<*packet<T>>,
} }
pub impl<T: Owned> send_packet<T> : Drop { pub impl<T: Owned> Drop for send_packet<T> {
fn finalize(&self) { fn finalize(&self) {
if self.p != None { if self.p != None {
let mut p = None; let mut p = None;
@ -189,7 +183,7 @@ pub mod pipes {
mut p: Option<*packet<T>>, mut p: Option<*packet<T>>,
} }
pub impl<T: Owned> recv_packet<T> : Drop { pub impl<T: Owned> Drop for recv_packet<T> {
fn finalize(&self) { fn finalize(&self) {
if self.p != None { if self.p != None {
let mut p = None; let mut p = None;

View file

@ -23,8 +23,7 @@ extern mod std;
use io::WriterUtil; use io::WriterUtil;
// Represents a position on a canvas. // Represents a position on a canvas.
struct Point struct Point {
{
x: int, x: int,
y: int, y: int,
} }
@ -108,8 +107,7 @@ impl AsciiArt
// Allows AsciiArt to be converted to a string using the libcore ToStr trait. // Allows AsciiArt to be converted to a string using the libcore ToStr trait.
// Note that the %s fmt! specifier will not call this automatically. // Note that the %s fmt! specifier will not call this automatically.
impl AsciiArt : ToStr impl ToStr for AsciiArt {
{
pure fn to_str(&self) -> ~str pure fn to_str(&self) -> ~str
{ {
// Convert each line into a string. // Convert each line into a string.
@ -139,8 +137,7 @@ trait Canvas
// Here we provide an implementation of the Canvas methods for AsciiArt. // Here we provide an implementation of the Canvas methods for AsciiArt.
// Other implementations could also be provided (e.g. for PDF or Apple's Quartz) // Other implementations could also be provided (e.g. for PDF or Apple's Quartz)
// and code can use them polymorphically via the Canvas trait. // and code can use them polymorphically via the Canvas trait.
impl AsciiArt : Canvas impl Canvas for AsciiArt {
{
fn add_point(&mut self, shape: Point) fn add_point(&mut self, shape: Point)
{ {
self.add_pt(shape.x, shape.y); self.add_pt(shape.x, shape.y);

View file

@ -31,7 +31,7 @@ impl Positioned for Point {
} }
} }
impl Point: Movable; impl Movable for Point;
pub fn main() { pub fn main() {
let p = Point{ x: 1, y: 2}; let p = Point{ x: 1, y: 2};

View file

@ -81,7 +81,7 @@ pub struct Buffer {
} }
pub impl Buffer : Drop { pub impl Drop for Buffer {
fn finalize(&self) {} fn finalize(&self) {}
} }

View file

@ -17,12 +17,12 @@ pub trait plus {
mod a { mod a {
use plus; use plus;
pub impl uint: plus { fn plus() -> int { self as int + 20 } } pub impl plus for uint { fn plus() -> int { self as int + 20 } }
} }
mod b { mod b {
use plus; use plus;
pub impl ~str: plus { fn plus() -> int { 200 } } pub impl plus for ~str { fn plus() -> int { 200 } }
} }
trait uint_utils { trait uint_utils {

View file

@ -2,7 +2,7 @@ pub trait Number: NumConv {
static pure fn from<T:Number>(n: T) -> Self; static pure fn from<T:Number>(n: T) -> Self;
} }
pub impl float: Number { pub impl Number for float {
static pure fn from<T:Number>(n: T) -> float { n.to_float() } static pure fn from<T:Number>(n: T) -> float { n.to_float() }
} }
@ -10,7 +10,7 @@ pub trait NumConv {
pure fn to_float(&self) -> float; pure fn to_float(&self) -> float;
} }
pub impl float: NumConv { pub impl NumConv for float {
pure fn to_float(&self) -> float { *self } pure fn to_float(&self) -> float { *self }
} }

View file

@ -21,84 +21,84 @@ use std::cmp::FuzzyEq;
pub trait TypeExt {} pub trait TypeExt {}
pub impl u8: TypeExt {} pub impl TypeExt for u8 {}
pub impl u16: TypeExt {} pub impl TypeExt for u16 {}
pub impl u32: TypeExt {} pub impl TypeExt for u32 {}
pub impl u64: TypeExt {} pub impl TypeExt for u64 {}
pub impl uint: TypeExt {} pub impl TypeExt for uint {}
pub impl i8: TypeExt {} pub impl TypeExt for i8 {}
pub impl i16: TypeExt {} pub impl TypeExt for i16 {}
pub impl i32: TypeExt {} pub impl TypeExt for i32 {}
pub impl i64: TypeExt {} pub impl TypeExt for i64 {}
pub impl int: TypeExt {} pub impl TypeExt for int {}
pub impl f32: TypeExt {} pub impl TypeExt for f32 {}
pub impl f64: TypeExt {} pub impl TypeExt for f64 {}
pub impl float: TypeExt {} pub impl TypeExt for float {}
pub trait NumExt: TypeExt Eq Ord NumCast {} pub trait NumExt: TypeExt Eq Ord NumCast {}
pub impl u8: NumExt {} pub impl NumExt for u8 {}
pub impl u16: NumExt {} pub impl NumExt for u16 {}
pub impl u32: NumExt {} pub impl NumExt for u32 {}
pub impl u64: NumExt {} pub impl NumExt for u64 {}
pub impl uint: NumExt {} pub impl NumExt for uint {}
pub impl i8: NumExt {} pub impl NumExt for i8 {}
pub impl i16: NumExt {} pub impl NumExt for i16 {}
pub impl i32: NumExt {} pub impl NumExt for i32 {}
pub impl i64: NumExt {} pub impl NumExt for i64 {}
pub impl int: NumExt {} pub impl NumExt for int {}
pub impl f32: NumExt {} pub impl NumExt for f32 {}
pub impl f64: NumExt {} pub impl NumExt for f64 {}
pub impl float: NumExt {} pub impl NumExt for float {}
pub trait UnSignedExt: NumExt {} pub trait UnSignedExt: NumExt {}
pub impl u8: UnSignedExt {} pub impl UnSignedExt for u8 {}
pub impl u16: UnSignedExt {} pub impl UnSignedExt for u16 {}
pub impl u32: UnSignedExt {} pub impl UnSignedExt for u32 {}
pub impl u64: UnSignedExt {} pub impl UnSignedExt for u64 {}
pub impl uint: UnSignedExt {} pub impl UnSignedExt for uint {}
pub trait SignedExt: NumExt {} pub trait SignedExt: NumExt {}
pub impl i8: SignedExt {} pub impl SignedExt for i8 {}
pub impl i16: SignedExt {} pub impl SignedExt for i16 {}
pub impl i32: SignedExt {} pub impl SignedExt for i32 {}
pub impl i64: SignedExt {} pub impl SignedExt for i64 {}
pub impl int: SignedExt {} pub impl SignedExt for int {}
pub impl f32: SignedExt {} pub impl SignedExt for f32 {}
pub impl f64: SignedExt {} pub impl SignedExt for f64 {}
pub impl float: SignedExt {} pub impl SignedExt for float {}
pub trait IntegerExt: NumExt {} pub trait IntegerExt: NumExt {}
pub impl u8: IntegerExt {} pub impl IntegerExt for u8 {}
pub impl u16: IntegerExt {} pub impl IntegerExt for u16 {}
pub impl u32: IntegerExt {} pub impl IntegerExt for u32 {}
pub impl u64: IntegerExt {} pub impl IntegerExt for u64 {}
pub impl uint: IntegerExt {} pub impl IntegerExt for uint {}
pub impl i8: IntegerExt {} pub impl IntegerExt for i8 {}
pub impl i16: IntegerExt {} pub impl IntegerExt for i16 {}
pub impl i32: IntegerExt {} pub impl IntegerExt for i32 {}
pub impl i64: IntegerExt {} pub impl IntegerExt for i64 {}
pub impl int: IntegerExt {} pub impl IntegerExt for int {}
pub trait FloatExt: NumExt FuzzyEq<Self> {} pub trait FloatExt: NumExt FuzzyEq<Self> {}
pub impl f32: FloatExt {} pub impl FloatExt for f32 {}
pub impl f64: FloatExt {} pub impl FloatExt for f64 {}
pub impl float: FloatExt {} pub impl FloatExt for float {}
fn test_float_ext<T:FloatExt>(n: T) { io::println(fmt!("%?", n < n)) } fn test_float_ext<T:FloatExt>(n: T) { io::println(fmt!("%?", n < n)) }

View file

@ -13,7 +13,7 @@ use num::NumCast::from;
pub trait NumExt: Eq Ord NumCast {} pub trait NumExt: Eq Ord NumCast {}
pub impl f32: NumExt {} pub impl NumExt for f32 {}
fn num_eq_one<T:NumExt>(n: T) { io::println(fmt!("%?", n == from(1))) } fn num_eq_one<T:NumExt>(n: T) { io::println(fmt!("%?", n == from(1))) }

View file

@ -13,8 +13,8 @@ use num::NumCast::from;
pub trait NumExt: Eq NumCast {} pub trait NumExt: Eq NumCast {}
pub impl f32: NumExt {} pub impl NumExt for f32 {}
pub impl int: NumExt {} pub impl NumExt for int {}
fn num_eq_one<T:NumExt>() -> T { fn num_eq_one<T:NumExt>() -> T {
from(1) from(1)

View file

@ -19,7 +19,7 @@ impl Eq for MyInt {
pure fn ne(&self, other: &MyInt) -> bool { !self.eq(other) } pure fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
} }
impl MyInt : MyNum; impl MyNum for MyInt;
fn f<T:MyNum>(x: T, y: T) -> bool { fn f<T:MyNum>(x: T, y: T) -> bool {
return x == y; return x == y;

View file

@ -31,7 +31,7 @@ impl Eq for MyInt {
pure fn ne(&self, other: &MyInt) -> bool { !self.eq(other) } pure fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
} }
impl MyInt : MyNum; impl MyNum for MyInt;
fn f<T:Copy MyNum>(x: T, y: T) -> (T, T, T) { fn f<T:Copy MyNum>(x: T, y: T) -> (T, T, T) {
return (x + y, x - y, x * y); return (x + y, x - y, x * y);

View file

@ -20,7 +20,7 @@ impl Add<MyInt, MyInt> for MyInt {
pure fn add(other: &MyInt) -> MyInt { mi(self.val + other.val) } pure fn add(other: &MyInt) -> MyInt { mi(self.val + other.val) }
} }
impl MyInt : MyNum; impl MyNum for MyInt;
fn f<T:MyNum>(x: T, y: T) -> T { fn f<T:MyNum>(x: T, y: T) -> T {
return x.add(&y); return x.add(&y);

View file

@ -30,7 +30,7 @@ impl Add<MyInt, MyInt> for MyInt {
fn add(other: &MyInt) -> MyInt { self.chomp(other) } fn add(other: &MyInt) -> MyInt { self.chomp(other) }
} }
impl MyInt : MyNum; impl MyNum for MyInt;
fn f<T:MyNum>(x: T, y: T) -> T { fn f<T:MyNum>(x: T, y: T) -> T {
return x.add(&y).chomp(&y); return x.add(&y).chomp(&y);

View file

@ -19,7 +19,7 @@ struct A { x: int }
impl Foo for A { fn f() -> int { 10 } } impl Foo for A { fn f() -> int { 10 } }
impl Bar for A { fn g() -> int { 20 } } impl Bar for A { fn g() -> int { 20 } }
impl Baz for A { fn h() -> int { 30 } } impl Baz for A { fn h() -> int { 30 } }
impl A : Quux; impl Quux for A;
fn f<T: Quux Foo Bar Baz>(a: &T) { fn f<T: Quux Foo Bar Baz>(a: &T) {
assert a.f() == 10; assert a.f() == 10;

View file

@ -19,7 +19,7 @@ mod base {
dummy: (), dummy: (),
} }
pub impl Foo : ::base::HasNew<Foo> { pub impl ::base::HasNew<Foo> for Foo {
static pure fn new() -> Foo { static pure fn new() -> Foo {
unsafe { io::println("Foo"); } unsafe { io::println("Foo"); }
Foo { dummy: () } Foo { dummy: () }
@ -30,7 +30,7 @@ mod base {
dummy: (), dummy: (),
} }
pub impl Bar : ::base::HasNew<Bar> { pub impl ::base::HasNew<Bar> for Bar {
static pure fn new() -> Bar { static pure fn new() -> Bar {
unsafe { io::println("Bar"); } unsafe { io::println("Bar"); }
Bar { dummy: () } Bar { dummy: () }