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;

0 commit comments

Comments
 (0)