-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Add arg splat experiment initial tuple impl #153697
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
base: main
Are you sure you want to change the base?
Changes from all commits
a57f0ae
12cbb30
6af64c8
ed63b76
bb6293a
c0ee4d3
be7ac75
a49e71e
ab9d855
c42e116
fdd4be9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| //! Attribute parsing for the `#[splat]` function argument overloading attribute. | ||
| //! This attribute modifies typecheck to support overload resolution, then modifies codegen for performance. | ||
|
|
||
| use super::prelude::*; | ||
|
|
||
| pub(crate) struct SplatParser; | ||
|
|
||
| impl NoArgsAttributeParser for SplatParser { | ||
| const PATH: &[Symbol] = &[sym::splat]; | ||
| const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; | ||
| const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ | ||
| // FIXME(splat): do we want to allow MacroCall if the macro creates an argument | ||
| Allow(Target::Param), | ||
| ]); | ||
| const CREATE: fn(Span) -> AttributeKind = AttributeKind::Splat; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1136,6 +1136,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { | |
| }; | ||
|
|
||
| // Split the rust-call tupled arguments off. | ||
| // FIXME(splat): un-tuple splatted arguments in codegen, for performance | ||
|
teor2345 marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why "for performance"? If this follows the RustCall approach, the ABI requires untupling for correctness. I am confused by this comment.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see, I think I got confused by "splatted MIR lowering and tupling". This doesn't actually do anything on the ABI level yet, it passes things as structs. |
||
| let (first_args, untuple) = if sig.abi() == ExternAbi::RustCall | ||
| && let Some((tup, args)) = args.split_last() | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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'm somewhat worried that due to these errors being non-blocking for the rest of the compiler, that it's possible to cause weird ICEs, but that's nothing new wrt most of the ast validation checks.
View changes since the review
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 did my best to provide sensible defaults/substitutions on error.
Specifically, c_variadic gets priority, then the first splatted argument. Every other splat generates an error, then gets ignored in later stages.