diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2019-12-06 15:37:06 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-06 15:37:06 +0900 |
| commit | 6c0165fa78c19a879b14f95b92b83d368ba6797c (patch) | |
| tree | 67bf568fc6033e7c09c7800fccd566b676a1eae7 /src/librustc_error_codes | |
| parent | 3b878aa9ae719ec4dec574cf2d1848ef9023ff38 (diff) | |
| parent | 911b7d6d4dc19da085883d19b7a772b5ca35ffc9 (diff) | |
| download | rust-6c0165fa78c19a879b14f95b92b83d368ba6797c.tar.gz rust-6c0165fa78c19a879b14f95b92b83d368ba6797c.zip | |
Rollup merge of #66979 - reese:E0631-long-error, r=GuillaumeGomez
Add long error for E0631 and update ui tests. This PR adds a long error for `E0631`, which covers errors where closure argument types are mismatched. It also updates UI tests where this error is applicable. Part of #61137
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 | 27 |
2 files changed, 28 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..6188d5f61a7 --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0631.md @@ -0,0 +1,27 @@ +This error indicates a type mismatch in closure arguments. + +Erroneous code example: + +```compile_fail,E0631 +fn foo<F: Fn(i32)>(f: F) { +} + +fn main() { + foo(|x: &str| {}); +} +``` + +The error occurs because `foo` accepts a closure that takes an `i32` argument, +but in `main`, it is passed a closure with a `&str` argument. + +This can be resolved by changing the type annotation or removing it entirely +if it can be inferred. + +``` +fn foo<F: Fn(i32)>(f: F) { +} + +fn main() { + foo(|x: i32| {}); +} +``` |
