Skip to content
Permalink
Browse files

Fix fallout from change, adding explicit `Sized` annotations where ne…

…cessary.
  • Loading branch information...
nikomatsakis committed Dec 18, 2014
1 parent 2f3cff6 commit d08a08ab82031b6f935bdaf160a28d9520ded1ab
@@ -25,7 +25,7 @@ use kinds::Sized;

/// A common trait for cloning an object.
#[stable]
pub trait Clone {
pub trait Clone : Sized {
/// Returns a copy of the value.
#[stable]
fn clone(&self) -> Self;
@@ -74,7 +74,40 @@ pub trait FormatWriter {
///
/// This method should generally not be invoked manually, but rather through
/// the `write!` macro itself.
fn write_fmt(&mut self, args: &Arguments) -> Result { write(self, args) }
fn write_fmt(&mut self, args: &Arguments) -> Result {
// This Adapter is needed to allow `self` (of type `&mut
// Self`) to be cast to a FormatWriter (below) without
// requiring a `Sized` bound.
struct Adapter<'a,Sized? T:'a>(&'a mut T);

#[cfg(stage0)]
impl<'a,T> FormatWriter for Adapter<'a, T>
where T: FormatWriter
{
fn write(&mut self, bytes: &[u8]) -> Result {
self.0.write(bytes)
}

fn write_fmt(&mut self, args: &Arguments) -> Result {
self.0.write_fmt(args)
}
}

#[cfg(not(stage0))]
impl<'a, Sized? T> FormatWriter for Adapter<'a, T>
where T: FormatWriter
{
fn write(&mut self, bytes: &[u8]) -> Result {
self.0.write(bytes)
}

fn write_fmt(&mut self, args: &Arguments) -> Result {
self.0.write_fmt(args)
}
}

write(&mut Adapter(self), args)
}
}

/// A struct to represent both where to emit formatting strings to and how they
@@ -94,7 +94,7 @@ pub trait Extend<A> {
/// else.
#[lang="iterator"]
#[unstable = "just split up for object safety"]
pub trait Iterator<A> {
pub trait Iterator<A> : ::kinds::Sized {
/// Advance the iterator and return the next value. Return `None` when the end is reached.
fn next(&mut self) -> Option<A>;

@@ -982,7 +982,7 @@ impl_to_primitive_float! { f64 }

/// A generic trait for converting a number to a value.
#[experimental = "trait is likely to be removed"]
pub trait FromPrimitive {
pub trait FromPrimitive : ::kinds::Sized {
/// Convert an `int` to return an optional value of this type. If the
/// value cannot be represented by this value, the `None` is returned.
#[inline]
@@ -52,14 +52,14 @@ pub mod reseeding;
mod rand_impls;

/// A type that can be randomly generated using an `Rng`.
pub trait Rand {
pub trait Rand : Sized {
/// Generates a random instance of this type using the specified source of
/// randomness.
fn rand<R: Rng>(rng: &mut R) -> Self;
}

/// A random number generator.
pub trait Rng {
pub trait Rng : Sized {
/// Return the next random u32.
///
/// This rarely needs to be called directly, prefer `r.gen()` to
@@ -56,7 +56,7 @@ use syntax::ast;
use syntax::abi;
use syntax::codemap::Span;

pub trait Combine<'tcx> {
pub trait Combine<'tcx> : Sized {
fn infcx<'a>(&'a self) -> &'a InferCtxt<'a, 'tcx>;
fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.infcx().tcx }
fn tag(&self) -> String;
@@ -537,7 +537,7 @@ impl<'a,T> Iterator<(ParamSpace, uint, &'a T)> for EnumeratedItems<'a,T> {
// `foo`. Or use `foo.subst_spanned(tcx, substs, Some(span))` when
// there is more information available (for better errors).

pub trait Subst<'tcx> {
pub trait Subst<'tcx> : Sized {
fn subst(&self, tcx: &ty::ctxt<'tcx>, substs: &Substs<'tcx>) -> Self {
self.subst_spanned(tcx, substs, None)
}
@@ -56,7 +56,7 @@ pub trait TypeFoldable<'tcx> {
/// default implementation that does an "identity" fold. Within each
/// identity fold, it should invoke `foo.fold_with(self)` to fold each
/// sub-item.
pub trait TypeFolder<'tcx> {
pub trait TypeFolder<'tcx> : Sized {
fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>;

/// Invoked by the `super_*` routines when we enter a region
@@ -129,7 +129,7 @@ impl PpSourceMode {
}
}

trait PrinterSupport<'ast>: pprust::PpAnn {
trait PrinterSupport<'ast>: pprust::PpAnn + Sized {
/// Provides a uniform interface for re-extracting a reference to a
/// `Session` from a value that now owns it.
fn sess<'a>(&'a self) -> &'a Session;
@@ -12,7 +12,7 @@ use clean::*;
use std::iter::Extend;
use std::mem::{replace, swap};

pub trait DocFolder {
pub trait DocFolder : Sized {
fn fold_item(&mut self, item: Item) -> Option<Item> {
self.fold_item_recur(item)
}
@@ -249,7 +249,7 @@ impl AsciiCast<Ascii> for char {

/// Trait for copyless casting to an ascii vector.
#[experimental = "may be replaced by generic conversion traits"]
pub trait OwnedAsciiCast {
pub trait OwnedAsciiCast : Sized {
/// Check if convertible to ascii
fn is_ascii(&self) -> bool;

@@ -232,6 +232,7 @@ use error::{FromError, Error};
use fmt;
use int;
use iter::{Iterator, IteratorExt};
use kinds::Sized;
use mem::transmute;
use ops::{BitOr, BitXor, BitAnd, Sub, Not, FnOnce};
use option::Option;
@@ -1029,11 +1030,25 @@ pub trait Writer {
fn write_fmt(&mut self, fmt: &fmt::Arguments) -> IoResult<()> {
// Create a shim which translates a Writer to a FormatWriter and saves
// off I/O errors. instead of discarding them
struct Adaptor<'a, T:'a> {
struct Adaptor<'a, Sized? T:'a> {
inner: &'a mut T,
error: IoResult<()>,
}

#[cfg(not(stage0))]
impl<'a, Sized? T: Writer> fmt::FormatWriter for Adaptor<'a, T> {
fn write(&mut self, bytes: &[u8]) -> fmt::Result {
match self.inner.write(bytes) {
Ok(()) => Ok(()),
Err(e) => {
self.error = Err(e);
Err(fmt::Error)
}
}
}
}

#[cfg(stage0)]
impl<'a, T: Writer> fmt::FormatWriter for Adaptor<'a, T> {
fn write(&mut self, bytes: &[u8]) -> fmt::Result {
match self.inner.write(bytes) {
@@ -1627,16 +1642,24 @@ pub trait Acceptor<T> {
/// `Some`. The `Some` contains the `IoResult` representing whether the
/// connection attempt was successful. A successful connection will be wrapped
/// in `Ok`. A failed connection is represented as an `Err`.
pub struct IncomingConnections<'a, A:'a> {
pub struct IncomingConnections<'a, Sized? A:'a> {
inc: &'a mut A,
}

#[cfg(stage0)]
impl<'a, T, A: Acceptor<T>> Iterator<IoResult<T>> for IncomingConnections<'a, A> {
fn next(&mut self) -> Option<IoResult<T>> {
Some(self.inc.accept())
}
}

#[cfg(not(stage0))]
impl<'a, T, Sized? A: Acceptor<T>> Iterator<IoResult<T>> for IncomingConnections<'a, A> {
fn next(&mut self) -> Option<IoResult<T>> {
Some(self.inc.accept())
}
}

/// Creates a standard error for a commonly used flavor of error. The `detail`
/// field of the returned error will always be `None`.
///
@@ -53,7 +53,7 @@ impl<T> MoveMap<T> for OwnedSlice<T> {
}
}

pub trait Folder {
pub trait Folder : Sized {
// Any additions to this trait should happen in form
// of a call to a public `noop_*` function that only calls
// out to the folder again, not other `noop_*` functions.
@@ -54,8 +54,7 @@ pub enum FnKind<'a> {
/// explicitly, you need to override each method. (And you also need
/// to monitor future changes to `Visitor` in case a new method with a
/// new default implementation gets introduced.)
pub trait Visitor<'v> {

pub trait Visitor<'v> : Sized {
fn visit_name(&mut self, _span: Span, _name: Name) {
// Nothing to do.
}

0 comments on commit d08a08a

Please sign in to comment.
You can’t perform that action at this time.