Skip to content

Commit 1b3734f

Browse files
committed
Fix fallout from change, adding explicit Sized annotations where necessary.
1 parent 1f887c8 commit 1b3734f

File tree

14 files changed

+62
-20
lines changed

14 files changed

+62
-20
lines changed

src/libcore/clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use kinds::Sized;
2525

2626
/// A common trait for cloning an object.
2727
#[stable]
28-
pub trait Clone {
28+
pub trait Clone : Sized {
2929
/// Returns a copy of the value.
3030
#[stable]
3131
fn clone(&self) -> Self;

src/libcore/fmt/mod.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,26 @@ pub trait FormatWriter {
7474
///
7575
/// This method should generally not be invoked manually, but rather through
7676
/// the `write!` macro itself.
77-
fn write_fmt(&mut self, args: Arguments) -> Result { write(self, args) }
77+
fn write_fmt(&mut self, args: Arguments) -> Result {
78+
// This Adapter is needed to allow `self` (of type `&mut
79+
// Self`) to be cast to a FormatWriter (below) without
80+
// requiring a `Sized` bound.
81+
struct Adapter<'a,Sized? T:'a>(&'a mut T);
82+
83+
impl<'a, Sized? T> FormatWriter for Adapter<'a, T>
84+
where T: FormatWriter
85+
{
86+
fn write(&mut self, bytes: &[u8]) -> Result {
87+
self.0.write(bytes)
88+
}
89+
90+
fn write_fmt(&mut self, args: Arguments) -> Result {
91+
self.0.write_fmt(args)
92+
}
93+
}
94+
95+
write(&mut Adapter(self), args)
96+
}
7897
}
7998

8099
/// A struct to represent both where to emit formatting strings to and how they

src/libcore/iter.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ use num::{ToPrimitive, Int};
6565
use ops::{Add, Deref, FnMut};
6666
use option::Option;
6767
use option::Option::{Some, None};
68+
use std::kinds::Sized;
6869
use uint;
6970

7071
#[deprecated = "renamed to Extend"] pub use self::Extend as Extendable;
@@ -109,7 +110,7 @@ pub trait Extend<A> {
109110

110111
#[unstable = "new convention for extension traits"]
111112
/// An extension trait providing numerous methods applicable to all iterators.
112-
pub trait IteratorExt<A>: Iterator<A> {
113+
pub trait IteratorExt<A>: Iterator<A> + Sized {
113114
/// Chain this iterator with another, returning a new iterator that will
114115
/// finish iterating over the current iterator, and then iterate
115116
/// over the other specified iterator.
@@ -692,7 +693,7 @@ impl<A, I> IteratorExt<A> for I where I: Iterator<A> {}
692693

693694
/// Extention trait for iterators of pairs.
694695
#[unstable = "newly added trait, likely to be merged with IteratorExt"]
695-
pub trait IteratorPairExt<A, B>: Iterator<(A, B)> {
696+
pub trait IteratorPairExt<A, B>: Iterator<(A, B)> + Sized {
696697
/// Converts an iterator of pairs into a pair of containers.
697698
///
698699
/// Loops through the entire iterator, collecting the first component of
@@ -738,7 +739,7 @@ pub trait DoubleEndedIterator<A>: Iterator<A> {
738739

739740
/// Extension methods for double-ended iterators.
740741
#[unstable = "new extension trait convention"]
741-
pub trait DoubleEndedIteratorExt<A>: DoubleEndedIterator<A> {
742+
pub trait DoubleEndedIteratorExt<A>: DoubleEndedIterator<A> + Sized {
742743
/// Change the direction of the iterator
743744
///
744745
/// The flipped iterator swaps the ends on an iterator that can already

src/libcore/num/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ impl_to_primitive_float! { f64 }
980980

981981
/// A generic trait for converting a number to a value.
982982
#[experimental = "trait is likely to be removed"]
983-
pub trait FromPrimitive {
983+
pub trait FromPrimitive : ::kinds::Sized {
984984
/// Convert an `int` to return an optional value of this type. If the
985985
/// value cannot be represented by this value, the `None` is returned.
986986
#[inline]

src/libcore/ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ use mem;
9292
use clone::Clone;
9393
use intrinsics;
9494
use option::Option::{mod, Some, None};
95-
use kinds::{Send, Sync};
95+
use kinds::{Send, Sized, Sync};
9696

9797
use cmp::{PartialEq, Eq, Ord, PartialOrd, Equiv};
9898
use cmp::Ordering::{mod, Less, Equal, Greater};
@@ -243,7 +243,7 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
243243

244244
/// Methods on raw pointers
245245
#[stable]
246-
pub trait PtrExt<T> {
246+
pub trait PtrExt<T> : Sized {
247247
/// Returns the null pointer.
248248
#[deprecated = "call ptr::null instead"]
249249
fn null() -> Self;

src/librand/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ pub mod reseeding;
5252
mod rand_impls;
5353

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

6161
/// A random number generator.
62-
pub trait Rng {
62+
pub trait Rng : Sized {
6363
/// Return the next random u32.
6464
///
6565
/// This rarely needs to be called directly, prefer `r.gen()` to

src/librustc/middle/infer/combine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use syntax::ast;
5757
use syntax::abi;
5858
use syntax::codemap::Span;
5959

60-
pub trait Combine<'tcx> {
60+
pub trait Combine<'tcx> : Sized {
6161
fn infcx<'a>(&'a self) -> &'a InferCtxt<'a, 'tcx>;
6262
fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.infcx().tcx }
6363
fn tag(&self) -> String;

src/librustc/middle/subst.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ impl<'a,T> Iterator<(ParamSpace, uint, &'a T)> for EnumeratedItems<'a,T> {
519519
// `foo`. Or use `foo.subst_spanned(tcx, substs, Some(span))` when
520520
// there is more information available (for better errors).
521521

522-
pub trait Subst<'tcx> {
522+
pub trait Subst<'tcx> : Sized {
523523
fn subst(&self, tcx: &ty::ctxt<'tcx>, substs: &Substs<'tcx>) -> Self {
524524
self.subst_spanned(tcx, substs, None)
525525
}

src/librustc/middle/ty_fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub trait TypeFoldable<'tcx> {
5656
/// default implementation that does an "identity" fold. Within each
5757
/// identity fold, it should invoke `foo.fold_with(self)` to fold each
5858
/// sub-item.
59-
pub trait TypeFolder<'tcx> {
59+
pub trait TypeFolder<'tcx> : Sized {
6060
fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>;
6161

6262
/// Invoked by the `super_*` routines when we enter a region

src/librustc_driver/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl PpSourceMode {
141141
}
142142
}
143143

144-
trait PrinterSupport<'ast>: pprust::PpAnn {
144+
trait PrinterSupport<'ast>: pprust::PpAnn + Sized {
145145
/// Provides a uniform interface for re-extracting a reference to a
146146
/// `Session` from a value that now owns it.
147147
fn sess<'a>(&'a self) -> &'a Session;

src/librustdoc/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use clean::*;
1212
use std::iter::Extend;
1313
use std::mem::{replace, swap};
1414

15-
pub trait DocFolder {
15+
pub trait DocFolder : Sized {
1616
fn fold_item(&mut self, item: Item) -> Option<Item> {
1717
self.fold_item_recur(item)
1818
}

src/libstd/io/mod.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ use error::{FromError, Error};
232232
use fmt;
233233
use int;
234234
use iter::{Iterator, IteratorExt};
235+
use kinds::Sized;
235236
use mem::transmute;
236237
use ops::{BitOr, BitXor, BitAnd, Sub, Not, FnOnce};
237238
use option::Option;
@@ -1030,11 +1031,25 @@ pub trait Writer {
10301031
fn write_fmt(&mut self, fmt: fmt::Arguments) -> IoResult<()> {
10311032
// Create a shim which translates a Writer to a FormatWriter and saves
10321033
// off I/O errors. instead of discarding them
1033-
struct Adaptor<'a, T:'a> {
1034+
struct Adaptor<'a, Sized? T:'a> {
10341035
inner: &'a mut T,
10351036
error: IoResult<()>,
10361037
}
10371038

1039+
#[cfg(not(stage0))]
1040+
impl<'a, Sized? T: Writer> fmt::FormatWriter for Adaptor<'a, T> {
1041+
fn write(&mut self, bytes: &[u8]) -> fmt::Result {
1042+
match self.inner.write(bytes) {
1043+
Ok(()) => Ok(()),
1044+
Err(e) => {
1045+
self.error = Err(e);
1046+
Err(fmt::Error)
1047+
}
1048+
}
1049+
}
1050+
}
1051+
1052+
#[cfg(stage0)]
10381053
impl<'a, T: Writer> fmt::FormatWriter for Adaptor<'a, T> {
10391054
fn write(&mut self, bytes: &[u8]) -> fmt::Result {
10401055
match self.inner.write(bytes) {
@@ -1629,16 +1644,24 @@ pub trait Acceptor<T> {
16291644
/// `Some`. The `Some` contains the `IoResult` representing whether the
16301645
/// connection attempt was successful. A successful connection will be wrapped
16311646
/// in `Ok`. A failed connection is represented as an `Err`.
1632-
pub struct IncomingConnections<'a, A:'a> {
1647+
pub struct IncomingConnections<'a, Sized? A:'a> {
16331648
inc: &'a mut A,
16341649
}
16351650

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

1658+
#[cfg(not(stage0))]
1659+
impl<'a, T, Sized? A: Acceptor<T>> Iterator<IoResult<T>> for IncomingConnections<'a, A> {
1660+
fn next(&mut self) -> Option<IoResult<T>> {
1661+
Some(self.inc.accept())
1662+
}
1663+
}
1664+
16421665
/// Creates a standard error for a commonly used flavor of error. The `detail`
16431666
/// field of the returned error will always be `None`.
16441667
///

src/libsyntax/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<T> MoveMap<T> for OwnedSlice<T> {
5353
}
5454
}
5555

56-
pub trait Folder {
56+
pub trait Folder : Sized {
5757
// Any additions to this trait should happen in form
5858
// of a call to a public `noop_*` function that only calls
5959
// out to the folder again, not other `noop_*` functions.

src/libsyntax/visit.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ pub enum FnKind<'a> {
5454
/// explicitly, you need to override each method. (And you also need
5555
/// to monitor future changes to `Visitor` in case a new method with a
5656
/// new default implementation gets introduced.)
57-
pub trait Visitor<'v> {
58-
57+
pub trait Visitor<'v> : Sized {
5958
fn visit_name(&mut self, _span: Span, _name: Name) {
6059
// Nothing to do.
6160
}

0 commit comments

Comments
 (0)