about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKelvin Ly <kelvin.ly1618@gmail.com>2015-05-14 20:08:30 -0400
committerKelvin Ly <kelvin.ly1618@gmail.com>2015-05-14 20:08:30 -0400
commit6e9e76ae5fe6a3104c265b43dcb5705b5ccd2743 (patch)
tree36de2349fc5fb209e7f285b9f5efa2443dd686bc /src
parent67433c1a309d3c9457e49f15e80a2d927d165996 (diff)
Fix error codes E0197-E0200
Diffstat (limited to 'src')
-rw-r--r--src/librustc_typeck/diagnostics.rs66
1 files changed, 62 insertions, 4 deletions
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index 8375061aa09..7ec1299e7eb 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -161,6 +161,68 @@ it has been disabled for now.
 [iss20126]: https://github.com/rust-lang/rust/issues/20126
 "##,
 
+E0197: r##"
+Inherent implementations (one that do not implement a trait but provide
+methods associated with a type) are always safe because they are not
+implementing an unsafe trait. Removing the unsafe keyword from the inherent
+implementation will resolve this error.
+
+struct Foo;
+
+// this will cause this error
+unsafe impl Foo { }
+// converting it to this will fix it
+impl Foo { }
+
+"##,
+
+E0198: r##"
+A negative implementation is one that excludes a type from implementing a
+particular trait. Not being able to use a trait is always a safe operation,
+so negative implementations are always safe and never need to be marked as
+unsafe.
+
+struct Foo;
+
+// unsafe is unnecessary
+unsafe impl !Clone for Foo { }
+// this will compile
+impl !Clone for Foo { }
+
+"##,
+
+E0199: r##"
+Safe traits should not have unsafe implementations, therefore marking an
+implementation for a safe trait unsafe will cause a compiler error. Removing the
+unsafe marker on the trait noted in the error will resolve this problem.
+
+struct Foo;
+
+trait Bar { }
+
+// this won't compile because Bar is safe
+unsafe impl Bar for Foo { }
+// this will compile
+impl Bar for Foo { }
+
+"##,
+
+E0200: r##"
+Unsafe traits must have unsafe implementations. This error occurs when an
+implementation for an unsafe trait isn't marked as unsafe. This may be resolved
+by marking the unsafe implementation as unsafe.
+
+struct Foo;
+
+unsafe trait Bar { }
+
+// this won't compile because Bar is unsafe and impl isn't unsafe
+impl Bar for Foo { }
+// this will compile
+unsafe impl Bar for Foo { }
+
+"##,
+
 E0204: r##"
 An attempt to implement the `Copy` trait for a struct failed because one of the
 fields does not implement `Copy`. To fix this, you must implement `Copy` for the
@@ -386,10 +448,6 @@ register_diagnostics! {
     E0194,
     E0195, // lifetime parameters or bounds on method do not match the trait declaration
     E0196, // cannot determine a type for this closure
-    E0197, // inherent impls cannot be declared as unsafe
-    E0198, // negative implementations are not unsafe
-    E0199, // implementing trait is not unsafe
-    E0200, // trait requires an `unsafe impl` declaration
     E0201, // duplicate method in trait impl
     E0202, // associated items are not allowed in inherent impls
     E0203, // type parameter has more than one relaxed default bound,