]> git.lizzy.rs Git - rust.git/commitdiff
add long diagnostics for E0122
authorAlisdair Owens <awo101@zepler.net>
Sat, 29 Aug 2015 16:20:46 +0000 (17:20 +0100)
committerAlisdair Owens <awo101@zepler.net>
Sat, 29 Aug 2015 16:20:46 +0000 (17:20 +0100)
src/librustc_typeck/diagnostics.rs

index 0dbfffe5c644abba7c246926b7044e6e2fbe7dca..9f811eda4417d83ed55d5e35618ce07d05b1e2a6 100644 (file)
@@ -1642,6 +1642,26 @@ fn foo() -> _ { 5 } // error, explicitly write out the return type instead
 ```
 "##,
 
+E0122: r##"
+An attempt was made to add a generic constraint to a type alias. While Rust will
+allow this with a warning, it will not currently enforce the constraint.
+Consider the example below:
+
+```
+trait Foo{}
+
+type MyType<R: Foo> = (R, ());
+
+fn main() {
+    let t: MyType<u32>;
+}
+```
+
+We're able to declare a variable of type `MyType<u32>`, despite the fact that
+`u32` does not implement `Foo`. As a result, one should avoid using generic
+constraints in concert with type aliases.
+"##,
+
 E0124: r##"
 You declared two fields of a struct with the same name. Erroneous code
 example:
@@ -3010,7 +3030,6 @@ struct Foo<'a, T: 'a> {
     E0103, // @GuillaumeGomez: I was unable to get this error, try your best!
     E0104,
     E0118,
-    E0122,
 //  E0123,
 //  E0127,
 //  E0129,