-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Implement a explicit_generic_args_with_impl_trait
feature gate
#86176
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
0d25b89
to
d03079c
Compare
This comment has been minimized.
This comment has been minimized.
d03079c
to
52a8798
Compare
☔ The latest upstream changes (presumably #80080) made this pull request unmergeable. Please resolve the merge conflicts. |
52a8798
to
43a3064
Compare
This comment has been minimized.
This comment has been minimized.
43a3064
to
ebefa0c
Compare
☔ The latest upstream changes (presumably #83484) made this pull request unmergeable. Please resolve the merge conflicts. |
15a1422
to
35b80d9
Compare
☔ The latest upstream changes (presumably #86735) made this pull request unmergeable. Please resolve the merge conflicts. |
35b80d9
to
ffb2892
Compare
r? @bjorn3 as per GitHub suggestions |
I have no experience with the typechecker, maybe r? @lcnr (another github suggestion) |
I will take this review if @lcnr can't. That being said, I think it's prudent to get a sign off from the lang team here. I imagine this probably falls under the "make more reversible decisions" part of the initiative process. So probably just need someone to give the okay. So cc @rust-lang/lang |
I agree---since this is nightly-only, I think it's fine to go ahead with it. I'll nominate this for consideration at a future meeting, but in the interim, go ahead. |
☔ The latest upstream changes (presumably #87237) made this pull request unmergeable. Please resolve the merge conflicts. |
ffb2892
to
5527810
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple nits, but r=me for this after those are addressed.
#83701 needs modified to "become" a tracking issue before/when this lands (or a new issue could be opened)
@@ -687,6 687,9 @@ declare_features! ( | |||
/// Trait upcasting is casting, e.g., `dyn Foo -> dyn Bar` where `Foo: Bar`. | |||
(incomplete, trait_upcasting, "1.56.0", Some(65991), None), | |||
|
|||
/// Allows explicit generic arguments specification with `impl Trait` present. | |||
(active, explicit_generic_args_with_impl_trait, "1.56.0", Some(83701), None), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we can just co-opt that issue to be a tracking issue, yeah.
@@ -459,7 459,28 @@ impl<'o, 'tcx> dyn AstConv<'tcx> 'o { | |||
|
|||
let default_counts = gen_params.own_defaults(); | |||
let param_counts = gen_params.own_counts(); | |||
let named_type_param_count = param_counts.types - has_self as usize; | |||
let synth_type_param_count = if tcx.features().explicit_generic_args_with_impl_trait { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like a small comment here just explaining what we're doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -0,0 1,9 @@ | |||
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...in fact, I imagine the longer for that part of the diagnostic will probably co-opt some of this logic
r? @jackh726 |
When this gate is enabled, explicit generic arguments can be specified even if `impl Trait` is used in argument position. Generic arguments can only be specified for explicit generic parameters but not for the synthetic type parameters from `impl Trait`
5527810
to
9b90e7e
Compare
@bors r |
📌 Commit 9b90e7e has been approved by |
Rollup of 6 pull requests Successful merges: - rust-lang#86176 (Implement a `explicit_generic_args_with_impl_trait` feature gate) - rust-lang#87654 (Add documentation for the order of Option and Result) - rust-lang#87659 (Fix invalid suggestions for non-ASCII characters in byte constants) - rust-lang#87673 (Tweak opaque type mismatch error) - rust-lang#87687 (Inline some macros) - rust-lang#87690 (Add missing "allocated object" doc link to `<*mut T>::add`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…ackh726 Provide extra note if synthetic type args are specified Implement the unresolved question in rust-lang#83701 as suggested in rust-lang#86176 (comment). r? `@jackh726`
…ackh726 Provide extra note if synthetic type args are specified Implement the unresolved question in rust-lang#83701 as suggested in rust-lang#86176 (comment). r? ``@jackh726``
…1,nagisa Stabilize explicit_generic_args_with_impl_trait This is a stabilisation PR for `explicit_generic_args_with_impl_trait`. * [tracking issue](rust-lang#83701) - [Stabilisation report](rust-lang#83701 (comment)) - [FCP entered](rust-lang#83701 (comment)) * [implementation PR](rust-lang#86176) * [Reference PR](rust-lang/reference#1212) * There is no mention of using the turbofish operator in the book (other than an entry in the operator list in the appendix), so there is no documentation to change/add there, unless we felt like we should add a section on using turbofish, but that seems orthogonal to `explicit_generic_args_with_impl_trait`
Implements #83701
When this gate is enabled, explicit generic arguments can be specified even if
impl Trait
is used in argument position. Generic arguments can only be specified for explicit generic parameters but not for the synthetic type parameters fromimpl Trait
So code like this will be accepted: