about summary refs log tree commit diff
path: root/compiler/rustc_error_codes/src
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2020-06-30 22:41:57 +0100
committerMatthew Jasper <mjjasper1@gmail.com>2020-10-06 11:19:30 +0100
commit0dda4154bd254b629567739085471b8e50676c83 (patch)
tree5875bc721682c06a24f491822e399279aa68864f /compiler/rustc_error_codes/src
parent042464f75ae1272260b24896b3266a5c1ba62c6b (diff)
downloadrust-0dda4154bd254b629567739085471b8e50676c83.tar.gz
rust-0dda4154bd254b629567739085471b8e50676c83.zip
Fix tools
Diffstat (limited to 'compiler/rustc_error_codes/src')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0284.md38
1 files changed, 15 insertions, 23 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0284.md b/compiler/rustc_error_codes/src/error_codes/E0284.md
index a1ffa2bda00..18519b471b2 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0284.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0284.md
@@ -5,37 +5,29 @@ as the `collect` method for `Iterator`s.
 For example:
 
 ```compile_fail,E0284
-fn foo() -> Result<bool, ()> {
-    let results = [Ok(true), Ok(false), Err(())].iter().cloned();
-    let v: Vec<bool> = results.collect()?;
-    // Do things with v...
-    Ok(true)
+fn main() {
+    let n: u32 = 1;
+    let mut d: u64 = 2;
+    d = d + n.into();
 }
 ```
 
-Here we have an iterator `results` over `Result<bool, ()>`.
-Hence, `results.collect()` can return any type implementing
-`FromIterator<Result<bool, ()>>`. On the other hand, the
-`?` operator can accept any type implementing `Try`.
+Here we have an addition of `d` and `n.into()`. Hence, `n.into()` can return
+any type `T` where `u64: Add<T>`. On the other hand, the `into` method can
+rteurn any type where `u32: Into<T>`.
 
-The author of this code probably wants `collect()` to return a
-`Result<Vec<bool>, ()>`, but the compiler can't be sure
-that there isn't another type `T` implementing both `Try` and
-`FromIterator<Result<bool, ()>>` in scope such that
-`T::Ok == Vec<bool>`. Hence, this code is ambiguous and an error
-is returned.
+The author of this code probably wants `into()` to return a `u64`, but the
+compiler can't be sure that there isn't another type `T` where both
+`u32: Into<T>` and `u64: Add<T>`.
 
 To resolve this error, use a concrete type for the intermediate expression:
 
 ```
-fn foo() -> Result<bool, ()> {
-    let results = [Ok(true), Ok(false), Err(())].iter().cloned();
-    let v = {
-        let temp: Result<Vec<bool>, ()> = results.collect();
-        temp?
-    };
-    // Do things with v...
-    Ok(true)
+fn main() {
+    let n: u32 = 1;
+    let mut d: u64 = 2;
+    let m: u64 = n.into();
+    d = d + m;
 }
 ```