]> git.lizzy.rs Git - rust.git/commitdiff
Add `#[rustc_on_unimplemented]` annotations to more traits
authorP1start <rewi-github@whanau.org>
Tue, 20 Jan 2015 22:04:17 +0000 (11:04 +1300)
committerP1start <rewi-github@whanau.org>
Thu, 22 Jan 2015 09:22:04 +0000 (22:22 +1300)
src/libcore/fmt/mod.rs
src/libcore/iter.rs
src/libcore/marker.rs

index 0e8d31a62eed99f3c0cbab5a048d903ea4020327..60403d1c0117988e0c278429af58f5839c154c00 100644 (file)
@@ -243,6 +243,8 @@ pub trait Show {
 /// Format trait for the `:?` format. Useful for debugging, most all types
 /// should implement this.
 #[unstable = "I/O and core have yet to be reconciled"]
+#[rustc_on_unimplemented = "`{Self}` cannot be formatted using `:?`; if it is defined in your \
+                            crate, add `#[derive(Debug)]` or manually implement it"]
 pub trait Debug {
     /// Formats the value using the given formatter.
     fn fmt(&self, &mut Formatter) -> Result;
@@ -266,6 +268,8 @@ pub trait String {
 /// When a value can be semantically expressed as a String, this trait may be
 /// used. It corresponds to the default format, `{}`.
 #[unstable = "I/O and core have yet to be reconciled"]
+#[rustc_on_unimplemented = "`{Self}` cannot be formatted with the default formatter; try using \
+                            `:?` instead if you are using a format string"]
 pub trait Display {
     /// Formats the value using the given formatter.
     fn fmt(&self, &mut Formatter) -> Result;
index 773ac99b0dee2ff803f85430105c4a1c20596218..c31ad56fe5bab4e3f33001f6c27f4f30eec9ae9c 100644 (file)
@@ -82,6 +82,8 @@
 /// else.
 #[lang="iterator"]
 #[stable]
+#[rustc_on_unimplemented = "`{Self}` is not an iterator; maybe try calling `.iter()` or a similar \
+                            method"]
 pub trait Iterator {
     #[stable]
     type Item;
index a987a0a5068a887341e585b5da5c31f35c1bf7d8..f32552f300cc22eef7fbcd6017bbb679892eb034 100644 (file)
@@ -30,6 +30,7 @@
 /// Types able to be transferred across task boundaries.
 #[unstable = "will be overhauled with new lifetime rules; see RFC 458"]
 #[lang="send"]
+#[rustc_on_unimplemented = "`{Self}` cannot be sent between threads safely"]
 pub unsafe trait Send: 'static {
     // empty.
 }
@@ -37,6 +38,7 @@ pub unsafe trait Send: 'static {
 /// Types with a constant size known at compile-time.
 #[stable]
 #[lang="sized"]
+#[rustc_on_unimplemented = "`{Self}` does not have a constant size known at compile-time"]
 pub trait Sized {
     // Empty.
 }
@@ -193,6 +195,7 @@ pub trait Copy {
 /// `transmute`-ing from `&T` to `&mut T` is illegal).
 #[unstable = "will be overhauled with new lifetime rules; see RFC 458"]
 #[lang="sync"]
+#[rustc_on_unimplemented = "`{Self}` cannot be shared between threads safely"]
 pub unsafe trait Sync {
     // Empty
 }