mirror of
https://github.com/rust-lang/rust
synced 2024-10-02 14:54:35 +00:00
Add point-at-inference ui test for wrong arity case
This commit is contained in:
parent
22f853c620
commit
08cc628e73
23
tests/ui/type/type-check/point-at-inference-4.rs
Normal file
23
tests/ui/type/type-check/point-at-inference-4.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
struct S<A, B>(Option<(A, B)>);
|
||||
|
||||
impl<A, B> S<A, B> {
|
||||
fn infer(&self, a: A, b: B) {}
|
||||
//~^ NOTE associated function defined here
|
||||
//~| NOTE
|
||||
//~| NOTE
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let s = S(None);
|
||||
s.infer(0i32);
|
||||
//~^ ERROR this method takes 2 arguments but 1 argument was supplied
|
||||
//~| NOTE an argument is missing
|
||||
//~| HELP provide the argument
|
||||
//~| NOTE this is of type `i32`, which causes `s` to be inferred as `S<i32, _>`
|
||||
//~| HELP change the type of the numeric literal from `i32` to `u32`
|
||||
let t: S<u32, _> = s;
|
||||
//~^ ERROR mismatched types
|
||||
//~| NOTE expected `S<u32, _>`, found `S<i32, _>`
|
||||
//~| NOTE expected due to this
|
||||
//~| NOTE expected struct `S<u32, _>`
|
||||
}
|
38
tests/ui/type/type-check/point-at-inference-4.stderr
Normal file
38
tests/ui/type/type-check/point-at-inference-4.stderr
Normal file
|
@ -0,0 +1,38 @@
|
|||
error[E0061]: this method takes 2 arguments but 1 argument was supplied
|
||||
--> $DIR/point-at-inference-4.rs:12:7
|
||||
|
|
||||
LL | s.infer(0i32);
|
||||
| ^^^^^------ an argument is missing
|
||||
|
|
||||
note: associated function defined here
|
||||
--> $DIR/point-at-inference-4.rs:4:8
|
||||
|
|
||||
LL | fn infer(&self, a: A, b: B) {}
|
||||
| ^^^^^ ---- ----
|
||||
help: provide the argument
|
||||
|
|
||||
LL | s.infer(0i32, /* b */);
|
||||
| ~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/point-at-inference-4.rs:18:24
|
||||
|
|
||||
LL | s.infer(0i32);
|
||||
| ---- this is of type `i32`, which causes `s` to be inferred as `S<i32, _>`
|
||||
...
|
||||
LL | let t: S<u32, _> = s;
|
||||
| --------- ^ expected `S<u32, _>`, found `S<i32, _>`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected struct `S<u32, _>`
|
||||
found struct `S<i32, _>`
|
||||
help: change the type of the numeric literal from `i32` to `u32`
|
||||
|
|
||||
LL | s.infer(0u32);
|
||||
| ~~~
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0061, E0308.
|
||||
For more information about an error, try `rustc --explain E0061`.
|
Loading…
Reference in a new issue