diff options
| author | bors <bors@rust-lang.org> | 2016-06-15 22:12:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-15 22:12:26 -0700 |
| commit | 7339eca0cc700e2d75536dce3ca772eedfb86f08 (patch) | |
| tree | fa6c8ad4c71f91c29bb627883164ddaa799e43be /src/test | |
| parent | 58adb0760726bfb6f19c055caa58af51ef393b57 (diff) | |
| parent | 1020e3036badebc56b02661666b09a62112d04ec (diff) | |
| download | rust-7339eca0cc700e2d75536dce3ca772eedfb86f08.tar.gz rust-7339eca0cc700e2d75536dce3ca772eedfb86f08.zip | |
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
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/issue-18819.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-3044.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-4935.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/method-call-err-msg.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/not-enough-arguments.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/overloaded-calls-bad.rs | 8 | ||||
| -rw-r--r-- | src/test/compile-fail/variadic-ffi-3.rs | 2 |
7 files changed, 16 insertions, 1 deletions
diff --git a/src/test/compile-fail/issue-18819.rs b/src/test/compile-fail/issue-18819.rs index d89b2c6ce8c..3591b982414 100644 --- a/src/test/compile-fail/issue-18819.rs +++ b/src/test/compile-fail/issue-18819.rs @@ -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 } diff --git a/src/test/compile-fail/issue-3044.rs b/src/test/compile-fail/issue-3044.rs index 0f7cc2cb72b..68046056fb3 100644 --- a/src/test/compile-fail/issue-3044.rs +++ b/src/test/compile-fail/issue-3044.rs @@ -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. } diff --git a/src/test/compile-fail/issue-4935.rs b/src/test/compile-fail/issue-4935.rs index b37b8e237ed..438d238b6fe 100644 --- a/src/test/compile-fail/issue-4935.rs +++ b/src/test/compile-fail/issue-4935.rs @@ -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 diff --git a/src/test/compile-fail/method-call-err-msg.rs b/src/test/compile-fail/method-call-err-msg.rs index 3434cf96fce..212c09364cf 100644 --- a/src/test/compile-fail/method-call-err-msg.rs +++ b/src/test/compile-fail/method-call-err-msg.rs @@ -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); } diff --git a/src/test/compile-fail/not-enough-arguments.rs b/src/test/compile-fail/not-enough-arguments.rs index c952906e5e8..1f5a54477dd 100644 --- a/src/test/compile-fail/not-enough-arguments.rs +++ b/src/test/compile-fail/not-enough-arguments.rs @@ -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 } diff --git a/src/test/compile-fail/overloaded-calls-bad.rs b/src/test/compile-fail/overloaded-calls-bad.rs index 77ac97bc8b8..8763fb0913a 100644 --- a/src/test/compile-fail/overloaded-calls-bad.rs +++ b/src/test/compile-fail/overloaded-calls-bad.rs @@ -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 } diff --git a/src/test/compile-fail/variadic-ffi-3.rs b/src/test/compile-fail/variadic-ffi-3.rs index b43159b0d96..d8620ead836 100644 --- a/src/test/compile-fail/variadic-ffi-3.rs +++ b/src/test/compile-fail/variadic-ffi-3.rs @@ -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 |
