summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReese Williams <rtwill722@gmail.com>2019-12-03 07:51:11 -0500
committerReese Williams <rtwill722@gmail.com>2019-12-03 07:51:11 -0500
commit26a1ba85b890cdf7bbb7066c3a18aab84aef171f (patch)
tree7f7dea58da934342d11adfd986d0cbe686bdaa3c
parentAdd long error for E0631 and update ui tests. (diff)
downloadrust-26a1ba85b890cdf7bbb7066c3a18aab84aef171f.tar.gz
rust-26a1ba85b890cdf7bbb7066c3a18aab84aef171f.tar.bz2
rust-26a1ba85b890cdf7bbb7066c3a18aab84aef171f.tar.xz
Use simpler code example for E0631 long error.
-rw-r--r--src/librustc_error_codes/error_codes/E0631.md26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/librustc_error_codes/error_codes/E0631.md b/src/librustc_error_codes/error_codes/E0631.md
index ad419f8..6188d5f 100644
--- a/src/librustc_error_codes/error_codes/E0631.md
+++ b/src/librustc_error_codes/error_codes/E0631.md
@@ -3,27 +3,25 @@ This error indicates a type mismatch in closure arguments.
3Erroneous code example: 3Erroneous code example:
4 4
5```compile_fail,E0631 5```compile_fail,E0631
6fn test_strings(string_vec: Vec<String>) -> Vec<bool> { 6fn foo<F: Fn(i32)>(f: F) {
7 string_vec 7}
8 .iter() 8
9 .map(|arg: &i32| arg.eq("Test String")) 9fn main() {
10 .collect() 10 foo(|x: &str| {});
11} 11}
12``` 12```
13 13
14The closure passed to `map` expects a `&String` argument, since `some_vec` 14The error occurs because `foo` accepts a closure that takes an `i32` argument,
15has the type `Vec<String>`. 15but in `main`, it is passed a closure with a `&str` argument.
16However, the closure argument is annotated as an `&i32`, which does not match
17the type of the iterable.
18 16
19This can be resolved by changing the type annotation or removing it entirely 17This can be resolved by changing the type annotation or removing it entirely
20if it can be inferred. 18if it can be inferred.
21 19
22``` 20```
23fn test_strings(string_vec: Vec<String>) -> Vec<bool> { 21fn foo<F: Fn(i32)>(f: F) {
24 string_vec 22}
25 .iter() 23
26 .map(|arg| arg.eq("Test String")) 24fn main() {
27 .collect() 25 foo(|x: i32| {});
28} 26}
29``` 27```