1
Fork 0

librustc: Forbid pub or priv before trait implementations

This commit is contained in:
Patrick Walton 2013-02-26 17:12:00 -08:00
parent 573a31dfa7
commit 07c3f5c0de
67 changed files with 304 additions and 288 deletions

View file

@ -168,7 +168,7 @@ pub mod traits {
use kinds::Copy; use kinds::Copy;
use ops::Add; use ops::Add;
pub impl<T:Copy> Add<&[const T],@[T]> for @[T] { 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

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

View file

@ -299,7 +299,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 NumCast for f64 { impl NumCast for f64 {
/** /**
* Cast `n` to an `f64` * Cast `n` to an `f64`
*/ */

View file

@ -420,7 +420,7 @@ impl num::One for float {
static pure fn one() -> float { 1.0 } static pure fn one() -> float { 1.0 }
} }
pub impl NumCast for float { 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 NumCast for i16 { 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 NumCast for i32 { 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 NumCast for i64 { 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 NumCast for i8 { impl NumCast for i8 {
/** /**
* Cast `n` to a `i8` * Cast `n` to a `i8`
*/ */

View file

@ -58,7 +58,7 @@ mod inst {
} }
} }
pub impl NumCast for int { 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 NumCast for u16 { 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 NumCast for u32 { 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 NumCast for u64 { 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 NumCast for u8 { 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 iter::Times for uint { 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 NumCast for uint { impl NumCast for uint {
/** /**
* Cast `n` to a `uint` * Cast `n` to a `uint`
*/ */

View file

@ -56,7 +56,7 @@ pub enum Option<T> {
Some(T), Some(T),
} }
pub impl<T:Ord> Ord for Option<T> { impl<T:Ord> Ord for Option<T> {
pure fn lt(&self, other: &Option<T>) -> bool { pure fn lt(&self, other: &Option<T>) -> bool {
match (self, other) { match (self, other) {
(&None, &None) => false, (&None, &None) => false,

View file

@ -2362,7 +2362,7 @@ pub trait OwnedStr {
fn push_char(&mut self, c: char); fn push_char(&mut self, c: char);
} }
pub impl OwnedStr for ~str { 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 IterBytes for uint { 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 IterBytes for uint { 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

@ -451,7 +451,7 @@ impl LoanKind {
/// Creates and returns a new root_map /// Creates and returns a new root_map
pub impl to_bytes::IterBytes for root_map_key { 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(&self) -> span; fn span(&self) -> span;
} }
pub impl ast_node for @ast::expr { impl ast_node for @ast::expr {
fn id(&self) -> ast::node_id { self.id } fn id(&self) -> ast::node_id { self.id }
fn span(&self) -> span { self.span } fn span(&self) -> span { self.span }
} }
pub impl ast_node for @ast::pat { impl ast_node for @ast::pat {
fn id(&self) -> ast::node_id { self.id } fn id(&self) -> ast::node_id { self.id }
fn span(&self) -> span { self.span } fn span(&self) -> span { self.span }
} }
@ -295,7 +295,7 @@ pub trait get_type_for_node {
fn ty<N:ast_node>(&self, node: N) -> ty::t; fn ty<N:ast_node>(&self, node: N) -> ty::t;
} }
pub impl get_type_for_node for ty::ctxt { impl get_type_for_node for ty::ctxt {
fn ty<N:ast_node>(&self, node: N) -> ty::t { fn ty<N:ast_node>(&self, node: N) -> ty::t {
ty::node_id_to_type(*self, node.id()) ty::node_id_to_type(*self, node.id())
} }

View file

@ -107,7 +107,7 @@ pub trait get_insn_ctxt {
fn insn_ctxt(&self, s: &str) -> icx_popper; fn insn_ctxt(&self, s: &str) -> icx_popper;
} }
pub impl get_insn_ctxt for @CrateContext { impl get_insn_ctxt for @CrateContext {
fn insn_ctxt(&self, s: &str) -> icx_popper { fn insn_ctxt(&self, 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() {
@ -117,13 +117,13 @@ pub impl get_insn_ctxt for @CrateContext {
} }
} }
pub impl get_insn_ctxt for block { impl get_insn_ctxt for block {
fn insn_ctxt(&self, s: &str) -> icx_popper { fn insn_ctxt(&self, s: &str) -> icx_popper {
self.ccx().insn_ctxt(s) self.ccx().insn_ctxt(s)
} }
} }
pub impl get_insn_ctxt for fn_ctxt { impl get_insn_ctxt for fn_ctxt {
fn insn_ctxt(&self, s: &str) -> icx_popper { fn insn_ctxt(&self, s: &str) -> icx_popper {
self.ccx.insn_ctxt(s) self.ccx.insn_ctxt(s)
} }

View file

@ -538,13 +538,13 @@ pub trait get_node_info {
fn info(&self) -> Option<NodeInfo>; fn info(&self) -> Option<NodeInfo>;
} }
pub impl get_node_info for @ast::expr { impl get_node_info for @ast::expr {
fn info(&self) -> Option<NodeInfo> { fn info(&self) -> Option<NodeInfo> {
Some(NodeInfo { id: self.id, span: self.span }) Some(NodeInfo { id: self.id, span: self.span })
} }
} }
pub impl get_node_info for ast::blk { impl get_node_info for ast::blk {
fn info(&self) -> Option<NodeInfo> { fn info(&self) -> Option<NodeInfo> {
Some(NodeInfo { id: self.node.id, span: self.span }) Some(NodeInfo { id: self.node.id, span: self.span })
} }
@ -553,7 +553,7 @@ pub impl get_node_info for ast::blk {
// 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 get_node_info for optional_boxed_ast_expr { impl get_node_info for optional_boxed_ast_expr {
fn info(&self) -> Option<NodeInfo> { fn info(&self) -> Option<NodeInfo> {
self.chain_ref(|s| s.info()) self.chain_ref(|s| s.info())
} }
@ -1275,7 +1275,7 @@ pub struct mono_id_ {
pub type mono_id = @mono_id_; pub type mono_id = @mono_id_;
pub impl to_bytes::IterBytes for mono_param_id { 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) =>
@ -1289,7 +1289,7 @@ pub impl to_bytes::IterBytes for mono_param_id {
} }
} }
pub impl to_bytes::IterBytes for mono_id_ { 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

@ -151,14 +151,14 @@ pub impl DatumMode {
} }
} }
pub impl cmp::Eq for DatumMode { 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 to_bytes::IterBytes for DatumMode { 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)
} }

View file

@ -660,46 +660,46 @@ pub trait Vid {
pure fn to_uint(&self) -> uint; pure fn to_uint(&self) -> uint;
} }
pub impl Vid for TyVid { impl Vid for TyVid {
pure fn to_uint(&self) -> uint { **self } pure fn to_uint(&self) -> uint { **self }
} }
pub impl ToStr for TyVid { 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 Vid for IntVid { impl Vid for IntVid {
pure fn to_uint(&self) -> uint { **self } pure fn to_uint(&self) -> uint { **self }
} }
pub impl ToStr for IntVid { 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 Vid for FloatVid { impl Vid for FloatVid {
pure fn to_uint(&self) -> uint { **self } pure fn to_uint(&self) -> uint { **self }
} }
pub impl ToStr for FloatVid { 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 Vid for RegionVid { impl Vid for RegionVid {
pure fn to_uint(&self) -> uint { **self } pure fn to_uint(&self) -> uint { **self }
} }
pub impl ToStr for RegionVid { impl ToStr for RegionVid {
pure fn to_str(&self) -> ~str { fmt!("%?", self) } pure fn to_str(&self) -> ~str { fmt!("%?", self) }
} }
pub impl ToStr for FnSig { 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 ToStr for InferTy { 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(),
@ -709,7 +709,7 @@ pub impl ToStr for InferTy {
} }
} }
pub impl ToStr for IntVarValue { 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(),
@ -718,25 +718,25 @@ pub impl ToStr for IntVarValue {
} }
} }
pub impl to_bytes::IterBytes for TyVid { 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 to_bytes::IterBytes for IntVid { 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 to_bytes::IterBytes for FloatVid { 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 to_bytes::IterBytes for RegionVid { 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

@ -625,7 +625,7 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) {
} }
} }
pub impl AstConv for FnCtxt { 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 }
@ -659,7 +659,7 @@ pub impl FnCtxt {
} }
} }
pub impl region_scope for @mut FnCtxt { impl region_scope for @mut FnCtxt {
pure fn anon_region(&self, span: span) -> Result<ty::Region, ~str> { pure fn anon_region(&self, 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 AstConv for CrateCtxt { 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 Combine for Glb { impl Combine for Glb {
fn infcx(&self) -> @mut InferCtxt { self.infcx } fn infcx(&self) -> @mut InferCtxt { self.infcx }
fn tag(&self) -> ~str { ~"glb" } fn tag(&self) -> ~str { ~"glb" }
fn a_is_expected(&self) -> bool { self.a_is_expected } fn a_is_expected(&self) -> bool { self.a_is_expected }

View file

@ -59,7 +59,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 LatticeValue for ty::t { impl LatticeValue for ty::t {
static fn sub(&self, cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures { static fn sub(&self, cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures {
Sub(*cf).tys(*a, *b).to_ures() Sub(*cf).tys(*a, *b).to_ures()
} }
@ -305,7 +305,7 @@ pub trait TyLatticeDir {
fn ty_bot(&self, t: ty::t) -> cres<ty::t>; fn ty_bot(&self, t: ty::t) -> cres<ty::t>;
} }
pub impl LatticeDir for Lub { impl LatticeDir for Lub {
fn combine_fields(&self) -> CombineFields { **self } fn combine_fields(&self) -> CombineFields { **self }
fn bnd<T:Copy>(&self, b: &Bounds<T>) -> Option<T> { b.ub } fn bnd<T:Copy>(&self, b: &Bounds<T>) -> Option<T> { b.ub }
fn with_bnd<T:Copy>(&self, b: &Bounds<T>, +t: T) -> Bounds<T> { fn with_bnd<T:Copy>(&self, b: &Bounds<T>, +t: T) -> Bounds<T> {
@ -313,13 +313,13 @@ pub impl LatticeDir for Lub {
} }
} }
pub impl TyLatticeDir for Lub { impl TyLatticeDir for Lub {
fn ty_bot(&self, t: ty::t) -> cres<ty::t> { fn ty_bot(&self, t: ty::t) -> cres<ty::t> {
Ok(t) Ok(t)
} }
} }
pub impl LatticeDir for Glb { impl LatticeDir for Glb {
fn combine_fields(&self) -> CombineFields { **self } fn combine_fields(&self) -> CombineFields { **self }
fn bnd<T:Copy>(&self, b: &Bounds<T>) -> Option<T> { b.lb } fn bnd<T:Copy>(&self, b: &Bounds<T>) -> Option<T> { b.lb }
fn with_bnd<T:Copy>(&self, b: &Bounds<T>, +t: T) -> Bounds<T> { fn with_bnd<T:Copy>(&self, b: &Bounds<T>, +t: T) -> Bounds<T> {
@ -327,7 +327,7 @@ pub impl LatticeDir for Glb {
} }
} }
pub impl TyLatticeDir for Glb { impl TyLatticeDir for Glb {
fn ty_bot(&self, _t: ty::t) -> cres<ty::t> { fn ty_bot(&self, _t: ty::t) -> cres<ty::t> {
Ok(ty::mk_bot(self.infcx.tcx)) Ok(ty::mk_bot(self.infcx.tcx))
} }

View file

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

View file

@ -28,7 +28,7 @@ use syntax::ast::{m_const, purity, ret_style};
pub enum Sub = CombineFields; // "subtype", "subregion" etc pub enum Sub = CombineFields; // "subtype", "subregion" etc
pub impl Combine for Sub { impl Combine for Sub {
fn infcx(&self) -> @mut InferCtxt { self.infcx } fn infcx(&self) -> @mut InferCtxt { self.infcx }
fn tag(&self) -> ~str { ~"sub" } fn tag(&self) -> ~str { ~"sub" }
fn a_is_expected(&self) -> bool { self.a_is_expected } fn a_is_expected(&self) -> 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 InferStr for ty::t { 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 InferStr for FnSig { 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 InferStr for FnSig {
} }
} }
pub impl InferStr for ty::mt { 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 InferStr for ty::Region { 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> InferStr for Bound<V> { 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> InferStr for Bound<V> {
} }
} }
pub impl<T:InferStr> InferStr for Bounds<T> { 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> InferStr for Bounds<T> {
} }
} }
pub impl<V:Vid + ToStr,T:InferStr> InferStr for VarValue<V, T> { 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> InferStr for VarValue<V, T> {
} }
} }
pub impl InferStr for IntVarValue { 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 InferStr for ast::float_ty { 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 UnifyVid<Bounds<ty::t>> for ty::TyVid { impl UnifyVid<Bounds<ty::t>> for ty::TyVid {
static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt) static fn appropriate_vals_and_bindings(&self, 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 UnifyVid<Option<IntVarValue>> for ty::IntVid { impl UnifyVid<Option<IntVarValue>> for ty::IntVid {
static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt) static fn appropriate_vals_and_bindings(&self, 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 SimplyUnifiable for IntVarValue { impl SimplyUnifiable for IntVarValue {
static fn to_type_err(&self, err: expected_found<IntVarValue>) static fn to_type_err(&self, err: expected_found<IntVarValue>)
-> ty::type_err { -> ty::type_err {
return ty::terr_int_mismatch(err); return ty::terr_int_mismatch(err);
} }
} }
pub impl UnifyVid<Option<ast::float_ty>> for ty::FloatVid { impl UnifyVid<Option<ast::float_ty>> for ty::FloatVid {
static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt) static fn appropriate_vals_and_bindings(&self, 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 SimplyUnifiable for ast::float_ty { impl SimplyUnifiable for ast::float_ty {
static fn to_type_err(&self, err: expected_found<ast::float_ty>) static fn to_type_err(&self, 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,8 @@ pub trait region_scope {
} }
pub enum empty_rscope { empty_rscope } pub enum empty_rscope { empty_rscope }
pub impl region_scope for empty_rscope {
impl region_scope for empty_rscope {
pure fn anon_region(&self, _span: span) -> Result<ty::Region, ~str> { pure fn anon_region(&self, _span: span) -> Result<ty::Region, ~str> {
result::Ok(ty::re_static) result::Ok(ty::re_static)
} }
@ -40,7 +41,8 @@ pub impl region_scope for empty_rscope {
} }
pub enum type_rscope = Option<ty::region_variance>; pub enum type_rscope = Option<ty::region_variance>;
pub impl region_scope for type_rscope {
impl region_scope for type_rscope {
pure fn anon_region(&self, _span: span) -> Result<ty::Region, ~str> { pure fn anon_region(&self, _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)),
@ -74,7 +76,8 @@ pub fn in_anon_rscope<RS:region_scope + Copy + Durable>(self: RS,
-> @anon_rscope { -> @anon_rscope {
@anon_rscope {anon: r, base: self as region_scope} @anon_rscope {anon: r, base: self as region_scope}
} }
pub impl region_scope for @anon_rscope {
impl region_scope for @anon_rscope {
pure fn anon_region(&self, _span: span) -> Result<ty::Region, ~str> { pure fn anon_region(&self, _span: span) -> Result<ty::Region, ~str> {
result::Ok(self.anon) result::Ok(self.anon)
} }
@ -97,7 +100,8 @@ 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 region_scope for @mut binding_rscope {
impl region_scope for @mut binding_rscope {
pure fn anon_region(&self, _span: span) -> Result<ty::Region, ~str> { pure fn anon_region(&self, _span: span) -> Result<ty::Region, ~str> {
// XXX: Unsafe to work around purity // XXX: Unsafe to work around purity
unsafe { unsafe {

View file

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

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> GenericPort<T> for FlatPort<T, U, P> { 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> Unflattener<T> for PodUnflattener<T> { 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> Flattener<T> for PodFlattener<T> { 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,14 +406,14 @@ pub mod flatteners {
serialize_value: SerializeValue<T> serialize_value: SerializeValue<T>
} }
pub impl<D:Decoder,T:Decodable<D>> Unflattener<T> impl<D:Decoder,T:Decodable<D>> Unflattener<T>
for DeserializingUnflattener<D, 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>> Flattener<T> impl<S:Encoder,T:Encodable<S>> Flattener<T>
for SerializingFlattener<S, 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)
@ -519,7 +519,7 @@ pub mod bytepipes {
writer: W writer: W
} }
pub impl<R:Reader> BytePort for ReaderBytePort<R> { 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 = ~[];
@ -541,7 +541,7 @@ pub mod bytepipes {
} }
} }
pub impl<W:Writer> ByteChan for WriterByteChan<W> { 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);
} }
@ -572,7 +572,7 @@ pub mod bytepipes {
chan: comm::Chan<~[u8]> chan: comm::Chan<~[u8]>
} }
pub impl BytePort for PipeBytePort { 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, ~[]);
@ -604,7 +604,7 @@ pub mod bytepipes {
} }
} }
pub impl ByteChan for PipeByteChan { 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 serialize::Encoder for Encoder { 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 serialize::Encoder for PrettyEncoder { 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 serialize::Encoder for PrettyEncoder {
} }
} }
pub impl<S:serialize::Encoder> serialize::Encodable<S> for Json { 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 serialize::Decoder for Decoder { 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 serialize::Encoder for Serializer { 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> Encodable<S> for uint { 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> Decodable<D> for uint { 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> Encodable<S> for u8 { 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> Decodable<D> for u8 { 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> Encodable<S> for u16 { 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> Decodable<D> for u16 { 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> Encodable<S> for u32 { 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> Decodable<D> for u32 { 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> Encodable<S> for u64 { 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> Decodable<D> for u64 { 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> Encodable<S> for int { 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> Decodable<D> for int { 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> Encodable<S> for i8 { 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> Decodable<D> for i8 { 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> Encodable<S> for i16 { 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> Decodable<D> for i16 { 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> Encodable<S> for i32 { 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> Decodable<D> for i32 { 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> Encodable<S> for i64 { 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> Decodable<D> for i64 { 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> Encodable<S> for &str { 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> Encodable<S> for ~str { 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> Decodable<D> for ~str { 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> Encodable<S> for @str { 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> Decodable<D> for @str { 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> Encodable<S> for float { 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> Decodable<D> for float { 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> Encodable<S> for f32 { 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> Decodable<D> for f32 { 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> Encodable<S> for f64 { 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> Decodable<D> for f64 { 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> Encodable<S> for bool { 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> Decodable<D> for bool { 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> for () { 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> for () { 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>> Encodable<S> for &T { 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>> Encodable<S> for ~T { 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>> Decodable<D> for ~T { 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>> Encodable<S> for @T { 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>> Decodable<D> for @T { 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>> Encodable<S> for &[T] { 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>> Encodable<S> for &[T] {
} }
} }
pub impl<S:Encoder,T:Encodable<S>> Encodable<S> for ~[T] { 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>> Encodable<S> for ~[T] {
} }
} }
pub impl<D:Decoder,T:Decodable<D>> Decodable<D> for ~[T] { 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>> Decodable<D> for ~[T] {
} }
} }
pub impl<S:Encoder,T:Encodable<S>> Encodable<S> for @[T] { 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>> Encodable<S> for @[T] {
} }
} }
pub impl<D:Decoder,T:Decodable<D>> Decodable<D> for @[T] { 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>> Decodable<D> for @[T] {
} }
} }
pub impl<S:Encoder,T:Encodable<S>> Encodable<S> for Option<T> { 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>> Encodable<S> for Option<T> {
} }
} }
pub impl<D:Decoder,T:Decodable<D>> Decodable<D> for Option<T> { 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,8 +396,7 @@ pub impl<D:Decoder,T:Decodable<D>> Decodable<D> for Option<T> {
} }
} }
pub impl<S:Encoder,T0:Encodable<S>,T1:Encodable<S>> Encodable<S> impl<S:Encoder,T0:Encodable<S>,T1:Encodable<S>> Encodable<S> for (T0, T1) {
for (T0, T1) {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
match *self { match *self {
(ref t0, ref t1) => { (ref t0, ref t1) => {
@ -410,8 +409,7 @@ pub impl<S:Encoder,T0:Encodable<S>,T1:Encodable<S>> Encodable<S>
} }
} }
pub impl<D:Decoder,T0:Decodable<D>,T1:Decodable<D>> Decodable<D> impl<D:Decoder,T0:Decodable<D>,T1:Decodable<D>> Decodable<D> for (T0, T1) {
for (T0, T1) {
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) {
( (
@ -422,7 +420,7 @@ pub impl<D:Decoder,T0:Decodable<D>,T1:Decodable<D>> Decodable<D>
} }
} }
pub impl< impl<
S: Encoder, S: Encoder,
T0: Encodable<S>, T0: Encodable<S>,
T1: Encodable<S>, T1: Encodable<S>,
@ -441,7 +439,7 @@ pub impl<
} }
} }
pub impl< impl<
D: Decoder, D: Decoder,
T0: Decodable<D>, T0: Decodable<D>,
T1: Decodable<D>, T1: Decodable<D>,
@ -458,7 +456,7 @@ pub impl<
} }
} }
pub impl< impl<
S: Encoder, S: Encoder,
T0: Encodable<S>, T0: Encodable<S>,
T1: Encodable<S>, T1: Encodable<S>,
@ -479,7 +477,7 @@ pub impl<
} }
} }
pub impl< impl<
D: Decoder, D: Decoder,
T0: Decodable<D>, T0: Decodable<D>,
T1: Decodable<D>, T1: Decodable<D>,
@ -498,7 +496,7 @@ pub impl<
} }
} }
pub impl< impl<
S: Encoder, S: Encoder,
T0: Encodable<S>, T0: Encodable<S>,
T1: Encodable<S>, T1: Encodable<S>,
@ -521,7 +519,7 @@ pub impl<
} }
} }
pub impl< impl<
D: Decoder, D: Decoder,
T0: Decodable<D>, T0: Decodable<D>,
T1: Decodable<D>, T1: Decodable<D>,
@ -552,7 +550,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> EncoderHelpers for S { 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| {
@ -568,7 +566,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> DecoderHelpers for D { 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

@ -140,7 +140,7 @@ impl WorkKey {
type WorkMap = LinearMap<WorkKey, ~str>; type WorkMap = LinearMap<WorkKey, ~str>;
pub impl<S:Encoder> Encodable<S> for WorkMap { 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)| {
@ -151,7 +151,7 @@ pub impl<S:Encoder> Encodable<S> for WorkMap {
} }
} }
pub impl<D:Decoder> Decodable<D> for WorkMap { 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

@ -61,7 +61,7 @@ type Name = uint;
// with a macro expansion // with a macro expansion
type Mrk = uint; type Mrk = uint;
pub impl<S:Encoder> Encodable<S> for ident { 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!())
@ -74,7 +74,7 @@ pub impl<S:Encoder> Encodable<S> for ident {
} }
} }
pub impl<D:Decoder> Decodable<D> for ident { 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!())
@ -87,7 +87,7 @@ pub impl<D:Decoder> Decodable<D> for ident {
} }
} }
pub impl to_bytes::IterBytes for ident { 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)
} }
@ -246,7 +246,7 @@ pub enum binding_mode {
bind_infer bind_infer
} }
pub impl to_bytes::IterBytes for binding_mode { 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),
@ -291,7 +291,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 to_bytes::IterBytes for mutability { 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)
} }
@ -304,13 +304,13 @@ pub enum Abi {
RustAbi RustAbi
} }
pub impl to_bytes::IterBytes for Abi { 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 ToStr for Abi { impl ToStr for Abi {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
match *self { match *self {
RustAbi => ~"\"rust\"" RustAbi => ~"\"rust\""
@ -327,13 +327,13 @@ pub enum Sigil {
ManagedSigil ManagedSigil
} }
pub impl to_bytes::IterBytes for Sigil { 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 ToStr for Sigil { impl ToStr for Sigil {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
match *self { match *self {
BorrowedSigil => ~"&", BorrowedSigil => ~"&",
@ -412,7 +412,7 @@ pub enum inferable<T> {
infer(node_id) infer(node_id)
} }
pub impl<T:to_bytes::IterBytes> to_bytes::IterBytes for inferable<T> { 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) =>
@ -430,7 +430,7 @@ pub impl<T:to_bytes::IterBytes> to_bytes::IterBytes for inferable<T> {
#[deriving_eq] #[deriving_eq]
pub enum rmode { by_ref, by_val, by_copy } pub enum rmode { by_ref, by_val, by_copy }
pub impl to_bytes::IterBytes for rmode { 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)
} }
@ -771,13 +771,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 ToStr for int_ty { 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 to_bytes::IterBytes for int_ty { 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)
} }
@ -788,13 +788,13 @@ pub impl to_bytes::IterBytes for int_ty {
#[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 ToStr for uint_ty { 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 to_bytes::IterBytes for uint_ty { 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)
} }
@ -805,13 +805,13 @@ pub impl to_bytes::IterBytes for uint_ty {
#[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 ToStr for float_ty { 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 to_bytes::IterBytes for float_ty { 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)
} }
@ -865,7 +865,7 @@ pub enum Onceness {
Many Many
} }
pub impl ToStr for Onceness { impl ToStr for Onceness {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
match *self { match *self {
Once => ~"once", Once => ~"once",
@ -874,7 +874,7 @@ pub impl ToStr for Onceness {
} }
} }
pub impl to_bytes::IterBytes for Onceness { 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);
} }
@ -924,7 +924,7 @@ pub enum ty_ {
ty_infer, ty_infer,
} }
pub impl to_bytes::IterBytes for Ty { 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);
} }
@ -960,7 +960,7 @@ pub enum purity {
extern_fn, // declared with "extern fn" extern_fn, // declared with "extern fn"
} }
pub impl ToStr for purity { 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",
@ -971,7 +971,7 @@ pub impl ToStr for purity {
} }
} }
pub impl to_bytes::IterBytes for purity { 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)
} }
@ -986,7 +986,7 @@ pub enum ret_style {
return_val, // everything else return_val, // everything else
} }
pub impl to_bytes::IterBytes for ret_style { 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)
} }
@ -1268,7 +1268,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 to_bytes::IterBytes for struct_mutability { 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 cmp::Eq for path_elt { 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 to_bytes::IterBytes for def_id { 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_utils for inlined_item { 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 Pos for BytePos { 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 cmp::Eq for BytePos { 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 cmp::Ord for BytePos { 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 Add<BytePos, BytePos> for BytePos { 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 Sub<BytePos, BytePos> for BytePos { 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 to_bytes::IterBytes for BytePos { 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 Pos for CharPos { 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 cmp::Eq for CharPos { 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 cmp::Ord for CharPos { 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 to_bytes::IterBytes for CharPos { 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 Add<CharPos,CharPos> for CharPos { 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 Sub<CharPos,CharPos> for CharPos { 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 cmp::Eq for span { 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> Encodable<S> for span { 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> Decodable<D> for span { 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

@ -1192,7 +1192,7 @@ mod test {
} }
} }
pub impl Encoder for TestEncoder { impl Encoder for TestEncoder {
fn emit_nil(&self) { self.add_to_log(CallToEmitNil) } fn emit_nil(&self) { self.add_to_log(CallToEmitNil) }
fn emit_uint(&self, +v: uint) {self.add_to_log(CallToEmitUint(v)); } fn emit_uint(&self, +v: uint) {self.add_to_log(CallToEmitUint(v)); }

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 append_types for @ast::path { 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}
@ -119,7 +119,7 @@ pub trait ext_ctxt_ast_builder {
fn strip_bounds(&self, bounds: &[ast::ty_param]) -> ~[ast::ty_param]; fn strip_bounds(&self, bounds: &[ast::ty_param]) -> ~[ast::ty_param];
} }
pub impl ext_ctxt_ast_builder for ext_ctxt { impl ext_ctxt_ast_builder for ext_ctxt {
fn ty_option(&self, ty: @ast::Ty) -> @ast::Ty { fn ty_option(&self, 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 proto::visitor<(), (), ()> for ext_ctxt { impl proto::visitor<(), (), ()> for ext_ctxt {
fn visit_proto(&self, _proto: protocol, fn visit_proto(&self, _proto: protocol,
_states: &[()]) { } _states: &[()]) { }

View file

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

View file

@ -46,7 +46,7 @@ pub trait gen_init {
fn gen_init_bounded(&self, ext_cx: ext_ctxt) -> @ast::expr; fn gen_init_bounded(&self, ext_cx: ext_ctxt) -> @ast::expr;
} }
pub impl gen_send for message { impl gen_send for message {
fn gen_send(&mut self, cx: ext_ctxt, try: bool) -> @ast::item { fn gen_send(&mut self, cx: ext_ctxt, try: bool) -> @ast::item {
debug!("pipec: gen_send"); debug!("pipec: gen_send");
let name = self.name(); let name = self.name();
@ -196,7 +196,7 @@ pub impl gen_send for message {
} }
} }
pub impl to_type_decls for state { impl to_type_decls for state {
fn to_type_decls(&self, cx: ext_ctxt) -> ~[@ast::item] { fn to_type_decls(&self, 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
@ -307,7 +307,7 @@ pub impl to_type_decls for state {
} }
} }
pub impl gen_init for protocol { impl gen_init for protocol {
fn gen_init(&self, cx: ext_ctxt) -> @ast::item { fn gen_init(&self, cx: ext_ctxt) -> @ast::item {
let ext_cx = cx; let ext_cx = cx;

View file

@ -21,7 +21,7 @@ use core::to_str::ToStr;
#[deriving_eq] #[deriving_eq]
pub enum direction { send, recv } pub enum direction { send, recv }
pub impl ToStr for direction { impl ToStr for direction {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
match *self { match *self {
send => ~"Send", send => ~"Send",

View file

@ -694,7 +694,7 @@ pub fn default_ast_fold() -> ast_fold_fns {
new_span: noop_span}; new_span: noop_span};
} }
pub impl ast_fold for ast_fold_fns { 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 reader for TtReader { 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

@ -50,9 +50,10 @@ pub enum ObsoleteSyntax {
ObsoleteTraitBoundSeparator, ObsoleteTraitBoundSeparator,
ObsoleteMutOwnedPointer, ObsoleteMutOwnedPointer,
ObsoleteMutVector, ObsoleteMutVector,
ObsoleteTraitImplVisibility,
} }
pub impl to_bytes::IterBytes for ObsoleteSyntax { 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);
@ -140,6 +141,12 @@ pub impl Parser {
in a mutable location, like a mutable local variable or an \ in a mutable location, like a mutable local variable or an \
`@mut` box" `@mut` box"
), ),
ObsoleteTraitImplVisibility => (
"visibility-qualified trait implementation",
"`pub` or `priv` is meaningless for trait implementations, \
because the `impl...for...` form defines overloads for \
methods that already exist; remove the `pub` or `priv`"
),
}; };
self.report(sp, kind, kind_str, desc); self.report(sp, kind, kind_str, desc);

View file

@ -76,7 +76,7 @@ use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith};
use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds}; use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds};
use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax}; use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax};
use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer}; use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer};
use parse::obsolete::{ObsoleteMutVector}; use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility};
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};
@ -2942,9 +2942,9 @@ pub impl Parser {
} }
// Parses two variants (with the region/type params always optional): // Parses two variants (with the region/type params always optional):
// impl<T> ~[T] : to_str { ... } // impl<T> Foo { ... }
// impl<T> to_str for ~[T] { ... } // impl<T> ToStr for ~[T] { ... }
fn parse_item_impl() -> item_info { fn parse_item_impl(visibility: ast::visibility) -> item_info {
fn wrap_path(p: Parser, pt: @path) -> @Ty { fn wrap_path(p: Parser, pt: @path) -> @Ty {
@Ty { @Ty {
id: p.get_id(), id: p.get_id(),
@ -2993,6 +2993,12 @@ pub impl Parser {
None None
}; };
// Do not allow visibility to be specified in `impl...for...`. It is
// meaningless.
if opt_trait.is_some() && visibility != ast::inherited {
self.obsolete(*self.span, ObsoleteTraitImplVisibility);
}
let mut meths = ~[]; let mut meths = ~[];
if !self.eat(token::SEMI) { if !self.eat(token::SEMI) {
self.expect(token::LBRACE); self.expect(token::LBRACE);
@ -3860,7 +3866,8 @@ pub impl Parser {
maybe_append(attrs, extra_attrs))); maybe_append(attrs, extra_attrs)));
} else if items_allowed && self.eat_keyword(~"impl") { } else if items_allowed && self.eat_keyword(~"impl") {
// IMPL ITEM // IMPL ITEM
let (ident, item_, extra_attrs) = self.parse_item_impl(); let (ident, item_, extra_attrs) =
self.parse_item_impl(visibility);
return iovi_item(self.mk_item(lo, self.last_span.hi, ident, item_, return iovi_item(self.mk_item(lo, self.last_span.hi, ident, item_,
visibility, visibility,
maybe_append(attrs, extra_attrs))); maybe_append(attrs, extra_attrs)));

View file

@ -17,7 +17,7 @@ pub mod kitty {
name : ~str, name : ~str,
} }
pub impl ToStr for cat { 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 add for name_pool { 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 cx for rt { 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 Drop for socket_handle { 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 Drop for rsrc { 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 Add<MyInt, MyInt> for MyInt { 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 Sub<MyInt, MyInt> for MyInt { 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 Mul<MyInt, MyInt> for MyInt { 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 Eq for MyInt { 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 MyNum for MyInt; 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 Hahaha for Lol { } 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 BikeMethods for Bike { 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

@ -155,7 +155,7 @@ pub mod pipes {
p: Option<*packet<T>>, p: Option<*packet<T>>,
} }
pub impl<T:Owned> Drop for send_packet<T> { impl<T:Owned> Drop for send_packet<T> {
fn finalize(&self) { fn finalize(&self) {
unsafe { unsafe {
if self.p != None { if self.p != None {
@ -187,7 +187,7 @@ pub mod pipes {
p: Option<*packet<T>>, p: Option<*packet<T>>,
} }
pub impl<T:Owned> Drop for recv_packet<T> { impl<T:Owned> Drop for recv_packet<T> {
fn finalize(&self) { fn finalize(&self) {
unsafe { unsafe {
if self.p != None { if self.p != None {

View file

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

View file

@ -16,12 +16,12 @@ pub trait plus {
mod a { mod a {
use plus; use plus;
pub impl plus for uint { fn plus() -> int { self as int + 20 } } impl plus for uint { fn plus() -> int { self as int + 20 } }
} }
mod b { mod b {
use plus; use plus;
pub impl plus for ~str { fn plus() -> int { 200 } } 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 Number for float { 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 NumConv for float { 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 TypeExt for u8 {} impl TypeExt for u8 {}
pub impl TypeExt for u16 {} impl TypeExt for u16 {}
pub impl TypeExt for u32 {} impl TypeExt for u32 {}
pub impl TypeExt for u64 {} impl TypeExt for u64 {}
pub impl TypeExt for uint {} impl TypeExt for uint {}
pub impl TypeExt for i8 {} impl TypeExt for i8 {}
pub impl TypeExt for i16 {} impl TypeExt for i16 {}
pub impl TypeExt for i32 {} impl TypeExt for i32 {}
pub impl TypeExt for i64 {} impl TypeExt for i64 {}
pub impl TypeExt for int {} impl TypeExt for int {}
pub impl TypeExt for f32 {} impl TypeExt for f32 {}
pub impl TypeExt for f64 {} impl TypeExt for f64 {}
pub impl TypeExt for float {} impl TypeExt for float {}
pub trait NumExt: TypeExt Eq Ord NumCast {} pub trait NumExt: TypeExt Eq Ord NumCast {}
pub impl NumExt for u8 {} impl NumExt for u8 {}
pub impl NumExt for u16 {} impl NumExt for u16 {}
pub impl NumExt for u32 {} impl NumExt for u32 {}
pub impl NumExt for u64 {} impl NumExt for u64 {}
pub impl NumExt for uint {} impl NumExt for uint {}
pub impl NumExt for i8 {} impl NumExt for i8 {}
pub impl NumExt for i16 {} impl NumExt for i16 {}
pub impl NumExt for i32 {} impl NumExt for i32 {}
pub impl NumExt for i64 {} impl NumExt for i64 {}
pub impl NumExt for int {} impl NumExt for int {}
pub impl NumExt for f32 {} impl NumExt for f32 {}
pub impl NumExt for f64 {} impl NumExt for f64 {}
pub impl NumExt for float {} impl NumExt for float {}
pub trait UnSignedExt: NumExt {} pub trait UnSignedExt: NumExt {}
pub impl UnSignedExt for u8 {} impl UnSignedExt for u8 {}
pub impl UnSignedExt for u16 {} impl UnSignedExt for u16 {}
pub impl UnSignedExt for u32 {} impl UnSignedExt for u32 {}
pub impl UnSignedExt for u64 {} impl UnSignedExt for u64 {}
pub impl UnSignedExt for uint {} impl UnSignedExt for uint {}
pub trait SignedExt: NumExt {} pub trait SignedExt: NumExt {}
pub impl SignedExt for i8 {} impl SignedExt for i8 {}
pub impl SignedExt for i16 {} impl SignedExt for i16 {}
pub impl SignedExt for i32 {} impl SignedExt for i32 {}
pub impl SignedExt for i64 {} impl SignedExt for i64 {}
pub impl SignedExt for int {} impl SignedExt for int {}
pub impl SignedExt for f32 {} impl SignedExt for f32 {}
pub impl SignedExt for f64 {} impl SignedExt for f64 {}
pub impl SignedExt for float {} impl SignedExt for float {}
pub trait IntegerExt: NumExt {} pub trait IntegerExt: NumExt {}
pub impl IntegerExt for u8 {} impl IntegerExt for u8 {}
pub impl IntegerExt for u16 {} impl IntegerExt for u16 {}
pub impl IntegerExt for u32 {} impl IntegerExt for u32 {}
pub impl IntegerExt for u64 {} impl IntegerExt for u64 {}
pub impl IntegerExt for uint {} impl IntegerExt for uint {}
pub impl IntegerExt for i8 {} impl IntegerExt for i8 {}
pub impl IntegerExt for i16 {} impl IntegerExt for i16 {}
pub impl IntegerExt for i32 {} impl IntegerExt for i32 {}
pub impl IntegerExt for i64 {} impl IntegerExt for i64 {}
pub impl IntegerExt for int {} impl IntegerExt for int {}
pub trait FloatExt: NumExt FuzzyEq<Self> {} pub trait FloatExt: NumExt FuzzyEq<Self> {}
pub impl FloatExt for f32 {} impl FloatExt for f32 {}
pub impl FloatExt for f64 {} impl FloatExt for f64 {}
pub impl FloatExt for float {} 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 NumExt for f32 {} 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 NumExt for f32 {} impl NumExt for f32 {}
pub impl NumExt for int {} 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 @@ mod base {
dummy: (), dummy: (),
} }
pub impl ::base::HasNew<Foo> for Foo { 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 ::base::HasNew<Bar> for Bar { 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: () }