]> git.lizzy.rs Git - rust.git/commitdiff
Add long error for E0631 and update ui tests.
authorReese Williams <rtwill722@gmail.com>
Tue, 3 Dec 2019 02:52:04 +0000 (21:52 -0500)
committerReese Williams <rtwill722@gmail.com>
Tue, 3 Dec 2019 03:01:27 +0000 (22:01 -0500)
14 files changed:
src/librustc_error_codes/error_codes.rs
src/librustc_error_codes/error_codes/E0631.md [new file with mode: 0644]
src/test/ui/anonymous-higher-ranked-lifetime.stderr
src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr
src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr
src/test/ui/closures/issue-41366.stderr
src/test/ui/issues/issue-43623.stderr
src/test/ui/issues/issue-60283.stderr
src/test/ui/mismatched_types/E0631.stderr
src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr
src/test/ui/mismatched_types/closure-mismatch.stderr
src/test/ui/mismatched_types/fn-variance-1.stderr
src/test/ui/mismatched_types/issue-36053-2.stderr
src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr

index 7f111b42403b574e0e049fbbd9ffc8877cb0bfa2..9e4b704170b9b38271269b01e42f5e8068002484 100644 (file)
 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"),
     // 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 (file)
index 0000000..ad419f8
--- /dev/null
@@ -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()
+}
+```
index 9be44c7f44807a8203b2affbe9c9ab1045e0afe2..c6d9a61bdd95aa82047d312cba5edc7d4e69b238 100644 (file)
@@ -121,3 +121,4 @@ LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<dyn Fn(&())>, &'t0 (), fn(&(),
 
 error: aborting due to 11 previous errors
 
+For more information about this error, try `rustc --explain E0631`.
index a15444207f5cd422ba989cdefcd64031335bc5ff..003339584681529f296a311586e29e05d6c8f1d4 100644 (file)
@@ -77,4 +77,5 @@ LL |     with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
 
 error: aborting due to 5 previous errors
 
-For more information about this error, try `rustc --explain E0308`.
+Some errors have detailed explanations: E0308, E0631.
+For more information about an error, try `rustc --explain E0308`.
index 9fbe95a9c39451edc207498bb60e653575b65fbf..1c6564ee426e50b3b7dfcad2746fbaa21a769f8e 100644 (file)
@@ -13,3 +13,4 @@ LL |     with_closure(|x: u32, y: i32| {
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0631`.
index 91d26efbc4f35309af98332c449cfc6d7348bed1..2f2871e9f0e90c89e1cfe7a6cbad4d9e544b278f 100644 (file)
@@ -19,4 +19,5 @@ LL |     (&|_|()) as &dyn for<'x> Fn(<u32 as T<'x>>::V);
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0271`.
+Some errors have detailed explanations: E0271, E0631.
+For more information about an error, try `rustc --explain E0271`.
index 2c57b8585d92400a0eae4b899a836bfc0a659521..d90eb53f9006ffe8d2d651257d41e05a9aba2d9c 100644 (file)
@@ -25,4 +25,5 @@ LL |     break_me::<Type, fn(_)>;
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0271`.
+Some errors have detailed explanations: E0271, E0631.
+For more information about an error, try `rustc --explain E0271`.
index 69c1d85e4e12d031e249e235834a7a950ba94091..d13dcd54a479aa079dde0093cee5101c7e57d786 100644 (file)
@@ -27,4 +27,5 @@ LL |     foo((), drop)
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0271`.
+Some errors have detailed explanations: E0271, E0631.
+For more information about an error, try `rustc --explain E0271`.
index 88c1efdbb90f4d64620e50981cabfef5c1f325ec..06f5c058f81f541a7fb62d1f172f05078382f2be 100644 (file)
@@ -46,3 +46,4 @@ LL |     bar(f);
 
 error: aborting due to 4 previous errors
 
+For more information about this error, try `rustc --explain E0631`.
index 85cad61210ebf7734fe37073611d859ac27808a0..ed5028247124f6e70ae74cbeacf4f71067327800 100644 (file)
@@ -45,4 +45,5 @@ LL |     baz(f);
 
 error: aborting due to 5 previous errors
 
-For more information about this error, try `rustc --explain E0271`.
+Some errors have detailed explanations: E0271, E0631.
+For more information about an error, try `rustc --explain E0271`.
index fd2b9f3c66b0451346c313cbbb0c236fa945e545..f3874c0907be033cb4980cba19d4244bff2e58ab 100644 (file)
@@ -24,4 +24,5 @@ LL |     baz(|_| ());
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0271`.
+Some errors have detailed explanations: E0271, E0631.
+For more information about an error, try `rustc --explain E0271`.
index 1a82dd53edc702964396823b5e4dad154b1b7353..88c92661994cbac367324c1398f1adf1f13ae32b 100644 (file)
@@ -24,3 +24,4 @@ LL |     apply(&mut 3, takes_imm);
 
 error: aborting due to 2 previous errors
 
+For more information about this error, try `rustc --explain E0631`.
index 72f3220cc1abaaf4ca3ef1fc7a5d0dee75d29bf2..da018aa89482c58cdf9a4318973389713ee0e213 100644 (file)
@@ -18,4 +18,5 @@ LL |     once::<&str>("str").fuse().filter(|a: &str| true).count();
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0599`.
+Some errors have detailed explanations: E0599, E0631.
+For more information about an error, try `rustc --explain E0599`.
index 2daf4781c7e6f3e4ef83182288a60c97809fbb36..3c999f200d9c7c113837402fd5824dd726e39823 100644 (file)
@@ -12,3 +12,4 @@ LL |     let z = call_it(3, f);
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0631`.