Fixes for issues #35215 and #35216

This commit is contained in:
William Lee 2016-08-04 00:32:49 -04:00
parent a0b4e67648
commit 61318156f8
10 changed files with 22 additions and 2 deletions

View File

@ -2384,6 +2384,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
arg_count,
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::<Vec<String>>();
if input_types.len() > 0 {
err.note(&format!("the following parameter type{} expected: {}",

View File

@ -14,4 +14,6 @@ extern "C" {
fn main() {
unsafe { printf(); } //~ ERROR E0060
//~| NOTE expected at least 1 parameter
//~| NOTE the following parameter type was expected
}

View File

@ -11,5 +11,7 @@
fn f(a: u16, b: &str) {}
fn main() {
f(0); //~ ERROR E0061
f(0); //~ ERROR E0061
//~| NOTE expected 2 parameters
//~| NOTE the following parameter types were expected
}

View File

@ -25,4 +25,5 @@ fn print_x(_: &Foo<Item=bool>, 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<Item=bool>, &str
//~| NOTE expected 2 parameters
}

View File

@ -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
// the first error is, um, non-ideal.
}

View File

@ -13,3 +13,4 @@
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

View File

@ -20,10 +20,13 @@ impl Foo {
fn main() {
let x = Foo;
x.zero(0) //~ ERROR this function takes 0 parameters but 1 parameter was supplied
//~^ 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
let y = Foo;
y.zero()

View File

@ -20,4 +20,5 @@ 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
}

View File

@ -42,7 +42,9 @@ 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
}

View File

@ -18,8 +18,10 @@ 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
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
let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
//~^ ERROR: mismatched types