diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 0aa523e9d5e47..8e8ff5cda77c6 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2466,16 +2466,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if arg_count == 1 {" was"} else {"s were"}), error_code); - err.span_label(sp, &format!("expected {}{} parameter{}", - if variadic {"at least "} else {""}, - expected_count, - if expected_count == 1 {""} else {"s"})); - let input_types = fn_inputs.iter().map(|i| format!("{:?}", i)).collect::>(); - if input_types.len() > 0 { - err.note(&format!("the following parameter type{} expected: {}", - if expected_count == 1 {" was"} else {"s were"}, - input_types.join(", "))); + if input_types.len() > 1 { + err.note("the following parameter types were expected:"); + err.note(&input_types.join(", ")); + } else if input_types.len() > 0 { + err.note(&format!("the following parameter type was expected: {}", + input_types[0])); + } else { + err.span_label(sp, &format!("expected {}{} parameter{}", + if variadic {"at least "} else {""}, + expected_count, + if expected_count == 1 {""} else {"s"})); } err.emit(); } diff --git a/src/test/compile-fail/E0060.rs b/src/test/compile-fail/E0060.rs index e1f2618c180f6..5182a2bf5a0a9 100644 --- a/src/test/compile-fail/E0060.rs +++ b/src/test/compile-fail/E0060.rs @@ -15,6 +15,5 @@ extern "C" { fn main() { unsafe { printf(); } //~^ ERROR E0060 - //~| NOTE expected at least 1 parameter - //~| NOTE the following parameter type was expected + //~| NOTE the following parameter type was expected: *const u8 } diff --git a/src/test/compile-fail/E0061.rs b/src/test/compile-fail/E0061.rs index ca04b059dc7f6..4c7c0dfd44c51 100644 --- a/src/test/compile-fail/E0061.rs +++ b/src/test/compile-fail/E0061.rs @@ -10,9 +10,15 @@ fn f(a: u16, b: &str) {} +fn f2(a: u16) {} + fn main() { f(0); //~^ ERROR E0061 - //~| NOTE expected 2 parameters - //~| NOTE the following parameter types were expected + //~| NOTE the following parameter types were expected: + //~| NOTE u16, &str + + f2(); + //~^ ERROR E0061 + //~| NOTE the following parameter type was expected: u16 } diff --git a/src/test/compile-fail/issue-18819.rs b/src/test/compile-fail/issue-18819.rs index cf650460c3de1..8035d798e32de 100644 --- a/src/test/compile-fail/issue-18819.rs +++ b/src/test/compile-fail/issue-18819.rs @@ -25,6 +25,6 @@ fn print_x(_: &Foo, extra: &str) { fn main() { print_x(X); //~^ ERROR this function takes 2 parameters but 1 parameter was supplied - //~| NOTE the following parameter types were expected: &Foo, &str - //~| NOTE expected 2 parameters + //~| NOTE the following parameter types were expected: + //~| NOTE &Foo, &str } diff --git a/src/test/compile-fail/issue-3044.rs b/src/test/compile-fail/issue-3044.rs index d19e3b2c7b0a8..b934cbe4b5d87 100644 --- a/src/test/compile-fail/issue-3044.rs +++ b/src/test/compile-fail/issue-3044.rs @@ -15,6 +15,6 @@ fn main() { }); //~^^ ERROR this function takes 2 parameters but 1 parameter was supplied //~| NOTE the following parameter types were expected - //~| NOTE expected 2 parameters + //~| NOTE _, _ // the first error is, um, non-ideal. } diff --git a/src/test/compile-fail/issue-4935.rs b/src/test/compile-fail/issue-4935.rs index 58a84f3490b3c..08707a187dfd1 100644 --- a/src/test/compile-fail/issue-4935.rs +++ b/src/test/compile-fail/issue-4935.rs @@ -14,4 +14,3 @@ fn foo(a: usize) {} fn main() { foo(5, 6) } //~^ ERROR this function takes 1 parameter but 2 parameters were supplied //~| NOTE the following parameter type was expected -//~| NOTE expected 1 parameter diff --git a/src/test/compile-fail/method-call-err-msg.rs b/src/test/compile-fail/method-call-err-msg.rs index bcf676dbede6f..b7e0c5b81d918 100644 --- a/src/test/compile-fail/method-call-err-msg.rs +++ b/src/test/compile-fail/method-call-err-msg.rs @@ -23,10 +23,9 @@ fn main() { //~^ NOTE expected 0 parameters .one() //~ ERROR this function takes 1 parameter but 0 parameters were supplied //~^ NOTE the following parameter type was expected - //~| NOTE expected 1 parameter .two(0); //~ ERROR this function takes 2 parameters but 1 parameter was supplied //~^ NOTE the following parameter types were expected - //~| NOTE expected 2 parameters + //~| NOTE isize, isize let y = Foo; y.zero() diff --git a/src/test/compile-fail/not-enough-arguments.rs b/src/test/compile-fail/not-enough-arguments.rs index f2f61fcaeec16..660d48da4dbc9 100644 --- a/src/test/compile-fail/not-enough-arguments.rs +++ b/src/test/compile-fail/not-enough-arguments.rs @@ -19,6 +19,6 @@ fn foo(a: isize, b: isize, c: isize, d:isize) { fn main() { foo(1, 2, 3); //~^ ERROR this function takes 4 parameters but 3 - //~| NOTE the following parameter types were expected - //~| NOTE expected 4 parameters + //~| NOTE the following parameter types were expected: + //~| NOTE isize, isize, isize, isize } diff --git a/src/test/compile-fail/overloaded-calls-bad.rs b/src/test/compile-fail/overloaded-calls-bad.rs index 1825ec61f1ed7..0aa9af3c8dad4 100644 --- a/src/test/compile-fail/overloaded-calls-bad.rs +++ b/src/test/compile-fail/overloaded-calls-bad.rs @@ -42,9 +42,7 @@ fn main() { let ans = s(); //~^ ERROR this function takes 1 parameter but 0 parameters were supplied //~| NOTE the following parameter type was expected - //~| NOTE expected 1 parameter let ans = s("burma", "shave"); //~^ ERROR this function takes 1 parameter but 2 parameters were supplied //~| NOTE the following parameter type was expected - //~| NOTE expected 1 parameter } diff --git a/src/test/compile-fail/variadic-ffi-3.rs b/src/test/compile-fail/variadic-ffi-3.rs index cc9a7c84eded4..334b8bb08aea5 100644 --- a/src/test/compile-fail/variadic-ffi-3.rs +++ b/src/test/compile-fail/variadic-ffi-3.rs @@ -17,11 +17,11 @@ extern "C" fn bar(f: isize, x: u8) {} fn main() { unsafe { foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied - //~^ NOTE the following parameter types were expected - //~| NOTE expected at least 2 parameters + //~^ NOTE the following parameter types were expected: + //~| NOTE isize, u8 foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied - //~^ NOTE the following parameter types were expected - //~| NOTE expected at least 2 parameters + //~^ NOTE the following parameter types were expected: + //~| NOTE isize, u8 let x: unsafe extern "C" fn(f: isize, x: u8) = foo; //~^ ERROR: mismatched types