Skip to content

De-implicit-self libstd #5277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/libstd/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ pub impl<T:Const + Owned> RWARC<T> {
* Failing will unlock the ARC while unwinding. However, unlike all other
* access modes, this will not poison the ARC.
*/
fn read<U>(blk: fn(x: &T) -> U) -> U {
fn read<U>(&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);
Expand All @@ -360,7 +360,7 @@ pub impl<T:Const + Owned> RWARC<T> {
* }
* ~~~
*/
fn write_downgrade<U>(blk: fn(v: RWWriteMode<T>) -> U) -> U {
fn write_downgrade<U>(&self, blk: fn(v: RWWriteMode<T>) -> U) -> U {
unsafe {
let state = get_shared_mutable_state(&self.x);
do (*borrow_rwlock(state)).write_downgrade |write_mode| {
Expand All @@ -373,7 +373,7 @@ pub impl<T:Const + Owned> RWARC<T> {
}

/// To be called inside of the write_downgrade block.
fn downgrade(token: RWWriteMode/&a<T>) -> RWReadMode/&a<T> {
fn downgrade(&self, token: RWWriteMode/&a<T>) -> RWReadMode/&a<T> {
// 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;
Expand Down
16 changes: 8 additions & 8 deletions src/libstd/base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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+/"
);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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()
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/libstd/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ pub struct DuplexStream<T, U> {
#[cfg(stage1)]
#[cfg(stage2)]
pub impl<T:Owned,U:Owned> DuplexStream<T, U> {
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<U> {
fn try_recv(&self) -> Option<U> {
self.port.try_recv()
}
pure fn peek() -> bool {
pure fn peek(&self) -> bool {
self.port.peek()
}
}
Expand Down
42 changes: 21 additions & 21 deletions src/libstd/ebml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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!");
Expand All @@ -255,7 +255,7 @@ pub mod reader {
r_doc
}

fn push_doc<T>(d: Doc, f: fn() -> T) -> T {
fn push_doc<T>(&self, d: Doc, f: fn() -> T) -> T {
let old_parent = self.parent;
let old_pos = self.pos;
self.parent = d;
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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);
Expand All @@ -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));
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ priv enum FutureState<A> {

/// Methods on the `future` type
pub impl<A:Copy> Future<A> {
fn get() -> A {
fn get(&self) -> A {
//! Get the value of the future
*(self.get_ref())
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub impl BufReader {
}
}

priv fn as_bytes_reader<A>(f: &fn(&BytesReader) -> A) -> A {
priv fn as_bytes_reader<A>(&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 {
Expand Down
Loading