Auto merge of #34000 - estebank:missingargs, r=jseyfried

Show types of all args when missing args

When there're missing arguments in a function call, present a list of
all the expected types:

```rust
fn main() {
    t("");
}

fn t(a: &str, x: String) {}
```

```bash
% rustc file.rs
file.rs:3:5: 2:8 error: this function takes 2 parameters but 0
parameters were supplied [E0061]
file.rs:3     t();
              ^~~
file.rs:3:5: 2:8 help: run `rustc --explain E0061` to see a detailed explanation
file.rs:3:5: 2:8 note: the following parameter types were expected: &str, std::string::String
error: aborting due to previous error
```

Fixes #33649
This commit is contained in:
bors 2016-06-15 22:12:26 -07:00 committed by GitHub
commit 7339eca0cc
8 changed files with 55 additions and 33 deletions

View file

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

View file

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

View file

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

View file

@ -21,10 +21,13 @@ fn main() {
let x = Foo;
x.zero(0) //~ ERROR this function takes 0 parameters but 1 parameter was supplied
.one() //~ ERROR this function takes 1 parameter but 0 parameters were supplied
//~^ NOTE the following parameter type was expected
.two(0); //~ ERROR this function takes 2 parameters but 1 parameter was supplied
//~^ NOTE the following parameter types were expected
let y = Foo;
y.zero()
.take() //~ ERROR no method named `take` found for type `Foo` in the current scope
//~^ NOTE the method `take` exists but the following trait bounds were not satisfied
.one(0);
}

View file

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

View file

@ -36,7 +36,13 @@ fn main() {
y: 3,
};
let ans = s("what"); //~ ERROR mismatched types
let ans = s(); //~ ERROR this function takes 1 parameter but 0 parameters were supplied
//~^ NOTE expected isize, found &-ptr
//~| NOTE expected type
//~| NOTE found type
let ans = s();
//~^ ERROR this function takes 1 parameter but 0 parameters were supplied
//~| NOTE the following parameter type was expected
let ans = s("burma", "shave");
//~^ ERROR this function takes 1 parameter but 2 parameters were supplied
//~| NOTE the following parameter type was expected
}

View file

@ -17,7 +17,9 @@ 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
foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied
//~^ NOTE the following parameter types were expected
let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
//~^ ERROR: mismatched types