Rollup merge of #89148 - estebank:used-type-param, r=oli-obk

Suggest `_` in turbofish if param will be inferred from fn argument
This commit is contained in:
Jubilee 2021-09-23 17:31:43 -07:00 committed by GitHub
commit 9e11d1cca4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 1 deletions

View file

@ -0,0 +1,8 @@
// run-rustfix
fn two_type_params<A, B>(_: B) {}
fn main() {
two_type_params::<String, _>(100); //~ ERROR this function takes 2 generic arguments
two_type_params::<String, _>(100);
}

View file

@ -0,0 +1,8 @@
// run-rustfix
fn two_type_params<A, B>(_: B) {}
fn main() {
two_type_params::<String>(100); //~ ERROR this function takes 2 generic arguments
two_type_params::<String, _>(100);
}

View file

@ -0,0 +1,21 @@
error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
--> $DIR/missing-type-param-used-in-param.rs:6:5
|
LL | two_type_params::<String>(100);
| ^^^^^^^^^^^^^^^ ------ supplied 1 generic argument
| |
| expected 2 generic arguments
|
note: function defined here, with 2 generic parameters: `A`, `B`
--> $DIR/missing-type-param-used-in-param.rs:3:4
|
LL | fn two_type_params<A, B>(_: B) {}
| ^^^^^^^^^^^^^^^ - -
help: add missing generic argument
|
LL | two_type_params::<String, _>(100);
| +++
error: aborting due to previous error
For more information about this error, try `rustc --explain E0107`.