Skip to content

Commit 08cc628

Browse files
committed
Add point-at-inference ui test for wrong arity case
1 parent 22f853c commit 08cc628

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
struct S<A, B>(Option<(A, B)>);
2+
3+
impl<A, B> S<A, B> {
4+
fn infer(&self, a: A, b: B) {}
5+
//~^ NOTE associated function defined here
6+
//~| NOTE
7+
//~| NOTE
8+
}
9+
10+
fn main() {
11+
let s = S(None);
12+
s.infer(0i32);
13+
//~^ ERROR this method takes 2 arguments but 1 argument was supplied
14+
//~| NOTE an argument is missing
15+
//~| HELP provide the argument
16+
//~| NOTE this is of type `i32`, which causes `s` to be inferred as `S<i32, _>`
17+
//~| HELP change the type of the numeric literal from `i32` to `u32`
18+
let t: S<u32, _> = s;
19+
//~^ ERROR mismatched types
20+
//~| NOTE expected `S<u32, _>`, found `S<i32, _>`
21+
//~| NOTE expected due to this
22+
//~| NOTE expected struct `S<u32, _>`
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
error[E0061]: this method takes 2 arguments but 1 argument was supplied
2+
--> $DIR/point-at-inference-4.rs:12:7
3+
|
4+
LL | s.infer(0i32);
5+
| ^^^^^------ an argument is missing
6+
|
7+
note: associated function defined here
8+
--> $DIR/point-at-inference-4.rs:4:8
9+
|
10+
LL | fn infer(&self, a: A, b: B) {}
11+
| ^^^^^ ---- ----
12+
help: provide the argument
13+
|
14+
LL | s.infer(0i32, /* b */);
15+
| ~~~~~~~~~~~~~~~
16+
17+
error[E0308]: mismatched types
18+
--> $DIR/point-at-inference-4.rs:18:24
19+
|
20+
LL | s.infer(0i32);
21+
| ---- this is of type `i32`, which causes `s` to be inferred as `S<i32, _>`
22+
...
23+
LL | let t: S<u32, _> = s;
24+
| --------- ^ expected `S<u32, _>`, found `S<i32, _>`
25+
| |
26+
| expected due to this
27+
|
28+
= note: expected struct `S<u32, _>`
29+
found struct `S<i32, _>`
30+
help: change the type of the numeric literal from `i32` to `u32`
31+
|
32+
LL | s.infer(0u32);
33+
| ~~~
34+
35+
error: aborting due to 2 previous errors
36+
37+
Some errors have detailed explanations: E0061, E0308.
38+
For more information about an error, try `rustc --explain E0061`.

0 commit comments

Comments
 (0)