Skip to content

Commit 74cb9b9

Browse files
committed
Fix trailing whitespace and duplicate error code.
New error code is E0623 Also cleanup/fix ui test
1 parent 994d76d commit 74cb9b9

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

src/librustc/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2027,5 +2027,5 @@ register_diagnostics! {
20272027
E0495, // cannot infer an appropriate lifetime due to conflicting requirements
20282028
E0566, // conflicting representation hints
20292029
E0587, // conflicting packed and align representation hints
2030-
E0622, // type mismatch in closure arguments
2030+
E0623, // type mismatch in closure arguments
20312031
}

src/librustc/traits/error_reporting.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
728728
let mut count_mismatch = None;
729729
if let ty::TyTuple(expected_tys, _) = expected_found.expected.sty {
730730
if let ty::TyTuple(found_tys, _) = expected_found.found.sty {
731-
if expected_tys.len() != found_tys.len() {
731+
if expected_tys.len() != found_tys.len() {
732732
// Expected `|| { }`, found `|x, y| { }`
733733
// Expected `fn(x) -> ()`, found `|| { }`
734734
count_mismatch = Some(self.report_arg_count_mismatch(span,
@@ -745,7 +745,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
745745
self.report_closure_arg_mismatch(span,
746746
found_span,
747747
expected_trait_ref,
748-
actual_trait_ref)
748+
actual_trait_ref)
749749
}
750750
} else {
751751
self.report_type_argument_mismatch(span,
@@ -828,15 +828,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
828828
found: ty::PolyTraitRef<'tcx>)
829829
-> DiagnosticBuilder<'tcx>
830830
{
831-
let mut err = struct_span_err!(self.tcx.sess, span, E0622,
831+
let mut err = struct_span_err!(self.tcx.sess, span, E0623,
832832
"type mismatch in closure arguments");
833833
if let Some(sp) = found_span {
834834
err.span_label(span, format!("expected closure that takes a `{}`", found));
835835
err.span_label(sp, format!("takes a `{}`", expected_ref));
836836
} else {
837837
panic!();
838838
}
839-
840839
err
841840
}
842841
}

src/test/ui/mismatched_types/closure-arg-type-mismatch.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::ops::{FnOnce, Fn};
12-
13-
pub fn main() {
11+
fn main() {
1412
let a = [(1u32,2u32)];
1513
let b = a.iter().map(|x: (u32, u32)| 45);
1614
let d1 = a.iter().map(|x: &(u16,u16)| 45);
1715
let d2 = a.iter().map(|x: (u16,u16)| 45);
1816
foo(|y: isize| ());
1917
}
2018

21-
fn foo<F>(m: F) where F: Fn(usize) {}
19+
fn foo<F>(m: F) where F: ::std::ops::Fn(usize) {}

src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
error[E0622]: type mismatch in closure arguments
2-
--> $DIR/closure-arg-type-mismatch.rs:15:26
1+
error[E0623]: type mismatch in closure arguments
2+
--> $DIR/closure-arg-type-mismatch.rs:13:26
33
|
4-
15 | let b = a.iter().map(|x: (u32, u32)| 45);
4+
13 | let b = a.iter().map(|x: (u32, u32)| 45);
55
| ^^^ ------------------ takes a `std::ops::FnMut<((u32, u32),)>`
66
| |
77
| expected closure that takes a `std::ops::FnMut<(&(u32, u32),)>`
88

9-
error[E0622]: type mismatch in closure arguments
10-
--> $DIR/closure-arg-type-mismatch.rs:16:27
9+
error[E0623]: type mismatch in closure arguments
10+
--> $DIR/closure-arg-type-mismatch.rs:14:27
1111
|
12-
16 | let d1 = a.iter().map(|x: &(u16,u16)| 45);
12+
14 | let d1 = a.iter().map(|x: &(u16,u16)| 45);
1313
| ^^^ ------------------ takes a `for<'r> std::ops::FnMut<(&'r (u16, u16),)>`
1414
| |
1515
| expected closure that takes a `std::ops::FnMut<(&(u32, u32),)>`
1616

17-
error[E0622]: type mismatch in closure arguments
18-
--> $DIR/closure-arg-type-mismatch.rs:17:27
17+
error[E0623]: type mismatch in closure arguments
18+
--> $DIR/closure-arg-type-mismatch.rs:15:27
1919
|
20-
17 | let d2 = a.iter().map(|x: (u16,u16)| 45);
20+
15 | let d2 = a.iter().map(|x: (u16,u16)| 45);
2121
| ^^^ ----------------- takes a `std::ops::FnMut<((u16, u16),)>`
2222
| |
2323
| expected closure that takes a `std::ops::FnMut<(&(u32, u32),)>`
2424

25-
error[E0622]: type mismatch in closure arguments
26-
--> $DIR/closure-arg-type-mismatch.rs:18:9
25+
error[E0623]: type mismatch in closure arguments
26+
--> $DIR/closure-arg-type-mismatch.rs:16:9
2727
|
28-
18 | foo(|y: isize| ());
28+
16 | foo(|y: isize| ());
2929
| ^^^ ------------- takes a `std::ops::Fn<(isize,)>`
3030
| |
3131
| expected closure that takes a `std::ops::Fn<(usize,)>`

0 commit comments

Comments
 (0)