diff options
| author | Reese Williams <rtwill722@gmail.com> | 2019-12-02 21:52:04 -0500 |
|---|---|---|
| committer | Reese Williams <rtwill722@gmail.com> | 2019-12-02 22:01:27 -0500 |
| commit | 7693bb9e1d122bea1b0645dcc201c6ed79c910e2 (patch) | |
| tree | 743cd8c89aabb51017a1492df875695172fcb540 /src/librustc_error_codes | |
| parent | 2da942f32802c8233a09744024dfbc34431adf65 (diff) | |
| download | rust-7693bb9e1d122bea1b0645dcc201c6ed79c910e2.tar.gz rust-7693bb9e1d122bea1b0645dcc201c6ed79c910e2.zip | |
Add long error for E0631 and update ui tests.
Diffstat (limited to 'src/librustc_error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes.rs | 2 | ||||
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0631.md | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs index 7f111b42403..9e4b704170b 100644 --- a/src/librustc_error_codes/error_codes.rs +++ b/src/librustc_error_codes/error_codes.rs @@ -347,6 +347,7 @@ E0622: include_str!("./error_codes/E0622.md"), E0623: include_str!("./error_codes/E0623.md"), E0624: include_str!("./error_codes/E0624.md"), E0626: include_str!("./error_codes/E0626.md"), +E0631: include_str!("./error_codes/E0631.md"), E0633: include_str!("./error_codes/E0633.md"), E0635: include_str!("./error_codes/E0635.md"), E0636: include_str!("./error_codes/E0636.md"), @@ -580,7 +581,6 @@ E0745: include_str!("./error_codes/E0745.md"), // rustc_const_unstable attribute must be paired with stable/unstable // attribute E0630, - E0631, // type mismatch in closure arguments E0632, // cannot provide explicit generic arguments when `impl Trait` is // used in argument position E0634, // type has conflicting packed representaton hints diff --git a/src/librustc_error_codes/error_codes/E0631.md b/src/librustc_error_codes/error_codes/E0631.md new file mode 100644 index 00000000000..ad419f82250 --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0631.md @@ -0,0 +1,29 @@ +This error indicates a type mismatch in closure arguments. + +Erroneous code example: + +```compile_fail,E0631 +fn test_strings(string_vec: Vec<String>) -> Vec<bool> { + string_vec + .iter() + .map(|arg: &i32| arg.eq("Test String")) + .collect() +} +``` + +The closure passed to `map` expects a `&String` argument, since `some_vec` +has the type `Vec<String>`. +However, the closure argument is annotated as an `&i32`, which does not match +the type of the iterable. + +This can be resolved by changing the type annotation or removing it entirely +if it can be inferred. + +``` +fn test_strings(string_vec: Vec<String>) -> Vec<bool> { + string_vec + .iter() + .map(|arg| arg.eq("Test String")) + .collect() +} +``` |
