Change extensions traits to blanket impls
This commit is contained in:
parent
c48a1ab158
commit
dd2a1e3469
@ -619,14 +619,15 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
|
|||||||
|
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
|
|
||||||
// It is illegal to invoke a method on a trait instance that
|
// It is illegal to create a trait object with methods which includes
|
||||||
// refers to the `Self` type. An error will be reported by
|
// the Self type. An error will be reported when we coerce to a trait
|
||||||
// `enforce_object_limitations()` if the method refers to the
|
// object if the method refers to the `Self` type. Substituting ty_err
|
||||||
// `Self` type anywhere other than the receiver. Here, we use
|
// here allows compiler to soldier on.
|
||||||
// a substitution that replaces `Self` with the object type
|
//
|
||||||
// itself. Hence, a `&self` method will wind up with an
|
// `confirm_candidate()` also relies upon this substitution
|
||||||
// argument type like `&Trait`.
|
// for Self. (fix)
|
||||||
let rcvr_substs = substs.with_self_ty(self_ty);
|
let rcvr_substs = substs.with_self_ty(ty::mk_err());
|
||||||
|
|
||||||
let trait_ref = Rc::new(TraitRef {
|
let trait_ref = Rc::new(TraitRef {
|
||||||
def_id: did,
|
def_id: did,
|
||||||
substs: rcvr_substs.clone()
|
substs: rcvr_substs.clone()
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
use cmp;
|
use cmp;
|
||||||
use collections::Collection;
|
use collections::Collection;
|
||||||
use io::{Reader, Writer, Stream, Buffer, DEFAULT_BUF_SIZE, IoResult, AsRefReader};
|
use io::{Reader, Writer, Stream, Buffer, DEFAULT_BUF_SIZE, IoResult};
|
||||||
use iter::ExactSize;
|
use iter::ExactSize;
|
||||||
use ops::Drop;
|
use ops::Drop;
|
||||||
use option::{Some, None, Option};
|
use option::{Some, None, Option};
|
||||||
@ -118,8 +118,6 @@ impl<R: Reader> Reader for BufferedReader<R> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R: Reader> AsRefReader for BufferedReader<R> {}
|
|
||||||
|
|
||||||
/// Wraps a Writer and buffers output to it
|
/// Wraps a Writer and buffers output to it
|
||||||
///
|
///
|
||||||
/// It can be excessively inefficient to work directly with a `Writer`. For
|
/// It can be excessively inefficient to work directly with a `Writer`. For
|
||||||
|
@ -189,7 +189,6 @@ mod test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl BytesReader for InitialZeroByteReader {}
|
|
||||||
|
|
||||||
struct EofReader;
|
struct EofReader;
|
||||||
|
|
||||||
@ -198,7 +197,6 @@ mod test {
|
|||||||
Err(io::standard_error(io::EndOfFile))
|
Err(io::standard_error(io::EndOfFile))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl BytesReader for EofReader {}
|
|
||||||
|
|
||||||
struct ErroringReader;
|
struct ErroringReader;
|
||||||
|
|
||||||
@ -207,7 +205,6 @@ mod test {
|
|||||||
Err(io::standard_error(io::InvalidInput))
|
Err(io::standard_error(io::InvalidInput))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl BytesReader for ErroringReader {}
|
|
||||||
|
|
||||||
struct PartialReader {
|
struct PartialReader {
|
||||||
count: int,
|
count: int,
|
||||||
|
@ -17,7 +17,7 @@ use collections::Collection;
|
|||||||
use option::None;
|
use option::None;
|
||||||
use result::{Err, Ok};
|
use result::{Err, Ok};
|
||||||
use io;
|
use io;
|
||||||
use io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult, AsRefReader, AsRefWriter};
|
use io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult};
|
||||||
use slice;
|
use slice;
|
||||||
use slice::AsSlice;
|
use slice::AsSlice;
|
||||||
use vec::Vec;
|
use vec::Vec;
|
||||||
@ -97,8 +97,6 @@ impl Writer for MemWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRefWriter for MemWriter {}
|
|
||||||
|
|
||||||
/// Reads from an owned byte vector
|
/// Reads from an owned byte vector
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
@ -165,8 +163,6 @@ impl Reader for MemReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRefReader for MemReader {}
|
|
||||||
|
|
||||||
impl Seek for MemReader {
|
impl Seek for MemReader {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn tell(&self) -> IoResult<u64> { Ok(self.pos as u64) }
|
fn tell(&self) -> IoResult<u64> { Ok(self.pos as u64) }
|
||||||
@ -313,8 +309,6 @@ impl<'a> Reader for BufReader<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AsRefReader for BufReader<'a> {}
|
|
||||||
|
|
||||||
impl<'a> Seek for BufReader<'a> {
|
impl<'a> Seek for BufReader<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn tell(&self) -> IoResult<u64> { Ok(self.pos as u64) }
|
fn tell(&self) -> IoResult<u64> { Ok(self.pos as u64) }
|
||||||
|
@ -929,13 +929,17 @@ pub trait AsRefReader {
|
|||||||
///
|
///
|
||||||
/// This is useful to allow applying adaptors while still
|
/// This is useful to allow applying adaptors while still
|
||||||
/// retaining ownership of the original value.
|
/// retaining ownership of the original value.
|
||||||
fn by_ref<'a>(&'a mut self) -> RefReader<'a, Self> {
|
fn by_ref<'a>(&'a mut self) -> RefReader<'a, Self>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Reader> AsRefReader for T {
|
||||||
|
fn by_ref<'a>(&'a mut self) -> RefReader<'a, T> {
|
||||||
RefReader { inner: self }
|
RefReader { inner: self }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A reader which can be converted to bytes.
|
/// A reader which can be converted to bytes.
|
||||||
pub trait BytesReader: Reader {
|
pub trait BytesReader {
|
||||||
/// Create an iterator that reads a single byte on
|
/// Create an iterator that reads a single byte on
|
||||||
/// each iteration, until EOF.
|
/// each iteration, until EOF.
|
||||||
///
|
///
|
||||||
@ -943,7 +947,11 @@ pub trait BytesReader: Reader {
|
|||||||
///
|
///
|
||||||
/// Any error other than `EndOfFile` that is produced by the underlying Reader
|
/// Any error other than `EndOfFile` that is produced by the underlying Reader
|
||||||
/// is returned by the iterator and should be handled by the caller.
|
/// is returned by the iterator and should be handled by the caller.
|
||||||
fn bytes<'r>(&'r mut self) -> extensions::Bytes<'r, Self> {
|
fn bytes<'r>(&'r mut self) -> extensions::Bytes<'r, Self>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Reader> BytesReader for T {
|
||||||
|
fn bytes<'r>(&'r mut self) -> extensions::Bytes<'r, T> {
|
||||||
extensions::Bytes::new(self)
|
extensions::Bytes::new(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1284,7 +1292,11 @@ pub trait AsRefWriter {
|
|||||||
/// This is useful to allow applying wrappers while still
|
/// This is useful to allow applying wrappers while still
|
||||||
/// retaining ownership of the original value.
|
/// retaining ownership of the original value.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn by_ref<'a>(&'a mut self) -> RefWriter<'a, Self> {
|
fn by_ref<'a>(&'a mut self) -> RefWriter<'a, Self>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Writer> AsRefWriter for T {
|
||||||
|
fn by_ref<'a>(&'a mut self) -> RefWriter<'a, T> {
|
||||||
RefWriter { inner: self }
|
RefWriter { inner: self }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user