Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

explicit_generic_args_with_impl_trait: fix min expected number of generics #87727

Merged
merged 3 commits into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion compiler/rustc_typeck/src/astconv/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
param_counts.consts + named_type_param_count
- default_counts.types
- default_counts.consts
- synth_type_param_count
};
debug!("expected_min: {:?}", expected_min);
debug!("arg_counts.lifetimes: {:?}", gen_args.num_lifetime_params());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error[E0107]: this function takes at most 1 generic argument but 2 generic arguments were supplied
error[E0107]: this function takes 1 generic argument but 2 generic arguments were supplied
--> $DIR/explicit-generic-args-for-impl.rs:6:5
|
LL | foo::<str, String>("".to_string());
| ^^^ ------ help: remove this generic argument
| |
| expected at most 1 generic argument
| expected 1 generic argument
|
note: function defined here, with at most 1 generic parameter: `T`
note: function defined here, with 1 generic parameter: `T`
--> $DIR/explicit-generic-args-for-impl.rs:3:4
|
LL | fn foo<T: ?Sized>(_f: impl AsRef<T>) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// check-pass

#![feature(explicit_generic_args_with_impl_trait)]

fn f<T: ?Sized>(_: impl AsRef<T>, _: impl AsRef<T>) {}

fn main() {
f::<[u8]>("a", b"a");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![feature(explicit_generic_args_with_impl_trait)]

fn f<T: ?Sized, U: ?Sized>(_: impl AsRef<T>, _: impl AsRef<U>) {}

fn main() {
f::<[u8]>("a", b"a");
//~^ ERROR: this function takes 2 generic arguments but 1 generic argument was supplied
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
--> $DIR/not-enough-args.rs:6:5
|
LL | f::<[u8]>("a", b"a");
| ^ ---- supplied 1 generic argument
| |
| expected 2 generic arguments
|
note: function defined here, with 2 generic parameters: `T`, `U`
--> $DIR/not-enough-args.rs:3:4
|
LL | fn f<T: ?Sized, U: ?Sized>(_: impl AsRef<T>, _: impl AsRef<U>) {}
| ^ - -
help: add missing generic argument
|
LL | f::<[u8], U>("a", b"a");
| ^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0107`.