Skip to content

Commit

Permalink
Rollup merge of rust-lang#35289 - birryree:E0060_E0061_format_update,…
Browse files Browse the repository at this point in the history
… r=jonathandturner

E0060 e0061 format update

This fixes rust-lang#35215 and fixes rust-lang#35216 as part of rust-lang#35233

A separate issue will be opened to track the bonus portion of the tickets as @jaredwy will be handling that part.

?r @jonathandturner
  • Loading branch information
Jonathan Turner committed Aug 4, 2016
2 parents bc531c8 + ded0d51 commit ca0cdf1
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}",
Expand Down
5 changes: 4 additions & 1 deletion src/test/compile-fail/E0060.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ extern "C" {
}

fn main() {
unsafe { printf(); } //~ ERROR E0060
unsafe { printf(); }
//~^ ERROR E0060
//~| NOTE expected at least 1 parameter
//~| NOTE the following parameter type was expected
}
5 changes: 4 additions & 1 deletion src/test/compile-fail/E0061.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
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
}
6 changes: 4 additions & 2 deletions src/test/compile-fail/issue-18819.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ 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
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
}
4 changes: 2 additions & 2 deletions src/test/compile-fail/issue-3044.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() {
needlesArr.iter().fold(|x, y| {
});
//~^^ ERROR this function takes 2 parameters but 1 parameter was supplied
//~^^^ NOTE the following parameter types were expected
//
//~| NOTE the following parameter types were expected
//~| NOTE expected 2 parameters
// the first error is, um, non-ideal.
}
6 changes: 4 additions & 2 deletions src/test/compile-fail/issue-4935.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
// Regression test for issue #4935

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
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
3 changes: 3 additions & 0 deletions src/test/compile-fail/method-call-err-msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/test/compile-fail/not-enough-arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +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 the following parameter types were expected
//~| NOTE expected 4 parameters
}
2 changes: 2 additions & 0 deletions src/test/compile-fail/overloaded-calls-bad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions src/test/compile-fail/variadic-ffi-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca0cdf1

Please sign in to comment.