Add arg splat experiment initial tuple impl#153697
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
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@rustbot ready I've rebased and cherry-picked @Ajay-singh1's bug fix and extra tests from #157434. |
This comment has been minimized.
This comment has been minimized.
| // FIXME(splat): should these fields be private, or merged into an Option<u16>? | ||
| /// Is any function argument splatted? | ||
| pub is_splatted: bool, | ||
|
|
||
| /// The index of the splatted function argument in `inputs`, only valid if `is_splatted` is true. | ||
| /// e.g. in `fn overload(a: u8, #[splat] b: (f32, usize))` the index is 1, and it can be called | ||
| /// as `overload(a, 1.0, 2)`. | ||
| pub splatted_index: u16, |
There was a problem hiding this comment.
Do you immediately need reflection support for this? If not, seems better to leave this for later and make the PR a bit smaller.
There was a problem hiding this comment.
I don't think so, happy to split the PR.
Would it be easier as 3 PRs?
- feature gate only
- splat attribute, typecheck, and MIR
- reflection
There was a problem hiding this comment.
Isn't the feature gate just a single line?
But reflection is sufficiently new that it might be worth separating. OTOH you have @oli-obk as reviewer who is intimately familiar with reflection so for him it's probably fine. I should have checked the reviewer before commenting, sorry.
There was a problem hiding this comment.
Isn't the feature gate just a single line?
About 200 lines when you add attribute parsing and tests. But I get your point.
But reflection is sufficiently new that it might be worth separating. OTOH you have @oli-obk as reviewer who is intimately familiar with reflection so for him it's probably fine.
I'll split it on Monday if I don't hear back from Oli, then other people might be able to review the other parts. Maybe there's more splits that make sense, I'll have a think about it.
There was a problem hiding this comment.
About 200 lines when you add attribute parsing and tests. But I get your point.
Ah that's more than just the feature gate then. :)
Separating the syntactic parts out also can make sense yeah, I've seen this for other new features in the past.
There was a problem hiding this comment.
Reflection is sufficiently simple that doing it together with adding the field to function signature makes sense
There was a problem hiding this comment.
Alright, I'll split it into two PRs:
- attribute parsing and syntax (Arg splat experiment - syntax impl #157605)
- type checking, lowering, and reflection (this PR, which I'll rebase after the first one merges)
It seems like most conflicting PRs either touch one or the other, so hopefully that will reduce the rebases.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
fixup! Add splat builtin attribute & feature gate
fixup! Add AST validation for #[splat]
fixup! Add HIR FnDecl for #[splat]
fixup! Impl HIR typeck for #[splat]
fixup! Impl TypeInfo for splat
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
☔ The latest upstream changes (presumably #157616) made this pull request unmergeable. Please resolve the merge conflicts. |
TODO
This PR is waiting on #157605 to merge, then I'll rebase it.
Description
View all comments
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 is the initial implementation of 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.
Further Work
Out of Scope for this PR