Skip to content

Commit be138ed

Browse files
committed
Add #[rustc_on_unimplemented] annotations to more traits
1 parent 5d2056a commit be138ed

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/libcore/fmt/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ pub trait Show {
243243
/// Format trait for the `:?` format. Useful for debugging, most all types
244244
/// should implement this.
245245
#[unstable = "I/O and core have yet to be reconciled"]
246+
#[rustc_on_unimplemented = "`{Self}` cannot be formatted using `:?`; if it is defined in your \
247+
crate, add `#[derive(Debug)]` or manually implement it"]
246248
pub trait Debug {
247249
/// Formats the value using the given formatter.
248250
fn fmt(&self, &mut Formatter) -> Result;
@@ -266,6 +268,8 @@ pub trait String {
266268
/// When a value can be semantically expressed as a String, this trait may be
267269
/// used. It corresponds to the default format, `{}`.
268270
#[unstable = "I/O and core have yet to be reconciled"]
271+
#[rustc_on_unimplemented = "`{Self}` cannot be formatted with the default formatter; try using \
272+
`:?` instead if you are using a format string"]
269273
pub trait Display {
270274
/// Formats the value using the given formatter.
271275
fn fmt(&self, &mut Formatter) -> Result;

src/libcore/iter.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ use uint;
8282
/// else.
8383
#[lang="iterator"]
8484
#[stable]
85+
#[rustc_on_unimplemented = "`{Self}` is not an iterator; maybe try calling `.iter()` or a similar \
86+
method"]
8587
pub trait Iterator {
8688
#[stable]
8789
type Item;

src/libcore/marker.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ use clone::Clone;
3030
/// Types able to be transferred across task boundaries.
3131
#[unstable = "will be overhauled with new lifetime rules; see RFC 458"]
3232
#[lang="send"]
33+
#[rustc_on_unimplemented = "`{Self}` cannot be sent between threads safely"]
3334
pub unsafe trait Send: 'static {
3435
// empty.
3536
}
3637

3738
/// Types with a constant size known at compile-time.
3839
#[stable]
3940
#[lang="sized"]
41+
#[rustc_on_unimplemented = "`{Self}` does not have a constant size known at compile-time"]
4042
pub trait Sized {
4143
// Empty.
4244
}
@@ -193,6 +195,7 @@ pub trait Copy {
193195
/// `transmute`-ing from `&T` to `&mut T` is illegal).
194196
#[unstable = "will be overhauled with new lifetime rules; see RFC 458"]
195197
#[lang="sync"]
198+
#[rustc_on_unimplemented = "`{Self}` cannot be shared between threads safely"]
196199
pub unsafe trait Sync {
197200
// Empty
198201
}

0 commit comments

Comments
 (0)