about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Kuo <matthew.kuo@dialexa.com>2020-03-01 14:15:44 -0600
committerMatthew Kuo <matthew.kuo@dialexa.com>2020-03-01 15:17:08 -0600
commit275dac7bfb6cfadd02c12edacbd4fdf529269424 (patch)
tree74736dffa60d6ffbb772597b1cf0147446ffc7e8
parent0eb878d2aa6e3a1cb315f3f328681b26bb4bffdb (diff)
downloadrust-275dac7bfb6cfadd02c12edacbd4fdf529269424.tar.gz
rust-275dac7bfb6cfadd02c12edacbd4fdf529269424.zip
doc(librustc_error_codes): add long error explanation for E0719
Progresses #61137
-rw-r--r--src/librustc_error_codes/error_codes.rs2
-rw-r--r--src/librustc_error_codes/error_codes/E0719.md35
-rw-r--r--src/test/ui/associated-type-bounds/duplicate.stderr1
-rw-r--r--src/test/ui/error-codes/E0719.stderr1
4 files changed, 38 insertions, 1 deletions
diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs
index 91a7b6c8958..a79fcb978ca 100644
--- a/src/librustc_error_codes/error_codes.rs
+++ b/src/librustc_error_codes/error_codes.rs
@@ -395,6 +395,7 @@ E0714: include_str!("./error_codes/E0714.md"),
 E0715: include_str!("./error_codes/E0715.md"),
 E0716: include_str!("./error_codes/E0716.md"),
 E0718: include_str!("./error_codes/E0718.md"),
+E0719: include_str!("./error_codes/E0719.md"),
 E0720: include_str!("./error_codes/E0720.md"),
 E0723: include_str!("./error_codes/E0723.md"),
 E0725: include_str!("./error_codes/E0725.md"),
@@ -604,7 +605,6 @@ E0747: include_str!("./error_codes/E0747.md"),
     E0710, // an unknown tool name found in scoped lint
     E0711, // a feature has been declared with conflicting stability attributes
     E0717, // rustc_promotable without stability attribute
-    E0719, // duplicate values for associated type binding
 //  E0721, // `await` keyword
     E0722, // Malformed `#[optimize]` attribute
     E0724, // `#[ffi_returns_twice]` is only allowed in foreign functions
diff --git a/src/librustc_error_codes/error_codes/E0719.md b/src/librustc_error_codes/error_codes/E0719.md
new file mode 100644
index 00000000000..38bc63550ac
--- /dev/null
+++ b/src/librustc_error_codes/error_codes/E0719.md
@@ -0,0 +1,35 @@
+The value for an associated type has already been specified.
+
+Erroneous code example:
+
+```compile_fail,E0719
+#![feature(associated_type_bounds)]
+
+trait FooTrait {}
+trait BarTrait {}
+
+// error: associated type `Item` in trait `Iterator` is specified twice
+struct Foo<T: Iterator<Item: FooTrait, Item: BarTrait>> { f: T }
+```
+
+`Item` in trait `Iterator` cannot be specified multiple times for struct `Foo`.
+To fix this, create a new trait that is a combination of the desired traits and
+specify the associated type with the new trait.
+
+Corrected example:
+
+```
+#![feature(associated_type_bounds)]
+
+trait FooTrait {}
+trait BarTrait {}
+trait FooBarTrait: FooTrait + BarTrait {}
+
+struct Foo<T: Iterator<Item: FooBarTrait>> { f: T }
+```
+
+For more information about associated types, see [the book][bk-at]. For more
+information on associated type bounds, see [RFC 2289][rfc-2289].
+
+[bk-at]: https://doc.rust-lang.org/book/ch19-03-advanced-traits.html#specifying-placeholder-types-in-trait-definitions-with-associated-types
+[rfc-2289]: https://rust-lang.github.io/rfcs/2289-associated-type-bounds.html
diff --git a/src/test/ui/associated-type-bounds/duplicate.stderr b/src/test/ui/associated-type-bounds/duplicate.stderr
index df1151d876c..82b2d32d09d 100644
--- a/src/test/ui/associated-type-bounds/duplicate.stderr
+++ b/src/test/ui/associated-type-bounds/duplicate.stderr
@@ -728,3 +728,4 @@ LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>;
 
 error: aborting due to 96 previous errors
 
+For more information about this error, try `rustc --explain E0719`.
diff --git a/src/test/ui/error-codes/E0719.stderr b/src/test/ui/error-codes/E0719.stderr
index a046fbfc3d0..0e4bbf083ba 100644
--- a/src/test/ui/error-codes/E0719.stderr
+++ b/src/test/ui/error-codes/E0719.stderr
@@ -16,3 +16,4 @@ LL | fn test() -> Box<dyn Iterator<Item = (), Item = Unit>> {
 
 error: aborting due to 2 previous errors
 
+For more information about this error, try `rustc --explain E0719`.