]> git.lizzy.rs Git - rust.git/commitdiff
Fix fallout from change, adding explicit `Sized` annotations where necessary.
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 18 Dec 2014 20:27:41 +0000 (15:27 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Fri, 2 Jan 2015 17:06:59 +0000 (12:06 -0500)
14 files changed:
src/libcore/clone.rs
src/libcore/fmt/mod.rs
src/libcore/iter.rs
src/libcore/num/mod.rs
src/libcore/ptr.rs
src/librand/lib.rs
src/librustc/middle/infer/combine.rs
src/librustc/middle/subst.rs
src/librustc/middle/ty_fold.rs
src/librustc_driver/pretty.rs
src/librustdoc/fold.rs
src/libstd/io/mod.rs
src/libsyntax/fold.rs
src/libsyntax/visit.rs

index 5d84d0c7797ecfe5e20be75223be58fc107e0963..159c2a505d51b89c1b06b062b4b7d6ab70e41872 100644 (file)
@@ -25,7 +25,7 @@
 
 /// 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;
index 87fcb12e29f9c95ddc442e94899f7f1dd7d47890..43f0d72eeba9219a5fa80daa36f60035afa2f8af 100644 (file)
@@ -74,7 +74,26 @@ 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);
+
+        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
index 7c53503b1ceb7ef4688756c9f74642c8c8914df3..229777f68431160e148e5d73a4e2b1db5107ecfc 100644 (file)
@@ -65,6 +65,7 @@
 use ops::{Add, Deref, FnMut};
 use option::Option;
 use option::Option::{Some, None};
+use std::kinds::Sized;
 use uint;
 
 #[deprecated = "renamed to Extend"] pub use self::Extend as Extendable;
@@ -109,7 +110,7 @@ pub trait Extend<A> {
 
 #[unstable = "new convention for extension traits"]
 /// An extension trait providing numerous methods applicable to all iterators.
-pub trait IteratorExt<A>: Iterator<A> {
+pub trait IteratorExt<A>: Iterator<A> + Sized {
     /// Chain this iterator with another, returning a new iterator that will
     /// finish iterating over the current iterator, and then iterate
     /// over the other specified iterator.
@@ -692,7 +693,7 @@ impl<A, I> IteratorExt<A> for I where I: Iterator<A> {}
 
 /// Extention trait for iterators of pairs.
 #[unstable = "newly added trait, likely to be merged with IteratorExt"]
-pub trait IteratorPairExt<A, B>: Iterator<(A, B)> {
+pub trait IteratorPairExt<A, B>: Iterator<(A, B)> + Sized {
     /// Converts an iterator of pairs into a pair of containers.
     ///
     /// Loops through the entire iterator, collecting the first component of
@@ -738,7 +739,7 @@ pub trait DoubleEndedIterator<A>: Iterator<A> {
 
 /// Extension methods for double-ended iterators.
 #[unstable = "new extension trait convention"]
-pub trait DoubleEndedIteratorExt<A>: DoubleEndedIterator<A> {
+pub trait DoubleEndedIteratorExt<A>: DoubleEndedIterator<A> + Sized {
     /// Change the direction of the iterator
     ///
     /// The flipped iterator swaps the ends on an iterator that can already
index 0d2ce4f60718f8faba2e1a961c3e0c9cf8dc2fae..d16478dd6cc7ee290f5187dabff5905c3f9de72f 100644 (file)
@@ -980,7 +980,7 @@ fn to_f64(&self) -> Option<f64> { impl_to_primitive_float_to_float!($T, f64, *se
 
 /// 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]
index faf1d781465c76457b4d08ef731a0cd58fcec2c3..38e47a5ad334e92acd22f83c1ed9b045268103d0 100644 (file)
@@ -92,7 +92,7 @@
 use clone::Clone;
 use intrinsics;
 use option::Option::{mod, Some, None};
-use kinds::{Send, Sync};
+use kinds::{Send, Sized, Sync};
 
 use cmp::{PartialEq, Eq, Ord, PartialOrd, Equiv};
 use cmp::Ordering::{mod, Less, Equal, Greater};
@@ -243,7 +243,7 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
 
 /// Methods on raw pointers
 #[stable]
-pub trait PtrExt<T> {
+pub trait PtrExt<T> : Sized {
     /// Returns the null pointer.
     #[deprecated = "call ptr::null instead"]
     fn null() -> Self;
index 568d245911826cbe0a38bdc939515eb007646bf2..bbcd99afdea9331330a1349e565f19964ada79f4 100644 (file)
 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
index e0bcdfc6d8d9375627b5702d13e4411349553548..ab6f6b601f6d039c4afbee04ec68dd5e0cb5d802 100644 (file)
@@ -57,7 +57,7 @@
 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;
index 3c5459ff3bc754cf19a7032e540359978c418d82..97e74b9f6bbb9ecb8987db0c2534da9a5ba10e32 100644 (file)
@@ -519,7 +519,7 @@ fn next(&mut self) -> Option<(ParamSpace, uint, &'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)
     }
index 83d2f6fb0e6d58909000c0c6171ea414a8f648f9..7b13bea7d79c7093fec3a9eeece7b4c77f9762ab 100644 (file)
@@ -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
index 773ea30d401fc361fdcb422017fd119983609875..a89292cfacbbbb1a5f0033ff7e8546c2c8efb6da 100644 (file)
@@ -141,7 +141,7 @@ fn call_with_pp_support<'tcx, A, B, F>(&self,
     }
 }
 
-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;
index 5623c0f0e535fb880b704cde3d6aeb8c91b9e12a..4f277cc868a1a04873ed3abbcbc2a04e57e689ae 100644 (file)
@@ -12,7 +12,7 @@
 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)
     }
index e8b852ee492b95c02e42ae4bc47daf4bf7d19449..cc8a67249d4cfe6fbe12fc585abcd6f0e04d50b0 100644 (file)
 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;
@@ -1030,11 +1031,25 @@ fn flush(&mut self) -> IoResult<()> { Ok(()) }
     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) {
@@ -1629,16 +1644,24 @@ fn incoming<'r>(&'r mut self) -> IncomingConnections<'r, Self> {
 /// `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`.
 ///
index 4f0169e31f2293ff65c26e55a845a8d80b612813..5234837a456c810c909bc34a15922d8332074a47 100644 (file)
@@ -53,7 +53,7 @@ fn move_map<F>(self, f: F) -> OwnedSlice<T> where F: FnMut(T) -> 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.
index 40ca6354ca6d14d114378799746d40b2de55527c..0b4a1fbdd2294634954a3a65a88f27c6c0119fc3 100644 (file)
@@ -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.
     }