Skip to content

Commit 863bb1f

Browse files
committed
Make {Default, From, FromIterator, One, Zero} well-formed
Using these traits in an object context previously resulted in an RFC 1214 warning.
1 parent 525ab4a commit 863bb1f

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

src/libcore/convert.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub trait Into<T>: Sized {
9595
/// assert_eq!(string, other_string);
9696
/// ```
9797
#[stable(feature = "rust1", since = "1.0.0")]
98-
pub trait From<T> {
98+
pub trait From<T>: Sized {
9999
/// Performs the conversion.
100100
#[stable(feature = "rust1", since = "1.0.0")]
101101
fn from(T) -> Self;

src/libcore/default.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
7979
#![stable(feature = "rust1", since = "1.0.0")]
8080

81+
use marker::Sized;
82+
8183
/// A trait for giving a type a useful default value.
8284
///
8385
/// A struct can derive default implementations of `Default` for basic types using
@@ -93,7 +95,7 @@
9395
/// }
9496
/// ```
9597
#[stable(feature = "rust1", since = "1.0.0")]
96-
pub trait Default {
98+
pub trait Default: Sized {
9799
/// Returns the "default value" for a type.
98100
///
99101
/// Default values are often some kind of initial value, identity value, or anything else that

src/libcore/iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ impl<'a, I: Iterator + ?Sized> Iterator for &'a mut I {
14901490
#[stable(feature = "rust1", since = "1.0.0")]
14911491
#[rustc_on_unimplemented="a collection of type `{Self}` cannot be \
14921492
built from an iterator over elements of type `{A}`"]
1493-
pub trait FromIterator<A> {
1493+
pub trait FromIterator<A>: Sized {
14941494
/// Builds a container with elements from something iterable.
14951495
///
14961496
/// # Examples

src/libcore/num/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub mod diy_float;
5858
#[unstable(feature = "zero_one",
5959
reason = "unsure of placement, wants to use associated constants",
6060
issue = "27739")]
61-
pub trait Zero {
61+
pub trait Zero: Sized {
6262
/// The "zero" (usually, additive identity) for this type.
6363
fn zero() -> Self;
6464
}
@@ -70,7 +70,7 @@ pub trait Zero {
7070
#[unstable(feature = "zero_one",
7171
reason = "unsure of placement, wants to use associated constants",
7272
issue = "27739")]
73-
pub trait One {
73+
pub trait One: Sized {
7474
/// The "one" (usually, multiplicative identity) for this type.
7575
fn one() -> Self;
7676
}

0 commit comments

Comments
 (0)