forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#87727 - SkiFire13:fix-87718, r=jackh726
explicit_generic_args_with_impl_trait: fix min expected number of generics Fixes rust-lang#87718 The problem was that `synth_type_param_count` was already subtracted from `named_type_param_count`, so this ended up being subtracted again. This caused `expected_min` to overflow, and ultimately resulting in weird and wrong behaviour. I've also added another test not present in the original issue but caused by the same bug.
- Loading branch information
Showing
5 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args-for-impl.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/issue-87718.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
21 changes: 21 additions & 0 deletions
21
src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |