diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index b9b39063667..b07e6cdaa80 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -335,7 +335,7 @@ pub impl RWARC { * Failing will unlock the ARC while unwinding. However, unlike all other * access modes, this will not poison the ARC. */ - fn read(blk: fn(x: &T) -> U) -> U { + fn read(&self, blk: fn(x: &T) -> U) -> U { let state = unsafe { get_shared_immutable_state(&self.x) }; do (&state.lock).read { check_poison(false, state.failed); @@ -360,7 +360,7 @@ pub impl RWARC { * } * ~~~ */ - fn write_downgrade(blk: fn(v: RWWriteMode) -> U) -> U { + fn write_downgrade(&self, blk: fn(v: RWWriteMode) -> U) -> U { unsafe { let state = get_shared_mutable_state(&self.x); do (*borrow_rwlock(state)).write_downgrade |write_mode| { @@ -373,7 +373,7 @@ pub impl RWARC { } /// To be called inside of the write_downgrade block. - fn downgrade(token: RWWriteMode/&a) -> RWReadMode/&a { + fn downgrade(&self, token: RWWriteMode/&a) -> RWReadMode/&a { // The rwlock should assert that the token belongs to us for us. let state = unsafe { get_shared_immutable_state(&self.x) }; let RWWriteMode((data, t, _poison)) = token; diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index dceb39312da..d8fc6a5b9ee 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -13,11 +13,11 @@ use core::str; use core::vec; pub trait ToBase64 { - pure fn to_base64() -> ~str; + pure fn to_base64(&self) -> ~str; } impl ToBase64 for &self/[u8] { - pure fn to_base64() -> ~str { + pure fn to_base64(&self) -> ~str { let chars = str::chars( ~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ); @@ -70,17 +70,17 @@ impl ToBase64 for &self/[u8] { } impl ToBase64 for &self/str { - pure fn to_base64() -> ~str { - str::to_bytes(self).to_base64() + pure fn to_base64(&self) -> ~str { + str::to_bytes(*self).to_base64() } } pub trait FromBase64 { - pure fn from_base64() -> ~[u8]; + pure fn from_base64(&self) -> ~[u8]; } impl FromBase64 for ~[u8] { - pure fn from_base64() -> ~[u8] { + pure fn from_base64(&self) -> ~[u8] { if self.len() % 4u != 0u { fail!(~"invalid base64 length"); } let len = self.len(); @@ -142,8 +142,8 @@ impl FromBase64 for ~[u8] { } impl FromBase64 for ~str { - pure fn from_base64() -> ~[u8] { - str::to_bytes(self).from_base64() + pure fn from_base64(&self) -> ~[u8] { + str::to_bytes(*self).from_base64() } } diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index e3437fc57aa..4189b37c2a4 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -29,19 +29,19 @@ pub struct DuplexStream { #[cfg(stage1)] #[cfg(stage2)] pub impl DuplexStream { - fn send(x: T) { + fn send(&self, x: T) { self.chan.send(x) } - fn try_send(x: T) -> bool { + fn try_send(&self, x: T) -> bool { self.chan.try_send(x) } - fn recv() -> U { + fn recv(&self, ) -> U { self.port.recv() } - fn try_recv() -> Option { + fn try_recv(&self) -> Option { self.port.try_recv() } - pure fn peek() -> bool { + pure fn peek(&self) -> bool { self.port.peek() } } diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 7ac58ae539f..bbf3fc8c072 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -217,7 +217,7 @@ pub mod reader { } priv impl Decoder { - fn _check_label(lbl: &str) { + fn _check_label(&self, lbl: &str) { if self.pos < self.parent.end { let TaggedDoc { tag: r_tag, doc: r_doc } = doc_at(self.parent.data, self.pos); @@ -233,7 +233,7 @@ pub mod reader { } } - fn next_doc(exp_tag: EbmlEncoderTag) -> Doc { + fn next_doc(&self, exp_tag: EbmlEncoderTag) -> Doc { debug!(". next_doc(exp_tag=%?)", exp_tag); if self.pos >= self.parent.end { fail!(~"no more documents in current node!"); @@ -255,7 +255,7 @@ pub mod reader { r_doc } - fn push_doc(d: Doc, f: fn() -> T) -> T { + fn push_doc(&self, d: Doc, f: fn() -> T) -> T { let old_parent = self.parent; let old_pos = self.pos; self.parent = d; @@ -266,7 +266,7 @@ pub mod reader { r } - fn _next_uint(exp_tag: EbmlEncoderTag) -> uint { + fn _next_uint(&self, exp_tag: EbmlEncoderTag) -> uint { let r = doc_as_u32(self.next_doc(exp_tag)); debug!("_next_uint exp_tag=%? result=%?", exp_tag, r); r as uint @@ -446,7 +446,7 @@ pub mod writer { // FIXME (#2741): Provide a function to write the standard ebml header. pub impl Encoder { - fn start_tag(tag_id: uint) { + fn start_tag(&self, tag_id: uint) { debug!("Start tag %u", tag_id); // Write the enum ID: @@ -458,7 +458,7 @@ pub mod writer { self.writer.write(zeroes); } - fn end_tag() { + fn end_tag(&self) { let last_size_pos = self.size_positions.pop(); let cur_pos = self.writer.tell(); self.writer.seek(last_size_pos as int, io::SeekSet); @@ -469,72 +469,72 @@ pub mod writer { debug!("End tag (size = %u)", size); } - fn wr_tag(tag_id: uint, blk: fn()) { + fn wr_tag(&self, tag_id: uint, blk: fn()) { self.start_tag(tag_id); blk(); self.end_tag(); } - fn wr_tagged_bytes(tag_id: uint, b: &[u8]) { + fn wr_tagged_bytes(&self, tag_id: uint, b: &[u8]) { write_vuint(self.writer, tag_id); write_vuint(self.writer, vec::len(b)); self.writer.write(b); } - fn wr_tagged_u64(tag_id: uint, v: u64) { + fn wr_tagged_u64(&self, tag_id: uint, v: u64) { do io::u64_to_be_bytes(v, 8u) |v| { self.wr_tagged_bytes(tag_id, v); } } - fn wr_tagged_u32(tag_id: uint, v: u32) { + fn wr_tagged_u32(&self, tag_id: uint, v: u32) { do io::u64_to_be_bytes(v as u64, 4u) |v| { self.wr_tagged_bytes(tag_id, v); } } - fn wr_tagged_u16(tag_id: uint, v: u16) { + fn wr_tagged_u16(&self, tag_id: uint, v: u16) { do io::u64_to_be_bytes(v as u64, 2u) |v| { self.wr_tagged_bytes(tag_id, v); } } - fn wr_tagged_u8(tag_id: uint, v: u8) { + fn wr_tagged_u8(&self, tag_id: uint, v: u8) { self.wr_tagged_bytes(tag_id, &[v]); } - fn wr_tagged_i64(tag_id: uint, v: i64) { + fn wr_tagged_i64(&self, tag_id: uint, v: i64) { do io::u64_to_be_bytes(v as u64, 8u) |v| { self.wr_tagged_bytes(tag_id, v); } } - fn wr_tagged_i32(tag_id: uint, v: i32) { + fn wr_tagged_i32(&self, tag_id: uint, v: i32) { do io::u64_to_be_bytes(v as u64, 4u) |v| { self.wr_tagged_bytes(tag_id, v); } } - fn wr_tagged_i16(tag_id: uint, v: i16) { + fn wr_tagged_i16(&self, tag_id: uint, v: i16) { do io::u64_to_be_bytes(v as u64, 2u) |v| { self.wr_tagged_bytes(tag_id, v); } } - fn wr_tagged_i8(tag_id: uint, v: i8) { + fn wr_tagged_i8(&self, tag_id: uint, v: i8) { self.wr_tagged_bytes(tag_id, &[v as u8]); } - fn wr_tagged_str(tag_id: uint, v: &str) { + fn wr_tagged_str(&self, tag_id: uint, v: &str) { str::byte_slice(v, |b| self.wr_tagged_bytes(tag_id, b)); } - fn wr_bytes(b: &[u8]) { + fn wr_bytes(&self, b: &[u8]) { debug!("Write %u bytes", vec::len(b)); self.writer.write(b); } - fn wr_str(s: &str) { + fn wr_str(&self, s: &str) { debug!("Write str: %?", s); self.writer.write(str::to_bytes(s)); } @@ -549,12 +549,12 @@ pub mod writer { priv impl Encoder { // used internally to emit things like the vector length and so on - fn _emit_tagged_uint(t: EbmlEncoderTag, v: uint) { + fn _emit_tagged_uint(&self, t: EbmlEncoderTag, v: uint) { assert v <= 0xFFFF_FFFF_u; self.wr_tagged_u32(t as uint, v as u32); } - fn _emit_label(label: &str) { + fn _emit_label(&self, label: &str) { // There are various strings that we have access to, such as // the name of a record field, which do not actually appear in // the encoded EBML (normally). This is just for diff --git a/src/libstd/future.rs b/src/libstd/future.rs index f105aacbc4f..68a9ce75593 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -47,7 +47,7 @@ priv enum FutureState { /// Methods on the `future` type pub impl Future { - fn get() -> A { + fn get(&self) -> A { //! Get the value of the future *(self.get_ref()) } diff --git a/src/libstd/io_util.rs b/src/libstd/io_util.rs index 6839981d201..7d673feaf25 100644 --- a/src/libstd/io_util.rs +++ b/src/libstd/io_util.rs @@ -24,7 +24,7 @@ pub impl BufReader { } } - priv fn as_bytes_reader(f: &fn(&BytesReader) -> A) -> A { + priv fn as_bytes_reader(&self, f: &fn(&BytesReader) -> A) -> A { // Recreating the BytesReader state every call since // I can't get the borrowing to work correctly let bytes_reader = BytesReader { diff --git a/src/libstd/json.rs b/src/libstd/json.rs index cfa66ae000a..4ebd151eb2e 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -387,7 +387,7 @@ pub fn Parser(rdr: io::Reader) -> Parser { } pub impl Parser { - fn parse() -> Result { + fn parse(&self) -> Result { match self.parse_value() { Ok(value) => { // Skip trailing whitespaces. @@ -405,9 +405,9 @@ pub impl Parser { } priv impl Parser { - fn eof() -> bool { self.ch == -1 as char } + fn eof(&self) -> bool { self.ch == -1 as char } - fn bump() { + fn bump(&self) { self.ch = self.rdr.read_char(); if self.ch == '\n' { @@ -418,16 +418,16 @@ priv impl Parser { } } - fn next_char() -> char { + fn next_char(&self) -> char { self.bump(); self.ch } - fn error(msg: ~str) -> Result { + fn error(&self, msg: ~str) -> Result { Err(Error { line: self.line, col: self.col, msg: @msg }) } - fn parse_value() -> Result { + fn parse_value(&self) -> Result { self.parse_whitespace(); if self.eof() { return self.error(~"EOF while parsing value"); } @@ -448,11 +448,11 @@ priv impl Parser { } } - fn parse_whitespace() { + fn parse_whitespace(&self) { while char::is_whitespace(self.ch) { self.bump(); } } - fn parse_ident(ident: &str, value: Json) -> Result { + fn parse_ident(&self, ident: &str, value: Json) -> Result { if str::all(ident, |c| c == self.next_char()) { self.bump(); Ok(value) @@ -461,7 +461,7 @@ priv impl Parser { } } - fn parse_number() -> Result { + fn parse_number(&self) -> Result { let mut neg = 1f; if self.ch == '-' { @@ -491,7 +491,7 @@ priv impl Parser { Ok(Number(neg * res)) } - fn parse_integer() -> Result { + fn parse_integer(&self) -> Result { let mut res = 0f; match self.ch { @@ -523,7 +523,7 @@ priv impl Parser { Ok(res) } - fn parse_decimal(res: float) -> Result { + fn parse_decimal(&self, res: float) -> Result { self.bump(); // Make sure a digit follows the decimal place. @@ -549,7 +549,7 @@ priv impl Parser { Ok(res) } - fn parse_exponent(res: float) -> Result { + fn parse_exponent(&self, res: float) -> Result { self.bump(); let mut res = res; @@ -590,7 +590,7 @@ priv impl Parser { Ok(res) } - fn parse_str() -> Result<~str, Error> { + fn parse_str(&self) -> Result<~str, Error> { let mut escape = false; let mut res = ~""; @@ -654,7 +654,7 @@ priv impl Parser { self.error(~"EOF while parsing string") } - fn parse_list() -> Result { + fn parse_list(&self) -> Result { self.bump(); self.parse_whitespace(); @@ -684,7 +684,7 @@ priv impl Parser { }; } - fn parse_object() -> Result { + fn parse_object(&self) -> Result { self.bump(); self.parse_whitespace(); @@ -1072,87 +1072,87 @@ impl Eq for Error { pure fn ne(&self, other: &Error) -> bool { !(*self).eq(other) } } -trait ToJson { fn to_json() -> Json; } +trait ToJson { fn to_json(&self) -> Json; } impl ToJson for Json { - fn to_json() -> Json { copy self } + fn to_json(&self) -> Json { copy *self } } impl ToJson for @Json { - fn to_json() -> Json { (*self).to_json() } + fn to_json(&self) -> Json { (**self).to_json() } } impl ToJson for int { - fn to_json() -> Json { Number(self as float) } + fn to_json(&self) -> Json { Number(*self as float) } } impl ToJson for i8 { - fn to_json() -> Json { Number(self as float) } + fn to_json(&self) -> Json { Number(*self as float) } } impl ToJson for i16 { - fn to_json() -> Json { Number(self as float) } + fn to_json(&self) -> Json { Number(*self as float) } } impl ToJson for i32 { - fn to_json() -> Json { Number(self as float) } + fn to_json(&self) -> Json { Number(*self as float) } } impl ToJson for i64 { - fn to_json() -> Json { Number(self as float) } + fn to_json(&self) -> Json { Number(*self as float) } } impl ToJson for uint { - fn to_json() -> Json { Number(self as float) } + fn to_json(&self) -> Json { Number(*self as float) } } impl ToJson for u8 { - fn to_json() -> Json { Number(self as float) } + fn to_json(&self) -> Json { Number(*self as float) } } impl ToJson for u16 { - fn to_json() -> Json { Number(self as float) } + fn to_json(&self) -> Json { Number(*self as float) } } impl ToJson for u32 { - fn to_json() -> Json { Number(self as float) } + fn to_json(&self) -> Json { Number(*self as float) } } impl ToJson for u64 { - fn to_json() -> Json { Number(self as float) } + fn to_json(&self) -> Json { Number(*self as float) } } impl ToJson for float { - fn to_json() -> Json { Number(self) } + fn to_json(&self) -> Json { Number(*self) } } impl ToJson for f32 { - fn to_json() -> Json { Number(self as float) } + fn to_json(&self) -> Json { Number(*self as float) } } impl ToJson for f64 { - fn to_json() -> Json { Number(self as float) } + fn to_json(&self) -> Json { Number(*self as float) } } impl ToJson for () { - fn to_json() -> Json { Null } + fn to_json(&self) -> Json { Null } } impl ToJson for bool { - fn to_json() -> Json { Boolean(self) } + fn to_json(&self) -> Json { Boolean(*self) } } impl ToJson for ~str { - fn to_json() -> Json { String(copy self) } + fn to_json(&self) -> Json { String(copy *self) } } impl ToJson for @~str { - fn to_json() -> Json { String(copy *self) } + fn to_json(&self) -> Json { String(copy **self) } } impl ToJson for (A, B) { - fn to_json() -> Json { - match self { + fn to_json(&self) -> Json { + match *self { (ref a, ref b) => { List(~[a.to_json(), b.to_json()]) } @@ -1161,8 +1161,8 @@ impl ToJson for (A, B) { } impl ToJson for (A, B, C) { - fn to_json() -> Json { - match self { + fn to_json(&self) -> Json { + match *self { (ref a, ref b, ref c) => { List(~[a.to_json(), b.to_json(), c.to_json()]) } @@ -1171,11 +1171,11 @@ impl ToJson for (A, B, C) { } impl ToJson for ~[A] { - fn to_json() -> Json { List(self.map(|elt| elt.to_json())) } + fn to_json(&self) -> Json { List(self.map(|elt| elt.to_json())) } } impl ToJson for LinearMap<~str, A> { - fn to_json() -> Json { + fn to_json(&self) -> Json { let mut d = LinearMap::new(); for self.each |&(key, value)| { d.insert(copy *key, value.to_json()); @@ -1185,8 +1185,8 @@ impl ToJson for LinearMap<~str, A> { } impl ToJson for Option { - fn to_json() -> Json { - match self { + fn to_json(&self) -> Json { + match *self { None => Null, Some(ref value) => value.to_json() } diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 95e10cf5b12..7a5c40f403f 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -187,13 +187,13 @@ pub mod v4 { pub struct Ipv4Rep { a: u8, b: u8, c: u8, d: u8 } pub trait AsUnsafeU32 { - unsafe fn as_u32() -> u32; + unsafe fn as_u32(&self) -> u32; } impl AsUnsafeU32 for Ipv4Rep { // this is pretty dastardly, i know - unsafe fn as_u32() -> u32 { - *((ptr::addr_of(&self)) as *u32) + unsafe fn as_u32(&self) -> u32 { + *((ptr::addr_of(self)) as *u32) } } pub fn parse_to_ipv4_rep(ip: &str) -> result::Result { diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index eea9f427326..f270739b2f2 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -823,31 +823,31 @@ pub fn socket_buf(sock: TcpSocket) -> TcpSocketBuf { /// Convenience methods extending `net::tcp::TcpSocket` pub impl TcpSocket { - pub fn read_start() -> result::Result<@Port< + pub fn read_start(&self) -> result::Result<@Port< result::Result<~[u8], TcpErrData>>, TcpErrData> { - read_start(&self) + read_start(self) } - pub fn read_stop() -> + pub fn read_stop(&self) -> result::Result<(), TcpErrData> { - read_stop(&self) + read_stop(self) } - fn read(timeout_msecs: uint) -> + fn read(&self, timeout_msecs: uint) -> result::Result<~[u8], TcpErrData> { - read(&self, timeout_msecs) + read(self, timeout_msecs) } - fn read_future(timeout_msecs: uint) -> + fn read_future(&self, timeout_msecs: uint) -> future::Future> { - read_future(&self, timeout_msecs) + read_future(self, timeout_msecs) } - pub fn write(raw_write_data: ~[u8]) + pub fn write(&self, raw_write_data: ~[u8]) -> result::Result<(), TcpErrData> { - write(&self, raw_write_data) + write(self, raw_write_data) } - pub fn write_future(raw_write_data: ~[u8]) + pub fn write_future(&self, raw_write_data: ~[u8]) -> future::Future> { - write_future(&self, raw_write_data) + write_future(self, raw_write_data) } - pub fn get_peer_addr() -> ip::IpAddr { + pub fn get_peer_addr(&self) -> ip::IpAddr { unsafe { if self.socket_data.ipv6 { let addr = uv::ll::ip6_addr("", 0); @@ -1264,11 +1264,11 @@ enum TcpReadResult { } trait ToTcpErr { - fn to_tcp_err() -> TcpErrData; + fn to_tcp_err(&self) -> TcpErrData; } impl ToTcpErr for uv::ll::uv_err_data { - fn to_tcp_err() -> TcpErrData { + fn to_tcp_err(&self) -> TcpErrData { TcpErrData { err_name: self.err_name, err_msg: self.err_msg } } } diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index faa26e24812..eb5ad2b6d73 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -74,7 +74,7 @@ pub mod chained { } priv impl T { - pure fn search_rem(k: &K, h: uint, idx: uint, + pure fn search_rem(&self, k: &K, h: uint, idx: uint, e_root: @Entry) -> SearchResult { let mut e0 = e_root; let mut comp = 1u; // for logging @@ -100,7 +100,7 @@ pub mod chained { }; } - pure fn search_tbl(k: &K, h: uint) -> SearchResult { + pure fn search_tbl(&self, k: &K, h: uint) -> SearchResult { let idx = h % vec::len(self.chains); match copy self.chains[idx] { None => { @@ -120,7 +120,7 @@ pub mod chained { } } - fn rehash() { + fn rehash(&self) { let n_old_chains = self.chains.len(); let n_new_chains: uint = uint::next_power_of_two(n_old_chains+1u); let mut new_chains = chains(n_new_chains); @@ -134,7 +134,7 @@ pub mod chained { } pub impl T { - pure fn each_entry(blk: fn(@Entry) -> bool) { + pure fn each_entry(&self, blk: fn(@Entry) -> bool) { // n.b. we can't use vec::iter() here because self.chains // is stored in a mutable location. let mut i = 0u, n = self.chains.len(); @@ -176,7 +176,7 @@ pub mod chained { } } - fn insert(k: K, v: V) -> bool { + fn insert(&self, k: K, v: V) -> bool { let hash = k.hash_keyed(0,0) as uint; match self.search_tbl(&k, hash) { NotFound => { @@ -220,7 +220,7 @@ pub mod chained { } } - fn remove(k: &K) -> bool { + fn remove(&self, k: &K) -> bool { match self.search_tbl(k, k.hash_keyed(0,0) as uint) { NotFound => false, FoundFirst(idx, entry) => { @@ -260,7 +260,8 @@ pub mod chained { } } - fn update_with_key(key: K, newval: V, ff: fn(K, V, V) -> V) -> bool { + fn update_with_key(&self, key: K, newval: V, ff: fn(K, V, V) -> V) + -> bool { /* match self.find(key) { None => return self.insert(key, val), @@ -311,7 +312,7 @@ pub mod chained { } } - fn update(key: K, newval: V, ff: fn(V, V) -> V) -> bool { + fn update(&self, key: K, newval: V, ff: fn(V, V) -> V) -> bool { return self.update_with_key(key, newval, |_k, v, v1| ff(v,v1)); } @@ -325,7 +326,7 @@ pub mod chained { } pub impl T { - fn to_writer(wr: io::Writer) { + fn to_writer(&self, wr: io::Writer) { if self.count == 0u { wr.write_str(~"{}"); return; diff --git a/src/libstd/std.rc b/src/libstd/std.rc index f29872bf387..a3b18e50df2 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -28,7 +28,7 @@ not required in or otherwise suitable for the core library. #[allow(vecs_implicitly_copyable)]; #[deny(non_camel_case_types)]; -#[allow(deprecated_self)]; +#[deny(deprecated_self)]; #[allow(deprecated_mutable_fields)]; #[no_core]; diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index e02d09954d3..6c8d719e5f5 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -99,7 +99,7 @@ fn new_sem_and_signal(count: int, num_condvars: uint) #[doc(hidden)] pub impl &self/Sem { - fn acquire() { + fn acquire(&self) { let mut waiter_nobe = None; unsafe { do (**self).with |state| { @@ -121,7 +121,7 @@ pub impl &self/Sem { let _ = comm::recv_one(option::unwrap(waiter_nobe)); } } - fn release() { + fn release(&self) { unsafe { do (**self).with |state| { state.count += 1; @@ -135,12 +135,12 @@ pub impl &self/Sem { // FIXME(#3154) move both copies of this into Sem, and unify the 2 structs #[doc(hidden)] pub impl &self/Sem<()> { - fn access(blk: fn() -> U) -> U { + fn access(&self, blk: fn() -> U) -> U { let mut release = None; unsafe { do task::unkillable { self.acquire(); - release = Some(SemRelease(self)); + release = Some(SemRelease(*self)); } } blk() @@ -148,12 +148,12 @@ pub impl &self/Sem<()> { } #[doc(hidden)] pub impl &self/Sem<~[Waitqueue]> { - fn access(blk: fn() -> U) -> U { + fn access(&self, blk: fn() -> U) -> U { let mut release = None; unsafe { do task::unkillable { self.acquire(); - release = Some(SemAndSignalRelease(self)); + release = Some(SemAndSignalRelease(*self)); } } blk() @@ -385,7 +385,7 @@ pub impl Semaphore { fn release(&self) { (&self.sem).release() } /// Run a function with ownership of one of the semaphore's resources. - fn access(blk: fn() -> U) -> U { (&self.sem).access(blk) } + fn access(&self, blk: fn() -> U) -> U { (&self.sem).access(blk) } } /**************************************************************************** diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 7a4da436d12..3801fdf8834 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -209,25 +209,25 @@ pub pure fn strftime(format: &str, tm: &Tm) -> ~str { pub impl Tm { /// Convert time to the seconds from January 1, 1970 - fn to_timespec() -> Timespec { + fn to_timespec(&self) -> Timespec { unsafe { let mut sec = 0i64; if self.tm_gmtoff == 0_i32 { - rustrt::rust_timegm(self, &mut sec); + rustrt::rust_timegm(*self, &mut sec); } else { - rustrt::rust_mktime(self, &mut sec); + rustrt::rust_mktime(*self, &mut sec); } Timespec::new(sec, self.tm_nsec) } } /// Convert time to the local timezone - fn to_local() -> Tm { + fn to_local(&self) -> Tm { at(self.to_timespec()) } /// Convert time to the UTC - fn to_utc() -> Tm { + fn to_utc(&self) -> Tm { at_utc(self.to_timespec()) } @@ -235,7 +235,7 @@ pub impl Tm { * Return a string of the current time in the form * "Thu Jan 1 00:00:00 1970". */ - pure fn ctime() -> ~str { self.strftime(~"%c") } + pure fn ctime(&self) -> ~str { self.strftime(~"%c") } /// Formats the time according to the format string. pure fn strftime(&self, format: &str) -> ~str { @@ -248,7 +248,7 @@ pub impl Tm { * local: "Thu, 22 Mar 2012 07:53:18 PST" * utc: "Thu, 22 Mar 2012 14:53:18 UTC" */ - pure fn rfc822() -> ~str { + pure fn rfc822(&self) -> ~str { if self.tm_gmtoff == 0_i32 { self.strftime(~"%a, %d %b %Y %T GMT") } else { @@ -262,7 +262,7 @@ pub impl Tm { * local: "Thu, 22 Mar 2012 07:53:18 -0700" * utc: "Thu, 22 Mar 2012 14:53:18 -0000" */ - pure fn rfc822z() -> ~str { + pure fn rfc822z(&self) -> ~str { self.strftime(~"%a, %d %b %Y %T %z") } @@ -272,7 +272,7 @@ pub impl Tm { * local: "2012-02-22T07:53:18-07:00" * utc: "2012-02-22T14:53:18Z" */ - pure fn rfc3339() -> ~str { + pure fn rfc3339(&self) -> ~str { if self.tm_gmtoff == 0_i32 { self.strftime(~"%Y-%m-%dT%H:%M:%SZ") } else { diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index e5435ca18b7..eac6e090f1f 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -200,7 +200,7 @@ struct Logger { } pub impl Logger { - fn info(i: &str) { + fn info(&self, i: &str) { io::println(~"workcache: " + i.to_owned()); } }