Add arg splat experiment feature gate and stub#153697
Add arg splat experiment feature gate and stub#153697teor2345 wants to merge 10 commits intorust-lang:mainfrom
Conversation
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
It should be better for someone on https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/On.20overloading/with/573924937 to review this, @oli-obk could you take over? |
|
Let's wait for the ongoing discussion on Zulip to figure out whether we need to have a proc macro, an AST manipulating attribute (like |
89102bf to
c784a57
Compare
c784a57 to
2d9e563
Compare
|
I've implemented the first stage of argument type checking (THIR), but I need help with fixing:
|
This comment has been minimized.
This comment has been minimized.
| let tuple_type = if tuple_arguments.is_splatted() { | ||
| let tuple_type = self | ||
| .try_structurally_resolve_type(call_span, formal_input_tys[tupled_arg_index]); | ||
| if tuple_type.is_ty_var() { | ||
| let tuple_len = provided_args.len().checked_sub(tupled_arg_index); | ||
| if let Some(tuple_len) = tuple_len { | ||
| // FIXME(splat before merging): how do we force the type variable to resolve to (a supertype) of the caller's tupled argument types? | ||
| Ty::new_tup_from_iter( | ||
| self.tcx, | ||
| iter::repeat_with(|| self.next_ty_var(call_span)).take(tuple_len), | ||
| ) |
There was a problem hiding this comment.
This works but disables type inference, the old type variable should be inferred as a tuple containing the new type variables.
| // FIXME(splat before merging): if splatting, update the caller's arguments to be a tuple, so MIR typecheck passes | ||
| ( | ||
| formal_input_tys[..tupled_arg_index] | ||
| .into_iter() | ||
| .cloned() | ||
| .chain(arg_types.into_iter()) | ||
| .collect(), | ||
| expected_input_tys, | ||
| ) |
There was a problem hiding this comment.
This code de-tuples the callee's arguments, and type checks them against the caller's arguments.
But I don't know how to modify the caller so its arguments become tupled in MIR.
This comment has been minimized.
This comment has been minimized.
|
The job Click to see the possible cause of the failure (guessed by this bot) |
…lmann Fix typos and markdown errors This PR fixes some typos and markdown errors I found while writing rust-lang#153697. I've split it out to reduce the size of that PR.
…lmann Fix typos and markdown errors This PR fixes some typos and markdown errors I found while writing rust-lang#153697. I've split it out to reduce the size of that PR.
…lmann Fix typos and markdown errors This PR fixes some typos and markdown errors I found while writing rust-lang#153697. I've split it out to reduce the size of that PR.
|
☔ The latest upstream changes (presumably #153489) made this pull request unmergeable. Please resolve the merge conflicts. |
This PR is part of the argument splatting lang experiment, and FFI overloading / C++ interop project goals:
Example code using existing unstable features:
Discussion of implementation strategy:
The PR only contains the initial stubs for the feature:
splatincomplete feature gate#[splat]attribute on function arguments#[splat]function parameter check at THIR levelOnce this PR merges, we can add further functionality, then test it out in interop tools.
TODOs